[foreign-jextract] RFR: 8261642: improve jextract source generation mode and remove class generation [v2]

Jorn Vernee jvernee at openjdk.java.net
Mon Feb 15 15:09:55 UTC 2021

On Mon, 15 Feb 2021 15:03:09 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> forgot about this - I cannot really do this, as nested structs don't return a new builder - in other words, the OutputFactory code doesn't really know if it should begin a class or not. I could do `if (newBuilder != currentBuilder) newBuilder.classBegin() ...` but I don't think that improves much?
> Yeah, I was looking at `classEnd()` where you use `if (prefixElementNames.isEmpty())` to check if the struct builder is for an anonymous nested struct or not. So I thought you could do the same for `classBegin()` and have:
>     @Override
>     void classBegin() {
>         if (prefixElementNames.isEmpty()) {
>             super.classBegin();
>             addLayout(layoutField(), ((Type.Declared)structType).tree().layout().get())
>                     .emitGetter(this, MEMBER_MODS, Constant.SUFFIX_ONLY);
>         }
>     }
> ?

Also, it might make things clearer by creating an `isAnonymousNested()` predicate for that (just for reader's sake).


PR: https://git.openjdk.java.net/panama-foreign/pull/450

More information about the panama-dev mailing list