Hi,

I want to wrap tuples like in python, but in lua its a table initialized 
for a function with{}.
This makes it possible to mention only the parameters the user wants to 
specify, and not a whole range, which is hard to remember in position etc.
But in my case certain groups of arguments are related, while others are 
for other task done with the same command. So  it would be very hard to 
use from Lua, or even C++, doing it the standard way with simple 
arguments to a function.

It is explained here, how its done in lua:

http://www.lua.org/pil/5.3.html

In wxLua i like to use:

wx.a2dCommand_GroupAB{ what = a2dCommand_GroupAB:BoolOperation_GroupAB, 
operation = BOOL_A_SUB_B, selectedA = true, selectedB = true }
AddCommandToMenu( booleanObjects, _("Boolean A-B"), _("Boolean 
Subtract"), command );

I have many of those type of commands, so i would like to generate a 
binding in an elegant way for all of them.
The question is how can one interface such thing to C++/wxWidgets. The 
thing is  that  the arguments  in general are all of different types.
I think that almost results in a hash, with pointers to member 
functions?? Or maybe wxVariants??
I believe what i am looking for is some standard hash like structure in 
which the wrapper stores the arguments.
Next my commands have a member function/constructor, with one argument 
being that hash. That member function checks  what is  in the hash,  and 
do the right thing.

BUT maybe it could wrap directly in to what is show down here, and that 
would be save and compiler checked.
Like a special keyword in the *.i file, that has a function definition, 
with all possible arguments/tuples,  and  wraps them in a special way to 
C++.
Like iterating over the table, and for each key in there, call a 
specific Args::argumentX() function.
After the iteration the Args object containing all arguments found is 
complete, and the constructor is called with that Args objects as parameter.

Ideas very welcome!

Klaas

Currently inside C++ i do something like the above, but used from within 
C++ itself.
That is based on the Args object, its members functions returning a 
reference to itself:

a2dCommand_GroupAB* command = new a2dCommand_GroupAB( 
a2dCommand_GroupAB::Args().
                what( a2dCommand_GroupAB::BoolOperation_GroupAB ).
                operation( BOOL_A_SUB_B ).
                selectedA( true ).
                selectedB( true ) );
AddCommandToMenu( booleanObjects, _("Boolean A-B"), _("Boolean 
Subtract"), command );

Here it is in Doxygen /and code, maybe it helps.

http://www.wxart2d.org/wxart2dDoxygen/html/classa2dCommand__GroupAB.html
http://www.wxart2d.org/wxart2dDoxygen/html/classa2dCommand.html


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to