From: John L. <jr...@us...> - 2007-12-22 06:07:23
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16833/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua.cpp wxlua_bind.cpp Log Message: * Updated the naming conventions of the wxLua C/C++ functions to get rid of the term "tag" which dates back to Lua 4. Lua 5 does not use "tags", but rather metatables to attach functions to userdata in Lua. The new term for the C++ objects that wxLua wraps in Lua userdata and assigns a metatable to are wxLua types. wxLua types < 0, the WXLUA_TXXX types, correspond to the LUA_TXXX Lua types. wxLua types > 0 are types from the bindings and denote a class or struct. - Most notably for people who have written their own overrides for their bindings will be that wxLuaState::PushUserTag() is now wxluaT_PushUserDataType(). Those two functions existed before, but basically did the same thing. The calling arguments of PushUserTag() were taken however and were the reverse of what PushUserDataType() had. - wxluaT_new/get/set/tag() are now wxluaT_new/setmetatable() and wxluaT_type() where the latter works just like lua_type(), but returns one of the wxLua types. - Fix crash in wxListCtrl and wxTreeCtrl::AssignImageList() to use the %ungc tag to release wxLua from deleting the input wxImageList. Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** wxlua.cpp 20 Dec 2007 02:26:58 -0000 1.9 --- wxlua.cpp 22 Dec 2007 06:07:16 -0000 1.10 *************** *** 31,38 **** // Lua MetaTable Tag for Class 'wxLuaState' ! int s_wxluatag_wxLuaState = -1; ! static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaState_delete[] = { &s_wxluatag_wxLuaState, NULL }; ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaState_delete[1] = {{ wxlua_userdata_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatagArray_wxLua_wxLuaState_delete }}; --- 31,38 ---- // Lua MetaTable Tag for Class 'wxLuaState' ! int g_wxluatype_wxLuaState = -1; ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaState_delete[] = { &g_wxluatype_wxLuaState, NULL }; ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaState_delete[1] = {{ wxlua_userdata_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatypeArray_wxLua_wxLuaState_delete }}; *************** *** 52,65 **** // Lua MetaTable Tag for Class 'wxLuaObject' ! int s_wxluatag_wxLuaObject = -1; ! static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaObject_GetAllocationFlag[] = { &s_wxluatag_wxLuaObject, NULL }; static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_GetAllocationFlag[1] = {{ wxLua_wxLuaObject_GetAllocationFlag, WXLUAMETHOD_METHOD, 1, 1, s_wxluatagArray_wxLua_wxLuaObject_GetAllocationFlag }}; // int GetAllocationFlag() const static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L) { // get this ! wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call GetAllocationFlag int returns = (self->GetAllocationFlag()); --- 52,65 ---- // Lua MetaTable Tag for Class 'wxLuaObject' ! int g_wxluatype_wxLuaObject = -1; ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_GetAllocationFlag[] = { &g_wxluatype_wxLuaObject, NULL }; static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_GetAllocationFlag[1] = {{ wxLua_wxLuaObject_GetAllocationFlag, WXLUAMETHOD_METHOD, 1, 1, s_wxluatypeArray_wxLua_wxLuaObject_GetAllocationFlag }}; // int GetAllocationFlag() const static int LUACALL wxLua_wxLuaObject_GetAllocationFlag(lua_State *L) { // get this ! wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, g_wxluatype_wxLuaObject); // call GetAllocationFlag int returns = (self->GetAllocationFlag()); *************** *** 70,76 **** } ! static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaObject_GetObject[] = { &s_wxluatag_wxLuaObject, NULL }; static int LUACALL wxLua_wxLuaObject_GetObject(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_GetObject[1] = {{ wxLua_wxLuaObject_GetObject, WXLUAMETHOD_METHOD, 1, 1, s_wxluatagArray_wxLua_wxLuaObject_GetObject }}; // %override wxLua_wxLuaObject_GetObject // void *GetObject() const --- 70,76 ---- } ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_GetObject[] = { &g_wxluatype_wxLuaObject, NULL }; static int LUACALL wxLua_wxLuaObject_GetObject(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_GetObject[1] = {{ wxLua_wxLuaObject_GetObject, WXLUAMETHOD_METHOD, 1, 1, s_wxluatypeArray_wxLua_wxLuaObject_GetObject }}; // %override wxLua_wxLuaObject_GetObject // void *GetObject() const *************** *** 78,82 **** { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call GetObject that push the item onto the stack, or nil if (self->GetObject()) --- 78,82 ---- { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, g_wxluatype_wxLuaObject); // call GetObject that push the item onto the stack, or nil if (self->GetObject()) *************** *** 87,93 **** ! static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaObject_SetObject[] = { &s_wxluatag_wxLuaObject, NULL }; static int LUACALL wxLua_wxLuaObject_SetObject(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_SetObject[1] = {{ wxLua_wxLuaObject_SetObject, WXLUAMETHOD_METHOD, 1, 1, s_wxluatagArray_wxLua_wxLuaObject_SetObject }}; // %override wxLua_wxLuaObject_SetObject // void SetObject(void *object) --- 87,93 ---- ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_SetObject[] = { &g_wxluatype_wxLuaObject, NULL }; static int LUACALL wxLua_wxLuaObject_SetObject(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_SetObject[1] = {{ wxLua_wxLuaObject_SetObject, WXLUAMETHOD_METHOD, 1, 1, s_wxluatypeArray_wxLua_wxLuaObject_SetObject }}; // %override wxLua_wxLuaObject_SetObject // void SetObject(void *object) *************** *** 95,99 **** { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call SetObject self->SetObject(1); --- 95,99 ---- { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, g_wxluatype_wxLuaObject); // call SetObject self->SetObject(1); *************** *** 103,111 **** ! static wxLuaArgTag s_wxluatagArray_wxLua_wxLuaObject_delete[] = { &s_wxluatag_wxLuaObject, NULL }; ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_delete[1] = {{ wxlua_userdata_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatagArray_wxLua_wxLuaObject_delete }}; static int LUACALL wxLua_wxLuaObject_constructor(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_constructor[1] = {{ wxLua_wxLuaObject_constructor, WXLUAMETHOD_CONSTRUCTOR, 0, 0, s_wxluaargArray_None }}; // %override wxLua_wxLuaObject_constructor // wxLuaObject(void *object) --- 103,111 ---- ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_delete[] = { &g_wxluatype_wxLuaObject, NULL }; ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_delete[1] = {{ wxlua_userdata_delete, WXLUAMETHOD_METHOD|WXLUAMETHOD_DELETE, 1, 1, s_wxluatypeArray_wxLua_wxLuaObject_delete }}; static int LUACALL wxLua_wxLuaObject_constructor(lua_State *L); ! static wxLuaBindCFunc s_wxluafunc_wxLua_wxLuaObject_constructor[1] = {{ wxLua_wxLuaObject_constructor, WXLUAMETHOD_CONSTRUCTOR, 0, 0, g_wxluaargtypeArray_None }}; // %override wxLua_wxLuaObject_constructor // wxLuaObject(void *object) *************** *** 120,124 **** wxluaO_addgcobject(L, returns); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxLuaObject, returns); // return the number of parameters return 1; --- 120,124 ---- wxluaO_addgcobject(L, returns); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, returns, g_wxluatype_wxLuaObject); // return the number of parameters return 1; Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** wxlstate.cpp 20 Dec 2007 02:26:58 -0000 1.155 --- wxlstate.cpp 22 Dec 2007 06:07:16 -0000 1.156 *************** *** 25,29 **** //#include "wxluadebug/include/wxldebug.h" // for debugging only ! const char* wxlua_lreg_tags_key = "wxLua metatable class tags"; const char* wxlua_lreg_refs_key = "wxLua object references"; const char* wxlua_lreg_debug_refs_key = "wxLuaDebugData references"; --- 25,29 ---- //#include "wxluadebug/include/wxldebug.h" // for debugging only ! const char* wxlua_lreg_types_key = "wxLua metatable class types"; const char* wxlua_lreg_refs_key = "wxLua object references"; [...1264 lines suppressed...] *************** *** 3148,3155 **** } ! wxString wxLuaState::GetLuaTagName(int tag) const { wxCHECK_MSG(Ok(), wxEmptyString, wxT("Invalid wxLuaState")); ! return wxluaT_gettagname(M_WXLSTATEDATA->m_lua_State, tag); } --- 3133,3140 ---- } ! wxString wxLuaState::GetwxLuaTypeName(int wxl_type) const { wxCHECK_MSG(Ok(), wxEmptyString, wxT("Invalid wxLuaState")); ! return wxluaT_typename(M_WXLSTATEDATA->m_lua_State, wxl_type); } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** wxlbind.cpp 20 Dec 2007 02:26:58 -0000 1.109 --- wxlbind.cpp 22 Dec 2007 06:07:15 -0000 1.110 *************** *** 25,299 **** WX_DEFINE_LIST(wxLuaBindingList); ! wxLuaArgTag s_wxluaargArray_None[1] = {0}; ! wxLuaBindDefine s_wxluadefineArray_None[1] = {{0, 0}}; ! ! int s_wxluaarg_None = WXLUA_TNONE; ! int s_wxluaarg_Nil = WXLUA_TNIL; ! int s_wxluaarg_Boolean = WXLUA_TBOOLEAN; ! int s_wxluaarg_LightUserData = WXLUA_TLIGHTUSERDATA; // raw data ! int s_wxluaarg_Number = WXLUA_TNUMBER; [...1930 lines suppressed...] sm_bindingList_initialized = true; } + + bool wxLuaBinding::SetBaseClass(wxLuaBindClass *wxlClass) + { + if (!wxlClass->baseclassName) // check if there is a baseclassName at all + return false; + + wxLuaBindClass* baseClass = m_classArray; // potential base class + for (size_t n = 0; n < m_classCount; ++n, ++baseClass) + { + if (strcmp(baseClass->name, wxlClass->baseclassName) == 0) + { + wxlClass->baseclass = baseClass; + return true; + } + } + + return false; + } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** wxlcallb.cpp 15 Dec 2007 16:56:41 -0000 1.52 --- wxlcallb.cpp 22 Dec 2007 06:07:15 -0000 1.53 *************** *** 116,125 **** wxLuaState wxlState(m_wxlState); ! int event_tag = 0; // If !m_wxlBindEvent, we would have errored in the constructor, but... if (m_wxlBindEvent != NULL) { ! event_tag = *m_wxlBindEvent->class_tag; // These wxEventTypes can be wxScrollEvents or wxSpinEvents --- 116,125 ---- wxLuaState wxlState(m_wxlState); ! int event_wxl_type = 0; // If !m_wxlBindEvent, we would have errored in the constructor, but... if (m_wxlBindEvent != NULL) { ! event_wxl_type = *m_wxlBindEvent->wxluatype; // These wxEventTypes can be wxScrollEvents or wxSpinEvents *************** *** 131,144 **** const wxLuaBindClass *wxlClass = wxlState.GetBindClass("wxSpinEvent"); if (wxlClass != NULL) ! event_tag = *wxlClass->class_tag; else ! event_tag = g_wxluatag_wxEvent; // get the s_wxluatag_wxEvent } } else ! event_tag = g_wxluatag_wxEvent; // get the s_wxluatag_wxEvent // Should never get here, but error out in case we do ! wxCHECK_RET(event_tag != WXLUA_NOTAG, wxT("Unknown wxEvent wxLua tag for : ") + wxString(event->GetClassInfo()->GetClassName())); wxlState.lua_CheckStack(LUA_MINSTACK); --- 131,144 ---- const wxLuaBindClass *wxlClass = wxlState.GetBindClass("wxSpinEvent"); if (wxlClass != NULL) ! event_wxl_type = *wxlClass->wxluatype; else ! event_wxl_type = g_wxluatag_wxEvent; // get the s_wxluatag_wxEvent } } else ! event_wxl_type = g_wxluatag_wxEvent; // get the s_wxluatag_wxEvent // Should never get here, but error out in case we do ! wxCHECK_RET(event_wxl_type != WXLUA_TUNKNOWN, wxT("Unknown wxEvent wxLua tag for : ") + wxString(event->GetClassInfo()->GetClassName())); wxlState.lua_CheckStack(LUA_MINSTACK); *************** *** 152,156 **** // Tracking this causes clashes in the object registry table // since many can be created and deleted and the mem address is resused by C++. ! wxlState.wxluaT_PushUserTag(event, event_tag, false); wxlState.LuaPCall(1, 0); } --- 152,156 ---- // Tracking this causes clashes in the object registry table // since many can be created and deleted and the mem address is resused by C++. ! wxlState.wxluaT_PushUserDataType(event, event_wxl_type, false); wxlState.LuaPCall(1, 0); } Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** wxlua_bind.cpp 20 Dec 2007 02:26:58 -0000 1.18 --- wxlua_bind.cpp 22 Dec 2007 06:07:16 -0000 1.19 *************** *** 45,51 **** // --------------------------------------------------------------------------- ! wxLuaBindDefine* wxLuaGetDefineList_wxlua(size_t &count) { ! static wxLuaBindDefine defineList[] = { { "LUA_TBOOLEAN", LUA_TBOOLEAN }, --- 45,51 ---- // --------------------------------------------------------------------------- ! wxLuaBindNumber* wxLuaGetDefineList_wxlua(size_t &count) { ! static wxLuaBindNumber numberList[] = { { "LUA_TBOOLEAN", LUA_TBOOLEAN }, *************** *** 60,68 **** { "LUA_TUSERDATA", LUA_TUSERDATA }, { "WXLUAMETHOD_CFUNCTION", WXLUAMETHOD_CFUNCTION }, { "WXLUAMETHOD_CONSTRUCTOR", WXLUAMETHOD_CONSTRUCTOR }, { "WXLUAMETHOD_DELETE", WXLUAMETHOD_DELETE }, { "WXLUAMETHOD_GETPROP", WXLUAMETHOD_GETPROP }, { "WXLUAMETHOD_METHOD", WXLUAMETHOD_METHOD }, - { "WXLUAMETHOD_OVERLOAD_BASE", WXLUAMETHOD_OVERLOAD_BASE }, { "WXLUAMETHOD_SETPROP", WXLUAMETHOD_SETPROP }, { "WXLUAMETHOD_STATIC", WXLUAMETHOD_STATIC }, --- 60,68 ---- { "LUA_TUSERDATA", LUA_TUSERDATA }, { "WXLUAMETHOD_CFUNCTION", WXLUAMETHOD_CFUNCTION }, + { "WXLUAMETHOD_CHECKED_OVERLOAD", WXLUAMETHOD_CHECKED_OVERLOAD }, { "WXLUAMETHOD_CONSTRUCTOR", WXLUAMETHOD_CONSTRUCTOR }, { "WXLUAMETHOD_DELETE", WXLUAMETHOD_DELETE }, { "WXLUAMETHOD_GETPROP", WXLUAMETHOD_GETPROP }, { "WXLUAMETHOD_METHOD", WXLUAMETHOD_METHOD }, { "WXLUAMETHOD_SETPROP", WXLUAMETHOD_SETPROP }, { "WXLUAMETHOD_STATIC", WXLUAMETHOD_STATIC }, *************** *** 91,96 **** { 0, 0 }, }; ! count = sizeof(defineList)/sizeof(wxLuaBindDefine) - 1; ! return defineList; } --- 91,96 ---- { 0, 0 }, }; ! count = sizeof(numberList)/sizeof(wxLuaBindNumber) - 1; ! return numberList; } *************** *** 131,135 **** // --------------------------------------------------------------------------- ! static wxLuaArgTag s_wxluatagArray_wxLua_function_CompileLuaScript[] = { &s_wxluaarg_String, &s_wxluaarg_String, NULL }; // %override wxLua_function_CompileLuaScript // %function int CompileLuaScript(const wxString& luaScript, const wxString& fileName) --- 131,135 ---- // --------------------------------------------------------------------------- ! static wxLuaArgType s_wxluatypeArray_wxLua_function_CompileLuaScript[] = { &g_wxluatype_TSTRING, &g_wxluatype_TSTRING, NULL }; // %override wxLua_function_CompileLuaScript // %function int CompileLuaScript(const wxString& luaScript, const wxString& fileName) *************** *** 152,156 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_CompileLuaScript[1] = {{ wxLua_function_CompileLuaScript, WXLUAMETHOD_CFUNCTION, 2, 2, s_wxluatagArray_wxLua_function_CompileLuaScript }}; // %override wxLua_function_GetBindings --- 152,156 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_CompileLuaScript[1] = {{ wxLua_function_CompileLuaScript, WXLUAMETHOD_CFUNCTION, 2, 2, s_wxluatypeArray_wxLua_function_CompileLuaScript }}; // %override wxLua_function_GetBindings *************** *** 208,219 **** const char* idx_str = lua_tostring(L, 2); ! if (strcmp(idx_str, "func") == 0) { ! lua_pushcfunction(L, wxlCFunc->func); return 1; } ! else if (strcmp(idx_str, "type") == 0) { ! lua_pushnumber(L, wxlCFunc->type); return 1; } --- 208,219 ---- const char* idx_str = lua_tostring(L, 2); ! if (strcmp(idx_str, "lua_cfunc") == 0) { ! lua_pushcfunction(L, wxlCFunc->lua_cfunc); return 1; } ! else if (strcmp(idx_str, "method_type") == 0) { ! lua_pushnumber(L, wxlCFunc->method_type); return 1; } *************** *** 228,240 **** return 1; } ! else if (strcmp(idx_str, "argtags") == 0) { size_t idx, count = wxlCFunc->maxargs; lua_createtable(L, count, 0); ! // check for terminating null argtag ! for (idx = 0; (idx < count) && wxlCFunc->argtags[idx]; ++idx) { ! lua_pushnumber(L, *wxlCFunc->argtags[idx]); lua_rawseti(L, -2, idx + 1); } --- 228,240 ---- return 1; } ! else if (strcmp(idx_str, "argtypes") == 0) { size_t idx, count = wxlCFunc->maxargs; lua_createtable(L, count, 0); ! // check for terminating null in argtypes ! for (idx = 0; (idx < count) && wxlCFunc->argtypes[idx]; ++idx) { ! lua_pushnumber(L, *wxlCFunc->argtypes[idx]); lua_rawseti(L, -2, idx + 1); } *************** *** 294,306 **** return 1; } ! else if (strcmp(idx_str, "type") == 0) { ! lua_pushnumber(L, wxlMethod->type); return 1; } ! else if (strcmp(idx_str, "funcs") == 0) { ! wxLuaBindCFunc* wxlCFunc = wxlMethod->funcs; ! size_t idx, count = wxlMethod->funcs_n; lua_createtable(L, count, 0); --- 294,306 ---- return 1; } ! else if (strcmp(idx_str, "method_type") == 0) { ! lua_pushnumber(L, wxlMethod->method_type); return 1; } ! else if (strcmp(idx_str, "wxluacfuncs") == 0) { ! wxLuaBindCFunc* wxlCFunc = wxlMethod->wxluacfuncs; ! size_t idx, count = wxlMethod->wxluacfuncs_n; lua_createtable(L, count, 0); *************** *** 321,327 **** return 1; } ! else if (strcmp(idx_str, "funcs_n") == 0) { ! lua_pushnumber(L, wxlMethod->funcs_n); return 1; } --- 321,327 ---- return 1; } ! else if (strcmp(idx_str, "wxluacfuncs_n") == 0) { ! lua_pushnumber(L, wxlMethod->wxluacfuncs_n); return 1; } *************** *** 396,412 **** return 1; } ! else if (strcmp(idx_str, "methods") == 0) { ! if (wxlClass->methods_n > 0) { ! wxLuaBindMethod* wxlMethod = wxlClass->methods; ! size_t idx, count = wxlClass->methods_n; lua_createtable(L, count, 0); for (idx = 0; idx < count; ++idx, ++wxlMethod) { - // Force the baseclass methods to be found - //wxLuaBinding::GetClassMethod(wxlClass, wxlMethod->name, true); FIXME - // Create table { wxLuaBindClass userdata } const void **ptr = (const void **)lua_newuserdata(L, sizeof(void *)); --- 396,409 ---- return 1; } ! else if (strcmp(idx_str, "wxluamethods") == 0) { ! if (wxlClass->wxluamethods_n > 0) { ! wxLuaBindMethod* wxlMethod = wxlClass->wxluamethods; ! size_t idx, count = wxlClass->wxluamethods_n; lua_createtable(L, count, 0); for (idx = 0; idx < count; ++idx, ++wxlMethod) { // Create table { wxLuaBindClass userdata } const void **ptr = (const void **)lua_newuserdata(L, sizeof(void *)); *************** *** 431,437 **** return 0; } ! else if (strcmp(idx_str, "methods_n") == 0) { ! lua_pushnumber(L, wxlClass->methods_n); return 1; } --- 428,434 ---- return 0; } ! else if (strcmp(idx_str, "wxluamethods_n") == 0) { ! lua_pushnumber(L, wxlClass->wxluamethods_n); return 1; } *************** *** 443,447 **** if (classInfoClass) { ! wxluaT_pushuserdatatype(L, *classInfoClass->class_tag, wxlClass->classInfo); return 1; } --- 440,444 ---- if (classInfoClass) { ! wxluaT_pushuserdatatype(L, wxlClass->classInfo, *classInfoClass->wxluatype); return 1; } *************** *** 450,456 **** return 0; } ! else if (strcmp(idx_str, "class_tag") == 0) { ! lua_pushnumber(L, *wxlClass->class_tag); return 1; } --- 447,453 ---- return 0; } ! else if (strcmp(idx_str, "wxluatype") == 0) { ! lua_pushnumber(L, *wxlClass->wxluatype); return 1; } *************** *** 482,498 **** if (wxlClass->enums_n > 0) { ! wxLuaBindDefine* wxlDefine = wxlClass->enums; size_t idx, count = wxlClass->enums_n; lua_createtable(L, count, 0); ! for (idx = 0; idx < count; ++idx, ++wxlDefine) { // Create table { name, value } lua_createtable(L, 0, 2); lua_pushstring(L, "name"); ! lua_pushstring(L, wxlDefine->name); lua_rawset(L, -3); lua_pushstring(L, "value"); ! lua_pushnumber(L, wxlDefine->value); lua_rawset(L, -3); --- 479,495 ---- if (wxlClass->enums_n > 0) { ! wxLuaBindNumber* wxlNumber = wxlClass->enums; size_t idx, count = wxlClass->enums_n; lua_createtable(L, count, 0); ! for (idx = 0; idx < count; ++idx, ++wxlNumber) { // Create table { name, value } lua_createtable(L, 0, 2); lua_pushstring(L, "name"); ! lua_pushstring(L, wxlNumber->name); lua_rawset(L, -3); lua_pushstring(L, "value"); ! lua_pushnumber(L, wxlNumber->value); lua_rawset(L, -3); *************** *** 549,555 **** return 1; } ! else if (strcmp(idx_str, "GetDefineCount") == 0) { ! lua_pushnumber(L, wxlBinding->GetDefineCount()); return 1; } --- 546,552 ---- return 1; } ! else if (strcmp(idx_str, "GetNumberCount") == 0) { ! lua_pushnumber(L, wxlBinding->GetNumberCount()); return 1; } *************** *** 620,638 **** return 1; } ! else if (strcmp(idx_str, "GetDefineArray") == 0) { ! wxLuaBindDefine* wxlDefine = wxlBinding->GetDefineArray(); ! size_t idx, count = wxlBinding->GetDefineCount(); lua_createtable(L, count, 0); ! for (idx = 0; idx < count; ++idx, ++wxlDefine) { // Create table { name, value } lua_createtable(L, 0, 2); lua_pushstring(L, "name"); ! lua_pushstring(L, wxlDefine->name); lua_rawset(L, -3); lua_pushstring(L, "value"); ! lua_pushnumber(L, wxlDefine->value); lua_rawset(L, -3); --- 617,635 ---- return 1; } ! else if (strcmp(idx_str, "GetNumberArray") == 0) { ! wxLuaBindNumber* wxlNumber = wxlBinding->GetNumberArray(); ! size_t idx, count = wxlBinding->GetNumberCount(); lua_createtable(L, count, 0); ! for (idx = 0; idx < count; ++idx, ++wxlNumber) { // Create table { name, value } lua_createtable(L, 0, 2); lua_pushstring(L, "name"); ! lua_pushstring(L, wxlNumber->name); lua_rawset(L, -3); lua_pushstring(L, "value"); ! lua_pushnumber(L, wxlNumber->value); lua_rawset(L, -3); *************** *** 672,676 **** for (idx = 0; idx < count; ++idx, ++wxlEvent) { ! // Create table { name, eventType, class_tag } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); --- 669,673 ---- for (idx = 0; idx < count; ++idx, ++wxlEvent) { ! // Create table { name, eventType, wxluatype } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); *************** *** 680,685 **** lua_pushnumber(L, *wxlEvent->eventType); lua_rawset(L, -3); ! lua_pushstring(L, "class_tag"); ! lua_pushnumber(L, *wxlEvent->class_tag); lua_rawset(L, -3); --- 677,682 ---- lua_pushnumber(L, *wxlEvent->eventType); lua_rawset(L, -3); ! lua_pushstring(L, "wxluatype"); ! lua_pushnumber(L, *wxlEvent->wxluatype); lua_rawset(L, -3); *************** *** 697,701 **** for (idx = 0; idx < count; ++idx, ++wxlObject) { ! // Create table { name, object, class_tag } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); --- 694,698 ---- for (idx = 0; idx < count; ++idx, ++wxlObject) { ! // Create table { name, object, wxluatype } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); *************** *** 705,715 **** lua_pushstring(L, "object"); if (wxlObject->objPtr != 0) ! wxluaT_pushusertag(L, wxlObject->objPtr, *wxlObject->class_tag, false); else ! wxluaT_pushusertag(L, *wxlObject->pObjPtr, *wxlObject->class_tag, false); lua_rawset(L, -3); ! lua_pushstring(L, "class_tag"); ! lua_pushnumber(L, *wxlObject->class_tag); lua_rawset(L, -3); --- 702,712 ---- lua_pushstring(L, "object"); if (wxlObject->objPtr != 0) ! wxluaT_pushuserdatatype(L, wxlObject->objPtr, *wxlObject->wxluatype, false); else ! wxluaT_pushuserdatatype(L, *wxlObject->pObjPtr, *wxlObject->wxluatype, false); lua_rawset(L, -3); ! lua_pushstring(L, "wxluatype"); ! lua_pushnumber(L, *wxlObject->wxluatype); lua_rawset(L, -3); *************** *** 725,729 **** ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetBindings[1] = {{ wxLua_function_GetBindings, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; // %override wxLua_function_GetGCUserdataInfo --- 722,726 ---- ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetBindings[1] = {{ wxLua_function_GetBindings, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; // %override wxLua_function_GetGCUserdataInfo *************** *** 735,739 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetGCUserdataInfo[1] = {{ wxLua_function_GetGCUserdataInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; // %override wxLua_function_GetTrackedEventCallbackInfo --- 732,736 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetGCUserdataInfo[1] = {{ wxLua_function_GetGCUserdataInfo, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; // %override wxLua_function_GetTrackedEventCallbackInfo *************** *** 746,750 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedEventCallbackInfo[1] = {{ wxLua_function_GetTrackedEventCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; // %override wxLua_function_GetTrackedWinDestroyCallbackInfo --- 743,747 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedEventCallbackInfo[1] = {{ wxLua_function_GetTrackedEventCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; // %override wxLua_function_GetTrackedWinDestroyCallbackInfo *************** *** 757,761 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWinDestroyCallbackInfo[1] = {{ wxLua_function_GetTrackedWinDestroyCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; // %override wxLua_function_GetTrackedWindowInfo --- 754,758 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWinDestroyCallbackInfo[1] = {{ wxLua_function_GetTrackedWinDestroyCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; // %override wxLua_function_GetTrackedWindowInfo *************** *** 767,773 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWindowInfo[1] = {{ wxLua_function_GetTrackedWindowInfo, WXLUAMETHOD_CFUNCTION, 0, 0, s_wxluaargArray_None }}; ! static wxLuaArgTag s_wxluatagArray_wxLua_function_iswxluatype[] = { &s_wxluaarg_Number, &s_wxluaarg_Number, NULL }; // %rename iswxluatype %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) static int LUACALL wxLua_function_iswxluatype(lua_State *L) --- 764,770 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWindowInfo[1] = {{ wxLua_function_GetTrackedWindowInfo, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_iswxluatype[] = { &g_wxluatype_TNUMBER, &g_wxluatype_TNUMBER, NULL }; // %rename iswxluatype %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) static int LUACALL wxLua_function_iswxluatype(lua_State *L) *************** *** 784,790 **** return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_iswxluatype[1] = {{ wxLua_function_iswxluatype, WXLUAMETHOD_CFUNCTION, 2, 2, s_wxluatagArray_wxLua_function_iswxluatype }}; ! static wxLuaArgTag s_wxluatagArray_wxLua_function_type[] = { &s_wxluaarg_LightUserData, NULL }; // %override wxLua_function_type // %function int type(int wxluaarg_tag) --- 781,787 ---- return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_iswxluatype[1] = {{ wxLua_function_iswxluatype, WXLUAMETHOD_CFUNCTION, 2, 2, s_wxluatypeArray_wxLua_function_iswxluatype }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_type[] = { &g_wxluatype_TLIGHTUSERDATA, NULL }; // %override wxLua_function_type // %function int type(int wxluaarg_tag) *************** *** 794,812 **** const char* ltypename = lua_typename(L, ltype); ! int wxluaarg_tag = WXLUA_NOTAG; ! ! // this may a wxLua data ! if (ltype == LUA_TUSERDATA) ! wxluaarg_tag = wxluaT_gettag(L, 1); ! ! // I guess it wasn't or isn't a userdata ! if (wxluaarg_tag == WXLUA_NOTAG) ! wxluaarg_tag = wxlua_getwxluatype(ltype); ! ! wxString tagName = wxluaT_gettagname(L, wxluaarg_tag); //wxlua_getwxluatypename(wxluaarg_tag); // push the results ! lua_pushstring(L, wx2lua(tagName)); ! lua_pushnumber(L, wxluaarg_tag); lua_pushstring(L, ltypename); --- 791,800 ---- const char* ltypename = lua_typename(L, ltype); ! int wxl_type = wxluaT_type(L, 1); ! wxString wxltypeName = wxluaT_typename(L, wxl_type); // push the results ! lua_pushstring(L, wx2lua(wxltypeName)); ! lua_pushnumber(L, wxl_type); lua_pushstring(L, ltypename); *************** *** 816,831 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_type[1] = {{ wxLua_function_type, WXLUAMETHOD_CFUNCTION, 1, 1, s_wxluatagArray_wxLua_function_type }}; ! static wxLuaArgTag s_wxluatagArray_wxLua_function_typename[] = { &s_wxluaarg_Number, NULL }; // %override wxLua_function_typename // %function wxString typename(int wxluaarg_tag) static int LUACALL wxLua_function_typename(lua_State *L) { - wxString returns; // int wxluaarg_tag ! int wxluaarg_tag = (int)wxlua_getnumbertype(L, 1); // call wxlua_getwxluatypename ! returns = wxluaT_gettagname(L, wxluaarg_tag); //wxlua_getwxluatypename(wxluaarg_tag); // push the result string wxlua_pushwxString(L, returns); --- 804,818 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_type[1] = {{ wxLua_function_type, WXLUAMETHOD_CFUNCTION, 1, 1, s_wxluatypeArray_wxLua_function_type }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_typename[] = { &g_wxluatype_TNUMBER, NULL }; // %override wxLua_function_typename // %function wxString typename(int wxluaarg_tag) static int LUACALL wxLua_function_typename(lua_State *L) { // int wxluaarg_tag ! int wxl_type = (int)wxlua_getnumbertype(L, 1); // call wxlua_getwxluatypename ! wxString returns = wxluaT_typename(L, wxl_type); // push the result string wxlua_pushwxString(L, returns); *************** *** 834,840 **** } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_typename[1] = {{ wxLua_function_typename, WXLUAMETHOD_CFUNCTION, 1, 1, s_wxluatagArray_wxLua_function_typename }}; ! static wxLuaArgTag s_wxluatagArray_wxLua_function_wxLUA_CHECK_VERSION[] = { &s_wxluaarg_Number, &s_wxluaarg_Number, &s_wxluaarg_Number, NULL }; // %function bool wxLUA_CHECK_VERSION(int major, int minor, int release) // actually a define static int LUACALL wxLua_function_wxLUA_CHECK_VERSION(lua_State *L) --- 821,827 ---- } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_typename[1] = {{ wxLua_function_typename, WXLUAMETHOD_CFUNCTION, 1, 1, s_wxluatypeArray_wxLua_function_typename }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_wxLUA_CHECK_VERSION[] = { &g_wxluatype_TNUMBER, &g_wxluatype_TNUMBER, &g_wxluatype_TNUMBER, NULL }; // %function bool wxLUA_CHECK_VERSION(int major, int minor, int release) // actually a define static int LUACALL wxLua_function_wxLUA_CHECK_VERSION(lua_State *L) *************** *** 853,859 **** return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION[1] = {{ wxLua_function_wxLUA_CHECK_VERSION, WXLUAMETHOD_CFUNCTION, 3, 3, s_wxluatagArray_wxLua_function_wxLUA_CHECK_VERSION }}; ! static wxLuaArgTag s_wxluatagArray_wxLua_function_wxLUA_CHECK_VERSION_FULL[] = { &s_wxluaarg_Number, &s_wxluaarg_Number, &s_wxluaarg_Number, &s_wxluaarg_Number, NULL }; // %function bool wxLUA_CHECK_VERSION_FULL(int major, int minor, int release, int subrel) // actually a define static int LUACALL wxLua_function_wxLUA_CHECK_VERSION_FULL(lua_State *L) --- 840,846 ---- return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION[1] = {{ wxLua_function_wxLUA_CHECK_VERSION, WXLUAMETHOD_CFUNCTION, 3, 3, s_wxluatypeArray_wxLua_function_wxLUA_CHECK_VERSION }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_wxLUA_CHECK_VERSION_FULL[] = { &g_wxluatype_TNUMBER, &g_wxluatype_TNUMBER, &g_wxluatype_TNUMBER, &g_wxluatype_TNUMBER, NULL }; // %function bool wxLUA_CHECK_VERSION_FULL(int major, int minor, int release, int subrel) // actually a define static int LUACALL wxLua_function_wxLUA_CHECK_VERSION_FULL(lua_State *L) *************** *** 874,878 **** return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION_FULL[1] = {{ wxLua_function_wxLUA_CHECK_VERSION_FULL, WXLUAMETHOD_CFUNCTION, 4, 4, s_wxluatagArray_wxLua_function_wxLUA_CHECK_VERSION_FULL }}; // --------------------------------------------------------------------------- --- 861,865 ---- return 1; } ! static wxLuaBindCFunc s_wxluafunc_wxLua_function_wxLUA_CHECK_VERSION_FULL[1] = {{ wxLua_function_wxLUA_CHECK_VERSION_FULL, WXLUAMETHOD_CFUNCTION, 4, 4, s_wxluatypeArray_wxLua_function_wxLUA_CHECK_VERSION_FULL }}; // --------------------------------------------------------------------------- *************** *** 912,917 **** static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &s_wxluatag_wxLuaObject, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &s_wxluatag_wxLuaState, "wxObject", NULL ,s_wxluadefineArray_None, 0, }, { 0, 0, 0, 0, 0, 0, 0 }, --- 899,904 ---- static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &g_wxluatype_wxLuaObject, "wxObject", NULL ,g_wxluanumberArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &g_wxluatype_wxLuaState, "wxObject", NULL ,g_wxluanumberArray_None, 0, }, { 0, 0, 0, 0, 0, 0, 0 }, *************** *** 933,937 **** m_nameSpace = wxT("wxlua"); m_classArray = wxLuaGetClassList_wxlua(m_classCount); ! m_defineArray = wxLuaGetDefineList_wxlua(m_defineCount); m_stringArray = wxLuaGetStringList_wxlua(m_stringCount); m_eventArray = wxLuaGetEventList_wxlua(m_eventCount); --- 920,924 ---- m_nameSpace = wxT("wxlua"); m_classArray = wxLuaGetClassList_wxlua(m_classCount); ! m_numberArray = wxLuaGetDefineList_wxlua(m_numberCount); m_stringArray = wxLuaGetStringList_wxlua(m_stringCount); m_eventArray = wxLuaGetEventList_wxlua(m_eventCount); |