tarantool / tarantool/tarantool
lua: add luaL_getmetatype() for cdata
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 3.7k
- Forks
- 419
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 88
Description
I have added luaL_iscallable() with cdata support in the scope of #3276 (it didn't land into 1.10/2.1 for now) and found that ability to get metatype of a cdata object (something like getmetatable() for tables) sometimes useful.
I think we need to provide it and export for C modules and ffi. The name can be discussed, but I propose luaL_getmetatype().
It also will help with 2nd point of https://github.com/tarantool/tarantool/issues/1517#issuecomment-240405735
Side note: it also seems that it worth to add something like ffi.metatype() to C API to set metatypes.
Known workaround: https://github.com/corsix/ffi-reflect/blob/4ee6eb7bd7e51312ec6e2d84c1d650a7efa2a895/reflect.lua#L357
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing luaL_iscallable() cdata work from #3276 and the ffi-reflect workaround linked in the issue. Clarify the API name and scope with maintainers, including whether setting metatypes belongs in this change. Done means an agreed, exported way to retrieve cdata metatypes for C modules and FFI, with coverage for the intended cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100