[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua/C++ binding library showdown: who's the best?
- From: Chris Marrin <chris@...>
- Date: Tue, 25 Oct 2005 07:48:54 -0700
David Given wrote:
On Monday 24 October 2005 17:23, Chris Marrin wrote:
Object* someFunction(double num);
To make someFunction() visible to Lua, you add this to the
initializeClass() method (which every class needs to implement):
How does it know what the parameters to someFunction() are? Other than that,
this sounds really rather good.
Why, it's magic, of course! Actually, it uses function templates to
construct a "thunk" function appropriate for the function signature.
This includes const function, and functions returning void. The only
restriction is that the types used must be known to the system. These
types are autocast to and from a Value type, which is our wrapper class
around the Lua stack types. It knows about all the primitive types, an
expanding string type called UTF8String, the Emma Object type and all
the Lua types like table, function and userdata.
We have the ability to create functions with 0-5 parameters. This is the
code that I leveraged from toLua++. It is very clever.
The only Lua type we don't currently support is thread. We don't use the
Lua thread support, so we can't test this. It would be very easy to add,
but might not be needed if you don't need to pass a thread object to or
return it from a C++ function.
chris marrin ,""$, "As a general rule,don't solve puzzles
firstname.lastname@example.org b` $ that open portals to Hell" ,,.
,.` ,b` ,` , 1$'
,|` mP ,` :$$' ,mm
,b" b" ,` ,mm m$$ ,m ,`P$$
m$` ,b` .` ,mm ,'|$P ,|"1$` ,b$P ,` :$1
b$` ,$: :,`` |$$ ,` $$` ,|` ,$$,,`"$$ .` :$|
b$| _m$`,:` :$1 ,` ,$Pm|` ` :$$,..;"' |$:
P$b, _;b$$b$1" |$$ ,` ,$$" ``' $$
```"```'" `"` `""` ""` ,P`