Comments (16)
I should also mention this is Lua 5.3, both stand alone an embedded in an application (Reaper).
from cffi-lua.
I also tried the code from lua-cffi documentation that is similar:
local cffi = require("cffi")
cffi.cdef [[
typedef struct point_t { double x; double y; } point_t;
]]
local point
point = cffi.metatype("point_t", {
__add = function(a, b)
return point(a.x + b.x, a.y + b.y)
end,
__len = function(a)
return math.sqrt(a:area())
end,
__index = {
area = function(a)
return a.x * a.x + a.y * a.y
end
}
})
local pt = point(3, 4)
print(pt.x, pt.y) -- 3, 4
print(#pt) -- 5
print(pt:area()) -- 25
local pt2 = a + point(0.5, 8)
print(#pt2) -- 12.5
with simliar results 'struct point_t' is not callable
from cffi-lua.
i will look into it later and add a testcase, seems like a bug
but I'm not home until end of the upcoming week, so it'll have to wait a little
from cffi-lua.
Sounds good. Much appreciated. This is an invaluable resource.
FYI, This affects latest version, 0.2.1 and 0.2.0. I built and tested them all. So it must have been around for a while.
from cffi-lua.
it's probably been there from the beginning, it's just surprising there is not a test case for it, since the test suite has grown relatively extensive (and largely on par with luajit's own ffi tests)
from cffi-lua.
Ya, I did look in the tests to see if I was missing something. I noticed there are relatively few metamethod tests given the number that Lua now supports. The other tests are quite extensive.
from cffi-lua.
most of the metamethods should not need testing as they are implemented identically to others (the code paths are the same, as they are generated via a macro)
unary metamethods are a bit special though
from cffi-lua.
this should now be fixed in a way that i'm happy with, feel free to give it a test if you like (i'll cut a release during next week)
from cffi-lua.
from cffi-lua.
never tried, i always installed libffi from homebrew when testing on macos, but never tested arm64 (should probably be the same?)
but libffi has no dependencies, so as long as you have the xcode commandline tools installed, i don't see why the usual configure+make+make install method wouldn't work?
from cffi-lua.
from cffi-lua.
as long as the fork does not break API (at least those that cffi uses), it will work (cffi does not make any non-portable assumptions about the target or the library)
never tried cross-compilation on macos; the generic approach with configure scripts is to pass --host with the correct triplet (not --target) and possibly set CC (and possibly some other tool vars, like AR) to the right cross-compiler (you might also want --disable-shared and static-link libffi into the module)
from cffi-lua.
from cffi-lua.
from cffi-lua.
from cffi-lua.
from cffi-lua.
Related Issues (20)
- Support struct array element assignment from table
- Support additional C type serialization with `ffi.string()`
- Support passing struct by value
- Release version 0.2.0 HOT 1
- get rid of malloc and abort usage HOT 1
- ensure no stack values with destructors are present in OOM scenarios
- Issues building on Debian for armhf HOT 14
- How much compatibility is wanted? HOT 4
- Segmentation fault when assigning a Lua callback to a C struct HOT 2
- Type comparison (istype) differs from LuaJIT HOT 4
- segfaults in ffi::newctype HOT 7
- Defining NDEBUG macro causes ffi.sizeof struct to return 0 HOT 2
- global load `ffi.load(..., true)` not work on Windows HOT 3
- Switch build system to XMake? HOT 1
- `unsigned short int` throws an error
- Create a meson subproject wrap file for libffi HOT 3
- Failing FFI example HOT 6
- windows build issues HOT 4
- need support iOS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cffi-lua.