[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT 2 ffi (casting / force hotpath)
- From: Florian Weimer <fw@...>
- Date: Sat, 22 Jan 2011 10:13:46 +0100
* Mike Pall:
> I hope the docs clear up many of your questions. If not, then
> please ask here. Feedback welcome!
I think it could be useful if you could create a cdata/userdata
combination. This would allow access to the blob in a userdata as a C
structure, and you could still provide an object-specific metatable.
I think this is surprising (to a C++ programmer at least):
| Objects which are passed as an argument to an external C function
| are kept alive until the call returns.
I think the lifetime should extend to full expression, that is, beyond
the call. The reason is that a function might return a pointer that
is passed in, such as:
char *check_string(char *);
If this is called as
do_something(check_string(ffi.new(...)))
then the returned pointer will not keep the original pointer live.