jnr / jnr-ffi

Java Abstracted Foreign Function Layer
Other
1.25k stars 156 forks source link

Add failing test to illustrate issue #319

Open mcsherrylabs opened 1 year ago

mcsherrylabs commented 1 year ago

I've added a test to show the issue I'm facing.

It looks like there is no way to pass a struct by value.

Any help appreciated? If it's not possible, is it on the way by any chance? Any recommendations? (I don't have access to the original code, but I could use SWIG?)

mcsherrylabs commented 1 year ago

@headius .... any steer appreciated ....

headius commented 1 year ago

I'll look into this tonight or early tomorrow! Thanks for the case.

headius commented 1 year ago

Could you open a bug describing the problem? Link to this test case so I or someone else can see exactly what the problem is.

mcsherrylabs commented 1 year ago

Could you open a bug describing the problem? Link to this test case so I or someone else can see exactly what the problem is.

I can do that. But I'm not sure it's an issue or my inexperience. Perhaps the solution is simple?

I can't find a way to have the c function interpret the struct by value ...

I can do this

long struct_num_al_test(SomeStruct *s) { return s -> count; }

using something in java like

public long struct_num_al_test(SomeStruct s);

But I cannot do this

long struct_num_al_test(SomeStruct s) { return s.count; }

Is this a bug?

headius commented 1 year ago

Ok thank you, that really helps me understand the problem!

I will need to poke around a bit to see if passing structs by value is supported. I'd say based on your test case, it is not, but I'm not sure if that is intentional (not implemented) or a bug (should work but doesn't and nobody realized until now).

basshelal commented 1 year ago

@headius We don't (yet) support Struct by value, see #14 . I've been trying to do some cleanups to safely add missing features (this one is the highest priority) but haven't had much free time to do so and I've found the code quite tricky to manage and understand.