From: John L. <jr...@us...> - 2007-06-16 06:21:51
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv19284/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlstate.cpp wxlua_bind.cpp Log Message: Add back the wxTreeCtrl into the stack dialog, on left of listctrl so you get both for easier navigation. Added functions to the wxlua.XXX table to get info about the status of wxLua Use qsort and bsearch to find the class methods ~ %25 faster Make wxLuaDebugData not always create it's ref data so it can !Ok() Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.113 retrieving revision 1.114 diff -C2 -d -r1.113 -r1.114 *** wxlstate.cpp 14 Jun 2007 23:59:48 -0000 1.113 --- wxlstate.cpp 16 Jun 2007 06:21:46 -0000 1.114 *************** *** 471,474 **** --- 471,503 ---- } + int LUACALL wxlua_tisrefed(lua_State* L, int stack_idx) + { + int tag = LUA_NOREF; + + lua_pushvalue(L, stack_idx); // push value to compare + + wxlua_pushkey_wxLuaReferences(L); // push name of table to get as key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the refs table) + int nTop = lua_gettop(L); // this is where refs table is + + lua_pushnil(L); + while (lua_next(L, nTop) != 0) // ref table can have holes in it + { + // value = -1, key = -2, table = -3, object = -4 + if (lua_equal(L, -1, -4)) + { + tag = (int)lua_tonumber(L, -2); + lua_pop(L, 2); // pop key, value + break; + } + else + lua_pop(L, 1); // pop value, lua_next will pop key at end + } + + lua_pop(L, 2); // pop object we pushed and the ref table + + return tag; + } + // ---------------------------------------------------------------------------- // Functions to get info about the tags wxlua uses to determine type *************** *** 578,585 **** ret = (luatype == LUA_TSTRING) ? 1 : 0; break; ! case WXLUAARG_LuaTable : ret = (luatype == LUA_TTABLE) ? 1 : 0; break; ! case WXLUAARG_LuaFunction : ret = (luatype == LUA_TFUNCTION) ? 1 : 0; break; --- 607,614 ---- ret = (luatype == LUA_TSTRING) ? 1 : 0; break; ! case WXLUAARG_Table : ret = (luatype == LUA_TTABLE) ? 1 : 0; break; ! case WXLUAARG_Function : ret = (luatype == LUA_TFUNCTION) ? 1 : 0; break; *************** *** 587,591 **** ret = (luatype == LUA_TUSERDATA) ? 1 : 0; break; ! case WXLUAARG_LuaThread : ret = (luatype == LUA_TTHREAD) ? 1 : 0; break; --- 616,620 ---- ret = (luatype == LUA_TUSERDATA) ? 1 : 0; break; ! case WXLUAARG_Thread : ret = (luatype == LUA_TTHREAD) ? 1 : 0; break; *************** *** 601,617 **** wxString wxlua_getwxluatypename(int wxluaarg_tag) { switch (wxluaarg_tag) { ! case WXLUAARG_None : return wxT("none"); ! case WXLUAARG_Nil : return wxT("nil"); ! case WXLUAARG_Boolean : return wxT("boolean"); ! case WXLUAARG_LightUserData : return wxT("lightuserdata"); ! case WXLUAARG_Number : return wxT("number"); ! case WXLUAARG_String : return wxT("string"); ! case WXLUAARG_LuaTable : return wxT("table"); ! case WXLUAARG_LuaFunction : return wxT("function"); ! case WXLUAARG_UserData : return wxT("userdata"); ! case WXLUAARG_LuaThread : return wxT("thread"); ! case WXLUAARG_Integer : return wxT("integer"); } --- 630,662 ---- wxString wxlua_getwxluatypename(int wxluaarg_tag) { + // try to use wxString's ref counting and return this existing copy + static wxString s[11] = { + wxT("none"), + wxT("nil"), + wxT("boolean"), + wxT("lightuserdata"), + wxT("number"), + wxT("string"), + wxT("table"), + wxT("function"), + wxT("userdata"), + wxT("thread"), + wxT("integer") + }; + switch (wxluaarg_tag) { ! case WXLUAARG_None : return s[0]; ! case WXLUAARG_Nil : return s[1]; ! case WXLUAARG_Boolean : return s[2]; ! case WXLUAARG_LightUserData : return s[3]; ! case WXLUAARG_Number : return s[4]; ! case WXLUAARG_String : return s[5]; ! case WXLUAARG_Table : return s[6]; ! case WXLUAARG_Function : return s[7]; ! case WXLUAARG_UserData : return s[8]; ! case WXLUAARG_Thread : return s[9]; ! ! case WXLUAARG_Integer : return s[10]; } *************** *** 629,636 **** case LUA_TNUMBER : return WXLUAARG_Number; case LUA_TSTRING : return WXLUAARG_String; ! case LUA_TTABLE : return WXLUAARG_LuaTable; ! case LUA_TFUNCTION : return WXLUAARG_LuaFunction; case LUA_TUSERDATA : return WXLUAARG_UserData; ! case LUA_TTHREAD : return WXLUAARG_LuaThread; //case LUA_T??? : return WXLUAARG_Integer; } --- 674,681 ---- case LUA_TNUMBER : return WXLUAARG_Number; case LUA_TSTRING : return WXLUAARG_String; ! case LUA_TTABLE : return WXLUAARG_Table; ! case LUA_TFUNCTION : return WXLUAARG_Function; case LUA_TUSERDATA : return WXLUAARG_UserData; ! case LUA_TTHREAD : return WXLUAARG_Thread; //case LUA_T??? : return WXLUAARG_Integer; } *************** *** 649,656 **** case WXLUAARG_Number : return LUA_TNUMBER; case WXLUAARG_String : return LUA_TSTRING; ! case WXLUAARG_LuaTable : return LUA_TTABLE; ! case WXLUAARG_LuaFunction : return LUA_TFUNCTION; case WXLUAARG_UserData : return LUA_TUSERDATA; ! case WXLUAARG_LuaThread : return LUA_TTHREAD; case WXLUAARG_Integer : return LUA_TNUMBER; } --- 694,701 ---- case WXLUAARG_Number : return LUA_TNUMBER; case WXLUAARG_String : return LUA_TSTRING; ! case WXLUAARG_Table : return LUA_TTABLE; ! case WXLUAARG_Function : return LUA_TFUNCTION; case WXLUAARG_UserData : return LUA_TUSERDATA; ! case WXLUAARG_Thread : return LUA_TTHREAD; case WXLUAARG_Integer : return LUA_TNUMBER; } *************** *** 1184,1187 **** --- 1229,1234 ---- } + // m_wxlStateData->m_windowList.Clear(); wxLuaCleanupWindows does this for us + ClearCallbacks(); CleanupWxLua(!m_lua_State_static); *************** *** 1203,1211 **** m_lua_State = NULL; } - - // Clear these after closing lua for gc to run - m_wxlStateData->m_callbackList.Clear(); - m_wxlStateData->m_winDestroyCallbackList.Clear(); - m_wxlStateData->m_windowList.Clear(); } --- 1250,1253 ---- *************** *** 1899,1902 **** --- 1941,1998 ---- } + // Link together all of the class member functions with base class functions + // with the same name so the overloads work for them too. + node = M_WXLSTATEDATA->m_wxlStateData->m_bindingList.GetFirst(); + while (node) + { + wxLuaBinding* binding = node->GetData(); + wxLuaBindClass* wxlClass = binding->GetClassArray(); + size_t i, class_count = binding->GetClassCount(); + + for (i = 0; i < class_count; ++i, ++wxlClass) + { + if (wxlClass->baseclass) // does it have a base class at all? + { + wxLuaBindMethod *wxlMethod = wxlClass->methods; + size_t j, method_count = wxlClass->methods_n; + + for (j = 0; j < method_count; ++j, ++wxlMethod) + { + // iterate through the base classes to find if this function is + // an overload, but only if we haven't checked already. + if (!WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_OVERLOAD_BASE|WXLUAMETHOD_DELETE)) + { + wxLuaBindClass *baseClass = wxlClass->baseclass; + wxLuaBindMethod *parentMethod = wxlMethod; + + while (baseClass) + { + parentMethod->type |= WXLUAMETHOD_OVERLOAD_BASE; // have checked this + + wxLuaBindMethod* baseMethod = wxLuaBinding::GetClassMethod(baseClass, wxlMethod->name, false); + if (baseMethod) + { + // don't link to base class delete functions + if (!WXLUA_HASBIT(baseMethod->type, WXLUAMETHOD_DELETE)) + { + parentMethod->basemethod = baseMethod; + parentMethod = baseMethod; + } + + // we have already checked the base classes below this + if (WXLUA_HASBIT(baseMethod->type, WXLUAMETHOD_OVERLOAD_BASE)) + break; + } + + baseClass = baseClass->baseclass; + } + } + } + } + } + + node = node->GetNext(); + } + // register our 'function' object handlers if (registerTypes) *************** *** 1909,1915 **** tsettagmethod(g_wxluatag_wxLuaFunction, "__call", wxlua_call_wxLuaFunction); const wxLuaBindClass* wxlClass = NULL; - wxlClass = GetLuaClass("wxEvent"); wxCHECK_RET(wxlClass, wxT("wxEvent lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); --- 2005,2011 ---- tsettagmethod(g_wxluatag_wxLuaFunction, "__call", wxlua_call_wxLuaFunction); + // Finally - set the global tags from the bindings we've just installed const wxLuaBindClass* wxlClass = NULL; wxlClass = GetLuaClass("wxEvent"); wxCHECK_RET(wxlClass, wxT("wxEvent lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); *************** *** 2095,2098 **** --- 2191,2232 ---- } + wxArrayString wxLuaState::GetTrackedObjectStrings() + { + wxArrayString names; + wxArrayInt counts; + + wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); + + wxLongToLongHashMap::iterator it; + wxLongToLongHashMap* hashMap = GetTrackedObjects(); + + for (it = hashMap->begin(); it != hashMap->end(); ++it) + { + wxString name(wxT("Unknown Tracked Item")); + + wxObject* obj = (wxObject*)it->second; + if (obj && obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) + name = obj->GetClassInfo()->GetClassName(); + + //name = wxString::Format(wxT("%p "), obj) + name; + + int idx = names.Index(name); + if (idx == wxNOT_FOUND) + { + names.Add(name); + counts.Add(1); + } + else + counts[idx]++; + } + + size_t n, count = names.GetCount(); + for (n = 0; n < count; ++n) + names[n] += wxString::Format(wxT(" %d"), counts[n]); + + names.Sort(); + return names; + } + bool wxLuaState::AddTrackedWindow(wxObject *obj) { *************** *** 2144,2147 **** --- 2278,2317 ---- } + wxArrayString wxLuaState::GetTrackedWindowStrings() + { + wxArrayString names; + wxArrayInt counts; + + wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); + + wxWindowList::compatibility_iterator node = GetLuaStateData()->m_windowList.GetFirst(); + while (node) + { + wxWindow *win= (wxWindow*)node->GetData(); + wxCHECK_MSG(win, false, wxT("Invalid wxLuaCallback")); + if (win && win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + { + wxString name(win->GetClassInfo()->GetClassName()); + int idx = names.Index(name); + if (idx == wxNOT_FOUND) + { + names.Add(name); + counts.Add(1); + } + else + counts[idx]++; + } + + node = node->GetNext(); + } + + size_t n, count = names.GetCount(); + for (n = 0; n < count; ++n) + names[n] += wxString::Format(wxT(" %d"), counts[n]); + + names.Sort(); + return names; + } + void wxLuaState::GarbageCollectWindows(bool closeWindows) { *************** *** 2168,2171 **** --- 2338,2387 ---- } + wxArrayString wxLuaState::GetTrackedCallbackStrings() + { + wxArrayString names; + wxArrayInt counts; + + wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); + + wxList::compatibility_iterator node = GetTrackedCallbackList()->GetFirst(); + while (node) + { + wxLuaCallback *wxlCallback = (wxLuaCallback *)node->GetData(); + wxCHECK_MSG(wxlCallback, false, wxT("Invalid wxLuaCallback")); + + wxString evtName; + if (GetLuaBindingList()) + { + wxLuaBindingList::compatibility_iterator bindNode = GetLuaBindingList()->GetFirst(); + for (; bindNode; bindNode = bindNode->GetNext()) + { + wxLuaBinding* binding = bindNode->GetData(); + evtName = binding->GetEventTypeName(wxlCallback->GetEventType()); + if (!evtName.IsEmpty()) break; + } + } + + wxString name = wxString::Format(wxT("%s (%d)"), evtName.c_str(), (int)wxlCallback->GetEventType()); + int idx = names.Index(name); + if (idx == wxNOT_FOUND) + { + names.Add(name); + counts.Add(1); + } + else + counts[idx]++; + + node = node->GetNext(); + } + + size_t n, count = names.GetCount(); + for (n = 0; n < count; ++n) + names[n] += wxString::Format(wxT(" %d"), counts[n]); + + names.Sort(); + return names; + } + void wxLuaState::AddTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback) { *************** *** 2184,2187 **** --- 2400,2436 ---- } + wxArrayString wxLuaState::GetTrackedWinDestroyCallbackStrings() + { + wxArrayString names; + wxArrayInt counts; + + wxCHECK_MSG(Ok(), names, wxT("Invalid wxLuaState")); + + wxList::compatibility_iterator node = GetTrackedWinDestroyCallbackList()->GetFirst(); + while (node) + { + wxLuaWinDestroyCallback *wxlDestroyCallBack = (wxLuaWinDestroyCallback *) node->GetData(); + wxCHECK_MSG(wxlDestroyCallBack, false, wxT("Invalid wxLuaWinDestroyCallback")); + + wxString name(wxT("Unknown Tracked Window Type")); + + wxObject* obj = (wxObject*)wxlDestroyCallBack->GetEvtHandler(); + if (obj && obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) + name = obj->GetClassInfo()->GetClassName(); + + names.Add(name); + counts.Add(1); + + node = node->GetNext(); + } + + size_t n, count = names.GetCount(); + for (n = 0; n < count; ++n) + names[n] += wxString::Format(wxT(" %d"), counts[n]); + + names.Sort(); + return names; + } + // ---------------------------------------------------------------------------- // wxLua Lua Registry Table Functions *************** *** 2294,2299 **** if ((g_wxluatag_NULL == stack_tag) || // FIXME, how to check when NULL is valid or not? (g_wxluatag_wxLuaFunction == stack_tag) || ! ((tag == WXLUAARG_String) && (IsDerivedClass(stack_tag, g_wxluatag_wxString) >= 0)) || ! (IsDerivedClass(stack_tag, tag) >= 0)) return true; } --- 2543,2548 ---- if ((g_wxluatag_NULL == stack_tag) || // FIXME, how to check when NULL is valid or not? (g_wxluatag_wxLuaFunction == stack_tag) || ! ((tag == WXLUAARG_String) && (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0)) || ! (wxlua_isderivedclass(L, stack_tag, tag) >= 0)) return true; } *************** *** 2309,2327 **** if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = ttag(stack_idx); if (g_wxluatag_wxLuaFunction == stack_tag) { ! wxLuaFunction *pFunction = (wxLuaFunction *)ttouserdata(stack_idx); return pFunction->GetObject(); } else if (g_wxluatag_NULL == stack_tag) return NULL; ! else if (IsDerivedClass(stack_tag, tag) >= 0) ! return ttouserdata(stack_idx); } terror(wxString::Format(_("wxLua: Expected user defined data type '%s' for parameter %d, but got '%s'."), GetLuaTagName(tag).c_str(), stack_idx, lua_TypeNameIndex(stack_idx).c_str())); return NULL; } --- 2558,2577 ---- if (wxlua_iswxuserdata(L, stack_idx)) { ! int stack_tag = wxlua_ttag(L, stack_idx); if (g_wxluatag_wxLuaFunction == stack_tag) { ! wxLuaFunction *pFunction = (wxLuaFunction *)wxlua_ttouserdata(L, stack_idx); return pFunction->GetObject(); } else if (g_wxluatag_NULL == stack_tag) return NULL; ! else if (wxlua_isderivedclass(L, stack_tag, tag) >= 0) ! return wxlua_ttouserdata(L, stack_idx); } terror(wxString::Format(_("wxLua: Expected user defined data type '%s' for parameter %d, but got '%s'."), GetLuaTagName(tag).c_str(), stack_idx, lua_TypeNameIndex(stack_idx).c_str())); + return NULL; } *************** *** 2330,2333 **** --- 2580,2584 ---- { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); + lua_State* L = M_WXLSTATEDATA->m_lua_State; if (data != NULL) *************** *** 2336,2340 **** // if the object we are referencing is derived from wxWindow ! if (IsDerivedClass(tag, g_wxluatag_wxWindow) >= 0) { wxWindow* win = wxDynamicCast(data, wxWindow); --- 2587,2591 ---- // if the object we are referencing is derived from wxWindow ! if (wxlua_isderivedclass(L, tag, g_wxluatag_wxWindow) >= 0) { wxWindow* win = wxDynamicCast(data, wxWindow); *************** *** 2375,2379 **** // Otherwise handle normally if (!handled) ! tpushusertag(data, tag); } else --- 2626,2630 ---- // Otherwise handle normally if (!handled) ! wxlua_tpushusertag(L, data, tag); } else *************** *** 2391,2395 **** { wxCHECK_MSG(Ok(), wxEmptyString, wxT("Invalid wxLuaState")); - lua_State* L = M_WXLSTATEDATA->m_lua_State; --- 2642,2645 ---- *************** *** 2400,2404 **** int stack_tag = wxlua_ttag(L, stack_idx); ! if (IsDerivedClass(stack_tag, g_wxluatag_wxString) >= 0) { wxString* wxstr = (wxString*)wxlua_ttouserdata(L, stack_idx, false); --- 2650,2654 ---- int stack_tag = wxlua_ttag(L, stack_idx); ! if (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0) { wxString* wxstr = (wxString*)wxlua_ttouserdata(L, stack_idx, false); *************** *** 2432,2436 **** { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); - lua_State* L = M_WXLSTATEDATA->m_lua_State; --- 2682,2685 ---- *************** *** 2440,2444 **** { int stack_tag = wxlua_ttag(L, stack_idx); ! return (IsDerivedClass(stack_tag, g_wxluatag_wxString) >= 0); } --- 2689,2693 ---- { int stack_tag = wxlua_ttag(L, stack_idx); ! return (wxlua_isderivedclass(L, stack_tag, g_wxluatag_wxString) >= 0); } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** wxlbind.cpp 14 Jun 2007 23:59:48 -0000 1.76 --- wxlbind.cpp 16 Jun 2007 06:21:46 -0000 1.77 *************** *** 37,44 **** int s_wxluaarg_Number = WXLUAARG_Number; int s_wxluaarg_String = WXLUAARG_String; ! int s_wxluaarg_LuaTable = WXLUAARG_LuaTable; ! int s_wxluaarg_LuaFunction = WXLUAARG_LuaFunction; int s_wxluaarg_UserData = WXLUAARG_UserData; // raw data ! int s_wxluaarg_LuaThread = WXLUAARG_LuaThread; int s_wxluaarg_Integer = WXLUAARG_Integer; --- 37,44 ---- int s_wxluaarg_Number = WXLUAARG_Number; int s_wxluaarg_String = WXLUAARG_String; ! int s_wxluaarg_Table = WXLUAARG_Table; ! int s_wxluaarg_Function = WXLUAARG_Function; int s_wxluaarg_UserData = WXLUAARG_UserData; // raw data ! int s_wxluaarg_Thread = WXLUAARG_Thread; int s_wxluaarg_Integer = WXLUAARG_Integer; *************** *** 71,78 **** int LUACALL wxlua_gc_wxLuaFunction(lua_State *L) { ! wxLuaState wxlState(L); ! wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! ! if (wxlua_iswxuserdata(L, 1) && (wxlua_ttag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *wxlFunction = (wxLuaFunction *)wxlua_ttouserdata(L, 1, true); --- 71,76 ---- int LUACALL wxlua_gc_wxLuaFunction(lua_State *L) { ! // Sanity check, but this is only attached to a wxLuaFunction, so it has to be ok. ! //if (wxlua_iswxuserdata(L, 1) && (wxlua_ttag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *wxlFunction = (wxLuaFunction *)wxlua_ttouserdata(L, 1, true); *************** *** 85,92 **** int LUACALL wxlua_call_wxLuaFunction(lua_State *L) { ! wxLuaState wxlState(L); ! wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! ! if (wxlua_iswxuserdata(L, 1) && (wxlua_ttag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *wxlFunction = (wxLuaFunction *)wxlua_ttouserdata(L, 1, false); --- 83,88 ---- int LUACALL wxlua_call_wxLuaFunction(lua_State *L) { ! // Sanity check, but this is only attached to a wxLuaFunction, so it has to be ok. ! //if (wxlua_iswxuserdata(L, 1) && (wxlua_ttag(L, 1) == g_wxluatag_wxLuaFunction)) { wxLuaFunction *wxlFunction = (wxLuaFunction *)wxlua_ttouserdata(L, 1, false); *************** *** 110,114 **** : m_wxlState(new wxLuaState(wxlState)), m_alloc_flag(wxLUAOBJECT_NONE), ! m_bool(false), m_int(0), m_string(NULL), m_arrayInt(NULL) { --- 106,110 ---- : m_wxlState(new wxLuaState(wxlState)), m_alloc_flag(wxLUAOBJECT_NONE), ! m_int(0) // GCC only wants one initializer { *************** *** 122,126 **** delete m_string; else if (m_alloc_flag == wxLUAOBJECT_ARRAYINT) ! delete m_arrayInt; // If a refererence exists, remove it, but don't bother if lua is being closed --- 118,122 ---- delete m_string; else if (m_alloc_flag == wxLUAOBJECT_ARRAYINT) ! delete m_arrayInt; // If a refererence exists, remove it, but don't bother if lua is being closed *************** *** 328,331 **** --- 324,328 ---- { wxLuaBindMethod* wxlMethod = wxLuaBinding::GetClassMethod(wxlClass, name); + if (wxlMethod != NULL) { *************** *** 491,499 **** // get methods are either WXLUAMETHOD_METHOD or WXLUAMETHOD_GETPROP // and they can't both have the same names so either type will work int t1 = 0xFF & ((const wxLuaBindMethod*)p1)->type; int t2 = 0xFF & ((const wxLuaBindMethod*)p2)->type; ! int t12 = int(t1) & int(t2); ! if ((t12 == WXLUAMETHOD_METHOD) || (t12 == WXLUAMETHOD_GETPROP) || ! (t12 == (int(WXLUAMETHOD_METHOD)|int(WXLUAMETHOD_GETPROP)))) return 0; --- 488,496 ---- // get methods are either WXLUAMETHOD_METHOD or WXLUAMETHOD_GETPROP // and they can't both have the same names so either type will work + // we have also set the reference item's type to 0 so we don't test positive for it int t1 = 0xFF & ((const wxLuaBindMethod*)p1)->type; int t2 = 0xFF & ((const wxLuaBindMethod*)p2)->type; ! if (WXLUA_HASBIT(t1, WXLUAMETHOD_METHOD|WXLUAMETHOD_GETPROP) || ! WXLUA_HASBIT(t2, WXLUAMETHOD_METHOD|WXLUAMETHOD_GETPROP)) return 0; *************** *** 1034,1040 **** { wxCHECK_MSG(wxlClass, NULL, wxT("Invalid wxLuaBindClass to find method from.")); ! /* ! wxLuaBindMethod methodItem = { 0, WXLUAMETHOD_METHOD, 0, 0, 0 }; ! methodItem.name = methodName; // this relies on LUA allocating tags in ascending order of definition --- 1031,1039 ---- { wxCHECK_MSG(wxlClass, NULL, wxT("Invalid wxLuaBindClass to find method from.")); ! ! #if 1 ! ! // Note : type must be 0 for the compare function to work ! wxLuaBindMethod methodItem = { methodName, 0, 0, 0, 0 }; // this relies on LUA allocating tags in ascending order of definition *************** *** 1047,1051 **** //wxPrintf(wxT("wxlMethod %d\n"), wxlMethod); ! */ wxLuaBindMethod *wxlMethod = wxlClass->methods; --- 1046,1057 ---- //wxPrintf(wxT("wxlMethod %d\n"), wxlMethod); ! ! if (wxlMethod != NULL) ! return wxlMethod; ! ! if (search_baseclasses && wxlClass->baseclass) ! return GetClassMethod(wxlClass->baseclass, methodName, search_baseclasses); ! ! #else wxLuaBindMethod *wxlMethod = wxlClass->methods; *************** *** 1058,1061 **** --- 1064,1070 ---- && (strcmp(wxlMethod->name, methodName) == 0)) { + /* // NOTE: This is now implemented in wxLuaState::RegisterBindings + + // iterate through the base classes to find if this function is // an overload, but only if we haven't checked already. *************** *** 1086,1090 **** } } ! return wxlMethod; } --- 1095,1099 ---- } } ! */ return wxlMethod; } *************** *** 1094,1097 **** --- 1103,1108 ---- return GetClassMethod(wxlClass->baseclass, methodName, search_baseclasses); + #endif + return NULL; } *************** *** 1349,1353 **** { // Force the baseclass methods to be found ! wxLuaBinding::GetClassMethod(wxlClass, wxlMethod->name, true); // Create table { wxLuaBindClass userdata } --- 1360,1364 ---- { // Force the baseclass methods to be found ! //wxLuaBinding::GetClassMethod(wxlClass, wxlMethod->name, true); FIXME // Create table { wxLuaBindClass userdata } Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wxlua_bind.cpp 14 Jun 2007 23:59:48 -0000 1.3 --- wxlua_bind.cpp 16 Jun 2007 06:21:46 -0000 1.4 *************** *** 60,72 **** { "LUA_TUSERDATA", LUA_TUSERDATA }, { "WXLUAARG_Boolean", WXLUAARG_Boolean }, { "WXLUAARG_Integer", WXLUAARG_Integer }, { "WXLUAARG_LightUserData", WXLUAARG_LightUserData }, - { "WXLUAARG_LuaFunction", WXLUAARG_LuaFunction }, - { "WXLUAARG_LuaTable", WXLUAARG_LuaTable }, - { "WXLUAARG_LuaThread", WXLUAARG_LuaThread }, { "WXLUAARG_Nil", WXLUAARG_Nil }, { "WXLUAARG_None", WXLUAARG_None }, { "WXLUAARG_Number", WXLUAARG_Number }, { "WXLUAARG_String", WXLUAARG_String }, { "WXLUAARG_UserData", WXLUAARG_UserData }, { "WXLUAMETHOD_CFUNCTION", WXLUAMETHOD_CFUNCTION }, --- 60,72 ---- { "LUA_TUSERDATA", LUA_TUSERDATA }, { "WXLUAARG_Boolean", WXLUAARG_Boolean }, + { "WXLUAARG_Function", WXLUAARG_Function }, { "WXLUAARG_Integer", WXLUAARG_Integer }, { "WXLUAARG_LightUserData", WXLUAARG_LightUserData }, { "WXLUAARG_Nil", WXLUAARG_Nil }, { "WXLUAARG_None", WXLUAARG_None }, { "WXLUAARG_Number", WXLUAARG_Number }, { "WXLUAARG_String", WXLUAARG_String }, + { "WXLUAARG_Table", WXLUAARG_Table }, + { "WXLUAARG_Thread", WXLUAARG_Thread }, { "WXLUAARG_UserData", WXLUAARG_UserData }, { "WXLUAMETHOD_CFUNCTION", WXLUAMETHOD_CFUNCTION }, *************** *** 150,153 **** --- 150,245 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_CompileLuaScript[1] = {{ wxLua_function_CompileLuaScript, WXLUAMETHOD_CFUNCTION, 2, 2, s_wxluatagArray_wxLua_function_CompileLuaScript }}; + // %override wxLua_function_GetTrackedEventCallbacks + // %function LuaTable GetTrackedEventCallbacks() + static int LUACALL wxLua_function_GetTrackedEventCallbacks(lua_State *L) + { + wxLuaState wxlState(L); + wxArrayString strArr = wxlState.GetTrackedCallbackStrings(); + size_t n, count = strArr.GetCount(); + long val = 0; + lua_createtable(L, 0, count); + + for (n = 0; n < count; ++n) + { + lua_pushstring(L, wx2lua(strArr[n].BeforeFirst(wxT(' ')))); + strArr[n].AfterLast(wxT(' ')).ToLong(&val); + lua_pushnumber(L, (double)val); + lua_rawset(L, -3); + } + + 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); + wxArrayString strArr = wxlState.GetTrackedWindowStrings(); + size_t n, count = strArr.GetCount(); + long val = 0; + lua_createtable(L, 0, count); + + for (n = 0; n < count; ++n) + { + lua_pushstring(L, wx2lua(strArr[n].BeforeLast(wxT(' ')))); + strArr[n].AfterLast(wxT(' ')).ToLong(&val); + lua_pushnumber(L, (double)val); + lua_rawset(L, -3); + } + + 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) + { + wxLuaState wxlState(L); + wxArrayString strArr = wxlState.GetTrackedObjectStrings(); + size_t n, count = strArr.GetCount(); + long val = 0; + lua_createtable(L, 0, count); + + for (n = 0; n < count; ++n) + { + lua_pushstring(L, wx2lua(strArr[n].BeforeLast(wxT(' ')))); + strArr[n].AfterLast(wxT(' ')).ToLong(&val); + lua_pushnumber(L, (double)val); + lua_rawset(L, -3); + } + + 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); + wxArrayString strArr = wxlState.GetTrackedWinDestroyCallbackStrings(); + size_t n, count = strArr.GetCount(); + long val = 0; + lua_createtable(L, 0, count); + + for (n = 0; n < count; ++n) + { + lua_pushstring(L, wx2lua(strArr[n].BeforeLast(wxT(' ')))); + strArr[n].AfterLast(wxT(' ')).ToLong(&val); + lua_pushnumber(L, (double)val); + lua_rawset(L, -3); + } + + 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_wxlua_iswxluatype[] = { &s_wxluaarg_Number, &s_wxluaarg_Number, NULL }; // %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) *************** *** 219,222 **** --- 311,318 ---- { { "CompileLuaScript", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_CompileLuaScript, 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 }, { "wxlua_iswxluatype", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_wxlua_iswxluatype, 1, NULL }, { "wxlua_type", WXLUAMETHOD_CFUNCTION, s_wxluafunc_wxLua_function_wxlua_type, 1, NULL }, |