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

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Dec 13 18:09:11 UTC 2023


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

>> yes, it's still used. The offset of an anon struct might be missing if it doesn't have any named fields nested inside. In that case, the offset is OptionalLong.empty(), and the UnsupportedFilter adds a Skip to the record: https://github.com/openjdk/jextract/blob/e790205da93c4aacd8524064d0f109d637b99161/src/main/java/org/openjdk/jextract/impl/UnsupportedFilter.java#L231-L233
>
> 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?

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

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


More information about the jextract-dev mailing list