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

Jorn Vernee jvernee at openjdk.org
Wed Dec 13 16:59:10 UTC 2023


On Wed, 13 Dec 2023 16:49:48 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   propagated varTree as named parent
>
> src/main/java/org/openjdk/jextract/impl/TreeMaker.java line 343:
> 
>> 341:      * };
>> 342:      */
>> 343:     private static OptionalLong offsetOfAnonymousRecord(Cursor outermostParent, Cursor anonRecord, Cursor record) {
> 
> What about DeclarationImpl::recordMemberOffset ? Is that still used? UnsupportedTypeFilter and StructBuilder depend on that for skipping - is is still the case that the anon record offset might be missing?

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

> src/main/java/org/openjdk/jextract/impl/TreeMaker.java line 346:
> 
>> 344:         AtomicReference<OptionalLong> result = new AtomicReference<>(OptionalLong.empty());
>> 345:         record.forEach(fc -> {
>> 346:             if (result.get().isPresent()) return;
> 
> Why don't we return after setting a result, instead of waiting for the next cursor and then returning if we see a result has been set?

We can not return from the outer function in the forEach. I don't think there is a way to short-circuit the forEach.

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

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


More information about the jextract-dev mailing list