From: John L. <jr...@us...> - 2007-08-03 22:17:20
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/include In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21726/wxLua/modules/wxlua/include Modified Files: wxlbind.h wxlcallb.h wxlstate.h Log Message: Simplify the wxLuaWinDestroyCallback to reuse the table of objects instead of it's own and have windows push into Lua the same as other objects. Index: wxlcallb.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlcallb.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** wxlcallb.h 26 Jul 2007 18:56:38 -0000 1.18 --- wxlcallb.h 3 Aug 2007 22:17:16 -0000 1.19 *************** *** 28,31 **** --- 28,34 ---- // ---------------------------------------------------------------------------- + #define WXLUACALLBACK_NOROUTINE 1000000 // use this for the lua_func_stack_idx + // param of the constructor for no Lua routine + class WXDLLIMPEXP_WXLUA wxLuaCallback : public wxObject { *************** *** 73,77 **** // wxLuaWinDestroyCallback - Handle the wxEVT_DESTROY event from wxWindows. // ! // Removes the reference to the window so lua won't delete it. // // Do NOT delete this, the wxEvtHandler deletes the callback user data itself. --- 76,82 ---- // wxLuaWinDestroyCallback - Handle the wxEVT_DESTROY event from wxWindows. // ! // Clears the metatable for the wxWindow userdata so that after a call to ! // win:Destroy() calling a function on win won't crash wxLua, but will generate ! // an error in Lua. // // Do NOT delete this, the wxEvtHandler deletes the callback user data itself. *************** *** 81,87 **** { public: ! wxLuaWinDestroyCallback(const wxLuaState& state, ! wxWindowID id, wxEvtHandler *evtHandler, ! int iTag); virtual ~wxLuaWinDestroyCallback(); --- 86,90 ---- { public: ! wxLuaWinDestroyCallback(const wxLuaState& state, wxWindow *win, int iTag); virtual ~wxLuaWinDestroyCallback(); *************** *** 89,95 **** void ClearwxLuaState() { m_wxlState.UnRef(); } ! wxLuaState GetwxLuaState() const { return m_wxlState; } ! int GetId() const { return m_id; } ! wxEvtHandler* GetEvtHandler() const { return m_evtHandler; } // Central event handler that calls OnDestroy() for the actual --- 92,97 ---- void ClearwxLuaState() { m_wxlState.UnRef(); } ! wxLuaState GetwxLuaState() const { return m_wxlState; } ! wxWindow* GetWindow() const { return m_window; } // Central event handler that calls OnDestroy() for the actual *************** *** 101,107 **** protected: ! wxLuaState m_wxlState; // store it since we're added to a list of it's callbacks. ! wxEvtHandler* m_evtHandler; ! int m_id; private: --- 103,108 ---- protected: ! wxLuaState m_wxlState; // store it since we're added to a list of it's callbacks. ! wxWindow* m_window; private: Index: wxlbind.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlbind.h,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** wxlbind.h 26 Jul 2007 18:56:38 -0000 1.57 --- wxlbind.h 3 Aug 2007 22:17:16 -0000 1.58 *************** *** 75,79 **** // copies of wxlua arg tags for binding types that are used very often extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxLuaFunction; // The lua tag for wxLuaFunctions. - extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxWinDestroyTable; // The lua tag for the wxWindow destroy tracking table extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_NULL; // The lua tag for NULL pointer extern WXDLLIMPEXP_DATA_WXLUA(int) g_wxluatag_wxEvent; // The lua tag for wxEvents --- 75,78 ---- Index: wxlstate.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/include/wxlstate.h,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** wxlstate.h 1 Aug 2007 19:15:37 -0000 1.89 --- wxlstate.h 3 Aug 2007 22:17:16 -0000 1.90 *************** *** 82,87 **** #define WXLUA_LREG_OBJECTS 5 #define WXLUA_LREG_CALLBASECLASSFUNC 6 ! #define WXLUA_METATABLE_TAG 7 ! #define WXLUA_METATABLE_CLASS 8 // Light user data used as keys in the lua registry table for wxLua items. --- 82,87 ---- #define WXLUA_LREG_OBJECTS 5 #define WXLUA_LREG_CALLBASECLASSFUNC 6 ! #define WXLUA_METATABLE_TAG 8 ! #define WXLUA_METATABLE_CLASS 9 // Light user data used as keys in the lua registry table for wxLua items. *************** *** 104,108 **** #define wxlua_pushkey_wxLuaReferences(L) lua_pushlightuserdata(L, &wxlua_lreg_references_key) // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table ! // t[wxLuaBindClass.name] = wxLuaBindClass, where the wxLuaBindClass is a lightuserdata. #define wxlua_pushkey_wxLuaClasses(L) lua_pushlightuserdata(L, &wxlua_lreg_classes_key) // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table --- 104,108 ---- #define wxlua_pushkey_wxLuaReferences(L) lua_pushlightuserdata(L, &wxlua_lreg_references_key) // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table ! // t[wxLuaBindClass.name] = wxLuaBindClass, where the wxLuaBindClass struct is a lightuserdata. #define wxlua_pushkey_wxLuaClasses(L) lua_pushlightuserdata(L, &wxlua_lreg_classes_key) // Push a key that is an index in the LUA_REGISTRYINDEX table that is a table *************** *** 162,165 **** --- 162,169 ---- // wxlua_pushkey_wxLuaObjects Lua registry table. WXDLLIMPEXP_WXLUA void LUACALL wxlua_tuntrackuserdata(lua_State* L, const void* u); + // If an object was pushed into Lua using wxlua_tpushusertag with track=true + // then this function will remove the metable of the object being tracked in the + // wxlua_pushkey_wxLuaObjects Lua registry table. + WXDLLIMPEXP_WXLUA void LUACALL wxlua_tcleartrackedmetatable(lua_State* L, const void* u); // Get the numeric tag of the object at the stack index using the metatable's "tag" key. // returns WXLUA_NOTAG if the metatable of the object doesn't have a "tag" |