From: John L. <jr...@us...> - 2008-01-23 06:43:44
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv692/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp wxlua.cpp wxlua_bind.cpp Log Message: Use positive values for WXLUA_TXXX types not negative. Initialize the wxLua types when the bindings are initialized not when installed into Lua so we can install the bindings in any order or number for multiple wxLuaStates. Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** wxlua.cpp 22 Dec 2007 06:07:16 -0000 1.10 --- wxlua.cpp 23 Jan 2008 06:43:40 -0000 1.11 *************** *** 31,37 **** // 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 }}; --- 31,37 ---- // Lua MetaTable Tag for Class 'wxLuaState' ! int wxluatype_wxLuaState = WXLUA_TUNKNOWN; ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaState_delete[] = { &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,58 **** // 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 }}; --- 52,58 ---- // Lua MetaTable Tag for Class 'wxLuaObject' ! int wxluatype_wxLuaObject = WXLUA_TUNKNOWN; ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_GetAllocationFlag[] = { &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 }}; *************** *** 61,65 **** { // get this ! wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, g_wxluatype_wxLuaObject); // call GetAllocationFlag int returns = (self->GetAllocationFlag()); --- 61,65 ---- { // get this ! wxLuaObject * self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, wxluatype_wxLuaObject); // call GetAllocationFlag int returns = (self->GetAllocationFlag()); *************** *** 70,74 **** } ! 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 }}; --- 70,74 ---- } ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_GetObject[] = { &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 }}; *************** *** 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()) --- 78,82 ---- { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, wxluatype_wxLuaObject); // call GetObject that push the item onto the stack, or nil if (self->GetObject()) *************** *** 87,91 **** ! 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 }}; --- 87,91 ---- ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_SetObject[] = { &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 }}; *************** *** 95,99 **** { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, g_wxluatype_wxLuaObject); // call SetObject self->SetObject(1); --- 95,99 ---- { // get this ! wxLuaObject *self = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, wxluatype_wxLuaObject); // call SetObject self->SetObject(1); *************** *** 103,107 **** ! 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 }}; --- 103,107 ---- ! static wxLuaArgType s_wxluatypeArray_wxLua_wxLuaObject_delete[] = { &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 }}; *************** *** 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; --- 120,124 ---- wxluaO_addgcobject(L, returns); // push the constructed class pointer ! wxluaT_pushuserdatatype(L, returns, 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.164 retrieving revision 1.165 diff -C2 -d -r1.164 -r1.165 *** wxlstate.cpp 20 Jan 2008 19:23:02 -0000 1.164 --- wxlstate.cpp 23 Jan 2008 06:43:39 -0000 1.165 *************** *** 884,903 **** // ---------------------------------------------------------------------------- ! int wxluaT_newmetatable(lua_State* L) { ! lua_newtable(L); // create a table for our new type ! int wxl_type = wxluaR_ref(L, -1, &wxlua_lreg_types_key); // insert the table into the registry table ! lua_pushlightuserdata(L, &wxlua_metatable_type_key); // push key lua_pushnumber(L, wxl_type); // push value lua_rawset(L, -3); // set t[key] = value; pop key and value return wxl_type; // leave the table on the stack } ! bool LUACALL wxluaT_setmetatable(lua_State *L, int wxl_type) { if (wxluaR_getref(L, wxl_type, &wxlua_lreg_types_key)) // get the metatable { // set it as the metatable of the object at the top of the stack if (lua_setmetatable(L, -2)) // pops table --- 884,936 ---- // ---------------------------------------------------------------------------- ! int wxluaT_newmetatable(lua_State* L, int wxl_type) { ! lua_newtable(L); // create a table for our new type lua_pushlightuserdata(L, &wxlua_metatable_type_key); // push key lua_pushnumber(L, wxl_type); // push value lua_rawset(L, -3); // set t[key] = value; pop key and value + lua_pushlightuserdata(L, &wxlua_lreg_types_key); // push key + lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push value (table) + + // make sure that the Lua table array is contiguous + int len = (int)lua_objlen(L, -1); // get the length of the table + while (++len < wxl_type) + { + lua_pushnumber(L, 0); + lua_rawseti(L, -2, len); + } + + // It is not allowed to reregister this type + lua_rawgeti(L, -1, wxl_type); + int t = lua_type(L, -1); + wxCHECK_MSG((t == LUA_TNUMBER) || (t == LUA_TNIL), WXLUA_TUNKNOWN, wxT("Attempting to reregister wxLua type")); + lua_pop(L, 1); + + // Add the metatable to the wxlua_lreg_types_key table + lua_pushvalue(L, -2); // copy the metatable + lua_rawseti(L, -2, wxl_type); // add it, pops table + lua_pop(L, 1); // pop wxlua_lreg_types_key table + return wxl_type; // leave the table on the stack } ! bool LUACALL wxluaT_getmetatable(lua_State* L, int wxl_type) { if (wxluaR_getref(L, wxl_type, &wxlua_lreg_types_key)) // get the metatable { + if (lua_type(L, -1) == LUA_TTABLE) + return true; + + lua_pop(L, 1); // pop nil or 0 placeholder + } + + return false; + } + + bool LUACALL wxluaT_setmetatable(lua_State *L, int wxl_type) + { + if (wxluaT_getmetatable(L, wxl_type)) // get the metatable + { // set it as the metatable of the object at the top of the stack if (lua_setmetatable(L, -2)) // pops table *************** *** 980,984 **** else { ! if (wxl_type == g_wxluatag_NULL) // FIXME NEEDED since there isn't a wxLuaBindClass return wxT("NULL"); --- 1013,1017 ---- else { ! if (wxl_type == wxluatype_NULL) // FIXME NEEDED since there isn't a wxLuaBindClass return wxT("NULL"); *************** *** 1014,1018 **** { // note: wxluaR_getref() doesn't leave anything on the stack on failure ! if (wxluaR_getref(L, wxl_type, &wxlua_lreg_types_key)) { // t[wxluatype] = { [bindclass_key] = lightuserdata wxLuaBindClass... (or nil if not a wxLua class type) --- 1047,1051 ---- { // note: wxluaR_getref() doesn't leave anything on the stack on failure ! if (wxluaT_getmetatable(L, wxl_type)) { // t[wxluatype] = { [bindclass_key] = lightuserdata wxLuaBindClass... (or nil if not a wxLua class type) *************** *** 1048,1053 **** if (wxlua_iswxuserdatatype(stack_type) && ! ((g_wxluatag_NULL == stack_type) || // FIXME, how to check when NULL is valid or not? ! ((wxl_type == WXLUA_TSTRING) && (wxluaT_isderivedtype(L, stack_type, g_wxluatag_wxString) >= 0)) || (wxluaT_isderivedtype(L, stack_type, wxl_type) >= 0))) return true; --- 1081,1086 ---- if (wxlua_iswxuserdatatype(stack_type) && ! ((wxluatype_NULL == stack_type) || // FIXME, how to check when NULL is valid or not? ! ((wxl_type == WXLUA_TSTRING) && (wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0)) || (wxluaT_isderivedtype(L, stack_type, wxl_type) >= 0))) return true; *************** *** 1060,1064 **** int stack_type = wxluaT_type(L, stack_idx); ! if (g_wxluatag_NULL == stack_type) return NULL; else if (wxluaT_isderivedtype(L, stack_type, wxl_type) >= 0) --- 1093,1097 ---- int stack_type = wxluaT_type(L, stack_idx); ! if (wxluatype_NULL == stack_type) return NULL; else if (wxluaT_isderivedtype(L, stack_type, wxl_type) >= 0) *************** *** 1086,1090 **** // if the object we are referencing is derived from wxWindow ! if (obj_ptr && (wxluaT_isderivedtype(L, wxl_type, g_wxluatag_wxWindow) >= 0)) { wxWindow* win = wxDynamicCast(obj_ptr, wxWindow); // double check that it's a wxWindow --- 1119,1123 ---- // if the object we are referencing is derived from wxWindow ! if (obj_ptr && (wxluaT_isderivedtype(L, wxl_type, *p_wxluatype_wxWindow) >= 0)) { wxWindow* win = wxDynamicCast(obj_ptr, wxWindow); // double check that it's a wxWindow *************** *** 1122,1126 **** *ptr = obj_ptr; // try to get the object's references table and set the metatable to the object ! if (wxluaR_getref(L, wxl_type, &wxlua_lreg_types_key)) { // pop the table and set it as the metatable for the newuserdata --- 1155,1159 ---- *ptr = obj_ptr; // try to get the object's references table and set the metatable to the object ! if (wxluaT_getmetatable(L, wxl_type)) { // pop the table and set it as the metatable for the newuserdata *************** *** 1318,1322 **** { int wxl_type = wxluaT_type(L, stack_idx); ! return (wxluaT_isderivedtype(L, wxl_type, g_wxluatag_wxString) >= 0); } --- 1351,1355 ---- { int wxl_type = wxluaT_type(L, stack_idx); ! return (wxluaT_isderivedtype(L, wxl_type, *p_wxluatype_wxString) >= 0); } *************** *** 1340,1344 **** int stack_type = wxluaT_type(L, stack_idx); ! if (wxluaT_isderivedtype(L, stack_type, g_wxluatag_wxString) >= 0) { wxString* wxstr = (wxString*)wxlua_touserdata(L, stack_idx, false); --- 1373,1377 ---- int stack_type = wxluaT_type(L, stack_idx); ! if (wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0) { wxString* wxstr = (wxString*)wxlua_touserdata(L, stack_idx, false); *************** *** 2354,2357 **** --- 2387,2393 ---- RegisterFunction(wxlua_printFunction, "print"); + // register our NULL type + wxluatype_NULL = wxluaT_newmetatable(L, wxluatype_NULL); + // now register bindings if (WXLUA_HASBIT(state_type, wxLUASTATE_OPENBINDINGS)) *************** *** 2757,2770 **** M_WXLSTATEDATA->m_wxlStateData->m_bindings_registered = true; - - lua_State* L = M_WXLSTATEDATA->m_lua_State; - - // Finally - set the global types from the bindings we've just installed - g_wxluatag_wxEvent = wxluaT_gettype(L, "wxEvent"); - g_wxluatag_wxString = wxluaT_gettype(L, "wxString"); - g_wxluatag_wxWindow = wxluaT_gettype(L, "wxWindow"); - g_wxluatag_wxArrayString = wxluaT_gettype(L, "wxArrayString"); - g_wxluatag_wxSortedArrayString = wxluaT_gettype(L, "wxSortedArrayString"); - g_wxluatag_wxArrayInt = wxluaT_gettype(L, "wxArrayInt"); } --- 2793,2796 ---- *************** *** 3054,3061 **** // ---------------------------------------------------------------------------- ! int wxLuaState::wxluaT_NewMetatable() { wxCHECK_MSG(Ok(), WXLUA_TUNKNOWN, wxT("Invalid wxLuaState")); ! return wxluaT_newmetatable(M_WXLSTATEDATA->m_lua_State); } --- 3080,3087 ---- // ---------------------------------------------------------------------------- ! int wxLuaState::wxluaT_NewMetatable(int wxl_type) { wxCHECK_MSG(Ok(), WXLUA_TUNKNOWN, wxT("Invalid wxLuaState")); ! return wxluaT_newmetatable(M_WXLSTATEDATA->m_lua_State, wxl_type); } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -d -r1.116 -r1.117 *** wxlbind.cpp 17 Jan 2008 22:37:30 -0000 1.116 --- wxlbind.cpp 23 Jan 2008 06:43:39 -0000 1.117 *************** *** 32,55 **** wxLuaBindNumber g_wxluanumberArray_None[1] = {{0, 0}}; ! int g_wxluatype_TNONE = WXLUA_TNONE; ! int g_wxluatype_TNIL = WXLUA_TNIL; ! int g_wxluatype_TBOOLEAN = WXLUA_TBOOLEAN; ! int g_wxluatype_TLIGHTUSERDATA = WXLUA_TLIGHTUSERDATA; // raw data ! int g_wxluatype_TNUMBER = WXLUA_TNUMBER; ! int g_wxluatype_TSTRING = WXLUA_TSTRING; ! int g_wxluatype_TTABLE = WXLUA_TTABLE; ! int g_wxluatype_TFUNCTION = WXLUA_TFUNCTION; ! int g_wxluatype_TUSERDATA = WXLUA_TUSERDATA; // raw data ! int g_wxluatype_TTHREAD = WXLUA_TTHREAD; ! int g_wxluatype_TINTEGER = WXLUA_TINTEGER; ! int g_wxluatype_TCFUNCTION = WXLUA_TCFUNCTION; ! int g_wxluatag_NULL = WXLUA_TUNKNOWN; ! int g_wxluatag_wxEvent = WXLUA_TUNKNOWN; ! int g_wxluatag_wxWindow = WXLUA_TUNKNOWN; ! int g_wxluatag_wxString = WXLUA_TUNKNOWN; ! int g_wxluatag_wxArrayString = WXLUA_TUNKNOWN; ! int g_wxluatag_wxSortedArrayString = WXLUA_TUNKNOWN; ! int g_wxluatag_wxArrayInt = WXLUA_TUNKNOWN; //----------------------------------------------------------------------------- --- 32,57 ---- wxLuaBindNumber g_wxluanumberArray_None[1] = {{0, 0}}; ! int wxluatype_TNONE = WXLUA_TNONE; ! int wxluatype_TNIL = WXLUA_TNIL; ! int wxluatype_TBOOLEAN = WXLUA_TBOOLEAN; ! int wxluatype_TLIGHTUSERDATA = WXLUA_TLIGHTUSERDATA; // raw data ! int wxluatype_TNUMBER = WXLUA_TNUMBER; ! int wxluatype_TSTRING = WXLUA_TSTRING; ! int wxluatype_TTABLE = WXLUA_TTABLE; ! int wxluatype_TFUNCTION = WXLUA_TFUNCTION; ! int wxluatype_TUSERDATA = WXLUA_TUSERDATA; // raw data ! int wxluatype_TTHREAD = WXLUA_TTHREAD; ! int wxluatype_TINTEGER = WXLUA_TINTEGER; ! int wxluatype_TCFUNCTION = WXLUA_TCFUNCTION; ! int wxluatype_NULL = WXLUA_TNULL; ! ! static int wxluatype_dummy = WXLUA_TUNKNOWN; ! int* p_wxluatype_wxEvent = &wxluatype_dummy; ! int* p_wxluatype_wxWindow = &wxluatype_dummy; ! int* p_wxluatype_wxString = &wxluatype_dummy; ! int* p_wxluatype_wxArrayString = &wxluatype_dummy; ! int* p_wxluatype_wxSortedArrayString = &wxluatype_dummy; ! int* p_wxluatype_wxArrayInt = &wxluatype_dummy; //----------------------------------------------------------------------------- *************** *** 393,397 **** lua_pop(L, 1); // remove the name of the function ! result = (*wxlMethod->wxluacfuncs[0].lua_cfunc)(L); } else --- 395,399 ---- lua_pop(L, 1); // remove the name of the function ! result = (*wxlMethod->wxluacfuncs[0].lua_cfunc)(L); } else *************** *** 583,587 **** { lua_pop(L, 2); // remove the table and the name of the function ! result = (*wxlMethod->wxluacfuncs[0].lua_cfunc)(L); } else --- 585,589 ---- { lua_pop(L, 2); // remove the table and the name of the function ! result = (*wxlMethod->wxluacfuncs[0].lua_cfunc)(L); } else *************** *** 703,707 **** { is_ok = (wxluaT_isuserdatatype(L, arg_lua, wxl_type) || ! (wxl_type == g_wxluatag_NULL)) ? 1 : 0; } --- 705,709 ---- { is_ok = (wxluaT_isuserdatatype(L, arg_lua, wxl_type) || ! (wxl_type == wxluatype_NULL)) ? 1 : 0; } *************** *** 940,943 **** --- 942,946 ---- wxLuaBindingList wxLuaBinding::sm_bindingList; bool wxLuaBinding::sm_bindingList_initialized = false; + int wxLuaBinding::sm_wxluatype_counter = WXLUA_T_MAX+1; wxLuaBinding::wxLuaBinding() *************** *** 966,969 **** --- 969,976 ---- for (size_t i = 0; i < m_classCount; ++i, ++wxlClass) { + // initialize types only once + if (*wxlClass->wxluatype == WXLUA_TUNKNOWN) + *wxlClass->wxluatype = wxLuaBinding::sm_wxluatype_counter++; + // Also sort the member functions for each class if (wxlClass->wxluamethods && (wxlClass->wxluamethods_n > 0)) *************** *** 1095,1100 **** // ------------------------------------------------------------------ // Create a new metatable for this class with a numerical wxLua type index ! wxl_type = wxluaT_newmetatable(L); // create metatable, is on top of stack ! *wxlClass->wxluatype = wxl_type; if (n == 0) --- 1102,1106 ---- // ------------------------------------------------------------------ // Create a new metatable for this class with a numerical wxLua type index ! wxl_type = wxluaT_newmetatable(L, *wxlClass->wxluatype); // create metatable, is on top of stack if (n == 0) Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** wxlcallb.cpp 15 Jan 2008 01:04:04 -0000 1.57 --- wxlcallb.cpp 23 Jan 2008 06:43:39 -0000 1.58 *************** *** 90,97 **** wxString wxLuaEventCallback::GetInfo() const { ! return wxString::Format(wxT("%s(%d) -> wxLuaEventCallback(%p, ids %d, %d)|wxEvtHandler(%p) -> %s"), lua2wx(m_wxlBindEvent ? m_wxlBindEvent->name : "?").c_str(), (int)GetEventType(), this, m_id, m_last_id, ! m_evtHandler, m_evtHandler->GetClassInfo()->GetClassName()); } --- 90,98 ---- wxString wxLuaEventCallback::GetInfo() const { ! return wxString::Format(wxT("%s(%d) -> wxLuaEventCallback(%p, ids %d, %d)|wxEvtHandler(%p) -> %s : %s"), lua2wx(m_wxlBindEvent ? m_wxlBindEvent->name : "?").c_str(), (int)GetEventType(), this, m_id, m_last_id, ! m_evtHandler, m_evtHandler->GetClassInfo()->GetClassName(), ! m_wxlState.GetwxLuaTypeName(*m_wxlBindEvent->wxluatype).c_str()); } *************** *** 147,155 **** event_wxl_type = *wxlClass->wxluatype; else ! event_wxl_type = g_wxluatag_wxEvent; // get the g_wxluatag_wxEvent } } else ! event_wxl_type = g_wxluatag_wxEvent; // get the g_wxluatag_wxEvent // Should never get here, but error out in case we do --- 148,156 ---- event_wxl_type = *wxlClass->wxluatype; else ! event_wxl_type = *p_wxluatype_wxEvent; // get the wxluatype_wxEvent } } else ! event_wxl_type = *p_wxluatype_wxEvent; // get the wxluatype_wxEvent // Should never get here, but error out in case we do Index: wxlua_bind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlua_bind.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** wxlua_bind.cpp 5 Jan 2008 00:15:46 -0000 1.20 --- wxlua_bind.cpp 23 Jan 2008 06:43:40 -0000 1.21 *************** *** 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) --- 131,135 ---- // --------------------------------------------------------------------------- ! static wxLuaArgType s_wxluatypeArray_wxLua_function_CompileLuaScript[] = { &wxluatype_TSTRING, &wxluatype_TSTRING, NULL }; // %override wxLua_function_CompileLuaScript // %function int CompileLuaScript(const wxString& luaScript, const wxString& fileName) *************** *** 724,728 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetBindings[1] = {{ wxLua_function_GetBindings, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetGCUserdataInfo[] = { &g_wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetGCUserdataInfo // %function LuaTable GetGCUserdataInfo(bool as_string = false) --- 724,728 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetBindings[1] = {{ wxLua_function_GetBindings, WXLUAMETHOD_CFUNCTION, 0, 0, g_wxluaargtypeArray_None }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetGCUserdataInfo[] = { &wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetGCUserdataInfo // %function LuaTable GetGCUserdataInfo(bool as_string = false) *************** *** 740,744 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetGCUserdataInfo[1] = {{ wxLua_function_GetGCUserdataInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetGCUserdataInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedEventCallbackInfo[] = { &g_wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedEventCallbackInfo // %function LuaTable GetTrackedEventCallbackInfo(bool as_string = false) --- 740,744 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetGCUserdataInfo[1] = {{ wxLua_function_GetGCUserdataInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetGCUserdataInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedEventCallbackInfo[] = { &wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedEventCallbackInfo // %function LuaTable GetTrackedEventCallbackInfo(bool as_string = false) *************** *** 757,761 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedEventCallbackInfo[1] = {{ wxLua_function_GetTrackedEventCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedEventCallbackInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedObjectInfo[] = { &g_wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedObjectInfo // %function LuaTable GetTrackedObjectInfo(bool as_string = false) --- 757,761 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedEventCallbackInfo[1] = {{ wxLua_function_GetTrackedEventCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedEventCallbackInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedObjectInfo[] = { &wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedObjectInfo // %function LuaTable GetTrackedObjectInfo(bool as_string = false) *************** *** 773,777 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedObjectInfo[1] = {{ wxLua_function_GetTrackedObjectInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedObjectInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedWinDestroyCallbackInfo[] = { &g_wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedWinDestroyCallbackInfo // %function LuaTable GetTrackedWinDestroyCallbackInfo(bool as_string = false) --- 773,777 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedObjectInfo[1] = {{ wxLua_function_GetTrackedObjectInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedObjectInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedWinDestroyCallbackInfo[] = { &wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedWinDestroyCallbackInfo // %function LuaTable GetTrackedWinDestroyCallbackInfo(bool as_string = false) *************** *** 790,794 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWinDestroyCallbackInfo[1] = {{ wxLua_function_GetTrackedWinDestroyCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedWinDestroyCallbackInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedWindowInfo[] = { &g_wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedWindowInfo // %function LuaTable GetTrackedWindowInfo(bool as_string = false) --- 790,794 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWinDestroyCallbackInfo[1] = {{ wxLua_function_GetTrackedWinDestroyCallbackInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedWinDestroyCallbackInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_GetTrackedWindowInfo[] = { &wxluatype_TBOOLEAN, NULL }; // %override wxLua_function_GetTrackedWindowInfo // %function LuaTable GetTrackedWindowInfo(bool as_string = false) *************** *** 806,810 **** static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWindowInfo[1] = {{ wxLua_function_GetTrackedWindowInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedWindowInfo }}; ! 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) --- 806,810 ---- static wxLuaBindCFunc s_wxluafunc_wxLua_function_GetTrackedWindowInfo[1] = {{ wxLua_function_GetTrackedWindowInfo, WXLUAMETHOD_CFUNCTION, 0, 1, s_wxluatypeArray_wxLua_function_GetTrackedWindowInfo }}; ! static wxLuaArgType s_wxluatypeArray_wxLua_function_iswxluatype[] = { &wxluatype_TNUMBER, &wxluatype_TNUMBER, NULL }; // %rename iswxluatype %function int wxlua_iswxluatype(int luatype, int wxluaarg_tag) static int LUACALL wxLua_function_iswxluatype(lua_State *L) *************** *** 823,827 **** 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) --- 823,827 ---- 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[] = { &wxluatype_TLIGHTUSERDATA, NULL }; // %override wxLua_function_type // %function int type(int wxluaarg_tag) *************** *** 846,850 **** 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) --- 846,850 ---- 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[] = { &wxluatype_TNUMBER, NULL }; // %override wxLua_function_typename // %function wxString typename(int wxluaarg_tag) *************** *** 863,867 **** 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) --- 863,867 ---- 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[] = { &wxluatype_TNUMBER, &wxluatype_TNUMBER, &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) *************** *** 882,886 **** 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) --- 882,886 ---- 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[] = { &wxluatype_TNUMBER, &wxluatype_TNUMBER, &wxluatype_TNUMBER, &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) *************** *** 940,945 **** 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 }, --- 940,945 ---- static wxLuaBindClass classList[] = { ! { "wxLuaObject", wxLuaObject_methods, wxLuaObject_methodCount, CLASSINFO(wxLuaObject), &wxluatype_wxLuaObject, "wxObject", NULL ,g_wxluanumberArray_None, 0, }, ! { "wxLuaState", wxLuaState_methods, wxLuaState_methodCount, CLASSINFO(wxLuaState), &wxluatype_wxLuaState, "wxObject", NULL ,g_wxluanumberArray_None, 0, }, { 0, 0, 0, 0, 0, 0, 0 }, *************** *** 972,977 **** { } ! void wxLuaBinding_wxlua::PostRegister(const wxLuaState&, int ) { } --- 972,983 ---- { } ! void wxLuaBinding_wxlua::PostRegister(const wxLuaState& wxlState, int luaTable) { + wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); + lua_State* L = wxlState.GetLuaState(); + + lua_pushlstring(L, "NULL", 4); + wxluaT_pushuserdatatype(L, NULL, wxluatype_NULL, true, true); + lua_rawset(L, luaTable); // set t["NULL"] = userdata(NULL) w/ NULL tag } |