From: John L. <jr...@us...> - 2006-05-04 02:47:40
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28004a/wxLua/modules/wxlua/src Modified Files: internal.cpp wxlbind.cpp wxlstate.cpp Log Message: switch to wxHashMap from wxHashTable as wxHashTable has been deprecated since 2.4 Index: internal.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/internal.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** internal.cpp 8 Apr 2006 23:05:39 -0000 1.39 --- internal.cpp 4 May 2006 02:47:34 -0000 1.40 *************** *** 423,438 **** void wxLuaCheckStack::DumpGlobals(lua_State *L) { ! wxHashTable* dumpList = new wxHashTable(wxKEY_INTEGER); lua_pushvalue(L, LUA_GLOBALSINDEX); ! DumpTable(L, lua_gettop(L), wxT("Globals"), *dumpList, 0); lua_pop(L, 1); - - delete dumpList; } void wxLuaCheckStack::DumpTable(lua_State *L, const wxString &name) { ! wxHashTable dumpList(wxKEY_INTEGER); lua_pushstring(L, wx2lua(name)); --- 423,436 ---- void wxLuaCheckStack::DumpGlobals(lua_State *L) { ! wxLuaStringToLongHashMap dumpList; lua_pushvalue(L, LUA_GLOBALSINDEX); ! DumpTable(L, lua_gettop(L), wxT("Globals"), dumpList, 0); lua_pop(L, 1); } void wxLuaCheckStack::DumpTable(lua_State *L, const wxString &name) { ! wxLuaStringToLongHashMap dumpList; lua_pushstring(L, wx2lua(name)); *************** *** 558,562 **** } ! void wxLuaCheckStack::DumpTable(lua_State *L, int index, const wxString& tablename, wxHashTable& dumpList, int indent) { wxString indentStr; --- 556,560 ---- } ! void wxLuaCheckStack::DumpTable(lua_State *L, int index, const wxString& tablename, wxLuaStringToLongHashMap& dumpList, int indent) { wxString indentStr; *************** *** 594,599 **** wxLogMessage(info); ! long key = dumpList.MakeKey(value); ! if (!dumpList.Get(key)) { if (valueType == wxT("Table")) --- 592,596 ---- wxLogMessage(info); ! if (dumpList.find(value) != dumpList.end()) { if (valueType == wxT("Table")) *************** *** 601,605 **** wxString tname = wxString::Format(wxT("%s.%s"), tablename.c_str(), indexValue.c_str()); ! dumpList.Put(key, (wxObject*)true); int tableIndex = lua_gettop(L); --- 598,602 ---- wxString tname = wxString::Format(wxT("%s.%s"), tablename.c_str(), indexValue.c_str()); ! dumpList[value] = 1; int tableIndex = lua_gettop(L); *************** *** 610,614 **** else { ! dumpList.Put(key, (wxObject*)true); } } --- 607,611 ---- else { ! dumpList[value] = 1; } } Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** wxlstate.cpp 3 May 2006 22:52:18 -0000 1.64 --- wxlstate.cpp 4 May 2006 02:47:34 -0000 1.65 *************** *** 78,85 **** // Hook into function calls to luaE_newthread (calls from coroutine.create/wrap) ! // and add the new lua_State as a child sharing it's wxLuaStateVariables void wxLuaState_newthread_handler(lua_State *L, lua_State *L1) { ! // L is the original lua_State, L1 new coroutine thread wxLuaState wxlState_orig(L); wxCHECK_RET(wxlState_orig.Ok(), wxT("Invalid wxLuaState")); --- 78,85 ---- // Hook into function calls to luaE_newthread (calls from coroutine.create/wrap) ! // and add the new lua_State as a child sharing it's wxLuaStateData void wxLuaState_newthread_handler(lua_State *L, lua_State *L1) { ! // L is the original lua_State, L1 is the new coroutine thread wxLuaState wxlState_orig(L); wxCHECK_RET(wxlState_orig.Ok(), wxT("Invalid wxLuaState")); *************** *** 116,120 **** wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); ! for (size_t n = 0; n < wxlState_orig.GetLuaStateRefData()->m_coroutineStates.GetCount(); n++) { if (wxlState_orig.GetLuaStateRefData()->m_coroutineStates[n] == wxlState) --- 116,121 ---- wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); ! size_t n, count = wxlState_orig.GetLuaStateRefData()->m_coroutineStates.GetCount(); ! for (n = 0; n < count; n++) { if (wxlState_orig.GetLuaStateRefData()->m_coroutineStates[n] == wxlState) *************** *** 320,340 **** bool painting = false; ! #if !wxCHECK_VERSION(2, 5, 0) ! wxNode* node; ! #else ! wxHashTable::Node* node; ! #endif ! ! // FIXME - wxGTK crashes if wxYield[IfNeeded] is called within a paint handler? I think ! wxlState.GetLuaStateRefData()->m_wxlStateData->m_pTrackedList->BeginFind(); ! node = wxlState.GetLuaStateRefData()->m_wxlStateData->m_pTrackedList->Next(); ! while (node) { ! if (wxDynamicCast(node->GetData(), wxPaintDC)) { painting = true; break; } - node = wxlState.GetLuaStateRefData()->m_wxlStateData->m_pTrackedList->Next(); } --- 321,334 ---- bool painting = false; ! wxLongToLongHashMap::iterator it; ! wxLongToLongHashMap* hashMap = &wxlState.GetLuaStateRefData()->m_wxlStateData->m_pTrackedList; ! for (it = hashMap->begin(); it != hashMap->end(); ++it) { ! wxObject* obj = (wxObject*)it->second; ! if (obj && wxDynamicCast(obj, wxPaintDC)) { painting = true; break; } } *************** *** 350,354 **** { wxLuaState wxlState(L); ! wxCHECK_MSG(wxlState.Ok(), 1, wxT("Invalid wxLuaState")); if (lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (wxlState.ttag(1) == wxlState.GetLuaFunctionTag())) --- 344,348 ---- { wxLuaState wxlState(L); ! wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); if (lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (wxlState.ttag(1) == wxlState.GetLuaFunctionTag())) *************** *** 518,523 **** m_callbase_func = false; m_inEventType = wxEVT_NULL; - m_pDerivedList = new wxHashTable(wxKEY_INTEGER); - m_pTrackedList = new wxHashTable(wxKEY_INTEGER); m_is_running = false; --- 512,515 ---- *************** *** 536,543 **** m_id = wxID_ANY; - // let the list delete these items - m_pDerivedList->DeleteContents(true); - m_pTrackedList->DeleteContents(true); - // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it m_eventHandlerList.DeleteContents(false); --- 528,531 ---- *************** *** 562,567 **** m_evtHandler = NULL; ! delete m_pDerivedList; ! delete m_pTrackedList; wxLuaBindingList::Node *node = m_bindings.GetFirst(); --- 550,568 ---- m_evtHandler = NULL; ! wxLongToLongHashMap::iterator it; ! ! for (it = m_pDerivedList.begin(); it != m_pDerivedList.end(); ++it) ! { ! wxLuaStringToLongHashMap* obj = (wxLuaStringToLongHashMap*)it->second; ! delete obj; ! } ! m_pDerivedList.clear(); ! ! for (it = m_pTrackedList.begin(); it != m_pTrackedList.end(); ++it) ! { ! wxObject* obj = (wxObject*)it->second; ! delete obj; ! } ! m_pTrackedList.clear(); wxLuaBindingList::Node *node = m_bindings.GetFirst(); *************** *** 1500,1504 **** { wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList->Put((long)pObject, pObject); } --- 1501,1505 ---- { wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList[(long)pObject] = (long)pObject; } *************** *** 1506,1510 **** { wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList->Put(obj_ptr, pObject); } --- 1507,1511 ---- { wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList[obj_ptr] = (long)pObject; } *************** *** 1513,1524 **** wxCHECK_MSG(Ok() && pObject, false, wxT("Invalid wxLuaState or object")); ! // we still have to delete item ourselves even if DeleteContents(true) ! wxObject *pDeleteObject = M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList->Delete((long) pObject); ! bool result = pDeleteObject != NULL; ! if (fDelete && (pDeleteObject != NULL)) ! delete pDeleteObject; ! return result; } --- 1514,1531 ---- wxCHECK_MSG(Ok() && pObject, false, wxT("Invalid wxLuaState or object")); ! wxLongToLongHashMap::iterator it = M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList.find((long) pObject); ! if (it != M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList.end()) ! { ! // remove the item from being tracked ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList.erase(it); ! wxObject *pDeleteObject = (wxObject*)it->second; ! if (fDelete && (pDeleteObject != NULL)) ! delete pDeleteObject; ! return true; ! } ! ! return false; } *************** *** 2399,2412 **** wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! wxHashTable *pHashTable = (wxHashTable *)GetLuaStateData()->m_pDerivedList->Get((long) pObject); ! ! if (pHashTable != NULL) { ! wxLuaObject *pLuaObject = (wxLuaObject *)pHashTable->Get(lua2wx(method)); ! if ((pLuaObject != NULL) && pLuaObject->GetObject()) { ! wxCHECK_MSG(pLuaObject->GetwxLuaState() == *this, false, wxT("wxLuaState GetDerivedMethod out of sync")); ! return true; } } --- 2406,2427 ---- wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! wxLongToLongHashMap::iterator it = GetLuaStateData()->m_pDerivedList.find((long) pObject); ! if (it != GetLuaStateData()->m_pDerivedList.end()) { ! wxLuaStringToLongHashMap *pHashTable = (wxLuaStringToLongHashMap *)it->second; ! if (pHashTable != NULL) { ! wxLuaStringToLongHashMap::iterator its = pHashTable->find(lua2wx(method)); ! if (its != pHashTable->end()) ! { ! wxLuaObject *pLuaObject = (wxLuaObject *)its->second; ! ! if ((pLuaObject != NULL) && pLuaObject->GetObject()) ! { ! wxCHECK_MSG(pLuaObject->GetwxLuaState() == *this, false, wxT("wxLuaState GetDerivedMethod out of sync")); ! return true; ! } ! } } } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** wxlbind.cpp 17 Apr 2006 22:46:25 -0000 1.31 --- wxlbind.cpp 4 May 2006 02:47:34 -0000 1.32 *************** *** 27,31 **** #include "wx/listimpl.cpp" ! // Binding tags are generated as positive tag id automatically when bound // so we set the inbuilt lua arg tags to negative values // --- 27,31 ---- #include "wx/listimpl.cpp" ! // Binding tags are generated as positive tag id automatically when bound // so we set the inbuilt lua arg tags to negative values // *************** *** 66,75 **** if ((pClass != NULL) && lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (wxlState.ttag(1) == *pClass->class_tag)) { ! wxHashTable *pHashTable = (wxHashTable *) wxlState.GetLuaStateData()-> ! m_pDerivedList->Delete((long)wxlState.ttouserdata(1, true)); ! ! if (pHashTable != NULL) { ! delete pHashTable; } --- 66,78 ---- if ((pClass != NULL) && lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (wxlState.ttag(1) == *pClass->class_tag)) { ! long key = (long)wxlState.ttouserdata(1, true); ! wxLongToLongHashMap::iterator it = wxlState.GetLuaStateData()->m_pDerivedList.find(key); ! if (it != wxlState.GetLuaStateData()->m_pDerivedList.end()) { ! wxLuaStringToLongHashMap *pHashTable = (wxLuaStringToLongHashMap *)it->second; ! wxlState.GetLuaStateData()->m_pDerivedList.erase(it); ! ! if (pHashTable != NULL) ! delete pHashTable; } *************** *** 198,212 **** { void *pObject = wxlState.ttouserdata(1); - bool fCreated = false; - wxHashTable *pHashTable = (wxHashTable *) wxlState.GetLuaStateData()->m_pDerivedList->Get((long) pObject); if (pHashTable == NULL) { ! pHashTable = new wxHashTable(wxKEY_STRING); if (pHashTable != NULL) { ! pHashTable->DeleteContents(true); ! ! wxlState.GetLuaStateData()->m_pDerivedList->Put((long) pObject, pHashTable); fCreated = true; } --- 201,219 ---- { void *pObject = wxlState.ttouserdata(1); + bool fCreated = false; + wxLuaStringToLongHashMap *pHashTable = NULL; + + wxLongToLongHashMap::iterator it = wxlState.GetLuaStateData()->m_pDerivedList.find((long) pObject); + if (it != wxlState.GetLuaStateData()->m_pDerivedList.end()) + { + pHashTable = (wxLuaStringToLongHashMap *)it->second; + } if (pHashTable == NULL) { ! pHashTable = new wxLuaStringToLongHashMap; if (pHashTable != NULL) { ! wxlState.GetLuaStateData()->m_pDerivedList[(long) pObject] = (long)pHashTable; fCreated = true; } *************** *** 218,226 **** if (!fCreated) { ! wxLuaObject *pObject = (wxLuaObject *)pHashTable->Delete(index); ! if (pObject != NULL) ! delete pObject; } ! pHashTable->Put(index, new wxLuaObject(L, 3)); } } --- 225,237 ---- if (!fCreated) { ! wxLuaStringToLongHashMap::iterator it = pHashTable->find(index); ! if (it != pHashTable->end()) ! { ! wxLuaObject *pObject = (wxLuaObject *)it->second; ! if (pObject != NULL) ! delete pObject; ! } } ! (*pHashTable)[index] = (long)new wxLuaObject(L, 3); } } |