本文整理汇总了C++中luaplus::LuaObject::SetMetaTable方法的典型用法代码示例。如果您正苦于以下问题:C++ LuaObject::SetMetaTable方法的具体用法?C++ LuaObject::SetMetaTable怎么用?C++ LuaObject::SetMetaTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luaplus::LuaObject
的用法示例。
在下文中一共展示了LuaObject::SetMetaTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateScriptObject
void BaseScriptComponent::CreateScriptObject(void)
{
LuaStateManager* pStateMgr = LuaStateManager::Get();
AC_ASSERT(pStateMgr);
AC_ASSERT(!m_scriptObject.IsNil());
LuaPlus::LuaObject metaTableObj = pStateMgr->GetGlobalVars().Lookup(METATABLE_NAME);
AC_ASSERT(!metaTableObj.IsNil());
LuaPlus::LuaObject boxedPtr = pStateMgr->GetLuaState()->BoxPointer(this);
boxedPtr.SetMetaTable(metaTableObj);
m_scriptObject.SetLightUserData("__object", this);
m_scriptObject.SetMetaTable(metaTableObj);
}
示例2: CreateScriptObject
void LuaScriptComponent::CreateScriptObject()
{
LuaStateManager* pStateManager = LuaStateManager::Get();
CB_ASSERT(pStateManager);
CB_ASSERT(!m_ScriptObject.IsNil());
LuaPlus::LuaObject metaTableObj = pStateManager->GetGlobalVars().Lookup(LUA_METATABLE_NAME);
CB_ASSERT(!metaTableObj.IsNil());
// bind the __object field in lua to this object
LuaPlus::LuaObject boxedPtr = pStateManager->GetLuaState()->BoxPointer(this);
boxedPtr.SetMetaTable(metaTableObj);
m_ScriptObject.SetLightUserData("__object", this);
m_ScriptObject.SetMetaTable(metaTableObj);
}
示例3:
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
LuaStateManager::LuaStateManager(void) : m_GlobalState(true)
{
//Create our metatable...
m_MetaTable = m_GlobalState->GetGlobals().CreateTable("LuaStateManagerMetaTable");
m_MetaTable.SetObject("__index", m_MetaTable);
// Here we register two functions to make them accessible to script.
m_MetaTable.RegisterObjectDirect("DoFile", (LuaStateManager *)0, &LuaStateManager::DoFile);
m_MetaTable.RegisterObjectDirect("DoResourceFile", (LuaStateManager *)0, &LuaStateManager::DoResourceFile);
m_MetaTable.RegisterObjectDirect("PrintDebugMessage", (LuaStateManager *)0, &LuaStateManager::PrintDebugMessage);
LuaPlus::LuaObject luaStateManObj = m_GlobalState->BoxPointer(this);
luaStateManObj.SetMetaTable(m_MetaTable);
// And here we expose the metatable as a named entity.
m_GlobalState->GetGlobals().SetObject("LuaStateManager", luaStateManObj);
}