[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Registering function
- From: Brian Hook <public@...>
- Date: Tue, 09 Oct 2001 17:19:15 -0700
For the Lua-impaired, can you explain how this works?  From looking at
it, I don't see where "this" is being passed?
Brian
> typedef int (*LuaStateCFunction)(LuaState state);
> 
> class LuaState
> {
> public:
> 	// Functions...
> 	void Register(const char* funcName, LuaStateCFunction function)
> 	{
> 		lua_pushstring(m_state, funcName);
> 		lua_pushcclosure(m_state, (lua_CFunction)function, 0);
> 		lua_settable(m_state, m_stackIndex);
> 	}
> 
> protected:
> 	lua_State* m_state;
> };
> 
> 
> static int Callback(LuaState state)
> {
> 	printf("Hi\n");
> 	return 0;
> }
> 
> 
> LuaState state;
> state.Register("Callback", Callback);
> 
> -Josh
>