lua-users home
lua-l archive

Re: http://lua-users.org/wiki/ObjectProperties - one question

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


On 2020年6月10日 13:35:31 +0100, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
> >>>>> "Milan" == Milan Obuch <lua-l@dino.sk> writes: 
> 
> Milan> Currently I am creating metatable with some method like this:
> Milan> 
> 
> 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.
Regards,
Milan

AltStyle によって変換されたページ (->オリジナル) /