Add MemoryLayout::byteOffset #157
Conversation
|
This seems like it should go to the |
Looks good, thanks for the thorough testing! |
@ChrisHegarty This change now passes all automated pre-integration checks, type
Since the source branch of this PR was last updated there has been 1 commit pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge As you do not have Committer status in this project, an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@JornVernee, @mcimadamore) but any other Committer may sponsor as well.
|
Mailing list message from Ty Young on panama-dev: On 5/11/20 3:36 AM, Chris Hegarty wrote:
This reminds me something I meant to bring up awhile ago: it would be Could those be added too?
|
Looks very good - many thanks! |
Right now all factories take bits (not bytes) as input, as that's more "primitive" and scales more to things like packed layouts. That said, I see your point. My feeling is that layout construction typically happens once, and then information is derived from the layout. When you construct you don't care much whether to use bits or bytes (other than for stylistic preferences) - but when you access layout information, you might be interested in getting either bits or bytes out, depending on which code you might need to interact with. So, in my view, fixing methods like "offset" takes the priority here. We'll keep evaluating against use cases and see how annoying that is. Thanks for bringing this up. |
Thanks Jorn, the intent was to target the |
/integrate |
@ChrisHegarty |
/sponsor |
@mcimadamore @ChrisHegarty The following commits have been pushed to foreign-memaccess since your change was applied:
Your commit was automatically rebased without conflicts. Pushed as commit 1bd6563. |
Hi,
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:
This allows for easier interoperation with MemoryAddress, which deals
with offsets and lengths in terms of bytes (rather than bits), e.g.
addr.addOffset(layout.byteOffset(groupElement("foo")))
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.
Progress
Reviewers
Download
$ git fetch https://git.openjdk.java.net/panama-foreign pull/157/head:pull/157
$ git checkout pull/157