On Wed, May 13, 2009 at 6:43 PM, klaas.holwerda <n...@klaasholwerda.nl>wrote:
> >
> > Currently, each binding function is crafted to get and check the input
> > parameter type with the minimum of code. Allowing a table like this
> > means that we'd have to look through it and assign the variables as
> > they come, keep track of them all to give messages about missing
> > required parameters, while still allowing for positional arguments. It
> > might also be a lot slower since you have create the wxVariant, fill
> > it, then read it out as opposed to simply creating the correct
> > variable type, filling it, and using it as is.
> I was more thinking not to have a general mechanism, that can be used
> always, but more how to wrap to a C++ member taking one argument being
> the wxVariant hash, or the function hash. So parameter checking is all
> up to the C++ member receiving that hash.
> The hash is build from the lua parameter list when using the special
> syntax, giving a table as input.
> It would be a specific kind of wrap, for only that member, and for other
> normal wrapped functions it would not work.
>
You would have to write an override function in the bindings for each one
you want to allow for a table. There's a few ways to do it, but I think this
should work, using some simple new type of variant as in my last post.
// Create the array and set the default values.
wxArrayMyVariant params[max params] =
{ MyVariant(), MyVariant(), MyVariant(5, WXLUA_TINTEGER), ...};
if Lua param #0 is not a Lua table then
params[0] = MyVariant(wxluaT_getuserdatatype(L, 2, wxluatype_wxFont),
wxluatype_wxFont);
params[1] = ...
else
go through each Lua parameter by name and put it into the params[] array
and error if a required param is missing
end
DoStuff((wxFont*)params[0].GetValue(), params[1].GetInt(),
params[2].GetXXX(), ...)
>
> %tableargs bool memberFunctionName( double a = 1.0, wxString b = "abc",
> int c = 1 )
> >
>
This would work.
>
> > I am currently working on adding the ability to have multiple base
> > classes. It's not too hard, but I have to ensure that I change all the
> > code that expects a single base class to not recurse into the list of
> > base classes.
> I hope this is not related to the above?? Not sure what this
> solves/means, multiple inheritance?
Yep, for wxBitmapCombobox which derives from two classes that both have a
number of functions that I'd rather not reproduce in each derived binding
class.
>
> Currently i am adding extra events to wxArt2D, instead of virtual
> functions, since i finally realized that, connecting function to events
> in wxLua is easy. But overriding virtual functions would need class
> defenition in wxLua, which are not there :-)
> So i like to fill up menu's in a drawing window, using a Theming event,
> which connect to/calls a lua function to fill the menu's.
> And such i struggle on :-)
>
Well, virtual functions are not *hard*, but they are annoying since you have
to write them by hand. I can't see any way to automate it reliably.
Regards,
John
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users