[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: http://lua-users.org/wiki/ObjectProperties - one question
- From: Milan Obuch <lua-l@...>
- Date: Wed, 10 Jun 2020 14:46:58 +0200
On Wed, 10 Jun 2020 13:35:31 +0100, Andrew Gierth
> >>>>> "Milan" == Milan Obuch <email@example.com> writes:
> Milan> Currently I am creating metatable with some method like this:
> Milan> luaL_newmetatable(L,TABLE_ID);
> Milan> luaL_openlib(L,NULL,table_instance_methods,0);
> Milan> lua_pop(L,1);
> Milan> I can then associate this metatable with some variable (I use
> Milan> light userdata) and this could be used for simple OOP-like
> Milan> programming.
> Milan> I just could not achive the same effect with luaL_newlibtable
> Milan> and luaL_setfuncs...
> luaL_newmetatable(L, TABLE_ID);
> luaL_setfuncs(L, table_instance_methods, 0);
> lua_pop(L, 1);
Thank you. Seems to be working. I think this should be put onto wiki as
more current solution, taking into account the change is actually
minimal, as I see it now.