Changed HOOKS singleton to register itself with lua correctly so that it can be used by lua.

This commit is contained in:
Kyzentun Keeslala
2015-07-08 15:39:00 -06:00
parent a8e22c3e81
commit f6d369372f
3 changed files with 15 additions and 12 deletions
+1
View File
@@ -977,6 +977,7 @@ int sm_main(int argc, char* argv[])
HOOKS->Init();
LUA = new LuaManager;
HOOKS->RegisterWithLua();
// Initialize the file extension type lists so everything can ask ActorUtil
// what the type of a file is.
+13 -12
View File
@@ -67,6 +67,19 @@ RString ArchHooks::GetClipboard()
return "";
}
/* XXX: Most singletons register with lua in their constructor. ArchHooks is
* instantiated before Lua, so we encounter a dependency problem when
* trying to register HOOKS. Work around it by registering HOOKS function
* which sm_main will call after instantiating Lua. */
void ArchHooks::RegisterWithLua()
{
Lua *L = LUA->Get();
lua_pushstring( L, "HOOKS" );
HOOKS->PushSelf( L );
lua_settable( L, LUA_GLOBALSINDEX );
LUA->Release( L );
}
// lua start
#include "LuaBinding.h"
#include "LuaReference.h"
@@ -85,18 +98,6 @@ public:
};
LUA_REGISTER_CLASS( ArchHooks );
/* XXX: ArchHooks is instantiated before Lua, so we encounter a dependency problem when
* trying to register HOOKS. Work around it by registering HOOKS in a static function,
* which LuaManager will call when it is instantiated. */
void LuaFunc_Register_Hooks( lua_State *L )
{
lua_pushstring( L, "HOOKS" );
HOOKS->PushSelf( L );
lua_settable( L, LUA_GLOBALSINDEX );
}
REGISTER_WITH_LUA_FUNCTION( LuaFunc_Register_Hooks );
/*
* (c) 2003-2004 Glenn Maynard, Chris Danford
* All rights reserved.
+1
View File
@@ -123,6 +123,7 @@ public:
// Lua
void PushSelf( lua_State *L );
void RegisterWithLua();
private:
/* This are helpers for GetMicrosecondsSinceStart on systems with a timer