Know the type carried by an Addressable
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Feb 23 17:23:46 UTC 2023
What version of jextract are you using? Addressable has been dropped in
Java 20.
I believe in the newer jextract all these will generate MemorySegment types.
Now to your question:
> * dynamically ask to an Addressable the type it carries
>
Not really - a memory segment is just a bag of bytes.
>
> * ask JExtract to generate more precise types
>
This is a possibility - e.g. jextract could add higher-level carriers
for structs and pointers. Note that here you don't really want an array
- when you use array syntax for a function declaration in C, the
compiler turns that into a pointer.
>
> * if the idea of an Addressable<T> (rather than simple Addressable)
> has been discussed and why it has not been followed
>
No, for the reason above, a memory segment is a bag of bytes. You can
freely dereference a memory segment as you please, reading any
combination of values. Adding typeful representation to segments is an
higher-level concern, presumably something jextract could add.
>
> 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!
It's something on our radar. Whatever solution we end up with, it will
have to balance carefully usability with performance - e.g. if we add
too much information, there might be an additional overhead to create
this representation, and not all jextract users might be ok with that.
Cheers
Maurizio
>
> 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/0dff5d17/attachment.htm>
More information about the panama-dev
mailing list