[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: _call me, please
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Thu, 20 Mar 2008 14:59:08 -0600
If you are going to use this:
luaL_newmetatable(L, "ak_complex");
then you need to manually add the fields for the metatable like so:
lua_pushcclosure(L, complex_number_new, 0);
lua_setfield(L, -2, "__call"); /* set the __call field */
Now you want to set this metatable to your library table...
/* luaL_register(L, 0, s_complex_m); YOU DON'T NEED THIS! */
luaL_register(L, "complex", s_complex_f);
lua_pushvalue(L, -2); /* the metatable */
lua_setmetatable(L, -2); /* sets and pops the metatable */
That should do what you want...
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
-Will Durant