RFR: 7903616: Bad formatting of layout string for structs with nested anon structs/unions [v3]

Jorn Vernee jvernee at openjdk.org
Wed Jan 10 12:40:52 UTC 2024


On Fri, 22 Dec 2023 14:48:19 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This PR fixes an indentation issue when generating a struct layout string.
>> 
>> Example:
>> 
>> 
>> struct Foo {
>>     struct {
>>         int x;
>>         union {
>>             int y;
>>             int z;
>>         };
>>     };
>> }; 
>> 
>> 
>> For this, jextract generates:
>> 
>> 
>>     private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
>>         MemoryLayout.structLayout(
>>         foo_h.C_INT.withName("x"),
>>         MemoryLayout.unionLayout(
>>         foo_h.C_INT.withName("y"),
>>         foo_h.C_INT.withName("z")
>>     ).withName("$anon$7:9")
>>     ).withName("$anon$5:5")
>>     ).withName("Foo");
>> 
>> 
>> With the fix in this PR, the generated string is:
>> 
>> 
>>     private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
>>         MemoryLayout.structLayout(
>>             foo_h.C_INT.withName("x"),
>>             MemoryLayout.unionLayout(
>>                 foo_h.C_INT.withName("y"),
>>                 foo_h.C_INT.withName("z")
>>             ).withName("$anon$7:9")
>>         ).withName("$anon$5:5")
>>     ).withName("Foo");
>> 
>> 
>> The fix is to correctly track required indentation when descending into a scoped declaration.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove redundant trailing semi

Marked as reviewed by jvernee (Committer).

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

PR Review: https://git.openjdk.org/jextract/pull/170#pullrequestreview-1813136097


More information about the jextract-dev mailing list