Know the type carried by an Addressable

Martin Pernollet martin.pernollet at protonmail.com
Thu Feb 23 17:16:29 UTC 2023


Hi,

When I generate OpenGL bindings with JExtract, all methods having int/float/double arrays in the native interface have a Java sibling declared with an Addressable without more precise typing.

E.g. in OpenGL C header files we have methods like
public void glGetBooleanv(int pname, boolean[] data);
public void glGetDoublev(int pname, double[] data);
public void glGetFloatv(int pname, float[] data);
public void glGetIntegerv(int pname, int[] data);

These are getter methods that provide the array that will be filled according to the queried parameter defined by its pname id.
The generated java bindings loose information since they state :
public void glGetBooleanv(int pname, Addressable data);
public void glGetDoublev(int pname, Addressable data);
public void glGetFloatv(int pname, Addressable data);
public void glGetIntegerv(int pname, Addressable data);

I wonder if it is possible to

- dynamically ask to an Addressable the type it carries
- ask JExtract to generate more precise types
- if the idea of an Addressable<T> (rather than simple Addressable) has been discussed and why it has not been followed

In the case of OpenGL, I can deal with it since there exists a registry defining all functions with their typed parameters, so I can generate the code able to make such conversion - but I think that would be nice to get it out of the box with JExtract!

Martin

Envoyé avec la messagerie sécurisée [Proton Mail](https://proton.me/).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230223/1f0643fa/attachment.htm>


More information about the panama-dev mailing list