Changed HOOKS singleton to register itself with lua correctly so that it can be used by lua.
This commit is contained in:
@@ -977,6 +977,7 @@ int sm_main(int argc, char* argv[])
|
|||||||
HOOKS->Init();
|
HOOKS->Init();
|
||||||
|
|
||||||
LUA = new LuaManager;
|
LUA = new LuaManager;
|
||||||
|
HOOKS->RegisterWithLua();
|
||||||
|
|
||||||
// Initialize the file extension type lists so everything can ask ActorUtil
|
// Initialize the file extension type lists so everything can ask ActorUtil
|
||||||
// what the type of a file is.
|
// what the type of a file is.
|
||||||
|
|||||||
@@ -67,6 +67,19 @@ RString ArchHooks::GetClipboard()
|
|||||||
return "";
|
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
|
// lua start
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
#include "LuaReference.h"
|
#include "LuaReference.h"
|
||||||
@@ -85,18 +98,6 @@ public:
|
|||||||
};
|
};
|
||||||
LUA_REGISTER_CLASS( ArchHooks );
|
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
|
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ public:
|
|||||||
|
|
||||||
// Lua
|
// Lua
|
||||||
void PushSelf( lua_State *L );
|
void PushSelf( lua_State *L );
|
||||||
|
void RegisterWithLua();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* This are helpers for GetMicrosecondsSinceStart on systems with a timer
|
/* This are helpers for GetMicrosecondsSinceStart on systems with a timer
|
||||||
|
|||||||
Reference in New Issue
Block a user