Skip to content

Commit

Permalink
cm: follow pattern of generated wasmimport calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Dec 26, 2024
1 parent 15d573c commit 7162ceb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 2 additions & 10 deletions cm/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@ func (err errorContext) String() string {
// [error-context.debug-message]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#error-contextdebug-message
func (err errorContext) DebugMessage() string {
var s string
errorContextDebugMessage(err, unsafe.Pointer(&s))
wasmimport_errorContextDebugMessage(err, unsafe.Pointer(&s))
return s
}

//go:wasmimport canon error-context.debug-message
//go:noescape
func errorContextDebugMessage(err errorContext, msg unsafe.Pointer)

// Drop represents the Canonical ABI [error-context.drop] function.
//
// [error-context.drop]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#error-contextdrop
func (err errorContext) Drop() {
errorContextDrop(err)
wasmimport_errorContextDrop(err)
}

//go:wasmimport canon error-context.drop
//go:noescape
func errorContextDrop(err errorContext)
13 changes: 13 additions & 0 deletions cm/error.wasm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cm

import "unsafe"

// msg uses unsafe.Pointer for compatibility with go1.23 and lower.
//
//go:wasmimport canon error-context.debug-message
//go:noescape
func wasmimport_errorContextDebugMessage(err errorContext, msg unsafe.Pointer)

//go:wasmimport canon error-context.drop
//go:noescape
func wasmimport_errorContextDrop(err errorContext)

0 comments on commit 7162ceb

Please sign in to comment.