Skip to content

feat: add a 'records' example, and some required instructions#171

Open
arcjet-rei wants to merge 8 commits intomainfrom
records-instructions-and-example
Open

feat: add a 'records' example, and some required instructions#171
arcjet-rei wants to merge 8 commits intomainfrom
records-instructions-and-example

Conversation

@arcjet-rei
Copy link
Contributor

@arcjet-rei arcjet-rei commented Mar 5, 2026

Picking up from @sd2k's PR #116 and making a number of additional
fixes, rebased onto the tip of main.

@sd2k's original PR message follows:

Prior to this commit there was ostensibly no support for 'record' WIT
types, but there wasn't actually much required for them to work. This
commit adds an example for use in the test harness and the required
instructions to load/store integer record fields.

Relates to #4

sd2k and others added 8 commits March 4, 2026 18:54
Prior to this commit there was ostensibly no support for 'record' WIT
types, but there wasn't actually much required for them to work. This
commit adds an example for use in the test harness and the required
instructions to load/store integer record fields.

Relates to #4.
Co-authored-by: blaine-arcjet <146491715+blaine-arcjet@users.noreply.github.com>
In the import direction, function params are already uint32, so using
api.EncodeU32/api.DecodeU32 is a wasteful roundtrip. Use simple
uint32() casts for imports and the API functions for exports where
CallWasm operates on uint64 values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update examples/records wit-bindgen to 0.53.1 and wit-component to
  0.245.1 to match other examples
- Regenerate CLI test snapshots to reflect the EncodeU32/DecodeU32
  codegen changes for export functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…romU64

Replace api.EncodeU32/api.DecodeU32/int64() with simple uint32()/uint64()
identity casts. The Encode/Decode helpers round-trip through uint64, which
causes Go compile errors when the result is assigned to a uint32 variable
(e.g. VariantLower slots) or when int64 is assigned to uint64. The canonical
ABI reinterpretation instructions are no-ops at the bit level, so identity
casts are correct — wazero only inspects the lower 32 bits for i32 values.

Adds regression tests for the variant-payload case that triggered the
original compile errors, and TODOs for E2E variant tests once variant type
definition generation is implemented.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants