ZFFramework
|
reflectable method for ZFObject More...
#include <ZFMethod.h>
Public Member Functions | |
template<typename T_ReturnType > | |
T_ReturnType | execute (ZFObject *obj) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1, Type2 param2) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1, Type2 param2, Type3 param3) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 , typename Type5 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4, Type5 param5) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 , typename Type5 , typename Type6 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4, Type5 param5, Type6 param6) const |
see ZFMethod | |
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 , typename Type5 , typename Type6 , typename Type7 > | |
T_ReturnType | execute (ZFObject *obj, Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4, Type5 param5, Type6 param6, Type7 param7) const |
see ZFMethod | |
void | objectInfoT (zfstring &ret) const |
see objectInfo | |
zfstring | objectInfo (void) const |
return object info | |
const ZFMethod * | methodAliasFrom (void) const |
see ZFMethodAlias | |
const ZFCoreArray< const ZFMethod * > & | methodAliasTo (void) const |
see ZFMethodAlias | |
const zfchar * | methodInternalId (void) const |
internal method id, for debug use only | |
zfbool | methodIsUserRegister (void) const |
whether the method is registered by ZFMethodUserRegister_0 | |
zfany | methodUserRegisterUserData (void) const |
store impl state for ZFMethodUserRegister_0 | |
void | methodUserRegisterUserData (ZFObject *userData) const |
store impl state for ZFMethodUserRegister_0 | |
zfbool | methodIsDynamicRegister (void) const |
whether the method is registered by ZFMethodDynamicRegister | |
zfany | methodDynamicRegisterUserData (void) const |
see ZFMethodDynamicRegister | |
const zfchar * | methodName (void) const |
get the method's name | |
const zfchar * | methodReturnTypeId (void) const |
get the method's return value's type id | |
const zfchar * | methodReturnTypeName (void) const |
get the method's return value's type name | |
zfindex | methodParamCount (void) const |
get the method's param num | |
zfindex | methodParamCountMin (void) const |
get the method's minimum param num, same as methodParamCount if no default param | |
zfbool | methodParamTypeIdIsMatch (const zfchar *methodParamTypeId0=0, const zfchar *methodParamTypeId1=0, const zfchar *methodParamTypeId2=0, const zfchar *methodParamTypeId3=0, const zfchar *methodParamTypeId4=0, const zfchar *methodParamTypeId5=0, const zfchar *methodParamTypeId6=0, const zfchar *methodParamTypeId7=0) const |
check whether method param type id matches | |
zfbool | methodParamTypeIdIsMatch (const ZFMethod *method) const |
see methodParamTypeIdIsMatch | |
const zfchar * | methodParamTypeIdAt (zfindex index) const |
get the method's param type id at index | |
const zfchar * | methodParamTypeNameAt (zfindex index) const |
get the method's param type name at index, usually for debug use | |
const zfchar * | methodParamNameAt (zfindex index) const |
get the method's param name at index, usually for debug use | |
ZFMethodParamDefaultValueCallback | methodParamDefaultValueCallbackAt (zfindex index) const |
get the method param's default value access callback | |
zfauto | methodParamDefaultValueAt (zfindex index) const |
get the method's param default value at index, null if no default param | |
zfindex | methodParamDefaultBeginIndex (void) const |
return the first default param's index, or zfindexMax if no default param | |
ZFFuncAddrType | methodInvoker (void) const |
invoker function address for both class member type and function type | |
void | methodInvoker (ZFFuncAddrType methodInvoker) const |
override original methodInvoker | |
ZFFuncAddrType | methodInvokerOrig (void) const |
see methodInvoker | |
ZFMethodGenericInvoker | methodGenericInvoker (void) const |
generic invoker for advanced reflection | |
zfauto | methodInvoke (ZFObject *ownerObjOrNull=0) const |
util method to invoke ZFMethodGenericInvoker | |
zfauto | methodInvoke (ZFObject *ownerObjOrNull, ZFObject *param0, ZFObject *param1=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMethodGenericInvokerDefaultParamRef)) const |
see methodInvoke | |
zfauto | methodInvokeDetail (ZFObject *ownerObjOrNull, const ZFCoreArray< zfauto > ¶ms, zfbool *success=0, zfstring *errorHint=0) const |
see methodInvoke | |
ZFMethodGenericInvoker | methodGenericInvokerOrig (void) const |
see methodGenericInvoker | |
void | methodGenericInvoker (ZFMethodGenericInvoker methodGenericInvoker) const |
change default impl for methodGenericInvoker | |
const ZFClass * | methodOwnerClass (void) const |
method's owner class, null for function type method | |
const ZFProperty * | methodOwnerProperty (void) const |
method's owner proeprty, null if none | |
ZFMethodPrivilegeType | methodPrivilegeType (void) const |
get the method's access type | |
zfbool | methodIsPublic (void) const |
util to check whether methodPrivilegeType is ZFMethodPrivilegeTypePublic | |
zfbool | methodIsProtected (void) const |
util to check whether methodPrivilegeType is ZFMethodPrivilegeTypeProtected | |
zfbool | methodIsPrivate (void) const |
util to check whether methodPrivilegeType is ZFMethodPrivilegeTypePrivate | |
ZFMethodType | methodType (void) const |
method type | |
zfbool | methodIsNormal (void) const |
util to check whether methodType is ZFMethodTypeNormal | |
zfbool | methodIsStatic (void) const |
util to check whether methodType is ZFMethodTypeStatic | |
zfbool | methodIsVirtual (void) const |
util to check whether methodType is ZFMethodTypeVirtual | |
zfbool | methodIsFunctionType (void) const |
true if this method is function type (declared by ZFMETHOD_FUNC_DECLARE_XXX series) | |
const zfchar * | methodNamespace (void) const |
get the method namespace, for func type only, null or empty string for global scope (ZF_NAMESPACE_GLOBAL) | |
zfbool | methodIsInternal (void) const |
whether the method is internal method | |
zfbool | methodIsInternalPrivate (void) const |
whether the method is internal private method | |
reflectable method for ZFObject
(for function type of ZFMethod, please refer to ZFMETHOD_FUNC_DECLARE_0)
to use ZFMethod, you must first declare it in your class:
or you may want to declare in header and define in cpp file:
param and return type must registered by ZFTYPEID_DECLARE series, and the param's num is limited to ZFMETHOD_MAX_PARAM
the ZFMETHOD_XXX macro takes many params, to walk through it, let's take a example:
to override a method declared in parent, simply override like normal virtual functions
once declared, the method would be automatically registered to it's owner class when it's owner class registered, see also ZFOBJECT_REGISTER
to access the method, use ZFMethodAccess/ZFMethodAccessDetail_0 is recommended:
also, you may use ZFClass's member function to reflect from string, such as ZFClass::methodForName
once you have successfully get the ZFMethod data, you can execute it without knowing the owner's class type:
if you want to reflect overloaded method, use both methodName and param's type id
zfbool ZFMethod::methodParamTypeIdIsMatch | ( | const zfchar * | methodParamTypeId0 = 0, |
const zfchar * | methodParamTypeId1 = 0, | ||
const zfchar * | methodParamTypeId2 = 0, | ||
const zfchar * | methodParamTypeId3 = 0, | ||
const zfchar * | methodParamTypeId4 = 0, | ||
const zfchar * | methodParamTypeId5 = 0, | ||
const zfchar * | methodParamTypeId6 = 0, | ||
const zfchar * | methodParamTypeId7 = 0 ) const |
check whether method param type id matches
null type id means not specified (any type matches), use ZFTypeId_void to explicitly limit param count
|
inline |
invoker function address for both class member type and function type
proto type:
void ZFMethod::methodInvoker | ( | ZFFuncAddrType | methodInvoker | ) | const |
override original methodInvoker
set null to remove the overrided value, the original invoker can be accessed by methodInvokerOrig
|
inline |
generic invoker for advanced reflection
as a static language, C++'s function invoking require explicit type declaration, which is a pain when binding with script languages
since ZFFramework supply reflection (though limited), we are trying to solve the dynamic script binding, how it works:
typical steps for users:
typical steps for impl:
the final script that calling ZFFFramework, should look like:
util method to invoke ZFMethodGenericInvoker
note all params must be exactly same type, use ZFDI_invoke if you want auto param conversion
void ZFMethod::methodGenericInvoker | ( | ZFMethodGenericInvoker | methodGenericInvoker | ) | const |
change default impl for methodGenericInvoker
the original invoker can be accessed by methodGenericInvokerOrig
|
inline |
whether the method is internal method
all method that have "_ZFP_" as prefix would be treated as internal method
internal method should not be used publicly, however, you may still apply reflection, see methodIsInternalPrivate
|
inline |
whether the method is internal private method
all method that have "_ZFP_I_" as prefix would be treated as internal private method
internal private method should not be used publicly, also, it would be ignored from reflection, see methodIsInternal