6#ifndef _ZFI_ZFMethod_h_
7#define _ZFI_ZFMethod_h_
23#define ZFTOKEN_ZFMethodAccessTypePublic "public"
25#define ZFTOKEN_ZFMethodAccessTypeProtected "protected"
27#define ZFTOKEN_ZFMethodAccessTypePrivate "private"
30#define _ZFP_ZFMethodType_ZFMethodTypeNormal()
31#define _ZFP_ZFMethodType_ZFMethodTypeStatic() static
32#define _ZFP_ZFMethodType_ZFMethodTypeVirtual() virtual
33#define _ZFP_ZFMethodType(ZFMethodType_) _ZFP_ZFMethodType_##ZFMethodType_()
35#define _ZFP_ZFMethodTypeChain_ZFMethodTypeNormal(...) __VA_ARGS__
36#define _ZFP_ZFMethodTypeChain_ZFMethodTypeStatic(...)
37#define _ZFP_ZFMethodTypeChain_ZFMethodTypeVirtual(...) __VA_ARGS__
38#define _ZFP_ZFMethodTypeChain(ZFMethodType_, ...) _ZFP_ZFMethodTypeChain_##ZFMethodType_(__VA_ARGS__)
49#define ZFTOKEN_ZFMethodTypeNormal ""
51#define ZFTOKEN_ZFMethodTypeStatic "static"
53#define ZFTOKEN_ZFMethodTypeVirtual "virtual"
58#define _ZFP_ZFMETHOD_INVOKER(N) \
60 template<typename T_ReturnType ZFM_REPEAT(N, ZFM_REPEAT_TEMPLATE, ZFM_COMMA, ZFM_COMMA)> \
61 inline T_ReturnType executeExact(ZFObject *obj ZFM_REPEAT(N, ZFM_REPEAT_PARAM, ZFM_COMMA, ZFM_COMMA)) const { \
62 if(this->methodInvoker()) { \
63 return reinterpret_cast< \
64 T_ReturnType (*)(const ZFMethod *, zfany const & ZFM_REPEAT(N, ZFM_REPEAT_PARAM, ZFM_COMMA, ZFM_COMMA)) \
65 >(this->methodInvoker()) \
66 (this, obj ZFM_REPEAT(N, ZFM_REPEAT_NAME, ZFM_COMMA, ZFM_COMMA)); \
69 return _ZFP_MtdGII<T_ReturnType ZFM_REPEAT(N, ZFM_REPEAT_TYPE, ZFM_COMMA, ZFM_COMMA)>(\
70 this, obj ZFM_REPEAT(N, ZFM_REPEAT_NAME, ZFM_COMMA, ZFM_COMMA) \
75 template<typename T_ReturnType ZFM_REPEAT(N, ZFM_REPEAT_TEMPLATE, ZFM_COMMA, ZFM_COMMA)> \
76 inline T_ReturnType _ZFP_execute(ZFObject *obj ZFM_REPEAT(N, ZFM_REPEAT_PARAM, ZFM_COMMA, ZFM_COMMA)) const { \
77 return reinterpret_cast< \
78 T_ReturnType (*)(const ZFMethod *, zfany const & ZFM_REPEAT(N, ZFM_REPEAT_PARAM, ZFM_COMMA, ZFM_COMMA)) \
79 >(this->methodInvoker()) \
80 (this, obj ZFM_REPEAT(N, ZFM_REPEAT_NAME, ZFM_COMMA, ZFM_COMMA)); \
84#define _ZFP_ZFMethodNoDefaultParam ZFM_EMPTY
85#define _ZFP_ZFMethodDefaultParam(DefaultValue) \
86 = (DefaultValue) ZFM_EMPTY
89#define _ZFP_MtdM_EMPTY(...)
90#define _ZFP_MtdM_EXPAND(...) __VA_ARGS__
91#define _ZFP_MtdP_EXPAND(...) __VA_ARGS__
92#define _ZFP_MtdD_EXPAND(...) __VA_ARGS__
105#define ZFMP_IN(ParamType, paramName) \
106 _ZFP_MtdM_EXPAND, ParamType, paramName, _ZFP_MtdM_EMPTY, _ZFP_ZFMethodNoDefaultParam
108#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue) \
109 _ZFP_MtdM_EXPAND, ParamType, paramName, _ZFP_MtdM_EXPAND, _ZFP_ZFMethodDefaultParam(DefaultValue)
111#define ZFMP_OUT(ParamType, paramName) \
112 _ZFP_MtdM_EXPAND, ParamType, paramName, _ZFP_MtdM_EMPTY, _ZFP_ZFMethodNoDefaultParam
114#define ZFMP_OUT_OPT(ParamType, paramName, DefaultValue) \
115 _ZFP_MtdM_EXPAND, ParamType, paramName, _ZFP_MtdM_EXPAND, _ZFP_ZFMethodDefaultParam(DefaultValue)
117#define ZFMP_IN_OUT(ParamType, paramName) \
118 _ZFP_MtdM_EXPAND, ParamType, paramName, _ZFP_MtdM_EMPTY, _ZFP_ZFMethodNoDefaultParam
120#define ZFMP_IN_OUT_OPT(ParamType, paramName, DefaultValue) \
121 _ZFP_MtdM_EXPAND, ParamType, paramName, _ZFP_MtdM_EXPAND, _ZFP_ZFMethodDefaultParam(DefaultValue)
123#define _ZFP_ZFMP_DUMMY() \
124 _ZFP_MtdM_EMPTY, ParamType, paramName, _ZFP_MtdM_EMPTY, _ZFP_ZFMethodNoDefaultParam
136 _ZFP_ZFMethodMP &add(
142 _ZFP_ZFMethodMP(
void) : paramCount(0) {
144 ~_ZFP_ZFMethodMP(
void);
146 _ZFP_ZFMethodMP(
ZF_IN const _ZFP_ZFMethodMP &ref);
256 void _ZFP_ZFMethod_init(
265 ,
ZF_IN const _ZFP_ZFMethodMP &mp
267 void _ZFP_ZFMethod_initClassMemberType(
278 _ZFP_ZFMETHOD_INVOKER(0)
279 _ZFP_ZFMETHOD_INVOKER(1)
280 _ZFP_ZFMETHOD_INVOKER(2)
281 _ZFP_ZFMETHOD_INVOKER(3)
282 _ZFP_ZFMETHOD_INVOKER(4)
283 _ZFP_ZFMETHOD_INVOKER(5)
284 _ZFP_ZFMETHOD_INVOKER(6)
285 _ZFP_ZFMETHOD_INVOKER(7)
286 _ZFP_ZFMETHOD_INVOKER(8)
311 return this->_ZFP_ZFMethod_methodId.sigId();
317 return this->_ZFP_ZFMethod_isUserRegister;
323 return this->_ZFP_ZFMethod_isUserRegister ? this->_ZFP_ZFMethod_methodUserData :
zfnull;
333 return this->_ZFP_ZFMethod_isDynamicRegister;
339 return this->_ZFP_ZFMethod_isDynamicRegister ? this->_ZFP_ZFMethod_methodUserData :
zfnull;
345 return this->_ZFP_ZFMethod_methodName;
352 return this->_ZFP_ZFMethod_returnTypeId;
359 return (
zfindex)this->_ZFP_ZFMethod_paramCount;
366 return (
zfindex)this->_ZFP_ZFMethod_paramCountMin;
390 return this->_ZFP_ZFMethod_paramTypeIdList()[index];
397 return this->_ZFP_ZFMethod_paramNameList()[index];
411 return (this->_ZFP_ZFMethod_paramDefaultBeginIndex == (
zfuint)-1 ?
zfindexMax() : (
zfindex)this->_ZFP_ZFMethod_paramDefaultBeginIndex);
447 return this->_ZFP_ZFMethod_invoker;
519 return this->_ZFP_ZFMethod_methodGenericInvoker;
590 return this->_ZFP_ZFMethod_ownerClass;
596 return this->_ZFP_ZFMethod_ownerProperty;
632 return (this->_ZFP_ZFMethod_ownerClass ==
zfnull);
639 return this->_ZFP_ZFMethod_methodNamespace;
654 return this->_ZFP_ZFMethod_isInternal;
666 return this->_ZFP_ZFMethod_isInternalPrivate;
670 ZFMethod *_ZFP_ZFMethod_removeConst(
void)
const {
671 return const_cast<ZFMethod *
>(
this);
675 inline ZFSigName *_ZFP_ZFMethod_paramTypeIdList(
void)
const {
676 return _ZFP_ZFMethod_paramBuf;
678 inline ZFSigName *_ZFP_ZFMethod_paramNameList(
void)
const {
684 zfuint _ZFP_ZFMethod_refCount;
686 zfbool _ZFP_ZFMethod_isInternal;
687 zfbool _ZFP_ZFMethod_isInternalPrivate;
688 zfbool _ZFP_ZFMethod_isUserRegister;
689 zfbool _ZFP_ZFMethod_isDynamicRegister;
690 zfany _ZFP_ZFMethod_methodUserData;
693 _ZFP_ZFMethodPrivateExt *_ZFP_ZFMethod_ext;
699 zfuint _ZFP_ZFMethod_paramCount;
700 zfuint _ZFP_ZFMethod_paramCountMin;
702 ZFListener *_ZFP_ZFMethod_paramDefaultValueCallbackList;
703 zfuint _ZFP_ZFMethod_paramDefaultBeginIndex;
706 unsigned short _ZFP_ZFMethod_accessType;
707 unsigned short _ZFP_ZFMethod_methodType;
708 const ZFClass *_ZFP_ZFMethod_ownerClass;
709 const ZFProperty *_ZFP_ZFMethod_ownerProperty;
716extern ZFLIB_ZFCore void _ZFP_ZFMethodDataHolderInit(
void);
729 ,
ZF_IN const _ZFP_ZFMethodMP &mp
735 _ZFP_ZFMethodRegisterHolder(
747 ,
ZF_IN const _ZFP_ZFMethodMP &mp
749 ~_ZFP_ZFMethodRegisterHolder(
void);
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define ZFCoreAssert(exp)
assert exp is zftrue
Definition ZFCoreLog_CommonLog.h:47
_ZFT_t_zfchar zfchar
char wrapper
Definition ZFCoreTypeDef_CharType.h:17
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:192
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_OUT
dummy macro that shows the param used as required output
Definition ZFCoreTypeDef_ClassType.h:188
#define zfclassNotPOD
shows the class is not a POD type, you should not memset it or declare it in stack or copy value by c...
Definition ZFCoreTypeDef_ClassType.h:48
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#define ZFCLASS_DISALLOW_COPY_CONSTRUCTOR(ClassName)
a macro to show that a class doesn't allow copy constructor
Definition ZFCoreTypeDef_ClassType.h:81
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
_zft_zfidentity zfidentity
identity type, ensured at least 32 bit, ensured unsigned
Definition ZFCoreTypeDef_CoreType.h:225
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
void(* ZFFuncAddrType)(void)
dummy function address type
Definition ZFCoreTypeDef_OtherType.h:277
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
void ZFMethodForNameGetAllT(ZFCoreArray< const ZFMethod * > &ret, const zfstring &classNameOrNamespace, const zfstring &methodName)
util method to find method, see ZFMethodForName
ZFMethodType
the method type
Definition ZFMethod.h:43
@ ZFMethodTypeVirtual
virtual method
Definition ZFMethod.h:46
@ ZFMethodTypeStatic
static method
Definition ZFMethod.h:45
@ ZFMethodTypeNormal
normal method
Definition ZFMethod.h:44
ZFCoreArray< const ZFMethod * > ZFMethodForNameGetAll(const zfstring &classNameOrNamespace, const zfstring &methodName)
see ZFMethodForNameGetAllT
Definition ZFMethod.h:808
void ZFMethodAliasRemove(const ZFMethod *aliasMethod)
see ZFMethodAlias
void ZFMethodGetAllT(ZFCoreArray< const ZFMethod * > &ret)
see ZFMethodGetAll
const ZFMethod * ZFMethodForName(const zfstring &classNameOrNamespace, const zfstring &methodName)
util method to find method
ZFCoreArray< const ZFMethod * > ZFMethodGetAll(void)
get all method currently registered
Definition ZFMethod.h:765
const ZFMethod * ZFMethodAlias(const ZFMethod *method, const zfstring &aliasName)
create new ZFMethod and alias to existing method
ZFMethodAccessType
access type for ZFMethod
Definition ZFMethod.h:17
@ ZFMethodAccessTypePublic
public
Definition ZFMethod.h:18
@ ZFMethodAccessTypeProtected
protected
Definition ZFMethod.h:19
@ ZFMethodAccessTypePrivate
private
Definition ZFMethod.h:20
generic invoker declare for ZFMethod::methodGenericInvoker
void(* ZFMethodGenericInvoker)(const ZFArgs &zfargs)
generic invoker for advanced reflection, see ZFMethod::methodGenericInvoker
Definition ZFMethodGenericInvoker.h:24
#define ZFMP_DEF()
mark the object as default param
Definition ZFMethodGenericInvoker.h:30
#define ZFMETHOD_MAX_PARAM
max param supported by ZFMethod
Definition ZFMethodGenericInvoker.h:16
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
ZFObject's class info.
Definition ZFClass.h:67
light weight array
Definition ZFCoreArray.h:331
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
reflectable method for ZFObject
Definition ZFMethod.h:252
ZFMethodType methodType(void) const
method type
Definition ZFMethod.h:615
const ZFListener & paramDefaultValueCallbackAt(zfindex index) const
get the method param's default value access callback
ZFFuncAddrType methodInvoker(void) const
invoker function address for both class member type and function type
Definition ZFMethod.h:446
zfbool isFuncType(void) const
true if this method is function type (declared by ZFMETHOD_FUNC_DECLARE_XXX series)
Definition ZFMethod.h:631
zfauto methodInvoke(ZFObject *ownerObjOrNull=zft_zfnull) const
util method to invoke ZFMethodGenericInvoker
zfbool methodInvokeCheck(ZFObject *ownerObjOrNull, zfstring *errorHint=zft_zfnull) const
check whether this method can be invoke with specified object
const zfstring & paramNameAt(zfindex index) const
get the method's param name at index, usually for debug use
Definition ZFMethod.h:395
ZFMethodAccessType methodAccessType(void) const
get the method's access type
Definition ZFMethod.h:602
void paramInfoT(zfstring &ret) const
util to return param info
zfauto methodInvokeDetail(ZFObject *ownerObjOrNull, const ZFCoreArray< zfauto > ¶ms, zfbool *success=zft_zfnull, zfstring *errorHint=zft_zfnull) const
see methodInvoke
zfany dynamicRegisterUserData(void) const
see ZFMethodDynamicRegister
Definition ZFMethod.h:338
const zfstring & methodName(void) const
get the method's name
Definition ZFMethod.h:344
const zfstring & methodNamespace(void) const
get the method namespace, for func type only, null or empty string for global scope (ZF_NAMESPACE_GLO...
Definition ZFMethod.h:638
zfstring objectInfo(void) const
return object info
Definition ZFMethod.h:293
zfindex paramCountMin(void) const
get the method's minimum param num, same as paramCount if no default param
Definition ZFMethod.h:365
void objectInfoT(zfstring &ret) const
see objectInfo
ZFFuncAddrType methodInvokerOrig(void) const
see methodInvoker
void methodInvoker(ZFFuncAddrType methodInvoker) const
override original methodInvoker
zfbool isInternal(void) const
whether the method is internal method
Definition ZFMethod.h:653
zfindex paramDefaultBeginIndex(void) const
return the first default param's index, or zfindexMax if no default param
Definition ZFMethod.h:410
zfbool isInternalPrivate(void) const
whether the method is internal private method
Definition ZFMethod.h:665
void userRegisterUserData(ZFObject *userData) const
store impl state for ZFMethodUserRegister_0
zfbool isPublic(void) const
util to check whether methodAccessType is ZFMethodAccessTypePublic
Definition ZFMethod.h:606
zfbool isPrivate(void) const
util to check whether methodAccessType is ZFMethodAccessTypePrivate
Definition ZFMethod.h:610
const zfstring & paramTypeIdAt(zfindex index) const
get the method's param type id at index
Definition ZFMethod.h:388
const ZFProperty * ownerProperty(void) const
method's owner proeprty, null if none
Definition ZFMethod.h:595
zfbool isProtected(void) const
util to check whether methodAccessType is ZFMethodAccessTypeProtected
Definition ZFMethod.h:608
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
const ZFMethod * aliasFrom(void) const
see ZFMethodAlias
ZFMethodGenericInvoker methodGenericInvokerOrig(void) const
see methodGenericInvoker
const ZFCoreArray< const ZFMethod * > & aliasTo(void) const
see ZFMethodAlias
zfany userRegisterUserData(void) const
store impl state for ZFMethodUserRegister_0
Definition ZFMethod.h:322
zfbool isDynamicRegister(void) const
whether the method is registered by ZFMethodDynamicRegister
Definition ZFMethod.h:332
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 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
void methodGenericInvoker(ZFMethodGenericInvoker methodGenericInvoker) const
change default impl for methodGenericInvoker
const ZFClass * ownerClass(void) const
method's owner class, null for function type method
Definition ZFMethod.h:589
zfbool paramTypeIdIsMatch(const ZFMethod *method) const
see paramTypeIdIsMatch
zfbool isVirtual(void) const
util to check whether methodType is ZFMethodTypeVirtual
Definition ZFMethod.h:623
zfbool isStatic(void) const
util to check whether methodType is ZFMethodTypeStatic
Definition ZFMethod.h:621
zfbool isUserRegister(void) const
whether the method is registered by ZFMethodUserRegister_0
Definition ZFMethod.h:316
zfauto paramDefaultValueAt(zfindex index) const
get the method's param default value at index, null if no default param
zfidentity methodId(void) const
internal method id, for debug use only
Definition ZFMethod.h:310
ZFMethodGenericInvoker methodGenericInvoker(void) const
generic invoker for advanced reflection
Definition ZFMethod.h:518
const zfstring & returnTypeId(void) const
get the method's return value's type id
Definition ZFMethod.h:351
zfbool isNormal(void) const
util to check whether methodType is ZFMethodTypeNormal
Definition ZFMethod.h:619
zfstring paramInfo(void) const
see paramInfoT
Definition ZFMethod.h:422
zfindex paramCount(void) const
get the method's param num
Definition ZFMethod.h:358
base class of all objects
Definition ZFObjectCore.h:209
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:28
readonly string container for internal use only
Definition ZFSigName.h:17
util method to cast ZFObject types freely
Definition zfany.h:35
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34