From: John L. <jr...@us...> - 2007-12-15 16:56:46
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv24974/wxLua/modules/wxlua/src Modified Files: wxlcallb.cpp wxlstate.cpp wxlua_bind.cpp Log Message: * Changed signature of the function wxLuaState::SetLuaDebugHook() so that the inputs to lua_sethook() are together and in the same order. - Renamed wxLuaCallback to wxLuaEventCallback to make it more clear that it is a callback for the wxEvents using wxEvtHandlers. Cleaned up the comments in the headers. Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** wxlstate.cpp 13 Dec 2007 06:23:55 -0000 1.151 --- wxlstate.cpp 15 Dec 2007 16:56:41 -0000 1.152 *************** *** 33,37 **** const char* wxlua_lreg_weakobjects_key = "wxLua objects pushed"; const char* wxlua_lreg_gcobjects_key = "wxLua gc objects to delete"; ! const char* wxlua_lreg_evtcallbacks_key = "wxLuaCallbacks"; const char* wxlua_lreg_windestroycallbacks_key = "wxLuaWinDestoyCallbacks"; const char* wxlua_lreg_topwindows_key = "wxLua top level wxWindows"; --- 33,37 ---- const char* wxlua_lreg_weakobjects_key = "wxLua objects pushed"; const char* wxlua_lreg_gcobjects_key = "wxLua gc objects to delete"; ! const char* wxlua_lreg_evtcallbacks_key = "wxLuaEventCallbacks"; const char* wxlua_lreg_windestroycallbacks_key = "wxLuaWinDestoyCallbacks"; [...1186 lines suppressed...] --- 2890,2895 ---- { // value = -1, key = -2, table = -3 ! wxLuaEventCallback* wxlCallback = (wxLuaEventCallback*)lua_touserdata(L, -2); ! wxCHECK_MSG(wxlCallback, names, wxT("Invalid wxLuaEventCallback")); names.Add(wxlCallback->GetInfo()); *************** *** 2955,2959 **** } ! wxArrayString wxLuaState::GetTrackedWinDestroyCallbackStrings() const { wxArrayString names; --- 2946,2950 ---- } ! wxArrayString wxLuaState::GetTrackedWinDestroyCallbackInfo() const { wxArrayString names; Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** wxlcallb.cpp 13 Dec 2007 06:23:55 -0000 1.51 --- wxlcallb.cpp 15 Dec 2007 16:56:41 -0000 1.52 *************** *** 1,5 **** ///////////////////////////////////////////////////////////////////////////// // Name: wxlcallb.cpp ! // Purpose: wxLuaCallback and wxLuaWinDestroyCallback // Author: Francis Irving, John Labenski // Created: 11/05/2002 --- 1,5 ---- ///////////////////////////////////////////////////////////////////////////// // Name: wxlcallb.cpp ! // Purpose: wxLuaEventCallback and wxLuaWinDestroyCallback // Author: Francis Irving, John Labenski // Created: 11/05/2002 *************** *** 22,35 **** //----------------------------------------------------------------------------- ! // wxLuaCallback //----------------------------------------------------------------------------- ! IMPLEMENT_ABSTRACT_CLASS(wxLuaCallback, wxObject) ! wxLuaCallback::wxLuaCallback(const wxLuaState& wxlState, int lua_func_stack_idx, ! wxWindowID win_id, wxWindowID last_id, ! wxEventType eventType, wxEvtHandler *evtHandler) ! : m_routine(0), m_wxlState(wxlState), ! m_evtHandler(evtHandler), m_id(win_id), m_last_id(last_id), ! m_wxlBindEvent(NULL) { --- 22,35 ---- //----------------------------------------------------------------------------- ! // wxLuaEventCallback //----------------------------------------------------------------------------- ! IMPLEMENT_ABSTRACT_CLASS(wxLuaEventCallback, wxObject) ! wxLuaEventCallback::wxLuaEventCallback(const wxLuaState& wxlState, int lua_func_stack_idx, ! wxWindowID win_id, wxWindowID last_id, ! wxEventType eventType, wxEvtHandler *evtHandler) ! : m_routine(0), m_wxlState(wxlState), ! m_evtHandler(evtHandler), m_id(win_id), m_last_id(last_id), ! m_wxlBindEvent(NULL) { *************** *** 38,42 **** m_wxlBindEvent = wxlState.GetBindEvent(eventType); ! m_wxlState.AddTrackedCallback(this); if (m_wxlBindEvent == NULL) --- 38,42 ---- m_wxlBindEvent = wxlState.GetBindEvent(eventType); ! m_wxlState.AddTrackedEventCallback(this); if (m_wxlBindEvent == NULL) *************** *** 51,63 **** // create a reference to the Lua event handler function ! if (lua_func_stack_idx != WXLUACALLBACK_NOROUTINE) m_routine = m_wxlState.wxluaR_Ref(lua_func_stack_idx, &wxlua_lreg_refs_key); m_evtHandler->Connect(win_id, last_id, eventType, ! (wxObjectEventFunction)&wxLuaCallback::EventHandler, this); } ! wxLuaCallback::~wxLuaCallback() { // Remove the reference to the Lua function that we are going to call --- 51,63 ---- // create a reference to the Lua event handler function ! if (lua_func_stack_idx != WXLUAEVENTCALLBACK_NOROUTINE) m_routine = m_wxlState.wxluaR_Ref(lua_func_stack_idx, &wxlua_lreg_refs_key); m_evtHandler->Connect(win_id, last_id, eventType, ! (wxObjectEventFunction)&wxLuaEventCallback::EventHandler, this); } ! wxLuaEventCallback::~wxLuaEventCallback() { // Remove the reference to the Lua function that we are going to call *************** *** 66,81 **** m_wxlState.wxluaR_Unref(m_routine, &wxlua_lreg_refs_key); // delete the reference to this handler ! m_wxlState.RemoveTrackedCallback(this); } } ! void wxLuaCallback::ClearwxLuaState() { m_wxlState.UnRef(); } ! wxString wxLuaCallback::GetInfo() const { ! return wxString::Format(wxT("%s(%d) -> wxLuaCallback(%p, ids %d, %d)|wxEvtHandler(%p) -> %s"), lua2wx(m_wxlBindEvent ? m_wxlBindEvent->name : "?").c_str(), (int)GetEventType(), this, m_id, m_last_id, --- 66,81 ---- m_wxlState.wxluaR_Unref(m_routine, &wxlua_lreg_refs_key); // delete the reference to this handler ! m_wxlState.RemoveTrackedEventCallback(this); } } ! void wxLuaEventCallback::ClearwxLuaState() { m_wxlState.UnRef(); } ! wxString wxLuaEventCallback::GetInfo() const { ! return wxString::Format(wxT("%s(%d) -> wxLuaEventCallback(%p, ids %d, %d)|wxEvtHandler(%p) -> %s"), lua2wx(m_wxlBindEvent ? m_wxlBindEvent->name : "?").c_str(), (int)GetEventType(), this, m_id, m_last_id, *************** *** 83,93 **** } ! void wxLuaCallback::EventHandler(wxEvent& event) { wxEventType evtType = event.GetEventType(); ! // Get the wxLuaCallback to use, NOT "this" since "this" is a central event handler function ! wxLuaCallback *theCallback = (wxLuaCallback *)event.m_callbackUserData; ! wxCHECK_RET(theCallback != NULL, wxT("Invalid wxLuaCallback in wxEvent user data")); // Ok if !Ok() since the wxLuaState may been cleared during shutdown or after destroy event --- 83,93 ---- } ! void wxLuaEventCallback::EventHandler(wxEvent& event) { wxEventType evtType = event.GetEventType(); ! // Get the wxLuaEventCallback to use, NOT "this" since "this" is a central event handler function ! wxLuaEventCallback *theCallback = (wxLuaEventCallback *)event.m_callbackUserData; ! wxCHECK_RET(theCallback != NULL, wxT("Invalid wxLuaEventCallback in wxEvent user data")); // Ok if !Ok() since the wxLuaState may been cleared during shutdown or after destroy event *************** *** 105,109 **** } ! void wxLuaCallback::CallFunction(wxEvent *event) { // Cannot call it if Lua is gone or the interpreter has been destroyed --- 105,109 ---- } ! void wxLuaEventCallback::CallFunction(wxEvent *event) { // Cannot call it if Lua is gone or the interpreter has been destroyed *************** *** 156,163 **** } else ! wxlState.wxlua_Error("wxLua: wxEvtHandler::Connect in wxLuaCallback::CallFunction: function is not a Lua function."); } else ! wxlState.wxlua_Error("wxLua: wxEvtHandler::Connect in wxLuaCallback::CallFunction: function has been garbage collected."); wxlState.lua_SetTop(oldTop); // pop function from the stack (if it's there) --- 156,163 ---- } else ! wxlState.wxlua_Error("wxLua: wxEvtHandler::Connect in wxLuaEventCallback::CallFunction: function is not a Lua function."); } else ! wxlState.wxlua_Error("wxLua: wxEvtHandler::Connect in wxLuaEventCallback::CallFunction: function has been garbage collected."); wxlState.lua_SetTop(oldTop); // pop function from the stack (if it's there) *************** *** 238,242 **** wxEvtHandler* evtHandler = m_window->GetEventHandler(); ! // Finally, clear out the wxLuaCallbacks for the very odd cases where // (activation) events can be sent during destruction. These can happen // if you pop up a modal dialog (asking if they want to save perhaps) --- 238,242 ---- wxEvtHandler* evtHandler = m_window->GetEventHandler(); ! // Finally, clear out the wxLuaEventCallbacks for the very odd cases where // (activation) events can be sent during destruction. These can happen // if you pop up a modal dialog (asking if they want to save perhaps) *************** *** 253,258 **** { // value = -1, key = -2, table = -3 ! wxLuaCallback* wxlCallback = (wxLuaCallback*)lua_touserdata(L, -2); ! wxCHECK_RET(wxlCallback, wxT("Invalid wxLuaCallback")); if ((wxlCallback->GetEvtHandler() == evtHandler) || --- 253,258 ---- { // value = -1, key = -2, table = -3 ! wxLuaEventCallback* wxlCallback = (wxLuaEventCallback*)lua_touserdata(L, -2); ! wxCHECK_RET(wxlCallback, wxT("Invalid wxLuaEventCallback")); if ((wxlCallback->GetEvtHandler() == evtHandler) || *************** *** 260,264 **** { // remove the ref to the routine since we're clearing the wxLuaState ! // See ~wxLuaCallback m_wxlState.wxluaR_Unref(wxlCallback->GetLuaRoutine(), &wxlua_lreg_refs_key); wxlCallback->ClearwxLuaState(); --- 260,264 ---- { // remove the ref to the routine since we're clearing the wxLuaState ! // See ~wxLuaEventCallback m_wxlState.wxluaR_Unref(wxlCallback->GetLuaRoutine(), &wxlua_lreg_refs_key); wxlCallback->ClearwxLuaState(); Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** wxlua_bind.cpp 13 Dec 2007 00:47:52 -0000 1.16 --- wxlua_bind.cpp 15 Dec 2007 16:56:41 -0000 1.17 *************** *** 727,772 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetBindings[1] = {{ wxLua_function_GetBindings, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedEventCallbacks ! // %function LuaTable GetTrackedEventCallbacks() ! static int LUACALL wxLua_function_GetTrackedEventCallbacks(lua_State *L) { ! wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedCallbackStrings()); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedEventCallbacks[1] = {{ wxLua_function_GetTrackedEventCallbacks, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedTopLevelWindows ! // %function LuaTable GetTrackedTopLevelWindows() ! static int LUACALL wxLua_function_GetTrackedTopLevelWindows(lua_State *L) { wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedWindowStrings()); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedTopLevelWindows[1] = {{ wxLua_function_GetTrackedTopLevelWindows, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedUserdata ! // %function LuaTable GetTrackedUserData() ! static int LUACALL wxLua_function_GetTrackedUserdata(lua_State *L) { ! wxlua_pushwxArrayStringtable(L, wxluaO_getgcobjectstrings(L)); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedUserdata[1] = {{ wxLua_function_GetTrackedUserdata, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedWindows ! // %function LuaTable GetTrackedWindows() ! static int LUACALL wxLua_function_GetTrackedWindows(lua_State *L) { ! wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedWinDestroyCallbackStrings()); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWindows[1] = {{ wxLua_function_GetTrackedWindows, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; static wxLuaArgTag s_wxluatagArray_wxLua_function_iswxluatype[] = { &s_wxluaarg_Number, &s_wxluaarg_Number, NULL }; --- 727,771 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetBindings[1] = {{ wxLua_function_GetBindings, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetGCUserdataInfo ! // %function LuaTable GetTrackedUserData() ! static int LUACALL wxLua_function_GetGCUserdataInfo(lua_State *L) { ! wxlua_pushwxArrayStringtable(L, wxluaO_getgcobjectinfo(L)); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetGCUserdataInfo[1] = {{ wxLua_function_GetGCUserdataInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedEventCallbackInfo ! // %function LuaTable GetTrackedEventCallbackInfo() ! static int LUACALL wxLua_function_GetTrackedEventCallbackInfo(lua_State *L) { wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedEventCallbackInfo()); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedEventCallbackInfo[1] = {{ wxLua_function_GetTrackedEventCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedWinDestroyCallbackInfo ! // %function LuaTable GetTrackedWinDestroyCallbackInfo() ! static int LUACALL wxLua_function_GetTrackedWinDestroyCallbackInfo(lua_State *L) { ! wxLuaState wxlState(L); ! wxlua_pushwxArrayStringtable(L, wxlState.GetTrackedWinDestroyCallbackInfo()); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWinDestroyCallbackInfo[1] = {{ wxLua_function_GetTrackedWinDestroyCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! // %override wxLua_function_GetTrackedWindowInfo ! // %function LuaTable GetTrackedTopLevelWindows() ! static int LUACALL wxLua_function_GetTrackedWindowInfo(lua_State *L) { ! wxlua_pushwxArrayStringtable(L, wxluaW_gettrackedwindowinfo(L)); return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWindowInfo[1] = {{ wxLua_function_GetTrackedWindowInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; static wxLuaArgTag s_wxluatagArray_wxLua_function_iswxluatype[] = { &s_wxluaarg_Number, &s_wxluaarg_Number, NULL }; *************** *** 887,894 **** { "CompileLuaScript", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_CompileLuaScript, 1, NULL }, { "GetBindings", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetBindings, 1, NULL }, ! { "GetTrackedEventCallbacks", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedEventCallbacks, 1, NULL }, ! { "GetTrackedTopLevelWindows", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedTopLevelWindows, 1, NULL }, ! { "GetTrackedUserdata", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedUserdata, 1, NULL }, ! { "GetTrackedWindows", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedWindows, 1, NULL }, { "iswxluatype", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_iswxluatype, 1, NULL }, { "type", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_type, 1, NULL }, --- 886,893 ---- { "CompileLuaScript", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_CompileLuaScript, 1, NULL }, { "GetBindings", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetBindings, 1, NULL }, ! { "GetGCUserdataInfo", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetGCUserdataInfo, 1, NULL }, ! { "GetTrackedEventCallbackInfo", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedEventCallbackInfo, 1, NULL }, ! { "GetTrackedWinDestroyCallbackInfo", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedWinDestroyCallbackInfo, 1, NULL }, ! { "GetTrackedWindowInfo", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_GetTrackedWindowInfo, 1, NULL }, { "iswxluatype", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_iswxluatype, 1, NULL }, { "type", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_type, 1, NULL }, |