[foreign-jextract] RFR: Add MemoryLayout::byteOffset
youngty1997 at gmail.com
Mon May 11 09:21:46 UTC 2020
On 5/11/20 3:36 AM, Chris Hegarty wrote:
> As part of feedback on the Foreign Memory API (when experimenting with
> its usage internally in the JDK), a small number of potential usability
> enhancements could be made to the API. This is the first such.
> This change:
> 1) renames MemoryLayout::offset to MemoryLayout::bitOffset, and
> 2) adds MemoryLayout::byteOffset
> This allows for easier interoperation with MemoryAddress, which deals
> with offsets and lengths in terms of bytes (rather than bits), e.g.
> This brings a nice symmetry to the API; there is a trio of bit-wise
> methods: bitAlignment, bitOffset, bitSize, and their matching byte-wise
> counterparts; byteAlignment, byteOffset, byteSize.
This reminds me something I meant to bring up awhile ago: it would be
nice to have a counterpart method "ofPaddingBytes" and pre-defined
layouts like "PAD_BYTE_1" to the existing Bit based versions.
Could those be added too?
> Commit messages:
> - fix typo in javadoc example
> - Initial MemoryLayout::byteOffset and test changes
> Changes: https://git.openjdk.java.net/panama-foreign/pull/157/files
> Webrev: https://webrevs.openjdk.java.net/panama-foreign/157/webrev.00
> Stats: 131 lines in 2 files changed: 103 ins; 1 del; 27 mod
> Patch: https://git.openjdk.java.net/panama-foreign/pull/157.diff
> Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/157/head:pull/157
> PR: https://git.openjdk.java.net/panama-foreign/pull/157
More information about the panama-dev