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:38:05 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> 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.

Addressed in: https://github.com/openjdk/jextract/pull/159/commits/cd00d68d0f0e08912ed358211a663a0fe6274ccb

`recordMemberOffset` is then just used when computing the layout string, so I've move the method to StructBuilder as well.

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

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


More information about the jextract-dev mailing list