From: John L. <jr...@us...> - 2007-12-22 06:07:43
|
Update of /cvsroot/wxlua/wxLua/bindings/wxlua In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16833/wxLua/bindings/wxlua Modified Files: override.hpp wxlua.i 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.i =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxlua/wxlua.i,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** wxlua.i 20 Dec 2007 02:26:55 -0000 1.13 --- wxlua.i 22 Dec 2007 06:07:08 -0000 1.14 *************** *** 64,71 **** // original class. ! WXLUAMETHOD_OVERLOAD_BASE // Class method has been checked to see if it is ! // overloaded from the base class. ! // Check WXLUAMETHOD::basemethod and if !NULL ! // this method is an overload from the base class %endenum --- 64,71 ---- // original class. ! WXLUAMETHOD_CHECKED_OVERLOAD // Class method has been checked to see if it is ! // overloaded from the base class. ! // Check WXLUAMETHOD::basemethod and if !NULL ! // this method is an overload from the base class %endenum *************** *** 97,104 **** %rename iswxluatype %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) ! // %override [wxlua_typename, wxlua_type#, lua_typename, lua_type#] type(void* object) // Given any type of object, returns four values: ! // wxlua name of the type - wxLuaState::GetLuaTagName(wxlua_type) ! // wxlua number of the type - wxlua_getwxluatype(lua_type(L, stack_idx)) or wxluaT_tag // lua name of the type - lua_typename(L, lua_type(L, stack_idx)) // lua number of the type - lua_type(L, stack_idx) --- 97,104 ---- %rename iswxluatype %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) ! // %override [wxlua_typename, wxlua_type#, lua_typename, lua_type#] type(any object) // Given any type of object, returns four values: ! // wxlua name of the type - wxluaT_gettypename(L, stack_idx) ! // wxlua number of the type - wxluaT_type(L, stack_idx) // lua name of the type - lua_typename(L, lua_type(L, stack_idx)) // lua number of the type - lua_type(L, stack_idx) *************** *** 137,141 **** int GetClassCount ! int GetDefineCount int GetStringCount int GetEventCount --- 137,141 ---- int GetClassCount ! int GetNumberCount int GetStringCount int GetEventCount *************** *** 145,152 **** {wxLuaBindClass*} GetClassArray {wxLuaBindMethod*} GetFunctionArray ! {name, value} GetDefineArray {name, value} GetStringArray ! {name, eventType, class_tag} GetEventArray ! {name, object, class_tag} GetObjectArray %endclass --- 145,152 ---- {wxLuaBindClass*} GetClassArray {wxLuaBindMethod*} GetFunctionArray ! {name, value} GetNumberArray {name, value} GetStringArray ! {name, eventType, wxluatype} GetEventArray ! {name, object, wxluatype} GetObjectArray %endclass *************** *** 156,163 **** wxString name ! {wxLuaBindMethod*} methods ! int methods_n wxClassInfo* classInfo ! int class_tag wxString baseclassName wxLuaBindClass* baseclass --- 156,163 ---- wxString name ! {wxLuaBindMethod*} wxluamethods ! int wxluamethods_n wxClassInfo* classInfo ! int wxluatype wxString baseclassName wxLuaBindClass* baseclass *************** *** 171,177 **** wxString name ! int type ! {wxLuaBindCFunc*} funcs ! int funcs_n wxLuaBindMethod* basemethod --- 171,177 ---- wxString name ! int method_type ! {wxLuaBindCFunc*} wxluacfuncs ! int wxluacfuncs_n wxLuaBindMethod* basemethod *************** *** 184,192 **** // No constructor as this is read only ! cfunction func ! int type int minargs int maxargs ! {int} argtags wxString class_name // added, not in struct --- 184,192 ---- // No constructor as this is read only ! cfunction lua_cfunc ! int method_type int minargs int maxargs ! {int} argtypes wxString class_name // added, not in struct *************** *** 222,226 **** bool IsRunning() const - wxString GetLuaTagName(int tag) const */ %endclass --- 222,225 ---- Index: override.hpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxlua/override.hpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** override.hpp 20 Dec 2007 02:26:55 -0000 1.15 --- override.hpp 22 Dec 2007 06:07:08 -0000 1.16 *************** *** 76,94 **** 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); --- 76,85 ---- 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); *************** *** 103,111 **** 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); --- 94,101 ---- 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); *************** *** 172,183 **** 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; } --- 162,173 ---- 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; } *************** *** 192,204 **** 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); } --- 182,194 ---- 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); } *************** *** 258,270 **** 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); --- 248,260 ---- 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); *************** *** 285,291 **** return 1; } ! else if (strcmp(idx_str, "funcs_n") == 0) { ! lua_pushnumber(L, wxlMethod->funcs_n); return 1; } --- 275,281 ---- return 1; } ! else if (strcmp(idx_str, "wxluacfuncs_n") == 0) { ! lua_pushnumber(L, wxlMethod->wxluacfuncs_n); return 1; } *************** *** 360,376 **** 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 *)); --- 350,363 ---- 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 *)); *************** *** 395,401 **** return 0; } ! else if (strcmp(idx_str, "methods_n") == 0) { ! lua_pushnumber(L, wxlClass->methods_n); return 1; } --- 382,388 ---- return 0; } ! else if (strcmp(idx_str, "wxluamethods_n") == 0) { ! lua_pushnumber(L, wxlClass->wxluamethods_n); return 1; } *************** *** 407,411 **** if (classInfoClass) { ! wxluaT_pushuserdatatype(L, *classInfoClass->class_tag, wxlClass->classInfo); return 1; } --- 394,398 ---- if (classInfoClass) { ! wxluaT_pushuserdatatype(L, wxlClass->classInfo, *classInfoClass->wxluatype); return 1; } *************** *** 414,420 **** return 0; } ! else if (strcmp(idx_str, "class_tag") == 0) { ! lua_pushnumber(L, *wxlClass->class_tag); return 1; } --- 401,407 ---- return 0; } ! else if (strcmp(idx_str, "wxluatype") == 0) { ! lua_pushnumber(L, *wxlClass->wxluatype); return 1; } *************** *** 446,462 **** 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); --- 433,449 ---- 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); *************** *** 513,519 **** return 1; } ! else if (strcmp(idx_str, "GetDefineCount") == 0) { ! lua_pushnumber(L, wxlBinding->GetDefineCount()); return 1; } --- 500,506 ---- return 1; } ! else if (strcmp(idx_str, "GetNumberCount") == 0) { ! lua_pushnumber(L, wxlBinding->GetNumberCount()); return 1; } *************** *** 584,602 **** 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); --- 571,589 ---- 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); *************** *** 636,640 **** for (idx = 0; idx < count; ++idx, ++wxlEvent) { ! // Create table { name, eventType, class_tag } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); --- 623,627 ---- for (idx = 0; idx < count; ++idx, ++wxlEvent) { ! // Create table { name, eventType, wxluatype } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); *************** *** 644,649 **** lua_pushnumber(L, *wxlEvent->eventType); lua_rawset(L, -3); ! lua_pushstring(L, "class_tag"); ! lua_pushnumber(L, *wxlEvent->class_tag); lua_rawset(L, -3); --- 631,636 ---- lua_pushnumber(L, *wxlEvent->eventType); lua_rawset(L, -3); ! lua_pushstring(L, "wxluatype"); ! lua_pushnumber(L, *wxlEvent->wxluatype); lua_rawset(L, -3); *************** *** 661,665 **** for (idx = 0; idx < count; ++idx, ++wxlObject) { ! // Create table { name, object, class_tag } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); --- 648,652 ---- for (idx = 0; idx < count; ++idx, ++wxlObject) { ! // Create table { name, object, wxluatype } lua_createtable(L, 0, 3); lua_pushstring(L, "name"); *************** *** 669,679 **** 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); --- 656,666 ---- 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); *************** *** 706,710 **** wxluaO_addgcobject(L, returns); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, s_wxluatag_wxLuaObject, returns); // return the number of parameters return 1; --- 693,697 ---- wxluaO_addgcobject(L, returns); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, returns, g_wxluatype_wxLuaObject); // return the number of parameters return 1; *************** *** 717,721 **** { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, s_wxluatag_wxLuaObject); // call SetObject self->SetObject(1); --- 704,708 ---- { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, g_wxluatype_wxLuaObject); // call SetObject self->SetObject(1); *************** *** 730,734 **** { // 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()) --- 717,721 ---- { // 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()) |