John, That's what I had picked up from reading the Lua documentation and works if I want to use a wxWidgets object. Here's what I want to do:
class Item { public: wxString RefID; bool InProcess; double Length; double Priority; double CalculateValue(); }; WX_WX_DECLARE_LIST(Item, ListItems); ListItems ProcessItems; The Item class is a very abbreviated version of what I have. What I need to do is to pass ProcessItems to a Lua function that will determine what Item to process next. The Lua function needs to access the public properties and the member function. It of course has to iterate over all the Items in the wxList ProcessItems. Scott John Labenski wrote: > On Fri, Oct 10, 2008 at 9:25 AM, Scott Kirkpatrick > <[EMAIL PROTECTED]> wrote: > >> I'm new to embedding a scripting engine in another application but I can >> follow how to call a Lua function from a wxWidgets application and how >> to pass data to it and get data back. I see that wxLua gives me the >> ability to do that with wxWidgets objects. However, I haven't been able >> to figure out how to do that with my own classes. >> >> I have a wxList of my custom objects that I need to pass to a Lua >> function and get a return value. I've looked at the wxLuacan >> application and realize that I have to do something with bindings but >> for the life of me, I can't figure out how to go about it. I haven't >> been able to locate a tutorial on the subject either. Can somebody give >> me a step-by-step for doing this? >> > > The best way to see how to run code is to check the binding functions > in modules/wxbind/src, constructors will create new objects and the > others will get an object from > > Also see here: http://www.lua.org/pil/25.2.html > > Warning, untested code. > > Example: > > Call this Lua function from C. > > function PrintwxPoint(pt) > print(pt.x, pt.y) > end > > C code would be (see wxLua_wxPoint_constructor in > modules/wxbind/src/wxcore.gdi.cpp) > > wxLuaState wxlState(myEventHandlerThatHandles_wxEVT_LUA_PRINT); > wxlState.RunString("function PrintwxPoint(...."); > > lua_State* L = wxlState.GetLuaState(); > > lua_getglobal(L, "PrintwxPoint"); // Lua func on stack > > if (Lua should own object we push) > wxPoint* pt= new wxPoint(1, 2); > // add to tracked memory list > wxluaO_addgcobject(L, (void*)pt, new > wxLua_wxObject_wxPoint((wxPoint*)pt)); > // push the constructed class pointer > wxluaT_pushuserdatatype(L, pt, wxluatype_wxPoint); > else > wxPoint pt(1,2); // must exist for the life of the Lua function > wxluaT_pushuserdatatype(L, &pt, wxluatype_wxPoint); > end > > int status = wxlState.LuaPCall(1, 0); // call PrintwxPoint w/ one param > > > > Hope this helps, > John > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > wxlua-users mailing list > wxlua-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wxlua-users > > -- Scott Kirkpatrick Software Engineer Control Logic Inc. (A Weinig Group Company) 8656 Huffman Ave. Connelly Springs, NC 28612 USA Phone : +1 828.397.5078 Ext. 23 Fax : +1 828.397.5292 Email : [EMAIL PROTECTED] Internet : www.weinigusa.com "WEINIG - ForWood Thinking" Weinig Technology EXPO 2008 February 28 - 29, 2008 For more details, visit us at www.weinigusa.com ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users