From: John L. <jr...@us...> - 2007-08-10 01:41:11
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10860/wxLua/modules/wxlua/include Modified Files: wxlstate.h Log Message: Push the wxLuaState into Lua instead of the wxLuaStateRefData Also Hash the wxLuaState instead of the wxLuaStateRefData Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** wxlstate.h 7 Aug 2007 20:23:25 -0000 1.91 --- wxlstate.h 10 Aug 2007 01:41:08 -0000 1.92 *************** *** 79,83 **** #define WXLUA_LREG_CLASSES 2 #define WXLUA_LREG_DERIVED_METHODS 3 ! #define WXLUA_LREG_WXLUASTATEREFDATA 4 #define WXLUA_LREG_OBJECTS 5 #define WXLUA_LREG_CALLBASECLASSFUNC 6 --- 79,83 ---- #define WXLUA_LREG_CLASSES 2 #define WXLUA_LREG_DERIVED_METHODS 3 ! #define WXLUA_LREG_WXLUASTATE 4 #define WXLUA_LREG_OBJECTS 5 #define WXLUA_LREG_CALLBASECLASSFUNC 6 *************** *** 90,94 **** extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_classes_key; // WXLUA_LREG_CLASSES extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_derivedmethods_key; // WXLUA_LREG_DERIVED_METHODS ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_wxluastaterefdata_key; // WXLUA_LREG_WXLUASTATEREFDATA extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_objects_key; // WXLUA_LREG_OBJECTS extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_callbaseclassfunc_key; // WXLUA_LREG_CALLBASECLASSFUNC --- 90,94 ---- extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_classes_key; // WXLUA_LREG_CLASSES extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_derivedmethods_key; // WXLUA_LREG_DERIVED_METHODS ! extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_wxluastate_key; // WXLUA_LREG_WXLUASTATE extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_objects_key; // WXLUA_LREG_OBJECTS extern WXDLLIMPEXP_DATA_WXLUA(int) wxlua_lreg_callbaseclassfunc_key; // WXLUA_LREG_CALLBASECLASSFUNC *************** *** 111,116 **** #define wxlua_pushkey_wxLuaDerivedMethods(L) lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key) // Push a key that is an index of the LUA_REGISTRYINDEX table who's value is a ! // lightuserdata of the wxLuaStateRefData for this lua_State. ! #define wxlua_pushkey_wxLuaStateRefData(L) lua_pushlightuserdata(L, &wxlua_lreg_wxluastaterefdata_key) // Push a key that is an index of the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua using t[lightuserdata] = [weak valued full userdata] --- 111,116 ---- #define wxlua_pushkey_wxLuaDerivedMethods(L) lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key) // Push a key that is an index of the LUA_REGISTRYINDEX table who's value is a ! // lightuserdata of the wxLuaState for this lua_State. ! #define wxlua_pushkey_wxLuaState(L) lua_pushlightuserdata(L, &wxlua_lreg_wxluastate_key) // Push a key that is an index of the LUA_REGISTRYINDEX table that is table of all // objects that we've pushed into Lua using t[lightuserdata] = [weak valued full userdata] *************** *** 358,362 **** #include "wx/hashmap.h" ! WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(wxLuaStateRefData *, wxHashMapLuaStateRefData, class WXDLLIMPEXP_WXLUA); class WXDLLIMPEXP_WXLUA wxLuaStateRefData : public wxObjectRefData --- 358,362 ---- #include "wx/hashmap.h" ! WX_DECLARE_VOIDPTR_HASH_MAP_WITH_DECL(wxLuaState *, wxHashMapLuaState, class WXDLLIMPEXP_WXLUA); class WXDLLIMPEXP_WXLUA wxLuaStateRefData : public wxObjectRefData *************** *** 369,374 **** // if 'force' = true then make sure all wxWindows are destroyed. bool CloseLuaState(bool force); - // Free up the tracked resources list. - void CleanupWxLua(bool closeLua = true); // clear all wxLuaCallbacks on destruction void ClearCallbacks(); --- 369,372 ---- *************** *** 385,395 **** bool m_own_stateData; // not a coroutine when true, so delete it when done ! // Get the wxLuaStateRefData from the corresponding lua_State ! // returns NULL if none found. ! static wxLuaStateRefData* GetLuaStateRefData(lua_State* L); ! // A mapping between hashmap[lua_State* L] = *wxLuaStateRefData // Note: The coroutine lua_States are not hashed since we cannot know when // they are deleted. We create wxLuaStates for them on the fly. ! static wxHashMapLuaStateRefData s_wxHashMapLuaStateRefData; }; --- 383,396 ---- bool m_own_stateData; // not a coroutine when true, so delete it when done ! // Get the wxLuaState from the corresponding lua_State ! // returns wxNullLuaState if none found. ! static wxLuaState GetLuaState(lua_State* L); ! // A mapping between hashmap[lua_State* L] = *wxLuaState ! // Note: The hashed new wxLuaState is not Refed since we want to know when ! // the ref count goes to 1 for cleanup and it is deleted when ! // it's wxLuaStateRefData is finally deleted. // Note: The coroutine lua_States are not hashed since we cannot know when // they are deleted. We create wxLuaStates for them on the fly. ! static wxHashMapLuaState s_wxHashMapLuaState; }; *************** *** 419,427 **** wxLuaState(wxEvtHandler *handler, wxWindowID id = wxID_ANY) { Create(handler, id); } // Create a wxLuaState from an existing lua_State ! wxLuaState(lua_State* L, wxLuaState_Type type = WXLUASTATE_ATTACH) { Create(L, type); } // Copy constructor, refs existing wxLuaState ! wxLuaState(const wxLuaState& wxlState) { Create(wxlState); } ! // Copy constructor, refs existing wxLuaStateRefData (internal use) ! wxLuaState(wxLuaStateRefData* refData, lua_State* L) { Create(refData, L); } // ALWAYS destroy lua_State instead of calling UnRef, else circular --- 420,426 ---- wxLuaState(wxEvtHandler *handler, wxWindowID id = wxID_ANY) { Create(handler, id); } // Create a wxLuaState from an existing lua_State ! inline wxLuaState(lua_State* L, wxLuaState_Type type = WXLUASTATE_ATTACH) { Create(L, type); } // Copy constructor, refs existing wxLuaState ! inline wxLuaState(const wxLuaState& wxlState) { Create(wxlState); } // ALWAYS destroy lua_State instead of calling UnRef, else circular *************** *** 437,442 **** // input lua_State bool Create(lua_State* L, wxLuaState_Type type = WXLUASTATE_ATTACH); - // attach to the refData (internal use) - bool Create(wxLuaStateRefData* refData, lua_State* L); // ----------------------------------------------------------------------- --- 436,439 ---- |