Skip to content
New issue

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

Type comparison (istype) differs from LuaJIT #26

Closed
niess opened this issue Dec 24, 2020 · 4 comments
Closed

Type comparison (istype) differs from LuaJIT #26

niess opened this issue Dec 24, 2020 · 4 comments

Comments

@niess
Copy link

niess commented Dec 24, 2020

Hello,

Thank your for your help on the previous issue.

this one might be intended? I came across the following difference between LuaJIT/ffi and cffi:

local ffi = jit and require('ffi') or require('cffi')

ffi.cdef([[
struct structure {
    double scalar;
    double vector[3];
};
]])

local structure = ffi.new('struct structure')
print(ffi.istype('double [3]', structure.vector))
print(ffi.istype('double (&)[3]', structure.vector))

the last istype returns true with LuaJIT/ffi but false with cffi, i.e. double [3] and double (&)[3] are considered as the same type in one case but different types in the second case.

@q66
Copy link
Owner

q66 commented Dec 24, 2020

you sure? it looks to me like the first istype returns false on cffi, and the last one returns true

@q66 q66 closed this as completed in 8e5775b Dec 24, 2020
@niess
Copy link
Author

niess commented Dec 24, 2020

@q66 You are right I inverted both cases in the explanation. Sorry. Yet there is still a difference in behaviour. But mabye it is intended?*

So with cffi one gets false, true but with LuaJIT/ffi one gets true, true. I.e. double [] and double (&)[] seem to be equivalent istype in LuaJIT/ffi but not with cffi.

@q66
Copy link
Owner

q66 commented Dec 24, 2020

well, not anymore, should be fixed

@niess
Copy link
Author

niess commented Dec 29, 2020

Thank you for the patch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants