class ReflectExport( reflect ) Function
A function object provides a virtual inteface to a function. Function uses Variant for Parameters and “this” pointer passing.
if(reflect::function::Function *function = dynamic->GetClass()->FindFunction("some_function")) { reflect::function::Parameters params(function); params.arg(4).arg("text"); Variant result; if(function->Call(dynamic, params, result)) printf("some_function returned: %s\n", result.ToString().c_str()); }
Functions are implemented by <FunctionImpl>.
Function | A function object provides a virtual inteface to a function. |
Functions | |
Call (method, by variant) | Calls this function with a variant object as self. |
Call (function) | Calls a non-method function without a “this” pointer. |
Call (method, by template param) | Calls a method with a statically typed “this” pointer. |
Call (const method, by template param) | Calls a method with a statically typed, but const, “this” pointer. |
NumParameters | The number of parameters passed to this function. |
ClassifyParameter | Returns the type of parameter at index, and changes is_mutable to true if the parameter is passed as a non-const reference. |
ParameterType | Returns the type of parameter at index. |
Name | |
IsMethod | Checks if this function is a member function, and needs a “this” pointer to be called. |
IsConstMethod | Checks if this function can be called with a const “this” pointer. |
CallObjectType | Returns the type of “this” pointer needed. |
Function (protected) | |
CallInternal (protected) | |
Parameters | Represents a parameter list passed to a Function. |
Functions | |
Parameters | Builds a parameter list for a function. |
Params | Returns the parameters as an array of Variant. |
ValidForFunction | Checks if this parameter list is valid to call a particular function. |
arg | Assign (non-mutable) values to parameter. |
ref | Assign (mutable) params (held in a variant) to parameter, using a chainable method. |
read | Deserialize text using a StandardSerializer. |
template<typename T> bool Call( const T * object, const Parameters & params, Variant & result = Variant::Void() ) const
Calls a method with a statically typed, but const, “this” pointer.
true | if the call succeeded |
false | if the parameters did not match or the result could not be written. |
class ReflectExport( reflect ) Parameters
Represents a parameter list passed to a Function.
Functions | |
Parameters | Builds a parameter list for a function. |
Params | Returns the parameters as an array of Variant. |
ValidForFunction | Checks if this parameter list is valid to call a particular function. |
arg | Assign (non-mutable) values to parameter. |
ref | Assign (mutable) params (held in a variant) to parameter, using a chainable method. |
read | Deserialize text using a StandardSerializer. |
Variant *Params() const
Returns the parameters as an array of Variant.
Assign (non-mutable) values to parameter. This method is chainable with itself and ref.
function::Parameters params(func); params.arg(3).arg("text");
FunctionParameter ref( Variant & value, int index = 0 )
Assign (mutable) params (held in a variant) to parameter, using a chainable method. The variant’s lifetime (and its reference) must scope any calls of this parameter list.
reflect::function::Parameters params(func); int i = 3; reflect::Variant mutable = Variant::Ref(i); params.ref(mutable).arg("text");
A function object provides a virtual inteface to a function.
class ReflectExport( reflect ) Function
Calls this function with a variant object as self.
bool Call( const Variant & object, const Parameters & params, Variant & result = Variant::Void() ) const
Calls a non-method function without a “this” pointer.
bool Call( const Parameters & params, Variant & result = Variant::Void() ) const
Calls a method with a statically typed “this” pointer.
template<typename T> bool Call( T * object, const Parameters & params, Variant & result = Variant::Void() ) const
Calls a method with a statically typed, but const, “this” pointer.
template<typename T> bool Call( const T * object, const Parameters & params, Variant & result = Variant::Void() ) const
The number of parameters passed to this function.
int NumParameters() const
Returns the type of parameter at index, and changes is_mutable to true if the parameter is passed as a non-const reference.
const Type *ClassifyParameter( int index, bool & is_mutable ) const
Returns the type of parameter at index.
const Type *ParameterType( int index ) const
const char *Name() const
Checks if this function is a member function, and needs a “this” pointer to be called.
bool IsMethod() const
Checks if this function can be called with a const “this” pointer.
virtual bool IsConstMethod() const = 0
Returns the type of “this” pointer needed.
const Type *CallObjectType() const
Function( const char * name, const Type * object_type, ParameterTypeFun arg_type_fun, const Type * result_type )
virtual bool CallInternal( const Variant & self, Variant * args, Variant & result ) const = 0
Represents a parameter list passed to a Function.
class ReflectExport( reflect ) Parameters
Builds a parameter list for a function.
Parameters( const Function * fun )
Returns the parameters as an array of Variant.
Variant *Params() const
Variants represent objects of any reflected type.
class ReflectExport( reflect ) Variant
Checks if this parameter list is valid to call a particular function.
bool ValidForFunction( const Function * function ) const
Assign (mutable) params (held in a variant) to parameter, using a chainable method.
FunctionParameter ref( Variant & value, int index = 0 )
Deserialize text using a StandardSerializer.
FunctionParameter read( const string:: Fragment & text, int index = 0 )