RFR: 7903609: Jextract can not handle some anonymous nested structs [v2]

Jorn Vernee jvernee at openjdk.org
Wed Dec 13 18:47:58 UTC 2023


On Wed, 13 Dec 2023 18:05:43 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Uhm - but shouldn't that function use the new attribute that you set?
>
> E.g.
> 
> public static OptionalLong recordMemberOffset(Declaration member) {
>         if (member instanceof Variable) {
>             return ClangOffsetOf.get(member);
>         } else {
>             // anonymous struct
>             Optional<Declaration> firstDecl = ((Scoped)member).members().stream().findFirst();
>             return firstDecl.isEmpty() ?
>                     OptionalLong.empty() :
>                     recordMemberOffset(firstDecl.get());
>         }
>     }
> 
> 
> Can't the `else` be simplified to look for the offset in the AnonStruct attribute? Or call your new function?

Right... I could simplify the check in UnsupportedFilter to look at the off in the attribute directly, instead of going through `recordMemberOffset`. I think in that case we can also simplify `recordMemberOffset` to return a `long` unconditionally.

-------------

PR Review Comment: https://git.openjdk.org/jextract/pull/159#discussion_r1425744881


More information about the jextract-dev mailing list