MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / NewImportType

Function NewImportType

importtype.go:16–31  ·  view source on GitHub ↗

NewImportType creates a new `ImportType` with the given `module` and `name` and the type provided.

(module, name string, ty AsExternType)

Source from the content-addressed store, hash-verified

14// NewImportType creates a new `ImportType` with the given `module` and `name` and the type
15// provided.
16func NewImportType(module, name string, ty AsExternType) *ImportType {
17 moduleVec := stringToByteVec(module)
18 nameVec := stringToByteVec(name)
19
20 // Creating an import type requires taking ownership, so create a copy
21 // so we don't have to invalidate pointers here. Shouldn't be too
22 // costly in theory anyway.
23 extern := ty.AsExternType()
24 ptr := C.wasm_externtype_copy(extern.ptr())
25 runtime.KeepAlive(extern)
26
27 // And once we've got all that create the import type!
28 importPtr := C.wasm_importtype_new(&moduleVec, &nameVec, ptr)
29
30 return mkImportType(importPtr, nil)
31}
32
33func mkImportType(ptr *C.wasm_importtype_t, owner interface{}) *ImportType {
34 importtype := &ImportType{_ptr: ptr, _owner: owner}

Callers 1

TestImportTypeFunction · 0.85

Calls 4

stringToByteVecFunction · 0.85
mkImportTypeFunction · 0.85
AsExternTypeMethod · 0.65
ptrMethod · 0.45

Tested by 1

TestImportTypeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…