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

[libffi] remove constant global.ffi.FFI_DEFAUL_ABI and friends and point to platform-specific preset.ffi.FFI_DEFAULT_ABI #1315

Closed
drcicero opened this issue Jan 28, 2023 · 4 comments

Comments

@drcicero
Copy link
Contributor

Hi, I am using "org.bytedeco" % "libffi-platform" % "3.4.4-1.5.8" (via Scala) on Linux.

I think the enum values:

/** enum ffi_abi */
public static final int
// #if defined(X86_WIN64)
// #elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
// #elif defined(X86_WIN32)
// #else
FFI_FIRST_ABI = 0,
FFI_SYSV = 1,
FFI_THISCALL = 3,
FFI_FASTCALL = 4,
FFI_STDCALL = 5,
FFI_PASCAL = 6,
FFI_REGISTER = 7,
FFI_MS_CDECL = 8,
FFI_LAST_ABI = 9,
FFI_DEFAULT_ABI = FFI_SYSV;
// #endif
should be removed, as there platform specific, e.g., the comments still show that in C they were platform-specifically defined via #ifdef.

It seems the correct way to go is to use the already defined presets.ffi.FFI_DEFAULT_ABI() methods and friends, which are defined as native and supplied from somewhere else:

public static native @MemberGetter int FFI_FIRST_ABI();
public static native @MemberGetter @Platform(not = "windows", pattern = ".*-x86_64") int FFI_UNIX64();
public static native @MemberGetter @Platform(not = "windows", pattern = ".*-x86_64") int FFI_EFI64();
public static native @MemberGetter @Platform(pattern = ".*-x86_64") int FFI_WIN64();
public static native @MemberGetter @Platform(pattern = ".*-x86_64") int FFI_GNUW64();
public static native @MemberGetter @Platform(pattern = ".*-x86") int FFI_THISCALL();
public static native @MemberGetter @Platform(pattern = ".*-x86") int FFI_FASTCALL();
public static native @MemberGetter @Platform(pattern = ".*-x86") int FFI_STDCALL();
public static native @MemberGetter @Platform(pattern = ".*-x86") int FFI_PASCAL();
public static native @MemberGetter @Platform(pattern = ".*-x86") int FFI_REGISTER();
public static native @MemberGetter @Platform(pattern = ".*-x86") int FFI_MS_CDECL();
public static native @MemberGetter @Platform(pattern = {".*-x86", ".*-arm.*"}) int FFI_SYSV();
public static native @MemberGetter @Platform(pattern = "(?!.*-arm64).*-arm.*") int FFI_VFP();
public static native @MemberGetter @Platform(pattern = ".*-ppc64.*") int FFI_LINUX();
public static native @MemberGetter @Platform(pattern = ".*-ppc64.*") int FFI_LINUX_STRUCT_ALIGN();
public static native @MemberGetter @Platform(pattern = ".*-ppc64.*") int FFI_LINUX_LONG_DOUBLE_128();
public static native @MemberGetter @Platform(pattern = ".*-ppc64.*") int FFI_LINUX_LONG_DOUBLE_IEEE128();
public static native @MemberGetter int FFI_LAST_ABI();
public static native @MemberGetter int FFI_DEFAULT_ABI();

I'm not sure where the native things get their value from, but those have the right value for me.

(I noticed this, because in the current state they are easy to confuse, e.g, when your call the method FFI_DEFAULT_ABI() you get the right value, but when you access the field FFI_DEFAULT_ABI you get the wrong value, and an error later when you try to pass it to prepare. They are even easier to confuse in Scala, where syntactic sugar often allows one to shorten x.f() to x.f.)

@saudet
Copy link
Member

saudet commented Jan 29, 2023

We can probably get that done with a couple of Info.skip.
Please open a pull request to that effect, contributions are welcome!

@drcicero
Copy link
Contributor Author

drcicero commented Jan 30, 2023

Instead of skipping lines by regex i would prefer to skip these by variable name; however it seems that's only possible with fields/methods; not enum variants, is it?

@saudet
Copy link
Member

saudet commented Jan 31, 2023

I don't think it's possible to skip individual enumerators at the moment, but it should be possible to skip whole enumerations. If you've tried something specific that doesn't work, please show me what you've tried exactly.

saudet added a commit to bytedeco/javacpp that referenced this issue Mar 25, 2023
…n JDK (issue bytedeco/javacv#2001)

 * Fix `Parser` ignoring `Info.skip` for enumerators that do not get translated (issue bytedeco/javacpp-presets#1315)
 * Fix `Parser` error on C++17 style namespace declarations containing `::` separators (issue #595)
@saudet
Copy link
Member

saudet commented Jun 6, 2023

Fix released with JavaCPP 1.5.9! Thanks for the contribution

@saudet saudet closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants