lua-users home
lua-l archive

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


You can add literal code on the pkg that will show up on the "main"
section of the output, like this:

${
static int my_helper(lua_State* L) {

   return 1; // very helpful
};
$}

'my_helper' would be a regular lua_Function, like all the other
wrappers tolua generates. If "${ ... $}" doesn't work, try adding
every line with a "$" at the beginning (like when you do $#include
"...")
Then, you add code into the function that registers all the wrappers
into the lua state, at the bottom, like this:

$<
tolua_function(tolua_S, "my_helper", my_helper);
$>

then you can use 'my_helper' from lua. You can (probably) nest the $<
... $> blocks inside classes or namespaces to have methods and stuff.

that should work on tolua..

Ariel.

On 8/4/07, RJP Computing <rjpcomputing@gmail.com> wrote:
> On 8/3/07, Ariel Manzur <puntob@gmail.com> wrote:
> > If it's a macro function, you can just add it as a regular function on
> > your .pkg, like this:
> >
> > void LIB_LOG(int level, char* message);
> >
> > (or maybe use the enum type for 'level', the compiler might complain).
>
> Great. I will try this.
>
> > There are also several ways to add extra stuff to your bindings,
> > depending on what you're adding (and what version/flavor of tolua
> > you're running).
>
> I am using toLua
> (http://www.tecgraf.puc-rio.br/~celes/tolua/ ) version 5.1,
> not toLua++. Is there a way to add straight helper functions inline? Can I
> get examples? I read the documentation and didn't mention anything about
> helper functions. Can you give a couple of examples of how to add extra
> stuff?
>
> Thanks for your help.
> --
> Regards,
> Ryan
> RJP Computing