lua-users home
lua-l archive

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


Hi there!

Is it possible to dynamically register C functions in Lua?

Pseudocode:

    add_function_to_lua(lua_State *L, char *libname, char *fname, int (*func)(lua_State *)) {
        struct luaL_reg *reg = malloc(sizeof(*reg));
        reg->name = fname;
        reg->func = func;

        luaL_register(L, libname, reg);
    }

Or is there a better, maybe a simpler way to do such a thing.

Thanks in advance for your replies!

-- 
Mit freundlichen Grüßen,
Kind regards,
Matthias Beyer

Proudly sent with mutt.
Happily signed with gnupg.

Attachment: pgpQLy5ij2vyw.pgp
Description: PGP signature