reflectable method for ZFObject More...
#include <ZFMethod.h>
Public Member Functions | |
| template<typename T_ReturnType> | |
| T_ReturnType | executeExact (ZFObject *obj) const |
| see ZFMethod | |
| template<typename T_ReturnType, typename Type0> | |
| T_ReturnType | executeExact (ZFObject *obj, Type0 param0) const |
| see ZFMethod | |
| template<typename T_ReturnType, typename Type0, typename Type1> | |
| T_ReturnType | executeExact (ZFObject *obj, Type0 param0, Type1 param1) const |
| see ZFMethod | |
| template<typename T_ReturnType, typename Type0, typename Type1, typename Type2> | |
| T_ReturnType | executeExact (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 | executeExact (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 | executeExact (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 | executeExact (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 | executeExact (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 | executeExact (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 * | aliasFrom (void) const |
| see ZFMethodAlias | |
| const ZFCoreArray< const ZFMethod * > & | aliasTo (void) const |
| see ZFMethodAlias | |
| zfidentity | methodId (void) const |
| internal method id, for debug use only | |
| zfbool | isUserRegister (void) const |
| whether the method is registered by ZFMethodUserRegister_0 | |
| zfany | userRegisterUserData (void) const |
| store impl state for ZFMethodUserRegister_0 | |
| void | userRegisterUserData (ZFObject *userData) const |
| store impl state for ZFMethodUserRegister_0 | |
| zfbool | isDynamicRegister (void) const |
| whether the method is registered by ZFMethodDynamicRegister | |
| zfany | dynamicRegisterUserData (void) const |
| see ZFMethodDynamicRegister | |
| const zfstring & | methodName (void) const |
| get the method's name | |
| const zfstring & | returnTypeId (void) const |
| get the method's return value's type id | |
| zfindex | paramCount (void) const |
| get the method's param num | |
| zfindex | paramCountMin (void) const |
| get the method's minimum param num, same as paramCount if no default param | |
| zfbool | paramTypeIdIsMatch (const zfchar *paramTypeId0=zft_zfnull, const zfchar *paramTypeId1=zft_zfnull, const zfchar *paramTypeId2=zft_zfnull, const zfchar *paramTypeId3=zft_zfnull, const zfchar *paramTypeId4=zft_zfnull, const zfchar *paramTypeId5=zft_zfnull, const zfchar *paramTypeId6=zft_zfnull, const zfchar *paramTypeId7=zft_zfnull) const |
| check whether method param type id matches | |
| zfbool | paramTypeIdIsMatch (const ZFMethod *method) const |
| see paramTypeIdIsMatch | |
| const zfstring & | paramTypeIdAt (zfindex index) const |
| get the method's param type id at index | |
| const zfstring & | paramNameAt (zfindex index) const |
| get the method's param name at index, usually for debug use | |
| const ZFListener & | paramDefaultValueCallbackAt (zfindex index) const |
| get the method param's default value access callback | |
| zfauto | paramDefaultValueAt (zfindex index) const |
| get the method's param default value at index, null if no default param | |
| zfindex | paramDefaultBeginIndex (void) const |
| return the first default param's index, or zfindexMax if no default param | |
| void | paramInfoT (zfstring &ret) const |
| util to return param info | |
| zfstring | paramInfo (void) const |
| see paramInfoT | |
| 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=zft_zfnull) const |
| util method to invoke ZFMethodGenericInvoker | |
| zfauto | methodInvoke (ZFObject *ownerObjOrNull, ZFObject *param0, ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF)) const |
| see methodInvoke | |
| zfbool | methodInvokeT (zfauto &ret, zfstring *errorHint, ZFObject *ownerObjOrNull, ZFObject *param0=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF)) const |
| see methodInvoke | |
| zfauto | methodInvokeDetail (ZFObject *ownerObjOrNull, const ZFCoreArray< zfauto > ¶ms, zfbool *success=zft_zfnull, zfstring *errorHint=zft_zfnull) const |
| see methodInvoke | |
| zfbool | methodInvokeCheck (ZFObject *ownerObjOrNull, zfstring *errorHint=zft_zfnull) const |
| check whether this method can be invoke with specified object | |
| ZFMethodGenericInvoker | methodGenericInvokerOrig (void) const |
| see methodGenericInvoker | |
| void | methodGenericInvoker (ZFMethodGenericInvoker methodGenericInvoker) const |
| change default impl for methodGenericInvoker | |
| const ZFClass * | ownerClass (void) const |
| method's owner class, null for function type method | |
| const ZFProperty * | ownerProperty (void) const |
| method's owner proeprty, null if none | |
| ZFMethodAccessType | methodAccessType (void) const |
| get the method's access type | |
| zfbool | isPublic (void) const |
| util to check whether methodAccessType is ZFMethodAccessTypePublic | |
| zfbool | isProtected (void) const |
| util to check whether methodAccessType is ZFMethodAccessTypeProtected | |
| zfbool | isPrivate (void) const |
| util to check whether methodAccessType is ZFMethodAccessTypePrivate | |
| ZFMethodType | methodType (void) const |
| method type | |
| zfbool | isNormal (void) const |
| util to check whether methodType is ZFMethodTypeNormal | |
| zfbool | isStatic (void) const |
| util to check whether methodType is ZFMethodTypeStatic | |
| zfbool | isVirtual (void) const |
| util to check whether methodType is ZFMethodTypeVirtual | |
| zfbool | isFuncType (void) const |
| true if this method is function type (declared by ZFMETHOD_FUNC_DECLARE_XXX series) | |
| const zfstring & | methodNamespace (void) const |
| get the method namespace, for func type only, null or empty string for global scope (ZF_NAMESPACE_GLOBAL) | |
| zfbool | isInternal (void) const |
| whether the method is internal method | |
| zfbool | isInternalPrivate (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
| void ZFMethod::paramInfoT | ( | zfstring & | ret | ) | const |
util to return param info
sample output: P0 p0, P1 p1 = def, or output nothing if no param
|
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
methods would be treated as internal if:
see also isInternalPrivate
|
inline |
whether the method is internal private method
methods would be treated as internal private if:
internal methods would be ignored from reflection, see also isInternal