[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: attaching garbage collect callback to arbitrary cdata
- From: Choonster TheMage <choonster.2010@...>
- Date: Wed, 18 Sep 2013 07:47:55 +1000
On 17 September 2013 17:08, Thijs Schreijer <thijs@thijsschreijer.nl> wrote:
>
>> -----Original Message-----
>> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
>> Behalf Of Rafis DoctorInfo
>> Sent: dinsdag 17 september 2013 8:40
>> To: Lua mailing list
>> Subject: attaching garbage collect callback to arbitrary cdata
>>
>> I'm trying to attach garbage collect callback to cdata<unsigned int>, but
>> it is not working "bad argument #1 to 'gc' (invalid C type)". It only
>> works then attaching to pointer based cdata.
>>
>> local ffi = require("ffi")
>>
>> local uint = ffi.gc(ffi.new("unsigned int", 123), function()
>> print("__gc called")
>> end)
>>
>> t = nil
>> collectgarbage()
>>
>> print("after")
>>
>> But why it is not possible? cdata and Lua's nil are different types:
>> type(cdata) ~= type(nil). Why can't LJ2 handle this?
>>
>> --
>> RG
>
> I don't have the answer to your question, but you might be better of asking this question on the LuaJIT mailing list [1] instead of the Lua list.
>
> Thijs
>
> [1] http://luajit.org/list.html
>
They've actually asked on both lists. There have been a few answers on
the LuaJIT list.