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 zfchar *, param)
)
, ZFMP_IN(const zfchar *, 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_t_zfchar zfchar
char wrapper
Definition ZFCoreTypeDef_CharType.h:17
#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:670
#define ZFMETHOD_FUNC_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:636

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:127
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:127
base class of all objects
Definition ZFObjectCore.h:214
2D size
Definition ZFUITypeDef.h:399

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:62
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:121
#define ZFMETHOD_USER_REGISTER_FOR_WRAPPER_VAR(WrapperClass, VarType, VarName)
see ZFMethodUserRegister_0
Definition ZFMethodUserRegister.h:385
#define ZFTYPEID_DECLARE(ZFLIB_, TypeName, Type)
register a type
Definition ZFTypeIdCore.h:98
#define ZFTYPEID_DEFINE_BY_STRING_CONVERTER(TypeName, Type, convertFromStringAction, convertToStringAction)
see ZFTYPEID_DECLARE
Definition ZFTypeIdCore.h:276