From: John L. <jr...@us...> - 2006-12-01 18:53:54
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv8146/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp Log Message: start checking for LuaDelete function from the end since that's where it'll be Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** wxlbind.cpp 1 Dec 2006 06:25:47 -0000 1.42 --- wxlbind.cpp 1 Dec 2006 18:53:48 -0000 1.43 *************** *** 229,234 **** wxlState.RemoveTrackedMemory((void*)key, true); // delete from m_pTrackedList ! wxLongToLongHashMap::iterator it = wxlState.GetLuaStateData()->m_pDerivedList.find(key); ! if (it != wxlState.GetLuaStateData()->m_pDerivedList.end()) { //wxPrintf(wxT("wxLua_lua_garbageCollect - Derived GC '%s'\n"), lua2wx(pClass->name).c_str()); --- 229,235 ---- wxlState.RemoveTrackedMemory((void*)key, true); // delete from m_pTrackedList ! wxLongToLongHashMap& pDerivedList = wxlState.GetLuaStateData()->m_pDerivedList; ! wxLongToLongHashMap::iterator it = pDerivedList.find(key); ! if (it != pDerivedList.end()) { //wxPrintf(wxT("wxLua_lua_garbageCollect - Derived GC '%s'\n"), lua2wx(pClass->name).c_str()); *************** *** 239,249 **** it->second = 0; ! ! wxlState.GetLuaStateData()->m_pDerivedList.erase(it); } //else wxPrintf(wxT("wxLua_lua_garbageCollect - Invalid WXLUACLASS derived hashmap iterator key %d!\n"), key); int iMethod, method_count = pClass->num_methods; ! for (iMethod = 0; iMethod < method_count; ++iMethod) { WXLUAMETHOD *pMethod = pClass->methods + iMethod; --- 240,251 ---- it->second = 0; ! pDerivedList.erase(it); } //else wxPrintf(wxT("wxLua_lua_garbageCollect - Invalid WXLUACLASS derived hashmap iterator key %d!\n"), key); + // LuaDelete is placed at the end, so start there first and if found + // call the function int iMethod, method_count = pClass->num_methods; ! for (iMethod = method_count-1; iMethod >= 0; --iMethod) { WXLUAMETHOD *pMethod = pClass->methods + iMethod; *************** *** 271,275 **** // onto the lua stack, setting its tag so that the function tag of the object // will be called to invoke the function. - // todo: Handling of properties // ---------------------------------------------------------------------------- --- 273,276 ---- *************** *** 558,561 **** --- 559,563 ---- void LUACALL wxLuaBinding::RegisterGeneratedClasses(const wxLuaState& wxlState_, int tableOffset, bool registerTypes) { + // Replace the metatable functions for the functions we push into lua static const luaL_reg s_funcTable[] = { *************** *** 575,579 **** int iTag = m_startTag; ! // install the classes, functions and methods for (size_t iClass = 0; iClass < m_classCount; ++iClass, iTag = (registerTypes ? wxlState.tnewtag() : iTag + 1)) --- 577,583 ---- int iTag = m_startTag; ! // install the classes, functions and methods, creating new tags ! // if this is the first time we're registering them, else assume ! // they are in numerical order. for (size_t iClass = 0; iClass < m_classCount; ++iClass, iTag = (registerTypes ? wxlState.tnewtag() : iTag + 1)) *************** *** 582,585 **** --- 586,590 ---- *pClass->class_tag = iTag; + // set the metatable functions for the classes for (size_t iFunction = 0; iFunction < s_funcCount; iFunction++) { *************** *** 587,590 **** --- 592,596 ---- } + // install public functions like constructors or global functions int iMethod, method_count = pClass->num_methods; for (iMethod = 0; iMethod < method_count; ++iMethod) *************** *** 602,606 **** m_lastTag = iTag; ! // register all the builtin functions for (size_t iFunction = 0; iFunction < m_functionCount; ++iFunction) { --- 608,612 ---- m_lastTag = iTag; ! // register all the builtin functions, global C style functions for (size_t iFunction = 0; iFunction < m_functionCount; ++iFunction) { *************** *** 620,624 **** //lua_rawset(L, tableOffset); ! // install the definitions for (size_t iDefine = 0; iDefine < m_defineCount; ++iDefine) { --- 626,630 ---- //lua_rawset(L, tableOffset); ! // install the numerical definitions for (size_t iDefine = 0; iDefine < m_defineCount; ++iDefine) { *************** *** 647,654 **** else wxlState.tpushusertag(*pObject->pObjPtr, *pObject->objClassTag); lua_rawset(L, tableOffset); } ! // register all the event types for (size_t iEvent = 0; iEvent < m_eventCount; ++iEvent) { --- 653,661 ---- else wxlState.tpushusertag(*pObject->pObjPtr, *pObject->objClassTag); + lua_rawset(L, tableOffset); } ! // register all the wxevent types for (size_t iEvent = 0; iEvent < m_eventCount; ++iEvent) { |