[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Possible to add methods in Lua to metatables defined in C?
- From: pansz <pan.shizhu@...>
- Date: Fri, 4 May 2012 11:40:09 +0800
On Fri, May 4, 2012 at 3:04 AM, Andrew Budd <firstname.lastname@example.org> wrote:
> Probably already obvious to most, but this is how I achieved the desired
> .prototype functionality
> at the bottom of the luaopen_array function
If you don't want to call a function, this is the obvious way to go.
But you really do not need to do getglobal(). Note that you need to
return 1 in your luaopen_array() function, this means the array table
is on the stack top.
when require "array", the global variable 'array' will be assigned
after luaopen_array() returned (with the return value in stack top),
it seems that you cannot get the global value of array inside luaopen_