lua-users home
lua-l archive

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


But if you connect "normal C userdata" to metatables, you can also do
this without library, as e. g. described in Roberto's Programming in
Lua, Caphter 31, "User defined types in C" for this new bitarray type.

Just what you definitely seem to need here is a code in the following form:

   luaL_newmetatable(L, "my-metatable-name");
...
    lua_newuserdata(L, nbytes);
    luaL_getmetatable(L, "my-metatable-name");
    lua_setmetatable(L, -2);

... so this would connect the metatable to the userdata element
defined with nbytes Bytes... .

This does NOT need any library functions, this is just standard Lua c  code... .

But how would you do this connection in case of lightuserdata element?
(if you might give a short summary, this would be nice ... of course I
could also look at your github code, this sounds interesting, thank
you).