Function

class ReflectExport(reflect) Function

A function object provides a virtual inteface to a function.  Function uses Variant for Parameters and “this” pointer passing.

Usage

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>.

Summary
FunctionA 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.
NumParametersThe number of parameters passed to this function.
ClassifyParameterReturns the type of parameter at index, and changes is_mutable to true if the parameter is passed as a non-const reference.
ParameterTypeReturns the type of parameter at index.
Name
IsMethodChecks if this function is a member function, and needs a “this” pointer to be called.
IsConstMethodChecks if this function can be called with a const “this” pointer.
CallObjectTypeReturns the type of “this” pointer needed.
Function (protected)
CallInternal (protected)
ParametersRepresents a parameter list passed to a Function.
Functions
ParametersBuilds a parameter list for a function.
ParamsReturns the parameters as an array of Variant.
ValidForFunctionChecks if this parameter list is valid to call a particular function.
argAssign (non-mutable) values to parameter.
refAssign (mutable) params (held in a variant) to parameter, using a chainable method.
readDeserialize text using a StandardSerializer.

Functions

Call (method, by variant)

bool Call(const Variant &object,  
const Parameters &params,  
Variant &result =  Variant::Void()) const

Calls this function with a variant object as self.

Returns

trueif the call succeeded
falseif the parameters did not match or the result could not be written.

Call (function)

bool Call(const Parameters &params,  
Variant &result =  Variant::Void()) const

Calls a non-method function without a “this” pointer.

Returns

trueif the call succeeded
falseif the parameters did not match or the result could not be written.

Call (method, by template param)

template<typename T> bool Call(*object,  
const Parameters &params,  
Variant &result =  Variant::Void()) const

Calls a method with a statically typed “this” pointer.

Returns

trueif the call succeeded
falseif the parameters did not match or the result could not be written.

Call (const method, by template param)

template<typename T> bool Call(const *object,  
const Parameters &params,  
Variant &result =  Variant::Void()) const

Calls a method with a statically typed, but const, “this” pointer.

Returns

trueif the call succeeded
falseif the parameters did not match or the result could not be written.

NumParameters

int NumParameters() const

The number of parameters passed to this function.

ClassifyParameter

const Type *ClassifyParameter(int index,
bool &is_mutable) const

Returns the type of parameter at index, and changes is_mutable to true if the parameter is passed as a non-const reference.

ParameterType

const Type *ParameterType(int index) const

Returns the type of parameter at index.

Name

const char *Name() const

IsMethod

bool IsMethod() const

Checks if this function is a member function, and needs a “this” pointer to be called.

IsConstMethod

virtual bool IsConstMethod() const = 0

Checks if this function can be called with a const “this” pointer.

CallObjectType

const Type *CallObjectType() const

Returns the type of “this” pointer needed.

Function (protected)

Function(const char *name,
const Type *object_type,
ParameterTypeFun arg_type_fun,
const Type *result_type)

CallInternal (protected)

virtual bool CallInternal(const Variant &self,
Variant *args,
Variant &result) const = 0

Parameters

class ReflectExport(reflect) Parameters

Represents a parameter list passed to a Function.

Summary
Functions
ParametersBuilds a parameter list for a function.
ParamsReturns the parameters as an array of Variant.
ValidForFunctionChecks if this parameter list is valid to call a particular function.
argAssign (non-mutable) values to parameter.
refAssign (mutable) params (held in a variant) to parameter, using a chainable method.
readDeserialize text using a StandardSerializer.

Functions

Parameters

Parameters(const Function *fun)

Builds a parameter list for a function.

Params

Variant *Params() const

Returns the parameters as an array of Variant.

ValidForFunction

bool ValidForFunction(const Function *function) const

Checks if this parameter list is valid to call a particular function.  The types must match exactly and the mutable parameters must cover the mutable parameters needed by the function call.

arg

Assign (non-mutable) values to parameter.  This method is chainable with itself and ref.

Usage

function::Parameters params(func);
params.arg(3).arg("text");

ref

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.

Usage

reflect::function::Parameters params(func);
int i = 3;
reflect::Variant mutable = Variant::Ref(i);
params.ref(mutable).arg("text");

read

FunctionParameter read(const string::Fragment &text,  
int index =  0)

Deserialize text using a StandardSerializer.

class ReflectExport(reflect) Function
A function object provides a virtual inteface to a function.
bool Call(const Variant &object,  
const Parameters &params,  
Variant &result =  Variant::Void()) const
Calls this function with a variant object as self.
bool Call(const Parameters &params,  
Variant &result =  Variant::Void()) const
Calls a non-method function without a “this” pointer.
template<typename T> bool Call(*object,  
const Parameters &params,  
Variant &result =  Variant::Void()) const
Calls a method with a statically typed “this” pointer.
template<typename T> bool Call(const *object,  
const Parameters &params,  
Variant &result =  Variant::Void()) const
Calls a method with a statically typed, but const, “this” pointer.
int NumParameters() const
The number of parameters passed to this function.
const Type *ClassifyParameter(int index,
bool &is_mutable) 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 *ParameterType(int index) const
Returns the type of parameter at index.
const char *Name() const
bool IsMethod() const
Checks if this function is a member function, and needs a “this” pointer to be called.
virtual bool IsConstMethod() const = 0
Checks if this function can be called with a const “this” pointer.
const Type *CallObjectType() const
Returns the type of “this” pointer needed.
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
class ReflectExport(reflect) Parameters
Represents a parameter list passed to a Function.
Parameters(const Function *fun)
Builds a parameter list for a function.
Variant *Params() const
Returns the parameters as an array of Variant.
class ReflectExport(reflect) Variant
Variants represent objects of any reflected type.
bool ValidForFunction(const Function *function) const
Checks if this parameter list is valid to call a particular function.
FunctionParameter ref(Variant &value,  
int index =  0)
Assign (mutable) params (held in a variant) to parameter, using a chainable method.
FunctionParameter read(const string::Fragment &text,  
int index =  0)
Deserialize text using a StandardSerializer.
Close