From: John L. <jr...@us...> - 2005-12-07 05:53:40
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2986/wxLua/modules/wxlua/src Modified Files: wxlcallb.cpp wxlstate.cpp Log Message: add getters for tracked events and destroy events make luastaterefdata lists not pointers Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** wxlstate.cpp 1 Dec 2005 06:43:53 -0000 1.11 --- wxlstate.cpp 7 Dec 2005 05:53:30 -0000 1.12 *************** *** 196,216 **** m_pDerivedList = new wxHashTable(wxKEY_INTEGER); m_pTrackedList = new wxHashTable(wxKEY_INTEGER); - m_pAppHandlerList = new wxList; - m_pDestroyHandlerList = new wxList; - m_pWindowList = new wxList; m_pDerivedList->DeleteContents(true); m_pTrackedList->DeleteContents(true); // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it [...1177 lines suppressed...] } ! int wxLuaState::luaL_OptInt(int numArg, int def) { wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState")); ! return (int)luaL_optint(M_WXLSTATEDATA->m_lua_State, numArg, def); ! } ! long wxLuaState::luaL_OptLong(int numArg, int def) ! { ! wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState")); ! return (long)luaL_optlong(M_WXLSTATEDATA->m_lua_State, numArg, def); ! } ! ! // ---------------------------------------------------------------------------- ! // others ! ! void wxLuaState::GetGlobals() ! { ! wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! lua_pushvalue(M_WXLSTATEDATA->m_lua_State, LUA_GLOBALSINDEX); } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** wxlcallb.cpp 29 Nov 2005 23:52:12 -0000 1.7 --- wxlcallb.cpp 7 Dec 2005 05:53:30 -0000 1.8 *************** *** 34,38 **** IMPLEMENT_ABSTRACT_CLASS(wxLuaCallback, wxEvtHandler) - // Encapsulate a lua function reference for use by a event callback wxLuaCallback::wxLuaCallback( const wxLuaState& state, int theRoutine, --- 34,37 ---- *************** *** 53,62 **** this); ! // FIXME - Need to track events attached to an application object ! // labenski - track all of them? useful to run ClearLuaState when window is destroyed ! //if (pEvtHandler->IsKindOf(CLASSINFO(wxApp))) ! { ! m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->Append(this); ! } } --- 52,56 ---- this); ! m_wxlState.AddTrackedEventHandler(this); } *************** *** 68,77 **** m_wxlState.tremove(m_routine); // delete the reference to this handler ! m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->DeleteObject(this); } } - // This function is called with "this" being of the type which the event is arriving - // at. The user data is used to route it to the correct place. void wxLuaCallback::EventHandler(wxEvent& event) { --- 62,69 ---- m_wxlState.tremove(m_routine); // delete the reference to this handler ! m_wxlState.RemoveTrackedEventHandler(this); } } void wxLuaCallback::EventHandler(wxEvent& event) { *************** *** 91,95 **** wxlState.removeTrackedWindow((wxWindow*)event.GetEventObject()); // delete the reference to this handler since we're clearing it ! wxlState.GetLuaStateRefData()->m_pAppHandlerList->DeleteObject(this); // Disconnect all callbacks associated with this window's evthandler --- 83,87 ---- wxlState.removeTrackedWindow((wxWindow*)event.GetEventObject()); // delete the reference to this handler since we're clearing it ! wxlState.RemoveTrackedEventHandler(this); // Disconnect all callbacks associated with this window's evthandler *************** *** 98,102 **** wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); ! wxNode* node = wxlState.GetLuaStateRefData()->m_pAppHandlerList->GetFirst(); while (node) { --- 90,94 ---- wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); ! wxNode* node = wxlState.GetTrackedEventHandlerList()->GetFirst(); while (node) { *************** *** 108,112 **** wxNode* pc_node = node; // remember current node node = node->GetNext(); ! wxlState.GetLuaStateRefData()->m_pAppHandlerList->Erase(pc_node); pCallback->ClearLuaState(); --- 100,104 ---- wxNode* pc_node = node; // remember current node node = node->GetNext(); ! wxlState.GetTrackedEventHandlerList()->Erase(pc_node); pCallback->ClearLuaState(); *************** *** 122,127 **** } - // Call a lua function to handle an event. The lua function will receive - // a single parameter, the type of event. void wxLuaCallback::CallFunction(wxEvent *pEvent) { --- 114,117 ---- *************** *** 135,138 **** --- 125,133 ---- int eventClassTag = s_wxluatag_wxEvent; + // FIXME - alternative to the s_wxluatag_XXX + //const WXLUACLASS* luaClass = m_wxlState.GetLuaClass("wxEvent"); + //wxCHECK_RET(luaClass, wxT("wxEvent lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); + //wxPrintf(wxT("Event tag %d %d\n"), *luaClass->class_tag, eventClassTag); + const WXLUAEVENT *pLuaEvent = m_wxlState.GetLuaEvent(pEvent); if (pLuaEvent) *************** *** 198,202 **** } ! m_wxlState.GetLuaStateRefData()->m_pDestroyHandlerList->Append(this); // connect the event handler --- 193,197 ---- } ! m_wxlState.AddTrackedDestroyEventHandler(this); // connect the event handler *************** *** 215,219 **** { if (m_wxlState.Ok()) ! m_wxlState.GetLuaStateRefData()->m_pDestroyHandlerList->DeleteObject(this); } --- 210,214 ---- { if (m_wxlState.Ok()) ! m_wxlState.RemoveTrackedDestroyEventHandler(this); } *************** *** 236,240 **** return; ! // Note: do not remove from m_pDestroyHandlerList here, wait 'till destructor if (m_wxlState.tget(m_wxlState.GetLuaDeleteTable())) --- 231,235 ---- return; ! // Note: do not remove from wxLuaState's destroyHandlerList here, wait 'till destructor if (m_wxlState.tget(m_wxlState.GetLuaDeleteTable())) |