Represents information about a class method recorded in a ReflectedClass.
$struct+ ReflectedClassMethod
{
$bool IsConst() const { return m_isConst; }
$ConstStringZ GetName() const { return m_name; }
$ssize_t GetNumArgs() const { return m_numArgs; }
$const ReflectedArg& GetArg(ssize_t i) const { return m_args[i]; }
//////////////// State //////////////////
ConstStringZ m_name;
ReflectedReturnType m_returnType;
const ReflectedArg* m_args;
ssize_t m_numArgs;
const octet_t* m_metaData;
bool m_isConst;
FunctionPointer m_address;
};
const ReflectedFunction& AsReflectedFunction(const ReflectedClassMethod& rcm);
ConstStringZ m_name
The name of the method represented as a pointer to a UTF-8 encoded null-terminated string (see ConstStringZ).
ReflectedReturnType m_returnType
The ReflectedReturnType records the function return type.
const ReflectedArg* m_args
Pointer to an array of ReflectedArg to record the names and types of the function arguments, or null if there are zero arguments.
ssize_t m_numArgs
The number of elements in the m_args array.
const octet_t* m_metaData
Pointer to metadata byte code on the class method or null if no metadata declared.
bool m_isConst
If true then the method was declared with the 'const' qualifier. A const method doesn't mutate the underlying object.
FunctionPointer m_address
The address of the associated free function (see FunctionPointer). A free function of the same name is generated for each reflected class method where the first argument is a pointer to the class or struct.
The following definition of struct X
namespace ns
{
$struct+ X
{
$xvector<int64> foo(int32 a, float64& b) const;
$void bar();
};
}
causes stubs to be created for the reflected methods:
namespace ns
{
inline ceda::xvector<ceda::int64> __stdcall foo(
X const* _self,
ceda::int32 a,
ceda::float64& b)
{
return _self->foo(a,b);
}
inline void __stdcall bar(X* _self)
{
_self->bar();
}
}
Pointers to the stubs are recorded in the m_address member of the ReflectedClassMethods defined when registering the ReflectedClass for X:
//### $struct+ ns::X
namespace ceda { XTarget* Ceda_Core_Object_exObject_GetXTarget(); }
namespace ns
{
ceda::ReflectedClass const& _GetReflected(X const*)
{
static const ceda::octet_t X_foo_return[] =
{
0x44,0x05
};
static const ceda::octet_t X_foo_a[] =
{
0x04
};
static const ceda::octet_t X_foo_b[] =
{
0x36,0x0d
};
static const ceda::ReflectedArg X_foo_args[] =
{
{ "a", X_foo_a },
{ "b", X_foo_b },
};
static const ceda::ReflectedClassMethod X_methods[] =
{
{"foo",{X_foo_return},X_foo_args,2,0,true,(ceda::FunctionPointer)(ceda::xvector<ceda::int64> (__stdcall *)(X const* _self,ceda::int32 a,ceda::float64& b))&ns::foo},
{"bar",{0},0,0,0,false,(ceda::FunctionPointer)(void (__stdcall *)(X* _self))&ns::bar},
};
static const ceda::ReflectedClass X_class =
{
0,
"ns::X",
sizeof(X),
0,
0,0,
0,0,
0,0,
X_methods,2,
0,
0,0,0,
0,
0,
{
sizeof(X),
0,
0,
0,
(ceda::ConstructArrayFn) (void (*)( X*, ceda::ssize_t, ceda::ssize_t)) ceda::ConstructArray<X>,
(ceda::CopyConstructArrayFn) (void (*)(X*, ceda::ssize_t, X const*, ceda::ssize_t, ceda::ssize_t)) ceda::CopyConstructArray<X>,
(ceda::AssignArrayFn) (void (*)(X*, ceda::ssize_t, X const*, ceda::ssize_t, ceda::ssize_t)) ceda::AssignArray<X>,
(ceda::DestructArrayFn) (void (*)( X*, ceda::ssize_t, ceda::ssize_t)) ceda::DestructArray<X>,
0,
0,
0,
0,
0,
0
}
};
return X_class;
}
ceda::TypeOps const& _GetTypeOps(X const*)
{
return ceda::GetReflectedClass<X>().m_ops;
}
// Registration of $struct+ ns::X
void _Register_X()
{
cxVerify(ceda::RegisterReflectedClass(&_GetReflected( (X*) 0),ceda::Ceda_Core_Object_exObject_GetXTarget()) == ceda::NSE_OK);
}
} // ns