ZFFramework
 
Loading...
Searching...
No Matches
Automatically lua binding

thanks to powerful reflection logic of ZFFramework (see also Reflection), we are able to achieve automatically lua binding without any other code
all reflectable ZFClass/ZFMethod/ZFProperty would be binded to lua automatically, even including anything that are dynamically loaded from library

example:

// in C++
, ZFMP_IN(const zfstring &, param)
)
, ZFMP_IN(const zfstring &, param)
) {
return param;
}
// in lua, just use the function directly
local ret = myFunc(param);
#define ZFLIB_APP
used to export symbols
Definition ZFCoreEnvDef.h:35
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_FUNC_DEFINE_1(ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:658
#define ZFMETHOD_FUNC_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:624

example:

// in C++
};
// in lua
local obj = MyClass();
local value = obj:myProp();
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
base class of all objects
Definition ZFObjectCore.h:209
2D size
Definition ZFUITypeDef.h:397

param and return supports any type that are registered by ZFTYPEID_DECLARE

// header file
class YourType {
public:
int yourProp;
};
ZFTYPEID_DECLARE(ZFLIB_APP, YourType, YourType)
// source file
v.yourProp = yourParser(src, srcLen);
return zftrue;
}, {
yourPrinter(s, v);
return zftrue;
})
// in lua
local obj = YourType();
local yourProp = obj:yourProp();
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:165
#define ZFMETHOD_USER_REGISTER_FOR_WRAPPER_VAR(WrapperClass, VarType, VarName)
see ZFMethodUserRegister_0
Definition ZFMethodUserRegister_Wrapper.h:59
#define ZFTYPEID_DECLARE(ZFLIB_, TypeName, Type)
register a type for reflection
Definition ZFTypeIdDeclare.h:137
#define ZFTYPEID_DEFINE_BY_STRING_CONVERTER(TypeName, Type, convertFromStringAction, convertToStringAction)
see ZFTYPEID_DECLARE
Definition ZFTypeIdDeclare.h:166