// ********************************************************************************************************* bool CDisplayerLua::init(const CLuaObject ¶meters) { //H_AUTO(R2_CDisplayerLua_init) // parameters should be a function that create the lua displayer CLuaStackChecker lsc(parameters.getLuaState()); _ToLua._LuaTable.release(); if (parameters.isString()) { getEditor().getEnv()[parameters.toString()].push(); // get method from the R2 env } else { parameters.push(); } CLuaState &ls = *parameters.getLuaState(); getEditor().getEnv().push(); // this is a method call if (CLuaIHM::executeFunctionOnStack(ls, 1, 1)) { _ToLua._LuaTable.pop(ls); } else { nlwarning("<CDisplayerLua::init> Error while calling displayer ctor (parameter should be a r2 method, or the *name* of a r2 method) : param is : "); parameters.dump(); return false; } return CDisplayerBase::init(parameters); }
// ************************************************************************ void CObjectTableClient::pushOnLuaStack(CLuaState &state, CLuaObject &metatable) const { //H_AUTO(R2_CObjectTableClient_pushOnLuaStack) // cache refptr here to avoid costly allocations CLuaStackChecker lsc(&state, 1); if (!_Ref.isValid()) { nlassert(metatable.isValid()); // return a new refptr on the sub table void *block = state.newUserData(sizeof(TRefPtrConst)); new (block) CObjectTable::TRefPtrConst(this); // create in place metatable.push(); state.setMetaTable(-2); _Ref.pop(state); } nlassert(_Ref.getLuaState() == &state); _Ref.push(); }