示例#1
0
void LuaInterface::init()
{
    createLuaState();

    // check if demangle_type is working as expected
    assert(Fw::demangleType<LuaObject>() == "LuaObject");

    // register LuaObject, the base of all other objects
    registerClass<LuaObject>();
    bindClassMemberFunction<LuaObject>("getUseCount", &LuaObject::getUseCount);
    bindClassMemberFunction<LuaObject>("getClassName", &LuaObject::getClassName);

    registerClassMemberFunction<LuaObject>("getFieldsTable", (LuaCppFunction) ([](LuaInterface* lua) {
        LuaObjectPtr obj = g_lua.popObject();
        obj->luaGetFieldsTable();
        return 1;
    }));
}
示例#2
0
void LuaInterface::init()
{
    createLuaState();

    // store global environment reference
    pushThread();
    getEnv();
    m_globalEnv = ref();
    pop();

    // check if demangle_class is working as expected
    assert(stdext::demangle_class<LuaObject>() == "LuaObject");

    // register LuaObject, the base of all other objects
    registerClass<LuaObject>();
    bindClassMemberFunction<LuaObject>("getUseCount", &LuaObject::getUseCount);
    bindClassMemberFunction<LuaObject>("getClassName", &LuaObject::getClassName);

    registerClassMemberFunction<LuaObject>("getFieldsTable", (LuaCppFunction) ([](LuaInterface* lua) -> int {
        LuaObjectPtr obj = g_lua.popObject();
        obj->luaGetFieldsTable();
        return 1;
    }));
}