[foreign] RFR: jextract should emit toplevel annotations

Henry Jen henry.jen at oracle.com
Wed May 30 18:32:48 UTC 2018


Look good to me.

Functional wise, I think it’s fine at this point. The big declaration on the top annotation is hard to read without separator though.

One potential issue is that, for undefined struct, the layout has a symbolic reference to an Annotation class, which won’t have any layout, is that working?

Cheers,
Henry


> On May 28, 2018, at 11:07 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> Hi,
> this patch fixes jextract so that it generates the toplevel annotations described in [1] - which are also the one understood by the binder in the foreign branch.
> 
> I've garbage collected the unused annotations (NativeType, Array and Offset).
> 
> The general tactic to generate the new layout strings is to parse a clang type into a Layout API object. Then use the toString method of the layout to generate the string description.
> 
> There are few subtleties in the code that does the parsing:
> 
> * there are two paths that generate record layouts: one is from Utils.getLayout, which generates a symbolic reference to the layout (e.g. $(Foo)). Another from Utils.getRecordLayout, which generates the full record layout description.
> 
> * getRecordLayout must recursively call getRecordLayout in case of nested anonymous struct, whose layout is inlined with the enclosing struct
> 
> * inside getRecordLayout padding is added to the layout, as needed, so as to respect the offset returned by clang
> 
> Webrev:
> 
> http://cr.openjdk.java.net/~mcimadamore/panama/jextract_toplevel/
> 
> Cheers
> Maurizio
> 
> [1] - http://cr.openjdk.java.net/~mcimadamore/panama/panama-binder-v3.html
> 
> 



More information about the panama-dev mailing list