lua-users home
lua-l archive

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



Perhaps I've glossed over the implementation details, but my point is that
you wouldn't need to explicitly decorate each member function you wanted to
bind to (nor would you need to write macros, or devise fancy templated
metadata).  After all, libraries like tolua are essentially reflection
libraries, but made specifically (and exclusively?) for binding to Lua.

You'd need to do the legwork of devising a user data that references a C
object, and translating Lua Numbers and Strings to C++ types and back, but
only once in the generic invocation code.  Once you've gotten it to work for
one class, then wouldn't just about any Objective C object be accessible
from Lua?

Taking it a step further, you could allow Lua to "new" any Objective C
object if reflection includes a class factory. After you've implemented this
system your problem might be preventing the Lua client from having TOO MUCH
access to the Objective C data model!

-Erik




> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] On Behalf Of David Dunham
> Sent: Saturday, September 08, 2007 4:46 PM
> To: Lua list
> Subject: Re: C/C++ bindings: automated or by hand?
> 
> On 8 Sep 2007, at 08:56, Erik Cassel wrote:
> 
> > I bind by hand, but I didn't set out to do so: My app already had a
> > reflection mechanism. All I did was create an adapter between the
> > reflection
> > system and Lua. In one stroke I had 100% binding to all classes,
> > functions,
> > properties and events.
> 
> I don't quite follow. I'm fairly familiar with Objective-C (which I
> think is pretty good on the reflection scale), and don't see how I
> would, in one stroke, be able to expose everything I've written.
> 
> (It would be pretty easy to do -[Object valueForKey:] and -[Object
> setValue:forKey:] of course.)
> 
> David Dunham       Development Manager
> +1 206 926 5722      GameHouse Studios