[foreign-jextract] RFR: 8274155 Foreign API refresh - jextract update
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Sep 23 10:02:29 UTC 2021
On Thu, 23 Sep 2021 03:05:55 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:
>> These are the jextract changes for the recent refresh of the Foreign Memory Access/Foreign Linker API. The biggest change in this API refresh comes from the removal of layout attributes. Jextract used to store several information in the form of layouts attributes. After some analysis, it turned out that in all cases, the use of layout attributes was not necessary, and it was really driven by the fact that jextract was, in certain places, using `MemoryLayout` as its main internal representation, instead of using the more flexible `Declaration`/`Type` APIs. Unfortunately, updating `RecordLayoutComputer` to work on `Declaration` rather than `MemoryLayout` caused changes in several part of the jextract parsing frontend.
>>
>> Other minor changes were required, to adjust jextract to the new API changes - but most of these are small. I've dropped several now redundant overloads (so the size of the generated bindings should be smaller). There's also an additional piece of code which is used to emit typedef for common C primitive types such as `C_INT` and the likes (since the layouts for these are no longer in `CLinker`).
>>
>> The test changes are mostly trivial updates to use the new API.
>
> src/jdk.incubator.jextract/share/classes/jdk/internal/clang/libclang/constants$0.java line 36:
>
>> 34: import static jdk.incubator.foreign.CLinker.*;
>> 35: import static jdk.internal.clang.libclang.CLayouts.*;
>> 36:
>
> Same comment as for RuntimeHelper. All these are extracted code. Need to figure out how to do CLayouts equivalent from jextract.
This is just a workaround I did to avoid rewriting all these constants classes (since they were using layouts like C_INT and such). So I defined the `CLayouts` class, and kept the rest identical to what it was before. If we regenerate all the bindings, all these dependencies will go away.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/577
More information about the panama-dev
mailing list