lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Mar 08, 2007 at 01:11:24PM -0500, Leigh McRae wrote:
> Actually I think your last one is really good.  I was also thinking of the
> multi-return idea but some of the code comes from C++ bindings.  So
> W_TextRegion() is a wrapper for my C++ class.  I didn't really want to
> change all my C++ code to suit lua.

Your wrapper function can do anything it wants without you needing to
change any of your 'real' C++ code. That is you can make the lua exported
W_TextRegion() function take a table of values keyed by mnemonic names for
their settings (so 'auto_size', 'justify', 'font', 'anchor', etc.) and
then have the C wrapper function call each function in succession as it
walks the argument table. Thus requiring no changes to the way your C++
functions work and still giving you a nice lua scripting interface.

Making the lua wrappers 'dumb' is certainly the easiest way to do things,
and it is good for a first try, but making it 'smart' makes for a much
more friendly scripting interface.

    -Etan