lua-users home
lua-l archive

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


Ashwin Hirschi wrote:
>>> Is there any documentation on the functionality in lauxlib.h?
>>
>> Let me try a very brief summary.
>
> Thanks, Luiz. That's a very useful summary, indeed!

I agree. Thanks, Luiz.

> Well, I for one write all my library code by hand. In fact, I'm a bit
> surprised so many people (seem to) consider using tolua, luabind and
> such as their first option.
>
> The thing is: wrapping a C/C++ library manually gives me the
> opportunity to re-work the original API into something that's much
> more "scripting-friendly". The last thing I'd want is end up with a
> near-literal Lua translation of the C/C++ stuff...

Exactly. My scripting support is going to be a fairly safe layer over
the C functions rather than a simple translation of them. For example,
the C code in question uses pointers to refer to all the objects, but
requires that you're very careful that the objects don't get deleted in
the process of acting on them. I want to continue using the pointers as
object identifiers, but will add in an intermediate layer in the wrapper
code that checks the pointer is valid before calling the C function,
thus making it a lot safer. And then there's all the functions in C that
I normally have to call repeatedly from within a loop, changing one of
the parameters each time. I'd like to change these in the scripting
interface to take a table of items that they act upon as a parameter so
that the iteration is implicit (from the script-writer's point of view).
And so on.

Basically, out of about 35 functions I want exposed to Lua, no more than
10 of them are close enough to a C equivalent that I'd want to use
automated wrapper code which I'd then have to modify anyway.

--
Ben Sizer
http://pages.eidosnet.co.uk/kylotan