Exemplo n.º 1
0
void LuaInterface::pushObject(const LuaObjectPtr& obj)
{
    // fills a new userdata with a new LuaObjectPtr pointer
    new(newUserdata(sizeof(LuaObjectPtr))) LuaObjectPtr(obj);

    // set the userdata metatable
    getGlobal(Fw::mkstr(obj->getClassName(), "_mt"));
    assert(!isNil());
    setMetatable();
}
Exemplo n.º 2
0
void LuaInterface::pushObject(const LuaObjectPtr& obj)
{
    // fills a new userdata with a new LuaObjectPtr pointer
    new(newUserdata(sizeof(LuaObjectPtr))) LuaObjectPtr(obj);
    m_totalObjRefs++;

    obj->luaGetMetatable();
    if(isNil())
        g_logger.fatal(stdext::format("metatable for class '%s' not found, did you bind the C++ class?", obj->getClassName()));
    setMetatable();
}
Exemplo n.º 3
0
void LuaInterface::pushCppFunction(const LuaCppFunction& func)
{
    // create a pointer to func (this pointer will hold the function existence)
    new(newUserdata(sizeof(LuaCppFunctionPtr))) LuaCppFunctionPtr(new LuaCppFunction(func));

    // sets the userdata __gc metamethod, needed to free the function pointer when it gets collected
    newTable();
    pushCFunction(&LuaInterface::luaCollectCppFunction);
    setField("__gc");
    setMetatable();

    // actually pushes a C function callback that will call the cpp function
    pushCFunction(&LuaInterface::luaCppFunctionCallback, 1);
}
Exemplo n.º 4
0
static int createLuaobj(lua_State* L, IniFile* ini)
{
    return newUserdata(L, ini, INI_META_LIB);
}