[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT 2 ffi (casting / force hotpath)
- From: Mike Pall <mikelu-1101@...>
- Date: Thu, 20 Jan 2011 23:46:48 +0100
Alex Bradbury wrote:
> Unless I missed it, I don't think there's currently a way to iterate
> over a C library namespace. This would be useful, for instance, to
> enable tab-completion in interactive Lua sessions.
Sorry, but that cannot work. C library namespaces are auto-binding:
only if you actually index them with a symbol, does the symbol get
bound (loaded from the library and associated with its declaration).
Internally the namespace is a userdata plus a cache. And the cache
contents are unsuitable for that purpose (empty at start of course).
Also, C declarations have no concept of origin. They could be valid
symbols in any and all libraries. Until you actually try to bind
them by indexing the namespace, they are not associated with any
particular library. In fact, you can bind the same symbol multiple
times in different namespaces. So iterating over all symbol
declarations wouldn't make much sense either.