On 10/20/06, Klaas Holwerda <[EMAIL PROTECTED]> wrote: > Hi, > > I think that to achieve that, you just need to bind some your own code > 'business logic' to wxLua, > and use wxLua extended with your own classes/code.
True, you can see how to bind C++ classes, enums, etc to lua by looking at the interface files in wxLua/bindings/, take a look at wxluasocket first as it's very small. There's docs about the meaning of the bits in the interface files on the website as well. This gets you the ability to access, call, and manipulate C++ objects from lua. > I found it difficult to communicate information from C++ back to the wxLua > script. > In the end i used some static pointers from C++ to get to the information in > C++ from lua. > My problem was that the top classes are not created in the wxLua script, but > i want to add class instances to the C++ > created classes from inside the wxLua script. > Next to that i wanted to call functions from c++ in the wxLua script. This is all done by the lua api, there's not much code to make this any easier in wxLua, but in the wxLuaState class there are some convenience functions to make it easy to get or push some objects from/into lua, like arrays. Take a look the the book PIL, Programming in Lua, ver 1 which is free on the web and is mostly correct for lua 5.1, though I think it was written for 4.x. The absolute dumbest way of doing this, this is how I do it; 1) Create some functions in a text file, an initial script if you will 2) Use utils/bin2c to embed them in your C++ app, see apps/wxlua/src/editor.h 3) Call wxlState.RunBuffer(the bin2c char array) when you create a wxLuaState 4) To run anything in lua from C++ call wxlState.RunString(wxT("calc_x2(x) return x*x end\n a=calc_x2(5);")) where you are literally running simple little scripts a bit at a time. You can easily stick simple values and data into lua using wxString::Format(wxT("a=%d\nb=%d...), C++ value a, b, ...) The first 3 are optional, but typically you'll probably want at least a little bit of lua code to start off with. You can also just load your init script from disk. To get a good feel for manipulating the stack look through the generated binding files in wxLua/modules/wxbind/src/*.cpp and compare the *.i files to them. Good luck, John Labenski > Wojtek Bocer wrote: > > Hello > > > > I'm a newbie to the Lua and wxLua. > > > > Is it possible to develop an application which uses wxLua as a GUI > > language and C++ as a 'business logic' language? I mean, it is easier > > to write wxWidgets apps by means of wxLua, but I would like to use > > wxLua only to the user interface part of my application. I presume > > some kind of communication is needed between interface part and logic > > part (reading user input etc). > > > > If so, have you got any examples of a C++ code which executes some > > wxLua code and exchanges information with it? > > > > -- > Unclassified > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > wxlua-users mailing list > wxlua-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wxlua-users > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users