RFR: 7903616: Bad formatting of layout string for structs with nested anon structs/unions
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Dec 21 16:12:15 UTC 2023
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.
-------------
Commit messages:
- Initial push
Changes: https://git.openjdk.org/jextract/pull/170/files
Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=170&range=00
Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903616
Stats: 9 lines in 1 file changed: 1 ins; 0 del; 8 mod
Patch: https://git.openjdk.org/jextract/pull/170.diff
Fetch: git fetch https://git.openjdk.org/jextract.git pull/170/head:pull/170
PR: https://git.openjdk.org/jextract/pull/170
More information about the jextract-dev
mailing list