<
justin@specialbusservice.com> wrote:
> On 29 May 2011, at 16:58, Duncan Cross <
duncan.cross@gmail.com> wrote:
>
>> On Sun, May 29, 2011 at 4:54 PM, Justin Cormack
>> <
justin@specialbusservice.com> wrote:
>>>>> Why cant you just add a __tobuffer metamethod to all the types?
>>>>
>>>> getmetatable(cdata) always seems to return 'ffi', currently.
>>>>
>>>
>>> You have to use ffi.metatype() to set a metatable. eg
>>> fd_t = ffi.metatype("struct {int fd;}", {__index = {close = close}, __gc =
>>> close})
>>> This can only be done on creation, but works nicely.
>>
>> Yep, I'm using ffi.metatype - but the metatable you set is still not
>> retrieved by getmetatable(), it still just returns 'ffi' for me. (Is
>> it different for you? Maybe this is a bug?)
>>
>> -Duncan
>>
>
> Why try to get the metatable, just pcall the method to see if it is there. I think it is a feature not a bug in this case.
>
Oh, I see what you mean now. Yes, you're right, it's fair enough for