RFR: 7903632: struct accessor info is not derived from toplevel layout decl

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Jan 16 16:18:57 UTC 2024


On Tue, 16 Jan 2024 16:14:31 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR dials back the code generation updates a little when it comes to struct getter/setter, so that both their layouts and offsets is now derived from the toplevel struct layout - using layout paths, as before.
> 
> This allows clients to e.g. tweak layouts in a single place (the topelevel struct layout declaration) to adjust things such as endianness.

src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 180:

> 178:         appendIndentedLines(STR."""
> 179:             public static \{type.getSimpleName()} \{javaName}(MemorySegment \{seg}) {
> 180:                 return \{seg}.get(\{layoutField}, \{offsetField});

overall, not too sure whether using separate layout/offset here is any better than using a var handle... opinions?

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

PR Review Comment: https://git.openjdk.org/jextract/pull/181#discussion_r1453657213


More information about the jextract-dev mailing list