[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there a C API equivalent to the new # operator for tables?
- From: "Jérôme VUARAND" <jerome.vuarand@...>
- Date: Wed, 15 Nov 2006 23:17:19 -0500
2006/11/15, Shmuel Zeigerman <shmuz@actcom.co.il>:
lua_objlen
Why isn't there one for user data ? lua_objlen return the block size
of a userdata, whereas #ud in Lua calls the "len" metamethod. Is there
an equivalent of lua_objlen that push its result on the stack and that
calls metamethods on userdata if there is any ?
The only fallback I found was to create a length function in Lua :
----
length = function(obj)
return #obj
end
----
and to lua_call it from my C code. But I can't figure out how to port
that function to C, there seems to be a missing API function (unless I
emulate the behaviour of the # operator by accessing metatable
myself).