q66 / cffi-lua

A portable C FFI for Lua 5.1+
MIT License
176 stars 24 forks source link

Parameterized pointer type regression #6

Closed vsergeev closed 3 years ago

vsergeev commented 3 years ago
local ffi = jit and require('ffi') or require('cffi')

ffi.cdef[[
typedef struct point {
    int x;
    int y;
} point_t;
]]

print(ffi.typeof("point_t")) --> ctype<struct point>
print(ffi.typeof("point_t *")) --> ctype<struct point *>
print(ffi.typeof("$ *", ffi.typeof("point_t"))) --> expected: ctype<struct point *>, get: ctype<struct point>

I'm expecting a pointer type for the parametrized typeof ffi.typeof("$ *", ffi.typeof("point_t"), but am getting the underlying structure type.

Running off of 07b30b0.

q66 commented 3 years ago

this one was kind of silly, the parsing and everything was actually working right, but it was returning an incorrect value on the lua stack :P

vsergeev commented 3 years ago

Great, thanks :+1: Works for me now.