From: John L. <jr...@us...> - 2007-12-13 00:47:58
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv15370/wxLua/modules/wxluasocket/src Modified Files: wxlsock.cpp wxluasocket.cpp Log Message: * Allowed using wxObject:DynamicCast() on an object and be able to use the object as both types. The problem was that wxEvent:GetEventObject() returned a wxObject which overwrote the wxWindow (perhaps) that you had as a userdata in Lua already. Additionally, if you delete an object all of the userdata that wrap it have their metatables cleared for safety. Functions renamed since they didn't do the same thing or behave the same. wxluaO_istrackedobject -> wxluaO_isgcobject wxluaO_addtrackedobject -> wxluaO_addgcobject wxluaO_removetrackedobject -> wxluaO_deletegcobject - Created a central luauserdata:delete() function for the bindings to reduce code. wxLua_wxluabind_delete(L) wxLuaStackDialog: You can expand both key and values of a table and more information is provided about items wxLua knows about. Index: wxluasocket.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxluasocket.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** wxluasocket.cpp 10 Dec 2007 05:39:10 -0000 1.34 --- wxluasocket.cpp 13 Dec 2007 00:47:53 -0000 1.35 *************** *** 346,362 **** static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaDebuggerServer_delete[] = { &s_wxluatag_wxLuaDebuggerServer, NULL }; ! static int LUACALL wxLua_wxLuaDebuggerServer_delete(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaDebuggerServer_delete[1] = {{ wxLua_wxLuaDebuggerServer_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatagArray_wxLua_wxLuaDebuggerServer_delete }}; ! static int LUACALL wxLua_wxLuaDebuggerServer_delete(lua_State *L) ! { ! wxLuaDebuggerServer * self = (wxLuaDebuggerServer *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerServer); ! // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxluaO_removetrackedobject(L, self, wxLUA_DELETE_CLEAR_OBJECT)) ! { ! lua_pushnil(L); ! lua_setmetatable(L, -2); ! } ! return 0; ! } static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaDebuggerServer_constructor[] = { &s_wxluaarg_Number, NULL }; --- 346,350 ---- static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaDebuggerServer_delete[] = { &s_wxluatag_wxLuaDebuggerServer, NULL }; ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaDebuggerServer_delete[1] = {{ wxLua_wxluabind_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatagArray_wxLua_wxLuaDebuggerServer_delete }}; static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaDebuggerServer_constructor[] = { &s_wxluaarg_Number, NULL }; *************** *** 372,376 **** wxLuaDebuggerServer* returns = new wxLuaDebuggerServer(portNumber); // add to tracked memory list ! wxluaO_addtrackedobject(L, returns); // push the constructed class pointer wxluaT_pushuserdatatype(L, s_wxluatag_wxLuaDebuggerServer, returns); --- 360,364 ---- wxLuaDebuggerServer* returns = new wxLuaDebuggerServer(portNumber); // add to tracked memory list ! wxluaO_addgcobject(L, returns); // push the constructed class pointer wxluaT_pushuserdatatype(L, s_wxluatag_wxLuaDebuggerServer, returns); *************** *** 482,498 **** static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaDebuggerEvent_delete[] = { &s_wxluatag_wxLuaDebuggerEvent, NULL }; ! static int LUACALL wxLua_wxLuaDebuggerEvent_delete(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaDebuggerEvent_delete[1] = {{ wxLua_wxLuaDebuggerEvent_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatagArray_wxLua_wxLuaDebuggerEvent_delete }}; ! static int LUACALL wxLua_wxLuaDebuggerEvent_delete(lua_State *L) ! { ! wxLuaDebuggerEvent * self = (wxLuaDebuggerEvent *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaDebuggerEvent); ! // if removed from tracked mem list, reset the tag so that gc() is not called on this object. ! if ((self != NULL) && wxluaO_removetrackedobject(L, self, wxLUA_DELETE_CLEAR_OBJECT)) ! { ! lua_pushnil(L); ! lua_setmetatable(L, -2); ! } ! return 0; ! } --- 470,474 ---- static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaDebuggerEvent_delete[] = { &s_wxluatag_wxLuaDebuggerEvent, NULL }; ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaDebuggerEvent_delete[1] = {{ wxLua_wxluabind_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatagArray_wxLua_wxLuaDebuggerEvent_delete }}; Index: wxlsock.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxlsock.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** wxlsock.cpp 10 Dec 2007 05:39:10 -0000 1.33 --- wxlsock.cpp 13 Dec 2007 00:47:53 -0000 1.34 *************** *** 275,279 **** if (!ok) break; ! *(wxInt32 *) pMemory = (wxInt32)item->GetReference(); pMemory += sizeof(wxInt32); --- 275,279 ---- if (!ok) break; ! *(wxInt32 *) pMemory = (wxInt32)item->GetRef(); pMemory += sizeof(wxInt32); |