We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be nice to have metatable support for ctypes themselves, as with the LuaJIT FFI:
local ffi = require('cffi') ffi.cdef[[ typedef struct point { int x; int y; } point_t; ]] local mt = { __tostring = function (self) return string.format("Point<%d, %d>", self.x, self.y) end, __index = { from_array = function (arr) return ffi.new("point_t", arr[1], arr[2]) end } } Point = ffi.metatype("point_t", mt) print(Point(1, 2)) --> Point<1, 2> print(Point.from_array({3, 4})) --> expected: Point<3, 4>, cffi-lua gives: 'ctype' is not indexable
This allows implementing static methods on the ctype, like alternate constructors, or utility functions namespaced under the ctype.
The text was updated successfully, but these errors were encountered:
metatype for ctypes is supported, but it seems this case is not handled, it probably should
Sorry, something went wrong.
07b30b0
Awesome, thanks 👍
No branches or pull requests
It would be nice to have metatable support for ctypes themselves, as with the LuaJIT FFI:
This allows implementing static methods on the ctype, like alternate constructors, or utility functions namespaced under the ctype.
The text was updated successfully, but these errors were encountered: