[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.1 (work1) now available
- From: Peter Cawley <lua@...>
- Date: Sat, 7 Apr 2012 15:56:36 +0100
On Sat, Apr 7, 2012 at 3:21 PM, Coda Highland <chighland@gmail.com> wrote:
> You'd still need to use operator delete on it instead of free if you
> need the destructor invoked.
You can explicitly invoke the destructor from the __gc metamethod:
int factory(lua_State* L)
{
T* object = new (reinterpret_cast<T*>(lua_newuserdata(L, sizeof(T)))) T;
/* set metatable here */
return 1;
}
int gc_metamethod(lua_State* L)
{
T* object = reinterpret_cast<T*>(lua_touserdata(L, 1));
object->~T();
return 0;
}
- References:
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Rena
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Coda Highland