acfoltzer opened PR #6884 from bytecodealliance:acf/wiggle-struct-field-offsets
to bytecodealliance:main
(assigned to acfoltzer):
Adds methods of the shape
GeneratedStruct::offset_of_<field_name>() -> u32
to allow clients to get the same offsets used in the generatedread
andwrite
methods. I don't believe there is currently a way to get these otherwise for applications that wish to selectively read and write to fields.I considered a couple alternatives to this:
Add methods like
read_<field_name>
andwrite_<field_name>
. The interface to these ends up being awkward because theGuestType
impls are currently for owned types, so these methods would be forced to either take ownership of the entire struct to write one field, or else silently clone the field.Add
#[repr(C)]
to the generated struct definition so that clients could use tools likememoffset
to calculate the offset themselves. I didn't want to depend on the witx offsets coinciding withrepr(C)
, though.I extended the Wiggle
records
to exercise these new methods.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
acfoltzer assigned PR #6884 to acfoltzer.
acfoltzer requested pchickey for a review on PR #6884.
acfoltzer requested wasmtime-core-reviewers for a review on PR #6884.
pchickey submitted PR review.
pchickey has enabled auto merge for PR #6884.
pchickey merged PR #6884.
Last updated: Dec 23 2024 at 12:05 UTC