[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua-swig design, was Re: example Lua game
- From: luagnome@...
- Date: Tue, 06 Nov 2001 16:28:26 +0100 (MET)
En réponse à Nick Trout <nick@videosystem.co.uk>:
> > I spent a couple days messing around with Lua + LuaSWIG + SDL, and
> > produced a little video game. The SDL wrapper may be of interest
> for
> > anyone interested in prototyping games,
>
> Just a note on the wrapper code generated by swig. It doesnt look
> fantastically efficient for the constants. Each one has userdata
> malloced (eg. a long) and there seems to be a mechanism for reading it
> using tags. toLua does this a lot more efficiently by just setting
> numbers (tolua_constant)! I bodged sdl.i into sdl.pkg and got tolua to
> generate a binding and spookily they are almost exactly the same size
> (232k).
>
> Only managed 4890. Bah.
>
Basically, Lua-swig generates 'userdata' for constants in order to avoid them to
be overwritten as if they were simple Lua global variables.
On the other hand, this trick also apply to global variables and permits to uses
'C' global variables (as long as they are of some basic type, char, int,
float...) as Lua global variables: writing to them modify the actual C variable
(as intented).
Hope it makes this "inefficient" choice a little bit clearer.
--the luagnome team, author of luaswig <http://luagnome.free.fr>