GithubHelp home page GithubHelp logo

Comments (16)

mavriq-dev avatar mavriq-dev commented on August 28, 2024

I should also mention this is Lua 5.3, both stand alone an embedded in an application (Reaper).

from cffi-lua.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

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.

q66 avatar q66 commented on August 28, 2024

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.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

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.

q66 avatar q66 commented on August 28, 2024

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.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

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.

q66 avatar q66 commented on August 28, 2024

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.

q66 avatar q66 commented on August 28, 2024

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.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

from cffi-lua.

q66 avatar q66 commented on August 28, 2024

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.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

from cffi-lua.

q66 avatar q66 commented on August 28, 2024

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.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

from cffi-lua.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

from cffi-lua.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

from cffi-lua.

mavriq-dev avatar mavriq-dev commented on August 28, 2024

from cffi-lua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.