Hi,
Am Samstag, dem 15.10.2022 um 11:04 -0700 schrieb m:
> > Which documentation? Please provide a link.
> I'll quote "Customizable mapping from Java method to native function
> name, and customizable invocation to simulate C preprocessor function
> macros" from the readme.
YOU can use JNA to simulate the result of preprocessor macros. As
explained in my first email, the information is not present at runtime
and thus can't be used, but you can read the header files and simulate.
> > You need to have a look at the header and convert the macro
> > definitions to Java code.
> Any resources on this part? Also, Does the same apply to identifiers.
> There are other Cpp X11 identifiers
> i.e.. XFixesSetSelectionOwnerNotifyMask, XA_PRIMARY, which I also
> don't know how to go about them.
Don't take this wrong, but you need to get a grab of C _and_ Java to
write mappings.
XA_PRIMARY is a preprocessor definition. If you look into the header
file, you see this:
#define XA_PRIMARY ((Atom) 1)
It now depends on whether you want to use the existing bindings in jna-
platform. For the latter, have a look here:
https://github.com/java-native-access/jna/blob/673079f3afae0b0dfeaa111071aeed909af5dcc3/contrib/platform/src/com/sun/jna/platform/unix/X11.java#L668
https://github.com/java-native-access/jna/blob/673079f3afae0b0dfeaa111071aeed909af5dcc3/contrib/platform/src/com/sun/jna/platform/unix/X11.java#L83-L168
https://github.com/java-native-access/jna/blob/673079f3afae0b0dfeaa111071aeed909af5dcc3/contrib/platform/src/com/sun/jna/platform/unix/X11.java#L62-L82
For the former:
Xdefs.h defines the Atom type as:
typedef unsigned long Atom;
So an Atom is just a C long. You now need to know that the size long of
long is platform dependend and that it is so common, that JNA has
NativeLong in its core. So the define becomes:
private static final NativeLong XA_PRIMARY = new NativeLong(1);
For XFixesSetSelectionOwnerNotifyMask you find in the header:
#define XFixesSetSelectionOwnerNotifyMask (1L << 0)
#define XFixesSelectionWindowDestroyNotifyMask (1L << 1)
#define XFixesSelectionClientCloseNotifyMask (1L << 2)
It depends how this is to be used. Naively I would map them as:
private static final long XFixesSetSelectionOwnerNotifyMask = 1 << 0;
private static final long XFixesSelectionWindowDestroyNotifyMask = 1 << 1;
private static final long XFixesSelectionClientCloseNotifyMask = 1 << 2;
I encourage you to have a look at the existing X11 bindings to get a bearing.
Greetings
Matthias