Function Class Reference

#include <reflectionbase.h>

Inheritance diagram for Function:

Detailed Description

Function represents a C++ function. It describes the name, return type and parameter types of the function, but also has the Invoke method to invoke the function.

There are three kinds of functions:

The implicit this argument is not part of the parameter types, but for the Invoke method it has to be specified as first argument if the function is an instance function.

Public Member Functions

MAXON_METHOD Result< void > Invoke (void *result, const Block< Argument > &arguments) const
 
template<typename T , typename... ARGS>
Result< typename InvokeHelper< T >::typeInvoke (ARGS &&... args) const
 
MAXON_METHOD ParameterType GetReturnType () const
 
MAXON_METHOD Block< const ParameterTypeGetParameterTypes () const
 
MAXON_METHOD const Block< const Parameter > & GetParameters () const
 
MAXON_METHOD Bool IsPure () const
 
MAXON_METHOD void * GetAddress () const
 
- Public Member Functions inherited from Member
enum maxon::reflection::Member::KIND MAXON_ENUM_FLAGS_CLASS (KIND)
 
MAXON_METHOD const ContainerGetEnclosingContainer () const
 
MAXON_METHOD KIND GetKind () const
 
MAXON_METHOD const IdGetSimpleName () const
 
MAXON_METHOD const IdGetId () const
 
MAXON_METHOD String ToString (const FormatStatement *fs=nullptr) const
 

Static Public Member Functions

static MAXON_METHOD const FunctionPrivateFindMethod (const InterfaceReference &vi, Int offset)
 
static const FunctionFind (const Id &memberId)
 
static MAXON_METHOD Result< void > FindAll (const Id &memberId, const ValueReceiver< const Function * > &result)
 
- Static Public Member Functions inherited from Member
static MAXON_METHOD Result< BoolGetMembers (const ValueReceiver< const Member & > &members)
 
static MAXON_METHOD const MemberFind (const Id &memberId)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL_DERIVED (Function, MAXON_REFERENCE_NONE, "net.maxon.reflection.interface.function")
 

Additional Inherited Members

- Public Types inherited from Member
enum class  KIND {
  PACKAGE ,
  CLASS ,
  FUNCTION ,
  INSTANCE_FUNCTION ,
  CONST_INSTANCE_FUNCTION ,
  CONTAINER_TEST ,
  FUNCTION_TEST
}
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL_DERIVED()

MAXON_INTERFACE_NONVIRTUAL_DERIVED ( Function  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.reflection.interface.function"   
)
private

◆ Invoke() [1/2]

MAXON_METHOD Result<void> Invoke ( void *  result,
const Block< Argument > &  arguments 
) const

Invokes this function with the given arguments. If this is an instance function, the this pointer has to be given as first argument. result has to point to an object of the return type of the function, the result will then be written to that object. For a function with void return type, result may be nullptr.

Parameters
[out]resultPointer to a value to which the function result is written. May be nullptr if the functions returns void. The type of the value must be the return type of the function, otherwise the behaviour is undefined.
[in]argumentsArguments for the function. For an instance function, the first argument is the this pointer. The arguments have to match in type, otherwise the behaviour is undefined.
Returns
An error if the argument count doesn't match or (for a non-void function) result is nullptr, otherwise OK.

◆ Invoke() [2/2]

Result<typename InvokeHelper<T>::type> Invoke ( ARGS &&...  args) const

Invokes this function with the given arguments. If this is an instance function, the this pointer has to be given as first argument. T has to be of the form R(A1, ..., An), where R is the return type of the function and A1, ..., An are the parameter types. For instance functions, A1 has to be the type of the additional this argument. If the types don't match the actual types of the function, the behaviour is undefined.

Template Parameters
TType of the function of the form R(A1, ..., An). If this doesn't match the actual type, the behaviour is undefined.
Parameters
[in]argsArguments for the function. For an instance function, the first argument is the this pointer.
Returns
An error if the argument count doesn't match, otherwise OK.

◆ GetReturnType()

MAXON_METHOD ParameterType GetReturnType ( ) const

◆ GetParameterTypes()

MAXON_METHOD Block<const ParameterType> GetParameterTypes ( ) const

◆ GetParameters()

MAXON_METHOD const Block<const Parameter>& GetParameters ( ) const

◆ IsPure()

MAXON_METHOD Bool IsPure ( ) const

◆ GetAddress()

MAXON_METHOD void* GetAddress ( ) const

◆ PrivateFindMethod()

static MAXON_METHOD const Function* PrivateFindMethod ( const InterfaceReference &  vi,
Int  offset 
)
static

◆ Find()

static const Function* Find ( const Id memberId)
static

◆ FindAll()

static MAXON_METHOD Result<void> FindAll ( const Id memberId,
const ValueReceiver< const Function * > &  result 
)
static

Finds all functions overloads which have the given (unqualified) id.

Parameters
[in]memberIdA member id.
[out]resultReceiver for the found functions.
Returns
OK unless a memory allocation failed.