lua-users home
lua-l archive

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


Hi!

you might want to take a look at tolua
(http://www.tecgraf.puc-rio.br/~celes/tolua/)
or one of the other code wrappers on the page http://www.lua.org/addons.html

what tolua does, it creates a wrapper function that does all the dirty work
for you ;)

if you have a C function, let's say:

	int calculate(int a, int b);

then tolua creates a wrapper function for it so that you can call it in lua
with two number arguments:

	print(calculate(1,2))

the hard way is to get the arguments from the stack by hand. not good for
readability and you have all kinds of possible pitfalls (like the trailing
nil problem with a lot of the standard library functions etc.)

Regards,
Peter

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of christinesherbrooke
> Sent: Friday, January 11, 2002 3:26 PM
> To: Multiple recipients of list
> Subject: Function lua_register
>
>
> Hi,
>
>
>       I have a dll (in C language) so I use the function
>
>                   lua_register(L,fnLua,fnC)
>
> to use function C in LUA .If I understand well, the function C must
> have ONLY ONE argument : L so the corresponding function in lua have
> also one argument.
>
>        I would like to know if it is possible to register a function
> C with TWO or more arguments.
>
>         Thank you very much.
>
>         Have a nice day.
>
>                       Christine ROLLAND.
>
>