lua-users home
lua-l archive

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


> on c++, only classes (and structs) with a constructor will have a 'new()'
> method.. You can add the constructor on your pkg (even if it's not
actually
> implemented).
> For C structs the only solution I can think of is to have a function that
> creates a new struct and returns it. example:
>
> CCLIB_START_STRUCT* get_new_CCLIB_START_STRUCT(char* lib_name="");
>
> you can have default parameters for C functions on tolua, so you can also
> use it to get the struct alredy initialized.
>
> Hope that helps..
>
> Ariel.

Thanks Ariel. Adding a "fake" constructor to the structs did the trick. I
haven't tried the second method yet, but I'll have to take a look at it if I
need to compile the library I'm working on in C. I really don't understand
why you have to do all this extra work. I mean, if you don't add a
constructor to such common as "typedef struct { ... }", the result is
useless, cause you can't create such types from a Lua script.

Greetings
Ignacio Burgueño