From: John L. <jla...@gm...> - 2005-12-29 17:07:58
|
On 12/29/05, klaas.holwerda <kho...@xs...> wrote: > Hi John, > > I got something working now, but still do not understand why i can not > debug into lua code itself. This is a problem, we need to somehow unwind the stack better. The facilities exist, but sometimes it just errors out some trivial thing with absolutely no reference to the line number. It'll take some digging into the lua_Debug code. > The problem with my script was, that > wx.a2dLuaWP:Message("blah blah") should be > wxart2d.a2dLuaWP:Message("blah blah") > Which has to do with the namespace. What is lua doing with the namespace > in front? Is it a function too? The "namespace" is a table where the contents of it are set by bindings. I think (untested though) that you can jam other bindings into the wx. namespace by just setting the namespace in the binding "rules" file, but it may take some fiddling. I think that currently there are some class name clashes that will occur, but nothing that cannot be fixed. > But now the question is, how does lua feedback to me what is wrong with > my script? > Can you tell me what i should do to get some kind of feedback when my > script is not right? You should use wxEVT_LUA_ERROR. Set an event handler for the wxLuaState to get these messages. See the other events in what's left of wxlinterp.h, soon to be removed. If you have the need for not having an event handler, but would rather override a virtual function, we could add virtual handlers in the wxLuaStateRefData (cannot be done in the wxLuaState since it's recreated as necessary, eg. it's the only ref data that actually exists throughout the life of the lua_State) that would use the events by default. > I did define LuaHandler derived from wxLuaHandler, but nothing in there > is called, i expected DisplayError() would do the trick, but it seems > more is needed. See the events in the wxlua app or better yet, for the wxluaeditor app. The wxLuaHandler is really for the socket mechanism, I'm not convinced it's necessary. It was added to remove the previous wxApp dependence on the socket code and is a middle man of sorts. > On the static bindings i found the next. > If i define in MyApp as i explained the binding: > > class MyApp > { > static wxart2d_binding m_wxart2dluab; > } > > And initialize the static instance like this: > > wxart2d_binding MyApp::m_wxart2dluab; > > BUT NOT call m_binding.GetBindingList()->Append(&m_binding); > Suddenly the next two become active, i can but a break point on the > last, and it stops. I don't understand when you say the "next two become active"? Next two of w= hat? > class wxart2d_BindingInit > { > public: > wxart2d_BindingInit() > { > m_binding.GetBindingList()->Append(&m_binding); > } > wxart2d_Binding m_binding; > }; > > wxart2d_BindingInit s_wxart2d_BindingInit; > > i conclude from this, that linking somehow only includes the > classes/libraries which are really used in the code/main program/exe. If > not used from there, it is not linked in and the static > wxart2d_BindingInit is also not called. And since my bindings for > wxArt2D are in a seperate library called luawraps, my main program did > not contain anything from that. > I think this in fact makes sence, why would one link anything from a > library which is not used. > (well it only looks like it is not used, since it is only used from > scripts ) What about, wxModule? I'll look into that this afternoon. If I remember correctly it does something very similar to gather up all the derived wxModule classes. I don't have any problems using this mechanism in gcc in Linux, but I have yet to try to add my own bindings with msvc. > So why is the initialization order not a problem in this case? Just > Luck, they are initialized in the right order. > But as soon if i take class wxart2d_BindingInit from my luawraps library > and but it into my program , it is wrong again. All static stuff in the > program is done first and next what is in the libraries, and it should > be the other way around. Can you reverse the order of linking the .o object files for your program and the libraries? Regards, John Labenski |