From: John L. <jr...@us...> - 2007-12-10 05:39:22
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv23281/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua.cpp wxlua_bind.cpp Log Message: genwxbind.lua - don't create "returns" variable before use to save a line of code. Applied Lua patches for 5.1.2 8-11 Added wxlua_lreg_createtable(..) to create the LUA_REGISTRYINDEX tables for wxLua Added wxlua_lreg_regtable_key in LUA_REGISTRYINDEX to help the wxLuaDebugData find wxLua's tables faster to give more information Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlua.cpp 7 Dec 2007 06:44:47 -0000 1.6 --- wxlua.cpp 10 Dec 2007 05:39:10 -0000 1.7 *************** *** 72,80 **** static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L) { - int returns; // get this wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call GetAllocationFlag ! returns = (self->GetAllocationFlag()); // push the result number lua_pushnumber(L, returns); --- 72,79 ---- static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L) { // get this wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call GetAllocationFlag ! int returns = (self->GetAllocationFlag()); // push the result number lua_pushnumber(L, returns); Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** wxlstate.cpp 8 Dec 2007 00:25:24 -0000 1.148 --- wxlstate.cpp 10 Dec 2007 05:39:10 -0000 1.149 *************** *** 25,30 **** const char* wxlua_lreg_tags_key = "wxLua metatable class tags"; const char* wxlua_lreg_refs_key = "wxLua object references"; ! const char* wxlua_lreg_debug_refs_key = "wxLuaDebug references"; ! const char* wxlua_lreg_classes_key = "wxLuaBindClasses structs"; const char* wxlua_lreg_derivedmethods_key = "wxLua derived class methods"; const char* wxlua_lreg_wxluastate_key = "wxLuaState"; --- 25,30 ---- const char* wxlua_lreg_tags_key = "wxLua metatable class tags"; const char* wxlua_lreg_refs_key = "wxLua object references"; ! const char* wxlua_lreg_debug_refs_key = "wxLuaDebugData references"; ! const char* wxlua_lreg_classes_key = "wxLuaBindClass structs"; const char* wxlua_lreg_derivedmethods_key = "wxLua derived class methods"; const char* wxlua_lreg_wxluastate_key = "wxLuaState"; *************** *** 37,40 **** --- 37,41 ---- const char* wxlua_lreg_wxeventtype_key = "wxLua wxEventType"; const char* wxlua_lreg_wxluadebughookdata_key = "wxLuaDebugHookData"; + const char* wxlua_lreg_regtable_key = "wxLua LUA_REGISTRYINDEX tables"; const char* wxlua_metatable_tag_key = "wxLua Metatable Class Tag"; *************** *** 61,65 **** // figure out the types here in c++ land lua_getglobal(L, "tostring"); ! for (i = 1; i <= n; i++) { if (i > 1) msg.Append(wxT("\t")); // Lua uses a tab too in luaB_print --- 62,66 ---- // figure out the types here in c++ land lua_getglobal(L, "tostring"); ! for (i = 1; i <= n; ++i) { if (i > 1) msg.Append(wxT("\t")); // Lua uses a tab too in luaB_print *************** *** 119,123 **** // Assume they've set the wxEvtHandler, ok if not, but it wouldn't make sense // We use wxLuaState::SendEvent() because it sets wxEvent::SetEventObject() for us. ! if (hookData->m_lua_debug_hook_send_evt) { wxLuaState wxlState(L); --- 120,124 ---- // Assume they've set the wxEvtHandler, ok if not, but it wouldn't make sense // We use wxLuaState::SendEvent() because it sets wxEvent::SetEventObject() for us. ! if (hookData->m_lua_debug_hook_send_evt) { wxLuaState wxlState(L); *************** *** 169,172 **** --- 170,204 ---- // ---------------------------------------------------------------------------- + + void wxlua_lreg_createtable(lua_State* L, void* lightuserdata_reg_key) + { + // clear the old ref to the table, even though it's weak kv + // it doesn't get cleared until the gc runs + lua_pushlightuserdata(L, &wxlua_lreg_regtable_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // get table + lua_pushlightuserdata(L, lightuserdata_reg_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // get table or nil + if (lua_istable(L, -1)) + { + lua_pushnil(L); // push value + lua_rawset(L, -3); // clear t[key] = nil + lua_pop(L, 1); + } + else + lua_pop(L, 2); + + // Add new LUA_REGISTRYINDEX[lightuserdata_reg_key table] = lightuserdata_reg_key + lua_pushlightuserdata(L, lightuserdata_reg_key); // push key + lua_newtable(L); // push value + lua_pushlightuserdata(L, &wxlua_lreg_regtable_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // get wxlua_lreg_regtable_key table + lua_pushvalue(L, -2); // push key (copy of the new table) + lua_pushvalue(L, -4); // push value (copy of lightuserdata key) + lua_rawset(L, -3); // set t[key] = value; pops key and value + lua_pop(L, 1); // pop wxlua_lreg_regtable_key table + lua_rawset(L, LUA_REGISTRYINDEX); // set the value + } + + // ---------------------------------------------------------------------------- // Lua helper functions // ---------------------------------------------------------------------------- *************** *** 678,681 **** --- 710,741 ---- } + wxArrayString LUACALL wxluaO_gettrackedobjectstrings(lua_State *L) + { + wxArrayString arrStr; + + lua_pushlightuserdata(L, &wxlua_lreg_delobjects_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + + lua_pushnil(L); + while (lua_next(L, -2) != 0) + { + // value = -1, key = -2, table = -3 + wxString name(wxT("wxObject?")); + + wxObject* obj = (wxObject*)lua_touserdata(L, -1); + if (obj && obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) + name = obj->GetClassInfo()->GetClassName(); + + arrStr.Add(wxString::Format(wxT("%s %p"), name.c_str(), obj)); + + lua_pop(L, 1); // pop value, lua_next will pop key at end + } + + lua_pop(L, 1); // pop table + + arrStr.Sort(); + return arrStr; + } + void LUACALL wxluaO_cleartrackedmetatable(lua_State *L, const void *u) { *************** *** 764,767 **** --- 824,853 ---- } + wxArrayString LUACALL wxluaW_gettrackedwindowstrings(lua_State *L) + { + wxArrayString arrStr; + + lua_pushlightuserdata(L, &wxlua_lreg_topwindows_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + + lua_pushnil(L); + while (lua_next(L, -2) != 0) + { + // value = -1, key = -2, table = -3 + wxWindow* win = (wxWindow*)lua_touserdata(L, -2); + wxCHECK_MSG(win, arrStr, wxT("Invalid wxWindow")); + + wxString name(win->GetClassInfo()->GetClassName()); + arrStr.Add(wxString::Format(wxT("%s(%p id=%d)"), name.c_str(), win, win->GetId())); + + lua_pop(L, 1); // pop value, lua_next will pop key at end + } + + lua_pop(L, 1); // pop table + + arrStr.Sort(); + return arrStr; + } + // ---------------------------------------------------------------------------- // Functions to get info about the tags wxlua uses to determine type *************** *** 783,787 **** wxlClass = wxlClass->baseclass; ! levels++; } --- 869,873 ---- wxlClass = wxlClass->baseclass; ! ++levels; } *************** *** 799,807 **** while (c != NULL) { ! if (c->class_tag == wxlBaseClass->class_tag) return levels; c = c->baseclass; ! levels++; } --- 885,893 ---- while (c != NULL) { ! if (c->class_tag == wxlBaseClass->class_tag) // comparing pointers return levels; c = c->baseclass; ! ++levels; } *************** *** 862,879 **** // if we don't know the type (it's not predefined) ! if ((ret < 0) && L) { ! if (luatype == LUA_TTABLE) ! { ! const wxLuaBindClass* wxlClass = wxluaT_getclass(L, wxluaarg_tag); ! ! const wxLuaBindClass* arrClass = wxluaT_getclass(L, "wxArrayString"); ! if (wxlClass && (wxlua_isderivedclass(wxlClass, arrClass) >= 0)) ! return 1; ! arrClass = wxluaT_getclass(L, "wxArrayInt"); ! if (wxlClass && (wxlua_isderivedclass(wxlClass, arrClass) >= 0)) ! return 1; ! } } --- 948,961 ---- // if we don't know the type (it's not predefined) ! if ((ret < 0) && L &&(luatype == LUA_TTABLE)) { ! const wxLuaBindClass* wxlClass = wxluaT_getclass(L, wxluaarg_tag); ! if (wxlua_isderivedclass(wxlClass, wxluaT_getclass(L, "wxArrayString")) >= 0) ! ret = 1; ! else if (wxlua_isderivedclass(wxlClass, wxluaT_getclass(L, "wxSortedArrayString")) >= 0) ! ret = 1; ! else if (wxlua_isderivedclass(wxlClass, wxluaT_getclass(L, "wxArrayInt")) >= 0) ! ret = 1; } *************** *** 1083,1104 **** const char** LUACALL wxlua_getchararray(lua_State *L, int stack_idx, int &count) { ! const char **pItems = NULL; count = 0; if (lua_istable(L, stack_idx)) { ! int nItems = lua_objlen(L, stack_idx); ! if (nItems > 0) ! pItems = new const char *[nItems]; ! if (pItems != NULL) { ! for (int idx = 1; idx <= nItems; ++idx) { ! lua_rawgeti(L, stack_idx, idx); ! const char *pValue = wxlua_getstringtype(L, -1); ! pItems[count++] = pValue; lua_pop(L, 1); } } } else --- 1165,1189 ---- const char** LUACALL wxlua_getchararray(lua_State *L, int stack_idx, int &count) { ! const char **arrChar = NULL; count = 0; if (lua_istable(L, stack_idx)) { ! int table_len = lua_objlen(L, stack_idx); ! if (table_len > 0) ! arrChar = new const char *[table_len]; ! ! if (arrChar != NULL) { ! for (int n = 0; n < table_len; ++n) { ! lua_rawgeti(L, stack_idx, n+1); // Lua array starts at 1 ! const char *s = wxlua_getstringtype(L, -1); ! arrChar[n] = s; // share Lua string lua_pop(L, 1); } } + + count = table_len; } else *************** *** 1109,1113 **** } ! return pItems; } --- 1194,1198 ---- } ! return arrChar; } *************** *** 1134,1138 **** count = (int)((wxArrayInt&)arr).GetCount(); intArray = new int[count]; ! for (int n = 0; n < count; n++) intArray[n] = ((wxArrayInt&)arr)[n]; --- 1219,1223 ---- count = (int)((wxArrayInt&)arr).GetCount(); intArray = new int[count]; ! for (int n = 0; n < count; ++n) intArray[n] = ((wxArrayInt&)arr)[n]; *************** *** 1798,1808 **** // remove refs table to try to clear memory gracefully ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_refs_key); ! lua_newtable(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); ! ! lua_pushlightuserdata(m_lua_State, &wxlua_lreg_debug_refs_key); ! lua_newtable(m_lua_State); ! lua_rawset(m_lua_State, LUA_REGISTRYINDEX); //lua_pushlightuserdata(m_lua_State, &wxlua_lreg_derivedmethods_key); // gc will delete them --- 1883,1888 ---- // remove refs table to try to clear memory gracefully ! wxlua_lreg_createtable(m_lua_State, &wxlua_lreg_refs_key); ! wxlua_lreg_createtable(m_lua_State, &wxlua_lreg_debug_refs_key); //lua_pushlightuserdata(m_lua_State, &wxlua_lreg_derivedmethods_key); // gc will delete them *************** *** 1855,1861 **** lua_pop(L, 1); // pop table ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); // push key ! lua_newtable(L); // push value ! lua_rawset(L, LUA_REGISTRYINDEX); // set t[key] = value, pops key and value // ---------------------------------------------------------------------- --- 1935,1939 ---- lua_pop(L, 1); // pop table ! wxlua_lreg_createtable(m_lua_State, &wxlua_lreg_evtcallbacks_key); // ---------------------------------------------------------------------- *************** *** 1880,1886 **** lua_pop(L, 1); // pop table ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); // push key ! lua_newtable(L); // push value ! lua_rawset(L, LUA_REGISTRYINDEX); // set t[key] = value, pops key and value } --- 1958,1962 ---- lua_pop(L, 1); // pop table ! wxlua_lreg_createtable(m_lua_State, &wxlua_lreg_windestroycallbacks_key); } *************** *** 1952,1955 **** --- 2028,2037 ---- M_WXLSTATEDATA->m_lua_State_static = WXLUA_HASBIT(state_type, wxLUASTATE_STATICSTATE); + // Make the GC a little more aggressive since we push void* data + // that may quite large. The upshot is that Lua runs faster. + // Empirically found by timing: "for i = 1, 1E6 do local p = wx.wxPoint() end" + lua_gc(L, LUA_GCSETPAUSE, 120); + lua_gc(L, LUA_GCSETSTEPMUL, 400); + // Create a new state to push into Lua, the last wxLuaStateRefData will delete it. // Note: we call SetRefData() so that we don't increase the ref count. *************** *** 1963,1967 **** lua_rawset( L, LUA_REGISTRYINDEX ); // set the value ! // start off not in an event wxlua_setwxeventtype(L, wxEVT_NULL); --- 2045,2049 ---- lua_rawset( L, LUA_REGISTRYINDEX ); // set the value ! // start off not in an event wxlua_setwxeventtype(L, wxEVT_NULL); *************** *** 1975,2007 **** // shouldn't bother anyone. ! // create the tags table in registry ! lua_pushlightuserdata(L, &wxlua_lreg_tags_key); ! lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); // set the value // create the refs table in registry ! lua_pushlightuserdata(L, &wxlua_lreg_refs_key); ! lua_newtable(L); ! lua_rawset(L, LUA_REGISTRYINDEX); // set the value // create the debug refs table in registry ! lua_pushlightuserdata(L, &wxlua_lreg_debug_refs_key); ! lua_newtable(L); ! lua_rawset(L, LUA_REGISTRYINDEX); // set the value // create the wxLuaBindClasses table in the registry ! lua_pushlightuserdata(L, &wxlua_lreg_classes_key); ! lua_newtable(L); ! lua_rawset(L, LUA_REGISTRYINDEX); // Create a table for overridden methods for C++ userdata objects ! lua_pushlightuserdata(L, &wxlua_lreg_derivedmethods_key); ! lua_newtable(L); ! lua_rawset( L, LUA_REGISTRYINDEX ); // set the value // Create a table for the userdata that we've pushed into Lua // Use weak values so the gc works on them lua_pushlightuserdata(L, &wxlua_lreg_weakobjects_key); ! lua_newtable(L); // main table lua_newtable(L); // metatable lua_pushlstring(L, "__mode", 6); --- 2057,2089 ---- // shouldn't bother anyone. ! lua_pushlightuserdata(L, &wxlua_lreg_regtable_key); ! lua_newtable(L); // main table ! lua_newtable(L); // metatable ! lua_pushlstring(L, "__mode", 6); ! lua_pushlstring(L, "kv", 2); ! lua_rawset(L, -3); // set mode of main table ! lua_setmetatable(L, -2); // via the metatable lua_rawset(L, LUA_REGISTRYINDEX); // set the value + // create the tags table in registry + wxlua_lreg_createtable(L, &wxlua_lreg_tags_key); + // create the refs table in registry ! wxlua_lreg_createtable(L, &wxlua_lreg_refs_key); // create the debug refs table in registry ! wxlua_lreg_createtable(L, &wxlua_lreg_debug_refs_key); // create the wxLuaBindClasses table in the registry ! wxlua_lreg_createtable(L, &wxlua_lreg_classes_key); // Create a table for overridden methods for C++ userdata objects ! wxlua_lreg_createtable(L, &wxlua_lreg_derivedmethods_key); // Create a table for the userdata that we've pushed into Lua // Use weak values so the gc works on them + wxlua_lreg_createtable(L, &wxlua_lreg_weakobjects_key); lua_pushlightuserdata(L, &wxlua_lreg_weakobjects_key); ! lua_rawget(L, LUA_REGISTRYINDEX); lua_newtable(L); // metatable lua_pushlstring(L, "__mode", 6); *************** *** 2009,2033 **** lua_rawset(L, -3); // set mode of main table lua_setmetatable(L, -2); // via the metatable ! lua_rawset( L, LUA_REGISTRYINDEX ); // set the value // Create a table for objects to delete ! lua_pushlightuserdata(L, &wxlua_lreg_delobjects_key); ! lua_newtable(L); ! lua_rawset( L, LUA_REGISTRYINDEX ); // set the value // Create a table for wxLuaCallbacks ! lua_pushlightuserdata(L, &wxlua_lreg_evtcallbacks_key); ! lua_newtable(L); ! lua_rawset( L, LUA_REGISTRYINDEX ); // set the value // Create a table for wxLuaWinDestroyCallbacks ! lua_pushlightuserdata(L, &wxlua_lreg_windestroycallbacks_key); ! lua_newtable(L); ! lua_rawset( L, LUA_REGISTRYINDEX ); // set the value // Create a table for top level wxWindows ! lua_pushlightuserdata(L, &wxlua_lreg_topwindows_key); ! lua_newtable(L); ! lua_rawset( L, LUA_REGISTRYINDEX ); // set the value if (WXLUA_HASBIT(state_type, wxLUASTATE_USESTATE)) --- 2091,2107 ---- lua_rawset(L, -3); // set mode of main table lua_setmetatable(L, -2); // via the metatable ! lua_pop(L, 1); // Create a table for objects to delete ! wxlua_lreg_createtable(L, &wxlua_lreg_delobjects_key); // Create a table for wxLuaCallbacks ! wxlua_lreg_createtable(L, &wxlua_lreg_evtcallbacks_key); // Create a table for wxLuaWinDestroyCallbacks ! wxlua_lreg_createtable(L, &wxlua_lreg_windestroycallbacks_key); // Create a table for top level wxWindows ! wxlua_lreg_createtable(L, &wxlua_lreg_topwindows_key); if (WXLUA_HASBIT(state_type, wxLUASTATE_USESTATE)) *************** *** 2160,2172 **** } ! void wxLuaState::SendEvent( wxLuaEvent &event ) const { ! wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! if (GetEventHandler()) { event.SetEventObject( (wxObject*)this ); ! GetEventHandler()->ProcessEvent(event); } } --- 2234,2248 ---- } ! bool wxLuaState::SendEvent( wxLuaEvent &event ) const { ! wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! if (M_WXLSTATEDATA->m_wxlStateData->m_evtHandler) { event.SetEventObject( (wxObject*)this ); ! return M_WXLSTATEDATA->m_wxlStateData->m_evtHandler->ProcessEvent(event); } + + return false; } *************** *** 2300,2305 **** int newtop = lua_gettop(L); - wxString errorMsg; if (!CheckRunError(status, &errorMsg)) { --- 2376,2381 ---- int newtop = lua_gettop(L); wxString errorMsg; + if (!CheckRunError(status, &errorMsg)) { *************** *** 2449,2453 **** // These are the various hooks you can install //LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, and LUA_MASKCOUNT ! lua_sethook(GetLuaState(), wxlua_debugHookFunction, hook, count); } --- 2525,2529 ---- // These are the various hooks you can install //LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, and LUA_MASKCOUNT ! lua_sethook(M_WXLSTATEDATA->m_lua_State, wxlua_debugHookFunction, hook, count); } *************** *** 2527,2542 **** // Finally - set the global tags from the bindings we've just installed ! const wxLuaBindClass* wxlClass = NULL; ! wxlClass = GetBindClass("wxEvent"); ! wxCHECK_RET(wxlClass, wxT("wxEvent Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); ! g_wxluatag_wxEvent = *wxlClass->class_tag; ! ! wxlClass = GetBindClass("wxString"); ! wxCHECK_RET(wxlClass, wxT("wxString Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); ! g_wxluatag_wxString = *wxlClass->class_tag; ! ! wxlClass = GetBindClass("wxWindow"); ! wxCHECK_RET(wxlClass, wxT("wxWindow Lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); ! g_wxluatag_wxWindow = *wxlClass->class_tag; } --- 2603,2612 ---- // Finally - set the global tags from the bindings we've just installed ! g_wxluatag_wxEvent = wxluaT_gettag(L, "wxEvent"); ! g_wxluatag_wxString = wxluaT_gettag(L, "wxString"); ! g_wxluatag_wxWindow = wxluaT_gettag(L, "wxWindow"); ! g_wxluatag_wxArrayString = wxluaT_gettag(L, "wxArrayString"); ! g_wxluatag_wxSortedArrayString = wxluaT_gettag(L, "wxSortedArrayString"); ! g_wxluatag_wxArrayInt = wxluaT_gettag(L, "wxArrayInt"); } *************** *** 2638,2669 **** wxArrayString wxLuaState::GetTrackedObjectStrings() { ! wxArrayString names; ! ! wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); ! ! lua_State* L = M_WXLSTATEDATA->m_lua_State; ! ! lua_pushlightuserdata(L, &wxlua_lreg_delobjects_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) ! { ! // value = -1, key = -2, table = -3 ! wxString name(wxT("wxObject?")); ! ! wxObject* obj = (wxObject*)lua_touserdata(L, -1); ! if (obj && obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) ! name = obj->GetClassInfo()->GetClassName(); ! ! names.Add(wxString::Format(wxT("%s %p"), name.c_str(), obj)); ! ! lua_pop(L, 1); // pop value, lua_next will pop key at end ! } ! ! lua_pop(L, 1); // pop table ! ! names.Sort(); ! return names; } --- 2708,2713 ---- wxArrayString wxLuaState::GetTrackedObjectStrings() { ! wxCHECK_MSG(Ok(), wxArrayString(), wxT("Invalid wxLuaState")); ! return wxluaO_gettrackedobjectstrings(M_WXLSTATEDATA->m_lua_State); } *************** *** 2688,2716 **** wxArrayString wxLuaState::GetTrackedWindowStrings() const { ! wxArrayString names; ! ! wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); ! lua_State* L = M_WXLSTATEDATA->m_lua_State; ! ! lua_pushlightuserdata(L, &wxlua_lreg_topwindows_key); // push key ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) ! ! lua_pushnil(L); ! while (lua_next(L, -2) != 0) ! { ! // value = -1, key = -2, table = -3 ! wxWindow* win = (wxWindow*)lua_touserdata(L, -2); ! wxCHECK_MSG(win, names, wxT("Invalid wxWindow")); ! ! wxString name(win->GetClassInfo()->GetClassName()); ! names.Add(wxString::Format(wxT("%s(%p id=%d)"), name.c_str(), win, win->GetId())); ! ! lua_pop(L, 1); // pop value, lua_next will pop key at end ! } ! ! lua_pop(L, 1); // pop table ! ! names.Sort(); ! return names; } --- 2732,2737 ---- wxArrayString wxLuaState::GetTrackedWindowStrings() const { ! wxCHECK_MSG(Ok(), wxArrayString(), wxT("Invalid wxLuaState")); ! return wxluaW_gettrackedwindowstrings(M_WXLSTATEDATA->m_lua_State); } *************** *** 3756,3760 **** { size_t i, count = pathlist.GetCount(); ! for (i = 0; i < count; i++) { wxFileName fname(pathlist[i]); --- 3777,3781 ---- { size_t i, count = pathlist.GetCount(); ! for (i = 0; i < count; ++i) { wxFileName fname(pathlist[i]); Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** wxlbind.cpp 8 Dec 2007 00:25:24 -0000 1.102 --- wxlbind.cpp 10 Dec 2007 05:39:10 -0000 1.103 *************** *** 41,49 **** int s_wxluaarg_CFunction = WXLUAARG_CFunction; ! int g_wxluatag_wxLuaFunction = 0; ! int g_wxluatag_NULL = 0; ! int g_wxluatag_wxEvent = 0; ! int g_wxluatag_wxWindow = 0; ! int g_wxluatag_wxString = 0; //----------------------------------------------------------------------------- --- 41,52 ---- int s_wxluaarg_CFunction = WXLUAARG_CFunction; ! int g_wxluatag_wxLuaFunction = WXLUA_NOTAG; ! int g_wxluatag_NULL = WXLUA_NOTAG; ! int g_wxluatag_wxEvent = WXLUA_NOTAG; ! int g_wxluatag_wxWindow = WXLUA_NOTAG; ! int g_wxluatag_wxString = WXLUA_NOTAG; ! int g_wxluatag_wxArrayString = WXLUA_NOTAG; ! int g_wxluatag_wxSortedArrayString = WXLUA_NOTAG; ! int g_wxluatag_wxArrayInt = WXLUA_NOTAG; //----------------------------------------------------------------------------- *************** *** 175,182 **** } - // If there was a function that matched run it, if > 1 ??? // Note that the top function is the one that is highest in the // derived functions from any baseclasses and should be the best choice. ! if (funcArray.GetCount() == 1) { lua_CFunction func = ((wxLuaBindCFunc*)funcArray[0])->func; --- 178,185 ---- } // Note that the top function is the one that is highest in the // derived functions from any baseclasses and should be the best choice. ! // Example is wxBookCtrlBaseEvent::GetSelection() and wxCommandEvent::GetSelection() ! if (funcArray.GetCount() > 0) { lua_CFunction func = ((wxLuaBindCFunc*)funcArray[0])->func; *************** *** 193,197 **** // Build an error message wxString fnCall = name + wxT("("); ! for (arg = 0; arg < arg_count; arg++) { if (arg > 0) fnCall += wxT(", "); --- 196,200 ---- // Build an error message wxString fnCall = name + wxT("("); ! for (arg = 0; arg < arg_count; ++arg) { if (arg > 0) fnCall += wxT(", "); *************** *** 214,218 **** wxString fnOverloadList = wxT("wxLua Function Overload Table:\n"); wxArrayString overloadMethodArray = wxlua_CreateMethodArgTagsMsg(L, wxlMethod); ! for (i = 0; i < (int)overloadMethodArray.GetCount(); i++) fnOverloadList += overloadMethodArray[i] + wxT("\n"); --- 217,221 ---- wxString fnOverloadList = wxT("wxLua Function Overload Table:\n"); wxArrayString overloadMethodArray = wxlua_CreateMethodArgTagsMsg(L, wxlMethod); ! for (i = 0; i < (int)overloadMethodArray.GetCount(); ++i) fnOverloadList += overloadMethodArray[i] + wxT("\n"); *************** *** 277,281 **** className = lua2wx(wxlClass->name) + wxT("::"); ! for (i = 0; i < funcs_count; i++) { i_func++; --- 280,284 ---- className = lua2wx(wxlClass->name) + wxT("::"); ! for (i = 0; i < funcs_count; ++i) { i_func++; *************** *** 292,296 **** else { ! for (arg = 0; arg < funcs[i].maxargs; arg++) { // optional args? --- 295,299 ---- else { ! for (arg = 0; arg < funcs[i].maxargs; ++arg) { // optional args? *************** *** 474,478 **** { public: ! wxLuaSmartwxArrayStringRefData(wxArrayString* arr, int del) : m_arr(arr), m_delete(del) { if (!m_arr) { m_arr = new wxArrayString; m_delete = true; } // always exists --- 477,481 ---- { public: ! wxLuaSmartwxArrayStringRefData(wxArrayString* arr, int del) : m_arr(arr), m_delete(del) { if (!m_arr) { m_arr = new wxArrayString; m_delete = true; } // always exists *************** *** 483,490 **** wxArrayString *m_arr; bool m_delete; ! }; wxLuaSmartwxArrayString::wxLuaSmartwxArrayString(wxArrayString *arr, bool del) ! { m_refData = new wxLuaSmartwxArrayStringRefData(arr, del); } --- 486,493 ---- wxArrayString *m_arr; bool m_delete; ! }; wxLuaSmartwxArrayString::wxLuaSmartwxArrayString(wxArrayString *arr, bool del) ! { m_refData = new wxLuaSmartwxArrayStringRefData(arr, del); } *************** *** 501,505 **** { public: ! wxLuaSmartwxSortedArrayStringRefData(wxSortedArrayString* arr, int del) : m_arr(arr), m_delete(del) { if (!m_arr) { m_arr = new wxSortedArrayString; m_delete = true; } // always exists --- 504,508 ---- { public: ! wxLuaSmartwxSortedArrayStringRefData(wxSortedArrayString* arr, int del) : m_arr(arr), m_delete(del) { if (!m_arr) { m_arr = new wxSortedArrayString; m_delete = true; } // always exists *************** *** 510,517 **** wxSortedArrayString *m_arr; bool m_delete; ! }; wxLuaSmartwxSortedArrayString::wxLuaSmartwxSortedArrayString(wxSortedArrayString *arr, bool del) ! { m_refData = new wxLuaSmartwxSortedArrayStringRefData(arr, del); } --- 513,520 ---- wxSortedArrayString *m_arr; bool m_delete; ! }; wxLuaSmartwxSortedArrayString::wxLuaSmartwxSortedArrayString(wxSortedArrayString *arr, bool del) ! { m_refData = new wxLuaSmartwxSortedArrayStringRefData(arr, del); } *************** *** 540,544 **** wxLuaSmartwxArrayInt::wxLuaSmartwxArrayInt(wxArrayInt *arr, bool del) ! { m_refData = new wxLuaSmartwxArrayIntRefData(arr, del); } --- 543,547 ---- wxLuaSmartwxArrayInt::wxLuaSmartwxArrayInt(wxArrayInt *arr, bool del) ! { m_refData = new wxLuaSmartwxArrayIntRefData(arr, del); } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** wxlcallb.cpp 7 Dec 2007 06:44:46 -0000 1.48 --- wxlcallb.cpp 10 Dec 2007 05:39:10 -0000 1.49 *************** *** 139,142 **** --- 139,145 ---- event_tag = g_wxluatag_wxEvent; // get the s_wxluatag_wxEvent + // Should never get here, but error out in case we do + wxCHECK_RET(event_tag != WXLUA_NOTAG, wxT("Unknown wxEvent wxLua tag for : ") + wxString(event->GetClassInfo()->GetClassName())); + wxlState.lua_CheckStack(LUA_MINSTACK); int oldTop = wxlState.lua_GetTop(); Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** wxlua_bind.cpp 7 Dec 2007 06:44:47 -0000 1.14 --- wxlua_bind.cpp 10 Dec 2007 05:39:10 -0000 1.15 *************** *** 775,779 **** static int LUACALL wxLua_function_iswxluatype(lua_State *L) { - int returns; // int wxluaarg_tag int wxluaarg_tag = (int)wxlua_getnumbertype(L, 2); --- 775,778 ---- *************** *** 781,785 **** int luatype = (int)wxlua_getnumbertype(L, 1); // call wxlua_iswxluatype ! returns = (wxlua_iswxluatype(luatype, wxluaarg_tag)); // push the result number lua_pushnumber(L, returns); --- 780,784 ---- int luatype = (int)wxlua_getnumbertype(L, 1); // call wxlua_iswxluatype ! int returns = (wxlua_iswxluatype(luatype, wxluaarg_tag)); // push the result number lua_pushnumber(L, returns); *************** *** 843,847 **** static int LUACALL wxLua_function_wxLUA_CHECK_VERSION(lua_State *L) { - bool returns; // int release int release = (int)wxlua_getnumbertype(L, 3); --- 842,845 ---- *************** *** 851,855 **** int major = (int)wxlua_getnumbertype(L, 1); // call wxLUA_CHECK_VERSION ! returns = (wxLUA_CHECK_VERSION(major, minor, release)); // push the result flag lua_pushboolean(L, returns); --- 849,853 ---- int major = (int)wxlua_getnumbertype(L, 1); // call wxLUA_CHECK_VERSION ! bool returns = (wxLUA_CHECK_VERSION(major, minor, release)); // push the result flag lua_pushboolean(L, returns); *************** *** 863,867 **** static int LUACALL wxLua_function_wxLUA_CHECK_VERSION_FULL(lua_State *L) { - bool returns; // int subrel int subrel = (int)wxlua_getnumbertype(L, 4); --- 861,864 ---- *************** *** 873,877 **** int major = (int)wxlua_getnumbertype(L, 1); // call wxLUA_CHECK_VERSION_FULL ! returns = (wxLUA_CHECK_VERSION_FULL(major, minor, release, subrel)); // push the result flag lua_pushboolean(L, returns); --- 870,874 ---- int major = (int)wxlua_getnumbertype(L, 1); // call wxLUA_CHECK_VERSION_FULL ! bool returns = (wxLUA_CHECK_VERSION_FULL(major, minor, release, subrel)); // push the result flag lua_pushboolean(L, returns); *************** *** 927,944 **** } - // --------------------------------------------------------------------------- // wxLuaBinding_wxlua() - the binding class // --------------------------------------------------------------------------- - // binding class - extern wxLuaBindClass *wxLuaGetClassList_wxlua(size_t &count); - extern wxLuaBindDefine *wxLuaGetDefineList_wxlua(size_t &count); - extern wxLuaBindString *wxLuaGetStringList_wxlua(size_t &count); - extern wxLuaBindEvent *wxLuaGetEventList_wxlua(size_t &count); - extern wxLuaBindObject *wxLuaGetObjectList_wxlua(size_t &count); - extern wxLuaBindMethod *wxLuaGetFunctionList_wxlua(size_t &count); - - IMPLEMENT_DYNAMIC_CLASS(wxLuaBinding_wxlua, wxLuaBinding) --- 924,931 ---- *************** *** 963,968 **** } - // bind wxLuaBinding_wxlua to a single wxLuaState bool wxLuaBinding_wxlua_bind(const wxLuaState& wxlState_) { --- 950,955 ---- } + // --------------------------------------------------------------------------- bool wxLuaBinding_wxlua_bind(const wxLuaState& wxlState_) { *************** *** 981,985 **** return true; } ! // initialize wxLuaBinding_wxlua for all wxLuaStates bool wxLuaBinding_wxlua_init() { --- 968,972 ---- return true; } ! bool wxLuaBinding_wxlua_init() { |