From: John L. <jr...@us...> - 2007-06-06 23:43:23
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv4156/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp Log Message: Rename structs WXLUACLASS, WXLUAMETHOD, WXLUADEFINE, WXLUASTRING, WXLUAEVENT to wxLuaBindClass, wxLuaBindMethod, wxLuaBindDefine, wxLuaBindString, wxLuaBindEvent Fix %renamed listCtrl:SetItemString to now use overload SetItem Fix recursion in traversing the base class methods Add IntArray_FromLuaTable for binding generator to do (int n, int* items) from a table Use NULL in bindings for items that are *pointers for clarity Use sizeof(struct name) instead of sizeof(array[0]) in bindings Rename wxLuaBinding GetLuaClassList to just GetClassArray since it's a C array Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** wxlstate.cpp 6 Jun 2007 18:03:48 -0000 1.102 --- wxlstate.cpp 6 Jun 2007 23:43:16 -0000 1.103 *************** *** 467,475 **** } ! int LUACALL wxlua_iswxluatype(int luatype, int wxluaarg_type) { int ret = -1; // unknown wxlua arg type ! switch (wxluaarg_type) { case WXLUAARG_None : --- 467,475 ---- } ! int LUACALL wxlua_iswxluatype(int luatype, int wxluaarg_tag) { int ret = -1; // unknown wxlua arg type ! switch (wxluaarg_tag) { case WXLUAARG_None : *************** *** 519,525 **** } ! wxString wxlua_getwxluatypename(int wxluaarg_type) { ! switch (wxluaarg_type) { case WXLUAARG_None : return wxT("none"); --- 519,525 ---- } ! wxString wxlua_getwxluatypename(int wxluaarg_tag) { ! switch (wxluaarg_tag) { case WXLUAARG_None : return wxT("none"); *************** *** 1732,1740 **** wxLuaBinding* binding = node->GetData(); ! WXLUACLASS* pClass = (WXLUACLASS *)binding->GetLuaClassList(); ! size_t i, class_count = binding->GetLuaClassCount(); for (i = 0; i < class_count; i++) { ! WXLUACLASS* pLuaClass = pClass + i; // pLuaClass->baseclass = NULL; FIXME --- 1732,1740 ---- wxLuaBinding* binding = node->GetData(); ! wxLuaBindClass* pClass = (wxLuaBindClass *)binding->GetClassArray(); ! size_t i, class_count = binding->GetClassCount(); for (i = 0; i < class_count; i++) { ! wxLuaBindClass* pLuaClass = pClass + i; // pLuaClass->baseclass = NULL; FIXME *************** *** 1781,1785 **** } ! const WXLUACLASS* wxLuaState::GetLuaClass(int iClassTag) const { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); --- 1781,1785 ---- } ! const wxLuaBindClass* wxLuaState::GetLuaClass(int iClassTag) const { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); *************** *** 1789,1795 **** if (wxlua_tget(L, iClassTag) && lua_istable(L, -1)) { ! lua_pushstring(L, "WXLUACLASS"); // t[iClassTag] = { __gc = WXLUACLASS (or nil if not a class tag) lua_rawget(L, -2); ! const WXLUACLASS* wxlClass = (WXLUACLASS *)lua_touserdata(L, -1); // actually lightuserdata lua_pop(L, 2); // pop wxLuaReferences table and lightuserdata (or nil if none) --- 1789,1795 ---- if (wxlua_tget(L, iClassTag) && lua_istable(L, -1)) { ! lua_pushstring(L, "wxLuaBindClass"); // t[iClassTag] = { __gc = wxLuaBindClass (or nil if not a class tag) lua_rawget(L, -2); ! const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata lua_pop(L, 2); // pop wxLuaReferences table and lightuserdata (or nil if none) *************** *** 1802,1806 **** /* ! WXLUACLASS classItem; classItem.class_tag = &iClassTag; --- 1802,1806 ---- /* ! wxLuaBindClass classItem; classItem.class_tag = &iClassTag; *************** *** 1812,1819 **** // this relies on LUA allocating tags in ascending order of definition // if LUA stops doing this, then the search may break. ! const WXLUACLASS *pLuaClass = (WXLUACLASS *) bsearch(&classItem, binding->GetLuaClassList(), binding->GetLuaClassCount(), ! sizeof(WXLUACLASS), wxLuaClassListCompareByTag); if (pLuaClass) --- 1812,1819 ---- // this relies on LUA allocating tags in ascending order of definition // if LUA stops doing this, then the search may break. ! const wxLuaBindClass *pLuaClass = (wxLuaBindClass *) bsearch(&classItem, binding->GetLuaClassList(), binding->GetLuaClassCount(), ! sizeof(wxLuaBindClass), wxLuaClassListCompareByTag); if (pLuaClass) *************** *** 1825,1829 **** } ! const WXLUACLASS* wxLuaState::GetLuaClass(const char* className) const { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); --- 1825,1829 ---- } ! const wxLuaBindClass* wxLuaState::GetLuaClass(const char* className) const { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); *************** *** 1834,1840 **** lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) ! lua_pushstring(L, className); // t["className"] = WXLUACLASS (or nil if not a class tag) lua_rawget(L, -2); ! const WXLUACLASS* wxlClass = (WXLUACLASS *)lua_touserdata(L, -1); // actually lightuserdata lua_pop(L, 2); // pop wxLuaClasses table and lightuserdata --- 1834,1840 ---- lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) ! lua_pushstring(L, className); // t["className"] = wxLuaBindClass (or nil if not a class tag) lua_rawget(L, -2); ! const wxLuaBindClass* wxlClass = (wxLuaBindClass *)lua_touserdata(L, -1); // actually lightuserdata lua_pop(L, 2); // pop wxLuaClasses table and lightuserdata *************** *** 1843,1847 **** } ! const WXLUACLASS* wxLuaState::GetLuaClass(const WXLUAMETHOD* method) const { wxLuaBindingList::compatibility_iterator node; --- 1843,1847 ---- } ! const wxLuaBindClass* wxLuaState::GetLuaClass(const wxLuaBindMethod* method) const { wxLuaBindingList::compatibility_iterator node; *************** *** 1850,1854 **** wxLuaBinding* binding = node->GetData(); ! const WXLUACLASS *pLuaClass = binding->GetLuaClass(method); if (pLuaClass) return pLuaClass; --- 1850,1854 ---- wxLuaBinding* binding = node->GetData(); ! const wxLuaBindClass *pLuaClass = binding->GetLuaClass(method); if (pLuaClass) return pLuaClass; *************** *** 1857,1861 **** return NULL; } ! const WXLUACLASS* wxLuaState::GetLuaClass(const WXLUAMETHOD_CFUNC* method_cfunc) const { wxLuaBindingList::compatibility_iterator node; --- 1857,1861 ---- return NULL; } ! const wxLuaBindClass* wxLuaState::GetLuaClass(const wxLuaBindCFunc* method_cfunc) const { wxLuaBindingList::compatibility_iterator node; *************** *** 1864,1868 **** wxLuaBinding* binding = node->GetData(); ! const WXLUACLASS *pLuaClass = binding->GetLuaClass(method_cfunc); if (pLuaClass) return pLuaClass; --- 1864,1868 ---- wxLuaBinding* binding = node->GetData(); ! const wxLuaBindClass *pLuaClass = binding->GetLuaClass(method_cfunc); if (pLuaClass) return pLuaClass; *************** *** 1877,1881 **** return true; ! const WXLUACLASS *pLuaClass = GetLuaClass(iClassTag); if (pLuaClass && pLuaClass->baseclass) return IsDerivedClass(*pLuaClass->baseclass->class_tag, iBaseClassTag); --- 1877,1881 ---- return true; ! const wxLuaBindClass *pLuaClass = GetLuaClass(iClassTag); if (pLuaClass && pLuaClass->baseclass) return IsDerivedClass(*pLuaClass->baseclass->class_tag, iBaseClassTag); *************** *** 1884,1888 **** } ! const WXLUAEVENT* wxLuaState::GetLuaEvent(wxEventType eventType_) const { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); --- 1884,1888 ---- } ! const wxLuaBindEvent* wxLuaState::GetLuaEvent(wxEventType eventType_) const { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); *************** *** 1892,1896 **** { wxLuaBinding* binding = node->GetData(); ! const WXLUAEVENT *pLuaEvent = binding->GetEvent(eventType_); if (pLuaEvent) --- 1892,1896 ---- { wxLuaBinding* binding = node->GetData(); ! const wxLuaBindEvent *pLuaEvent = binding->GetEvent(eventType_); if (pLuaEvent) *************** *** 1933,1937 **** if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxEvent == 0) { ! const WXLUACLASS* luaClass = GetLuaClass("wxEvent"); wxCHECK_MSG(luaClass, 0, wxT("wxEvent lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxEvent = *luaClass->class_tag; --- 1933,1937 ---- if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxEvent == 0) { ! const wxLuaBindClass* luaClass = GetLuaClass("wxEvent"); wxCHECK_MSG(luaClass, 0, wxT("wxEvent lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxEvent = *luaClass->class_tag; *************** *** 1947,1951 **** if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxWindow == 0) { ! const WXLUACLASS* luaClass = GetLuaClass("wxWindow"); wxCHECK_MSG(luaClass, 0, wxT("wxWindow lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxWindow = *luaClass->class_tag; --- 1947,1951 ---- if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxWindow == 0) { ! const wxLuaBindClass* luaClass = GetLuaClass("wxWindow"); wxCHECK_MSG(luaClass, 0, wxT("wxWindow lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxWindow = *luaClass->class_tag; *************** *** 1961,1965 **** if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString == 0) { ! const WXLUACLASS* luaClass = GetLuaClass("wxString"); wxCHECK_MSG(luaClass, 0, wxT("wxString lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString = *luaClass->class_tag; --- 1961,1965 ---- if (M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString == 0) { ! const wxLuaBindClass* luaClass = GetLuaClass("wxString"); wxCHECK_MSG(luaClass, 0, wxT("wxString lua tag is missing in wxLuaState, forgot to add wxWidgets binding?")); M_WXLSTATEDATA->m_wxlStateData->m_wxluatag_wxString = *luaClass->class_tag; *************** *** 2398,2402 **** return wxT("wxLuaFunction"); ! const WXLUACLASS *pClass = GetLuaClass(tag); if (pClass) return lua2wx(pClass->name); --- 2398,2402 ---- return wxT("wxLuaFunction"); ! const wxLuaBindClass *pClass = GetLuaClass(tag); if (pClass) return lua2wx(pClass->name); *************** *** 2405,2415 **** } ! WXLUAMETHOD* wxLuaState::GetLuaMethod(const WXLUACLASS *wxlClass, const char *methodName) { int i_method, method_count = wxlClass->methods_n; // find a method in the class, recurse through classes from which this class is derived. for (i_method = 0; i_method < method_count; ++i_method) { ! WXLUAMETHOD *wxlMethod = wxlClass->methods + i_method; if (WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_METHOD | WXLUAMETHOD_GETPROP) && (strcmp(wxlMethod->name, methodName) == 0)) --- 2405,2417 ---- } ! wxLuaBindMethod* wxLuaState::GetLuaMethod(const wxLuaBindClass *wxlClass, const char *methodName, bool search_baseclasses) { + wxCHECK_MSG(wxlClass, NULL, wxT("Invalid wxLuaBindClass to find method from.")); + int i_method, method_count = wxlClass->methods_n; // find a method in the class, recurse through classes from which this class is derived. for (i_method = 0; i_method < method_count; ++i_method) { ! wxLuaBindMethod *wxlMethod = wxlClass->methods + i_method; if (WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_METHOD | WXLUAMETHOD_GETPROP) && (strcmp(wxlMethod->name, methodName) == 0)) *************** *** 2419,2430 **** if (!WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_OVERLOAD_BASE)) { ! WXLUACLASS *baseClass = wxlClass->baseclass; ! WXLUAMETHOD *parentMethod = wxlMethod; while (baseClass) { ! parentMethod->type |= WXLUAMETHOD_OVERLOAD_BASE; ! WXLUAMETHOD* baseMethod = GetLuaMethod(baseClass, methodName); if (baseMethod) { --- 2421,2432 ---- if (!WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_OVERLOAD_BASE)) { ! wxLuaBindClass *baseClass = wxlClass->baseclass; ! wxLuaBindMethod *parentMethod = wxlMethod; while (baseClass) { ! parentMethod->type |= WXLUAMETHOD_OVERLOAD_BASE; // have checked this ! wxLuaBindMethod* baseMethod = GetLuaMethod(baseClass, methodName, false); if (baseMethod) { *************** *** 2445,2449 **** } ! if (wxlClass->baseclass) return GetLuaMethod(wxlClass->baseclass, methodName); --- 2447,2451 ---- } ! if (search_baseclasses && wxlClass->baseclass) return GetLuaMethod(wxlClass->baseclass, methodName); *************** *** 2451,2457 **** } ! WXLUAMETHOD* wxLuaState::GetLuaProperty(const WXLUACLASS *wxlClass, const char *propName, bool isLuaSetProp) { ! wxCHECK_MSG(wxlClass, NULL, wxT("Invalid WXLUACLASS in wxLuaState::GetLuaProperty")); int i_method, method_count = wxlClass->methods_n; --- 2453,2459 ---- } ! wxLuaBindMethod* wxLuaState::GetLuaProperty(const wxLuaBindClass *wxlClass, const char *propName, bool isLuaSetProp) { ! wxCHECK_MSG(wxlClass, NULL, wxT("Invalid wxLuaBindClass in wxLuaState::GetLuaProperty")); int i_method, method_count = wxlClass->methods_n; *************** *** 2459,2463 **** for (i_method = 0; i_method < method_count; ++i_method) { ! WXLUAMETHOD *wxlMethod = wxlClass->methods + i_method; if (isLuaSetProp) { --- 2461,2465 ---- for (i_method = 0; i_method < method_count; ++i_method) { ! wxLuaBindMethod *wxlMethod = wxlClass->methods + i_method; if (isLuaSetProp) { *************** *** 3255,3259 **** ! wxArrayString wxLuaState::CreateMethodArgTagsMsg(struct WXLUAMETHOD* wxlMethod) { wxArrayString overloadMethodArray; --- 3257,3261 ---- ! wxArrayString wxLuaState::CreateMethodArgTagsMsg(struct wxLuaBindMethod* wxlMethod) { wxArrayString overloadMethodArray; *************** *** 3261,3274 **** int i_func = 0; // count total number of overloads ! WXLUAMETHOD* method = wxlMethod; // traverse the methods down the baseclass methods if any while (method) { ! WXLUAMETHOD_CFUNC* funcs = method->funcs; int i, arg, funcs_count = wxlMethod->funcs_n; wxString className; ! const WXLUACLASS* wxlClass = GetLuaClass(method); if (wxlClass) className = lua2wx(wxlClass->name) + wxT("::"); --- 3263,3276 ---- int i_func = 0; // count total number of overloads ! wxLuaBindMethod* method = wxlMethod; // traverse the methods down the baseclass methods if any while (method) { ! wxLuaBindCFunc* funcs = method->funcs; int i, arg, funcs_count = wxlMethod->funcs_n; wxString className; ! const wxLuaBindClass* wxlClass = GetLuaClass(method); if (wxlClass) className = lua2wx(wxlClass->name) + wxT("::"); *************** *** 3329,3338 **** // Redirect lua function call to 1 method from a list of overloaded functions ! int LUACALL wxLuaState::CallOverloadedFunction(struct WXLUAMETHOD* wxlMethod) { wxCHECK_MSG(wxlMethod, 0, wxT("Invalid overloaded method table")); // don't remove the table, but do skip past it when counting args ! bool remove_table = wxlua_removetableforcall(GetLuaState(), true); int i, arg; --- 3331,3340 ---- // Redirect lua function call to 1 method from a list of overloaded functions ! int LUACALL wxLuaState::CallOverloadedFunction(struct wxLuaBindMethod* wxlMethod) { wxCHECK_MSG(wxlMethod, 0, wxT("Invalid overloaded method table")); // don't remove the table, but do skip past it when counting args ! bool remove_table = wxluabind_removetableforcall(GetLuaState(), true); int i, arg; *************** *** 3351,3355 **** // only look at the methods that could possibly work and traverse base classes wxArrayPtrVoid funcArray; ! WXLUAMETHOD* method = wxlMethod; while (method) { --- 3353,3357 ---- // only look at the methods that could possibly work and traverse base classes wxArrayPtrVoid funcArray; ! wxLuaBindMethod* method = wxlMethod; while (method) { *************** *** 3368,3372 **** } ! WXLUAMETHOD_CFUNC* bestFunc = NULL; // store the last function that worked. // Look at the available functions in parallel, per arg --- 3370,3374 ---- } ! wxLuaBindCFunc* bestFunc = NULL; // store the last function that worked. // Look at the available functions in parallel, per arg *************** *** 3378,3382 **** for (i = 0; i < (int)funcArray.GetCount(); i++) { ! WXLUAMETHOD_CFUNC* func = (WXLUAMETHOD_CFUNC*)funcArray[i]; bestFunc = func; invalidArg = arg; --- 3380,3384 ---- for (i = 0; i < (int)funcArray.GetCount(); i++) { ! wxLuaBindCFunc* func = (wxLuaBindCFunc*)funcArray[i]; bestFunc = func; invalidArg = arg; *************** *** 3422,3426 **** if (funcArray.GetCount() > 0) { ! lua_CFunction func = ((WXLUAMETHOD_CFUNC*)funcArray[0])->func; // successfully found overloaded function to handle wxLua call --- 3424,3428 ---- if (funcArray.GetCount() > 0) { ! lua_CFunction func = ((wxLuaBindCFunc*)funcArray[0])->func; // successfully found overloaded function to handle wxLua call Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** wxlbind.cpp 6 Jun 2007 18:03:48 -0000 1.64 --- wxlbind.cpp 6 Jun 2007 23:43:16 -0000 1.65 *************** *** 33,37 **** wxLuaArgTag s_wxluaargArray_None[1] = {0}; ! WXLUADEFINE s_wxluadefineArray_None[1] = {{0, 0}}; int s_wxluaarg_None = WXLUAARG_None; --- 33,37 ---- wxLuaArgTag s_wxluaargArray_None[1] = {0}; ! wxLuaBindDefine s_wxluadefineArray_None[1] = {{0, 0}}; int s_wxluaarg_None = WXLUAARG_None; *************** *** 94,97 **** --- 94,98 ---- // remove the userdata *this from the stack + // can't do this for static and nonstatic overloaded functions //if (pFunction->m_wxlMethod && WXLUA_HASBIT(pFunction->m_wxlMethod->type, WXLUAMETHOD_STATIC)) // lua_remove(L, 1); *************** *** 258,265 **** // ---------------------------------------------------------------------------- ! // wxlua_garbageCollect - if the class defines a gc function, then call it. // ---------------------------------------------------------------------------- ! int LUACALL wxlua_garbageCollect(lua_State *L) { wxLuaState wxlState(L); --- 259,266 ---- // ---------------------------------------------------------------------------- ! // wxluabind_garbageCollect - if the class defines a gc function, then call it. // ---------------------------------------------------------------------------- ! int LUACALL wxluabind_garbageCollect(lua_State *L) { wxLuaState wxlState(L); *************** *** 267,271 **** int retVal = 0; ! WXLUACLASS *wxlClass = (WXLUACLASS *)lua_touserdata(L, lua_upvalueindex(1)); //bool tracked = false; --- 268,272 ---- int retVal = 0; ! wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); //bool tracked = false; *************** *** 277,281 **** key = (long)wxlState.ttouserdata(1, true); ! wxCHECK_MSG(key != 0, 0, wxT("NULL user data in wxlua_garbageCollect")); //tracked = --- 278,282 ---- key = (long)wxlState.ttouserdata(1, true); ! wxCHECK_MSG(key != 0, 0, wxT("NULL user data in wxluabind_garbageCollect")); //tracked = *************** *** 316,320 **** } ! //wxPrintf(wxT("wxlua_garbageCollect - '%s' tag %d lua %d key %ld tracked %d return value %d\n"), // lua2wx(wxlClass ? wxlClass->name : "").c_str(), wxlClass ? *wxlClass->class_tag : 0, (int)L, key, (int)tracked, retVal); --- 317,321 ---- } ! //wxPrintf(wxT("wxluabind_garbageCollect - '%s' tag %d lua %d key %ld tracked %d return value %d\n"), // lua2wx(wxlClass ? wxlClass->name : "").c_str(), wxlClass ? *wxlClass->class_tag : 0, (int)L, key, (int)tracked, retVal); *************** *** 323,327 **** // ---------------------------------------------------------------------------- ! // wxlua_getTableFunc // // Called by LUA to find the method that corresponds to a given method name. --- 324,328 ---- // ---------------------------------------------------------------------------- ! // wxluabind_getTableFunc // // Called by LUA to find the method that corresponds to a given method name. *************** *** 335,339 **** #define CALL_BASECLASS_FUNC_LEN 5 ! int LUACALL wxlua_getTableFunc(lua_State *L) { wxLuaState wxlState(L); --- 336,340 ---- #define CALL_BASECLASS_FUNC_LEN 5 ! int LUACALL wxluabind_getTableFunc(lua_State *L) { wxLuaState wxlState(L); *************** *** 354,358 **** bool found = false; int result = 0; ! WXLUACLASS *wxlClass = (WXLUACLASS *)lua_touserdata(L, lua_upvalueindex(1)); const char *name = "{unknown}"; wxCharBuffer funcName; --- 355,359 ---- bool found = false; int result = 0; ! wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); const char *name = "{unknown}"; wxCharBuffer funcName; *************** *** 387,391 **** if (!found) { ! WXLUAMETHOD* wxlMethod = wxlState.GetLuaMethod(wxlClass, name); if (wxlMethod != NULL) { --- 388,392 ---- if (!found) { ! wxLuaBindMethod* wxlMethod = wxlState.GetLuaMethod(wxlClass, name); if (wxlMethod != NULL) { *************** *** 432,436 **** //if (lua2wx(funcName).Find(wxT("OnBeginDocument")) != -1) ! // wxPrintf(wxT("wxlua_getTableFunc func '%s' wxlClass %d '%s', userdata %d, lightuserdata %d, ttag %d, class_tag %d lua_State %d wxLuaStateRefData %d call base %d\n"), // lua2wx(funcName).c_str(), (long)wxlClass, wxlClass ? lua2wx(wxlClass->name).c_str() : wxT(""), init_isuserdata, init_islightuserdata, init_ttag, init_class_tag, (long)L, (long)wxlState.GetRefData(), (int)wxlState.GetCallBaseClassFunction()); --- 433,437 ---- //if (lua2wx(funcName).Find(wxT("OnBeginDocument")) != -1) ! // wxPrintf(wxT("wxluabind_getTableFunc func '%s' wxlClass %d '%s', userdata %d, lightuserdata %d, ttag %d, class_tag %d lua_State %d wxLuaStateRefData %d call base %d\n"), // lua2wx(funcName).c_str(), (long)wxlClass, wxlClass ? lua2wx(wxlClass->name).c_str() : wxT(""), init_isuserdata, init_islightuserdata, init_ttag, init_class_tag, (long)L, (long)wxlState.GetRefData(), (int)wxlState.GetCallBaseClassFunction()); *************** *** 442,446 **** // ---------------------------------------------------------------------------- ! // wxlua_setTableFunc // // Called by LUA to find the method that corresponds to a given method name. --- 443,447 ---- // ---------------------------------------------------------------------------- ! // wxluabind_setTableFunc // // Called by LUA to find the method that corresponds to a given method name. *************** *** 449,462 **** // ---------------------------------------------------------------------------- ! int LUACALL wxlua_setTableFunc(lua_State *L) { wxLuaState wxlState(L); wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! WXLUACLASS *wxlClass = (WXLUACLASS *)lua_touserdata(L, lua_upvalueindex(1)); const char *name = lua_tostring(L, 2); bool found = false; ! //wxPrintf(wxT("wxlua_setTableFunc '%s'\n"), lua2wx(name).c_str()); if ((wxlClass != NULL) && lua_isuserdata(L, 1) && --- 450,463 ---- // ---------------------------------------------------------------------------- ! int LUACALL wxluabind_setTableFunc(lua_State *L) { wxLuaState wxlState(L); wxCHECK_MSG(wxlState.Ok(), 0, wxT("Invalid wxLuaState")); ! wxLuaBindClass *wxlClass = (wxLuaBindClass *)lua_touserdata(L, lua_upvalueindex(1)); const char *name = lua_tostring(L, 2); bool found = false; ! //wxPrintf(wxT("wxluabind_setTableFunc '%s'\n"), lua2wx(name).c_str()); if ((wxlClass != NULL) && lua_isuserdata(L, 1) && *************** *** 464,469 **** (wxlState.ttag(1) == *wxlClass->class_tag)) { ! // See if there is a WXLUAMETHOD_SETPROP in the WXLUACLASS's WXLUAMETHODs ! WXLUAMETHOD *wxlMethod = wxlState.GetLuaProperty(wxlClass, name, true); if (wxlMethod != NULL) { --- 465,470 ---- (wxlState.ttag(1) == *wxlClass->class_tag)) { ! // See if there is a WXLUAMETHOD_SETPROP in the wxLuaBindClass's wxLuaBindMethods ! wxLuaBindMethod *wxlMethod = wxlState.GetLuaProperty(wxlClass, name, true); if (wxlMethod != NULL) { *************** *** 483,487 **** //wxPrintf(wxT("'%s' %d\n"), lua2wx(str).c_str(), lua_gettop(L)); ! //wxLuaCheckStack stk(L, wxT("wxlua_setTableFunc")); //stk.DumpStack(); --- 484,488 ---- //wxPrintf(wxT("'%s' %d\n"), lua2wx(str).c_str(), lua_gettop(L)); ! //wxLuaCheckStack stk(L, wxT("wxluabind_setTableFunc")); //stk.DumpStack(); *************** *** 543,556 **** } ! static int wxlua_checkremovetable = 0; ! int wxlua_removetableforcall(lua_State* L, bool only_check) { //void* p = (void *)lua_tocfunction(L, lua_upvalueindex(1)); void* p = (void *)lua_touserdata(L, lua_upvalueindex(1)); ! if (!only_check && (p == &wxlua_checkremovetable)) lua_remove(L, 1); ! return p == &wxlua_checkremovetable; } --- 544,557 ---- } ! static int wxluabind_checkremovetable = 0; ! int wxluabind_removetableforcall(lua_State* L, bool only_check) { //void* p = (void *)lua_tocfunction(L, lua_upvalueindex(1)); void* p = (void *)lua_touserdata(L, lua_upvalueindex(1)); ! if (!only_check && (p == &wxluabind_checkremovetable)) lua_remove(L, 1); ! return p == &wxluabind_checkremovetable; } *************** *** 560,564 **** int wxLuaEventListCompareFn(const void *p1, const void *p2) { ! return (*((const WXLUAEVENT *) p1)->eventType) - (*((const WXLUAEVENT *) p2)->eventType); } --- 561,565 ---- int wxLuaEventListCompareFn(const void *p1, const void *p2) { ! return (*((const wxLuaBindEvent *) p1)->eventType) - (*((const wxLuaBindEvent *) p2)->eventType); } *************** *** 568,572 **** int wxLuaClassListCompareByTag(const void *p1, const void *p2) { ! return (*((const WXLUACLASS *) p1)->class_tag) - (*((const WXLUACLASS *) p2)->class_tag); } --- 569,573 ---- int wxLuaClassListCompareByTag(const void *p1, const void *p2) { ! return (*((const wxLuaBindClass *) p1)->class_tag) - (*((const wxLuaBindClass *) p2)->class_tag); } *************** *** 580,588 **** wxLuaBinding::wxLuaBinding() : wxObject(), ! m_classCount(0), m_classList(NULL), ! m_defineCount(0), m_defineList(NULL), ! m_eventCount(0), m_eventList(NULL), ! m_objectCount(0), m_objectList(NULL), ! m_functionCount(0), m_functionList(NULL), m_bindings_registered(false), m_startTag(0), --- 581,589 ---- wxLuaBinding::wxLuaBinding() : wxObject(), ! m_classCount(0), m_classArray(NULL), ! m_defineCount(0), m_defineArray(NULL), ! m_eventCount(0), m_eventArray(NULL), ! m_objectCount(0), m_objectArray(NULL), ! m_functionCount(0), m_functionArray(NULL), m_bindings_registered(false), m_startTag(0), *************** *** 694,700 **** static const luaL_reg s_funcTable[] = { ! {"__gc", wxlua_garbageCollect }, ! {"__index", wxlua_getTableFunc }, ! {"__newindex", wxlua_setTableFunc } }; static const size_t s_funcCount = sizeof(s_funcTable)/sizeof(s_funcTable[0]); --- 695,701 ---- static const luaL_reg s_funcTable[] = { ! {"__gc", wxluabind_garbageCollect }, ! {"__index", wxluabind_getTableFunc }, ! {"__newindex", wxluabind_setTableFunc } }; static const size_t s_funcCount = sizeof(s_funcTable)/sizeof(s_funcTable[0]); *************** *** 713,717 **** for (size_t i_class = 0; i_class < m_classCount; ++i_class) { ! WXLUACLASS *wxlClass = m_classList + i_class; // Create a new tag if registering types, else use tag already set --- 714,718 ---- for (size_t i_class = 0; i_class < m_classCount; ++i_class) { ! wxLuaBindClass *wxlClass = m_classArray + i_class; // Create a new tag if registering types, else use tag already set *************** *** 724,735 **** iTag = *wxlClass->class_tag; ! // store a lookup table for the class tags to WXLUACLASS structs wxlua_tget(L, *wxlClass->class_tag); ! lua_pushstring(L, "WXLUACLASS"); lua_pushlightuserdata(L, (void *)wxlClass); lua_rawset(L, -3); // t[name] = tag lua_remove(L, -1); // remove wxLua's registry wxLuaClasses table ! // store a lookup table for the class names to WXLUACLASS structs wxlua_pushstring_wxLuaClasses(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) --- 725,736 ---- iTag = *wxlClass->class_tag; ! // store a lookup table for the class tags to wxLuaBindClass structs wxlua_tget(L, *wxlClass->class_tag); ! lua_pushstring(L, "wxLuaBindClass"); lua_pushlightuserdata(L, (void *)wxlClass); lua_rawset(L, -3); // t[name] = tag lua_remove(L, -1); // remove wxLua's registry wxLuaClasses table ! // store a lookup table for the class names to wxLuaBindClass structs wxlua_pushstring_wxLuaClasses(L); lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the classes table) *************** *** 746,750 **** } - int i_method, method_count = wxlClass->methods_n; --- 747,750 ---- *************** *** 776,780 **** for (i_method = 0; i_method < method_count; ++i_method) { ! WXLUAMETHOD *wxlMethod = wxlClass->methods + i_method; if (WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_CONSTRUCTOR | WXLUAMETHOD_CFUNCTION)) { --- 776,780 ---- for (i_method = 0; i_method < method_count; ++i_method) { ! wxLuaBindMethod *wxlMethod = wxlClass->methods + i_method; if (WXLUA_HASBIT(wxlMethod->type, WXLUAMETHOD_CONSTRUCTOR | WXLUAMETHOD_CFUNCTION)) { *************** *** 798,803 **** lua_pushstring(L, "__call"); //lua_pushcfunction(L, wxlMethod->func); ! lua_pushlightuserdata(L, &wxlua_checkremovetable); // push tag to recognize table call ! lua_pushcclosure(L, wxlMethod->funcs[0].func, 1); // push func with tag as upvalue lua_rawset(L, -3); --- 798,803 ---- lua_pushstring(L, "__call"); //lua_pushcfunction(L, wxlMethod->func); ! lua_pushlightuserdata(L, &wxluabind_checkremovetable); // push tag to recognize table call ! lua_pushcclosure(L, wxlMethod->funcs[0].func, 1); // push func with tag as upvalue lua_rawset(L, -3); *************** *** 844,853 **** for (size_t i = 0; i < m_functionCount; ++i) { ! if (strcmp(m_functionList[i].name, "wxGetCwd") == 0) { ! wxPrintf(wxT("Adding wxGetCwd '%s' %p\n"), lua2wx(m_functionList[i].name).c_str(), m_functionList[i].func); ! lua_pushstring(L, m_functionList[i].name); ! lua_pushcfunction(L, m_functionList[i].func); lua_rawset(L, -3); // same as lua_setfield(L, -2, "key") --- 844,853 ---- for (size_t i = 0; i < m_functionCount; ++i) { ! if (strcmp(m_functionArray[i].name, "wxGetCwd") == 0) { ! wxPrintf(wxT("Adding wxGetCwd '%s' %p\n"), lua2wx(m_functionArray[i].name).c_str(), m_functionArray[i].func); ! lua_pushstring(L, m_functionArray[i].name); ! lua_pushcfunction(L, m_functionArray[i].func); lua_rawset(L, -3); // same as lua_setfield(L, -2, "key") *************** *** 882,886 **** for (size_t i_func = 0; i_func < m_functionCount; ++i_func) { ! WXLUAMETHOD *wxlMethod = m_functionList + i_func; lua_pushstring(L, wxlMethod->name); lua_pushcfunction(L, wxlMethod->funcs[0].func); --- 882,886 ---- for (size_t i_func = 0; i_func < m_functionCount; ++i_func) { ! wxLuaBindMethod *wxlMethod = m_functionArray + i_func; lua_pushstring(L, wxlMethod->name); lua_pushcfunction(L, wxlMethod->funcs[0].func); *************** *** 899,903 **** for (size_t i_define = 0; i_define < m_defineCount; ++i_define) { ! WXLUADEFINE *pDefine = m_defineList + i_define; lua_pushstring(L, pDefine->name); lua_pushnumber(L, pDefine->value); --- 899,903 ---- for (size_t i_define = 0; i_define < m_defineCount; ++i_define) { ! wxLuaBindDefine *pDefine = m_defineArray + i_define; lua_pushstring(L, pDefine->name); lua_pushnumber(L, pDefine->value); *************** *** 908,912 **** for (size_t i_string = 0; i_string < m_stringCount; ++i_string) { ! WXLUASTRING *pString = m_stringList + i_string; lua_pushstring(L, pString->name); lua_pushstring(L, wx2lua(pString->value)); --- 908,912 ---- for (size_t i_string = 0; i_string < m_stringCount; ++i_string) { ! wxLuaBindString *pString = m_stringArray + i_string; lua_pushstring(L, pString->name); lua_pushstring(L, wx2lua(pString->value)); *************** *** 917,921 **** for (size_t i_object = 0; i_object < m_objectCount; ++i_object) { ! WXLUAOBJECT *pObject = m_objectList + i_object; lua_pushstring(L, pObject->name); --- 917,921 ---- for (size_t i_object = 0; i_object < m_objectCount; ++i_object) { ! wxLuaBindObject *pObject = m_objectArray + i_object; lua_pushstring(L, pObject->name); *************** *** 931,935 **** for (size_t i_event = 0; i_event < m_eventCount; ++i_event) { ! WXLUAEVENT *pEvent = m_eventList + i_event; lua_pushstring(L, pEvent->name); lua_pushnumber(L, *pEvent->eventType); --- 931,935 ---- for (size_t i_event = 0; i_event < m_eventCount; ++i_event) { ! wxLuaBindEvent *pEvent = m_eventArray + i_event; lua_pushstring(L, pEvent->name); lua_pushnumber(L, *pEvent->eventType); *************** *** 938,945 **** // sort the event list into order for faster lookup. ! qsort(m_eventList, m_eventCount, sizeof(WXLUAEVENT), wxLuaEventListCompareFn); } ! bool wxLuaBinding::SetBaseClass(WXLUACLASS *wxlClass) { if (!wxlClass->baseclassName) // check if there is a baseclassName at all --- 938,945 ---- // sort the event list into order for faster lookup. ! qsort(m_eventArray, m_eventCount, sizeof(wxLuaBindEvent), wxLuaEventListCompareFn); } ! bool wxLuaBinding::SetBaseClass(wxLuaBindClass *wxlClass) { if (!wxlClass->baseclassName) // check if there is a baseclassName at all *************** *** 948,952 **** for (size_t n = 0; n < m_classCount; ++n) { ! WXLUACLASS* baseClass = m_classList + n; // potential base class if (strcmp(baseClass->name, wxlClass->baseclassName) == 0) --- 948,952 ---- for (size_t n = 0; n < m_classCount; ++n) { ! wxLuaBindClass* baseClass = m_classArray + n; // potential base class if (strcmp(baseClass->name, wxlClass->baseclassName) == 0) *************** *** 960,972 **** } ! const WXLUAEVENT* wxLuaBinding::GetEvent(wxEventType eventType_) const { const int eventType = eventType_; ! WXLUAEVENT eventItem = { &eventType, "" }; ! const WXLUAEVENT *pLuaEvent = (WXLUAEVENT *)bsearch(&eventItem, ! m_eventList, m_eventCount, ! sizeof(WXLUAEVENT), wxLuaEventListCompareFn); return pLuaEvent; --- 960,972 ---- } ! const wxLuaBindEvent* wxLuaBinding::GetEvent(wxEventType eventType_) const { const int eventType = eventType_; ! wxLuaBindEvent eventItem = { &eventType, "" }; ! const wxLuaBindEvent *pLuaEvent = (wxLuaBindEvent *)bsearch(&eventItem, ! m_eventArray, m_eventCount, ! sizeof(wxLuaBindEvent), wxLuaEventListCompareFn); return pLuaEvent; *************** *** 975,987 **** wxString wxLuaBinding::GetEventTypeName(wxEventType eventType) const { ! const WXLUAEVENT* luaEvent = GetEvent(eventType); return (luaEvent != NULL) ? lua2wx(luaEvent->name) : wxString(); } ! const WXLUACLASS* wxLuaBinding::GetLuaClass(const WXLUAMETHOD* wxlMethod) const { for (size_t i_class = 0; i_class < m_classCount; ++i_class) { ! WXLUACLASS *wxlClass = m_classList + i_class; int i_method, method_count = wxlClass->methods_n; --- 975,987 ---- wxString wxLuaBinding::GetEventTypeName(wxEventType eventType) const { ! const wxLuaBindEvent* luaEvent = GetEvent(eventType); return (luaEvent != NULL) ? lua2wx(luaEvent->name) : wxString(); } ! const wxLuaBindClass* wxLuaBinding::GetLuaClass(const wxLuaBindMethod* wxlMethod) const { for (size_t i_class = 0; i_class < m_classCount; ++i_class) { ! wxLuaBindClass *wxlClass = m_classArray + i_class; int i_method, method_count = wxlClass->methods_n; *************** *** 1000,1008 **** } ! const WXLUACLASS* wxLuaBinding::GetLuaClass(const WXLUAMETHOD_CFUNC* wxlMethod_cfunc) const { for (size_t i_class = 0; i_class < m_classCount; ++i_class) { ! WXLUACLASS *wxlClass = m_classList + i_class; int i_method, method_count = wxlClass->methods_n; --- 1000,1008 ---- } ! const wxLuaBindClass* wxLuaBinding::GetLuaClass(const wxLuaBindCFunc* wxlMethod_cfunc) const { for (size_t i_class = 0; i_class < m_classCount; ++i_class) { ! wxLuaBindClass *wxlClass = m_classArray + i_class; int i_method, method_count = wxlClass->methods_n; Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** wxlcallb.cpp 23 Mar 2007 00:09:36 -0000 1.28 --- wxlcallb.cpp 6 Jun 2007 23:43:16 -0000 1.29 *************** *** 118,122 **** int eventClassTag = wxlState.GetwxEventTag(); // get the s_wxluatag_wxEvent ! const WXLUAEVENT *pLuaEvent = wxlState.GetLuaEvent(pEvent->GetEventType()); if (pLuaEvent) eventClassTag = *pLuaEvent->class_tag; --- 118,122 ---- int eventClassTag = wxlState.GetwxEventTag(); // get the s_wxluatag_wxEvent ! const wxLuaBindEvent *pLuaEvent = wxlState.GetLuaEvent(pEvent->GetEventType()); if (pLuaEvent) eventClassTag = *pLuaEvent->class_tag; |