From: k. h. <kla...@nl...> - 2006-01-17 14:20:56
|
Hi, I think there is someting wrong with the whole binding registration, and that because of that things get mixed up. In wxLuaBinding::RegisterGeneratedClasses() i enabled the print wxLogDebug(wxT("RegisterGenClasses %d '%s'\n"), iTag, lua2wx(pClass->name).c_str()); And i see that my object becomes registrated, but with the same itag as the wx binding. I don't know if this is what casuing it?? 14:14:15: RegisterGenClasses 4 'wxlCanObj' 14:14:31: RegisterGenClasses 4 'wxPageSetupDialogData' Later on i run the next lua script from a file: blah = wx.wxPageSetupDialogData() blah:GetPaperSize() canobj = wxluacan.wxlCanObj() canobj:Draw( bitmapDC, 0, 0 ) The canobj is really constructed ( breakspoint in C++), but function Draw is called on the wrong object, in fact it is called on the wx namespace object with the same iTag being 4. So the first function is oke, but the second fails. And that is because the pclass is the one of the wxPageSetupDialogData, and not of the wxlCanObj. wxLua_lua_getTableFunc(lua_State *L) in the end is able to print the function called, and the output indictaes that soemthing is wrong indeed: 14:53:30: class wxPageSetupDialogData function GetPaperSize 14:53:43: wxLua_lua_getTableFunc 'GetPaperSize' pClass 11590824, userdata 1, lightuserdata 0, ttag 4, class_tag 4 lua_State 26287736 wxLuaStateRefData 26278328 14:53:51: class wxPageSetupDialogData function Draw 14:53:52: wxLua_lua_getTableFunc 'Draw' pClass 11590824, userdata 1, lightuserdata 0, ttag 4, class_tag 4 lua_State 26287736 wxLuaStateRefData 26278328 This is all easy to reproduce on the sample i made. This evening i will upload this one, with the right rules and wxluacan.i file. It looks like the namespace is skipped or it is not legal to have classes with the same iTag?? What is this Itag?? This is the stack when ariving at 14:53:43: wxLua_lua_getTableFunc(lua_State * 0x01911e78) line 137 luaD_precall(lua_State * 0x01911e78, lua_TObject * 0x01912118) line 260 + 18 bytes luaD_call(lua_State * 0x01911e78, lua_TObject * 0x01912118, int 1) line 311 + 13 bytes callTMres(lua_State * 0x01911e78, const lua_TObject * 0x0191e718, const lua_TObject * 0x019120c8, const lua_TObject * 0x0199a398) line 105 + 21 bytes luaV_getnotable(lua_State * 0x01911e78, const lua_TObject * 0x019120c8, lua_TObject * 0x0199a398, int 0) line 140 + 21 bytes luaV_execute(lua_State * 0x01911e78) line 518 + 25 bytes luaD_call(lua_State * 0x01911e78, lua_TObject * 0x019120b8, int -1) line 313 + 9 bytes f_call(lua_State * 0x01911e78, void * 0x015bf9f0) line 672 + 22 bytes luaD_rawrunprotected(lua_State * 0x01911e78, void (lua_State *, void *)* 0x006624a1 f_call(lua_State *, void *), void * 0x015bf9f0) line 88 + 13 bytes luaD_pcall(lua_State * 0x01911e78, void (lua_State *, void *)* 0x006624a1 f_call(lua_State *, void *), void * 0x015bf9f0, int 144, int 0) line 416 + 17 bytes lua_pcall(lua_State * 0x01911e78, int 0, int -1, int 0) line 685 + 32 bytes wxLuaState::LuaDoFile(const wxString & {...}) line 2218 + 15 bytes wxLuaState::RunFile(const wxString & {...}) line 919 + 12 bytes MyFrame::OnRunScript(wxCommandEvent & {...}) line 265 + 18 bytes This is the stack when ariving at 14:53:52: wxLua_lua_getTableFunc(lua_State * 0x01911e78) line 137 luaD_precall(lua_State * 0x01911e78, lua_TObject * 0x01912118) line 260 + 18 bytes luaD_call(lua_State * 0x01911e78, lua_TObject * 0x01912118, int 1) line 311 + 13 bytes callTMres(lua_State * 0x01911e78, const lua_TObject * 0x0191e718, const lua_TObject * 0x019120c8, const lua_TObject * 0x0199a3d8) line 105 + 21 bytes luaV_getnotable(lua_State * 0x01911e78, const lua_TObject * 0x019120c8, lua_TObject * 0x0199a3d8, int 0) line 140 + 21 bytes luaV_execute(lua_State * 0x01911e78) line 518 + 25 bytes luaD_call(lua_State * 0x01911e78, lua_TObject * 0x019120b8, int -1) line 313 + 9 bytes f_call(lua_State * 0x01911e78, void * 0x015bf9f0) line 672 + 22 bytes luaD_rawrunprotected(lua_State * 0x01911e78, void (lua_State *, void *)* 0x006624a1 f_call(lua_State *, void *), void * 0x015bf9f0) line 88 + 13 bytes luaD_pcall(lua_State * 0x01911e78, void (lua_State *, void *)* 0x006624a1 f_call(lua_State *, void *), void * 0x015bf9f0, int 144, int 0) line 416 + 17 bytes lua_pcall(lua_State * 0x01911e78, int 0, int -1, int 0) line 685 + 32 bytes wxLuaState::LuaDoFile(const wxString & {...}) line 2218 + 15 bytes wxLuaState::RunFile(const wxString & {...}) line 919 + 12 bytes Hope this is enough to find the bug, i don't know how to solve it myself. regards, Klaas -- Unclassified |
From: k. h. <kla...@nl...> - 2006-01-17 14:43:04
|
And is i reverse the registration of the binding like this: // Register bindings wxLuaBindingList::Node *node; for (node = M_WXLSTATEDATA->m_bindings.GetLast(); node; node = node->GetPrevious() ) { wxLuaBinding* binding = node->GetData(); binding->RegisterBinding(L, registerTypes); } It is calling wxlCanObj::GetPaperSize, so the opposite, but still wrong. 5:30:44: class wxlCanObj function GetPaperSize 15:30:56: wxLua_lua_getTableFunc 'GetPaperSize' pClass 11310688, userdata 1, lightuserdata 0, ttag 4, class_tag 4 lua_State 26287736 wxLuaStateRefData 26278328 Klaas k. holwerda wrote: > Hi, > > I think there is someting wrong with the whole binding registration, > and that because of that things get mixed up. > -- Unclassified |
From: John L. <jla...@gm...> - 2006-01-19 04:20:12
|
Sorry about the delay, I've been away for a bit. > k. holwerda wrote: > > > > I think there is someting wrong with the whole binding registration, > > and that because of that things get mixed up. I've changed genwxbind.lua to have hook_lua_namespace and hook_cpp_namespace instead of just hook_namespace so that you can have the same namespace for lua, but different namespaces for the generated C++ code. See bindings/wxwidgets/wx.rules for how you should define them. Let me know if this fixes it for you? Regards, John Labenski |
From: k. h. <kla...@nl...> - 2006-01-19 11:21:54
|
Hi John, I believe i managed to merge your changes in, and i can generate the binding for the sample i made. They are called like this wxluacan_BindingInit etc. In the next routine, the nameSpace is indeed set to wx. void wxLuaBinding::RegisterBinding(const wxLuaState& wxlState, bool registerTypes) { int luaTable = RegisterFunctions(wxlState, registerTypes); lua_State *L = wxlState.GetLuaState(); // create a global lua_pushstring(L, wx2lua(nameSpace)); lua_pushvalue(L, luaTable); lua_rawset(L, LUA_GLOBALSINDEX); lua_pop(L, 1); } But it does NOT work. I think there are two tables created with the same name now? Things like this do not work in a script canvas = wx.GetCan() canobjrect = wx.wxlCanObjRect( 30, 40, 100, 20) But this one does: blah = wx.wxPageSetupDialogData() blah:GetPaperSize() If i change the order of binding the bindings again ( like i did with the two different namespaces ) int LUACALL wxLuaBinding::RegisterFunctions(const wxLuaState& wxlState_, bool registerTypes) { // Register bindings wxLuaBindingList::Node *node; //for (node = M_WXLSTATEDATA->m_bindings.GetFirst(); node; node = node->GetNext() ) for (node = M_WXLSTATEDATA->m_bindings.GetLast(); node; node = node->GetPrevious() ) { wxLuaBinding* binding = node->GetData(); binding->RegisterBinding(L, registerTypes); } The situation is reversed again. meaning this works: canvas = wx.GetCan() canobjrect = wx.wxlCanObjRect( 30, 40, 100, 20) And this not: blah = wx.wxPageSetupDialogData() blah:GetPaperSize() The situation is different from the two namespace situation, since in there the methods where called with the wrong pclass in wxLua_lua_getTableFunc. But knwo i do not even arrive there, lua does not know the functions. In short i think there is realy a bug with registrating/calling function from different bindings, but it is not visible now, since two namespace tables with the same name, does not bring me two that stage anymore. I think we should add my sample to CVS, and then try to find the errors. Without solving this issue wxLua is not usable yet i think. What do you think? Klaas John Labenski wrote: >Sorry about the delay, I've been away for a bit. > > > >>k. holwerda wrote: >> >> >>>I think there is someting wrong with the whole binding registration, >>>and that because of that things get mixed up. >>> >>> > >I've changed genwxbind.lua to have hook_lua_namespace and >hook_cpp_namespace instead of just hook_namespace so that you can have >the same namespace for lua, but different namespaces for the generated >C++ code. See bindings/wxwidgets/wx.rules for how you should define >them. Let me know if this fixes it for you? > >Regards, > John Labenski > > >------------------------------------------------------- >This SF.net email is sponsored by: Splunk Inc. Do you grep through log files >for problems? Stop! Download the new AJAX search engine that makes >searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642 >_______________________________________________ >Wxlua-users mailing list >Wxl...@li... >https://lists.sourceforge.net/lists/listinfo/wxlua-users > > -- Unclassified |