-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement module linking proposal (#46)
* Implement module linking proposal This commit binds the support added in bytecodealliance/wasmtime#2472 to bring support for the module linking to this Go extension. The support here is similar to bytecodealliance/wasmtime-py#47, which is hooking up modules/instances to `Extern` as well as adding dedicated instance/module types. * Update bazel build * Try to fix a Windows CI issue
- Loading branch information
1 parent
e5fed01
commit 7911ab8
Showing
14 changed files
with
429 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package wasmtime | ||
|
||
// #include <wasmtime.h> | ||
import "C" | ||
import "runtime" | ||
|
||
// InstanceType describes the exports of an instance. | ||
type InstanceType struct { | ||
_ptr *C.wasm_instancetype_t | ||
_owner interface{} | ||
} | ||
|
||
func mkInstanceType(ptr *C.wasm_instancetype_t, owner interface{}) *InstanceType { | ||
instancetype := &InstanceType{_ptr: ptr, _owner: owner} | ||
if owner == nil { | ||
runtime.SetFinalizer(instancetype, func(instancetype *InstanceType) { | ||
C.wasm_instancetype_delete(instancetype._ptr) | ||
}) | ||
} | ||
return instancetype | ||
} | ||
|
||
func (ty *InstanceType) ptr() *C.wasm_instancetype_t { | ||
ret := ty._ptr | ||
maybeGC() | ||
return ret | ||
} | ||
|
||
func (ty *InstanceType) owner() interface{} { | ||
if ty._owner != nil { | ||
return ty._owner | ||
} | ||
return ty | ||
} | ||
|
||
// AsExternType converts this type to an instance of `ExternType` | ||
func (ty *InstanceType) AsExternType() *ExternType { | ||
ptr := C.wasm_instancetype_as_externtype_const(ty.ptr()) | ||
return mkExternType(ptr, ty.owner()) | ||
} | ||
|
||
// Exports returns a list of `ExportType` items which are the items that will | ||
// be exported by this instance after instantiation. | ||
func (ty *InstanceType) Exports() []*ExportType { | ||
exports := &exportTypeList{} | ||
C.wasm_instancetype_exports(ty.ptr(), &exports.vec) | ||
runtime.KeepAlive(ty) | ||
return exports.mkGoList() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.