add_cboo_calls(::Type{CBOOedT}, cboolist)

Add the properties in cboolist to the list of properties that can be cboo-called for a type CBOOedT that has already been cboo-ified.

Only properties that are not already CBOO-ified for CBooedT are added. Previous added properties will not be updated.

Since add_cboo_calls is a function, in contrast to @cbooify, cboolist can be a literal container (for example Tuple or Vector) or a variable name bound to a container.

Returns a Vector of two-tuples (Tuple) of the properties that were added, that is, not already on the list.


julia> cbooified_properties(MyA)
(sx = MyAs.sx, x = MyAs.x, sin = sin, y = 3, mycos = MyAs.var"#1#3"())

julia> add_cboo_calls(MyA, (:x, :sx, :cf))
1-element Vector{Tuple{Symbol, Symbol}}:
 (:cf, :cf)

julia> add_cboo_calls(MyA, (:x, :sx, :cf))
cbooified_properties(::Type{T}) where T

Return a NamedTuple of CBOO-ified properties for type T. The keys are properties, and the values are the functions or data associated with the properties.


Return true if the @cbooify macro has been called on T.

whichmodule(::Type{T}) where T

Return the module in which T was CBOO-ified.

NOTE: this uses information stored by CBOOCall. Might be the same as info retrievable through Julia.

@cbooify(Type_to_cbooify, (f1, f2, fa = Mod.f2...), callmethod=nothing, getproperty=getfield)

Allow functions of the form f1(s::Type_to_cbooify, args...) to also be called with s.f1(args...) with no performance penalty.

callmethod and getproperty are keyword arguments.

If an element of the Tuple is an assignment sym = func, then sym is the property that will call func. sym must be a simple identifier (a symbol). func is not required to be a symbol. For example myf = Base._unexportedf.

If callmethod is supplied, then s.f1(args...) is translated to callmethod(s, f1, args...) instead of f1(s, args...).

@cbooify works by writing methods (or clobbering methods) for the functions Base.getproperty and Base.propertnames.

getproperty must be a function. If supplied, then it is called, rather than getfield, when looking up a property that is not on the list of functions. This can be useful if you want further specialzed behavior of getproperty.

@cbooify must by called after the definition of Type_to_cbooify, but may be called before the functions are defined.

If an entry is not function, then it is returned, rather than called. For example @cbooify MyStruct (y=3,). Callable objects meant to be called must be wrapped in a function.


  • Use within a module
module Amod
import CBOOCall

struct A

CBOOCall.@cbooify A (w, z)

w(a::A, y) = a.x + y
z(a::A, x, y) = a.x + y + x
end # module
julia> a = Amod.A(3);

julia> Amod.w(a, 4) == a.w(4) == 7

julia> CBOOCall.whichmodule(a)

julia> CBOOCall.cboofied_properties(a)
(w = Main.Amod.w, z = Main.Amod.z)
  • The following two calls have the same effect.
@cbooify(Type_to_cbooify, (f1, f2, ...))

@cbooify(Type_to_cbooify, (f1, f2, ...) callmethod=nothing, getproperty=getfield)