Skip to content

Commit c125514

Browse files
authored
Remove support for module linking (#85)
This gets tests to pass now that bytecodealliance/wasmtime#3958 has landed.
1 parent c85709d commit c125514

File tree

9 files changed

+60
-347
lines changed

9 files changed

+60
-347
lines changed

tests/test_instance.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,6 @@ def test_multiple_exports(self):
7171
assert(isinstance(instance.exports(store)[1], Func))
7272
assert(isinstance(instance.exports(store)[2], Global))
7373

74-
def test_instance_type(self):
75-
store = Store()
76-
module = Module(store.engine, """
77-
(module
78-
(func (export "a"))
79-
(func (export "b"))
80-
(global (export "c") i32 (i32.const 0))
81-
)
82-
""")
83-
ty = Instance(store, module, []).type(store)
84-
exports = ty.exports
85-
self.assertEqual(len(exports), 3)
86-
assert(isinstance(exports[0].type, FuncType))
87-
assert(exports[0].name == 'a')
88-
assert(isinstance(exports[1].type, FuncType))
89-
assert(exports[1].name == 'b')
90-
assert(isinstance(exports[2].type, GlobalType))
91-
assert(exports[2].name == 'c')
92-
9374
def test_import_func(self):
9475
store = Store()
9576
module = Module(store.engine, """

tests/test_module.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,43 +111,6 @@ def test_exports(self):
111111
self.assertEqual(ty.limits, Limits(1, None))
112112
self.assertEqual(ty.element, ValType.funcref())
113113

114-
def test_type(self):
115-
store = Store()
116-
module = Module(store.engine, """
117-
(module
118-
(import "" "" (func))
119-
(import "a" "bcd" (global i32))
120-
(import "" "x" (table 1 funcref))
121-
122-
(func (export "a") (param i32 f32) (result f64)
123-
f64.const 0)
124-
(global (export "") (mut i32) (i32.const 1))
125-
(memory (export "mem") 1)
126-
(table (export "table") 1 funcref)
127-
)
128-
""")
129-
ty = module.type
130-
imports = ty.imports
131-
exports = ty.exports
132-
assert(imports[0].module == '')
133-
assert(imports[0].name == '')
134-
assert(isinstance(imports[0].type, FuncType))
135-
assert(imports[1].module == 'a')
136-
assert(imports[1].name == 'bcd')
137-
assert(isinstance(imports[1].type, GlobalType))
138-
assert(imports[2].module == '')
139-
assert(imports[2].name == 'x')
140-
assert(isinstance(imports[2].type, TableType))
141-
142-
assert(exports[0].name == 'a')
143-
assert(isinstance(exports[0].type, FuncType))
144-
assert(exports[1].name == '')
145-
assert(isinstance(exports[1].type, GlobalType))
146-
assert(exports[2].name == 'mem')
147-
assert(isinstance(exports[2].type, MemoryType))
148-
assert(exports[3].name == 'table')
149-
assert(isinstance(exports[3].type, TableType))
150-
151114
def test_serialize(self):
152115
engine = Engine()
153116
module = Module(engine, '(module)')

tests/test_module_linking.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

wasmtime/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ._engine import Engine
1919
from ._store import Store, Storelike
2020
from ._types import FuncType, GlobalType, MemoryType, TableType
21-
from ._types import ValType, Limits, ImportType, ExportType, ModuleType, InstanceType
21+
from ._types import ValType, Limits, ImportType, ExportType
2222
from ._wat2wasm import wat2wasm
2323
from ._module import Module
2424
from ._value import Val, IntoVal

wasmtime/_bindings.py

Lines changed: 20 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,12 +2035,6 @@ def wasmtime_config_wasm_multi_value_set(arg0: Any, arg1: Any) -> None:
20352035
def wasmtime_config_wasm_multi_memory_set(arg0: Any, arg1: Any) -> None:
20362036
return _wasmtime_config_wasm_multi_memory_set(arg0, arg1) # type: ignore
20372037

2038-
_wasmtime_config_wasm_module_linking_set = dll.wasmtime_config_wasm_module_linking_set
2039-
_wasmtime_config_wasm_module_linking_set.restype = None
2040-
_wasmtime_config_wasm_module_linking_set.argtypes = [POINTER(wasm_config_t), c_bool]
2041-
def wasmtime_config_wasm_module_linking_set(arg0: Any, arg1: Any) -> None:
2042-
return _wasmtime_config_wasm_module_linking_set(arg0, arg1) # type: ignore
2043-
20442038
_wasmtime_config_wasm_memory64_set = dll.wasmtime_config_wasm_memory64_set
20452039
_wasmtime_config_wasm_memory64_set.restype = None
20462040
_wasmtime_config_wasm_memory64_set.argtypes = [POINTER(wasm_config_t), c_bool]
@@ -2101,41 +2095,6 @@ def wasmtime_config_cache_config_load(arg0: Any, arg1: Any) -> pointer:
21012095
def wasmtime_engine_increment_epoch(engine: Any) -> None:
21022096
return _wasmtime_engine_increment_epoch(engine) # type: ignore
21032097

2104-
class wasmtime_moduletype(Structure):
2105-
pass
2106-
2107-
wasmtime_moduletype_t = wasmtime_moduletype
2108-
2109-
_wasmtime_moduletype_delete = dll.wasmtime_moduletype_delete
2110-
_wasmtime_moduletype_delete.restype = None
2111-
_wasmtime_moduletype_delete.argtypes = [POINTER(wasmtime_moduletype_t)]
2112-
def wasmtime_moduletype_delete(ty: Any) -> None:
2113-
return _wasmtime_moduletype_delete(ty) # type: ignore
2114-
2115-
_wasmtime_moduletype_imports = dll.wasmtime_moduletype_imports
2116-
_wasmtime_moduletype_imports.restype = None
2117-
_wasmtime_moduletype_imports.argtypes = [POINTER(wasmtime_moduletype_t), POINTER(wasm_importtype_vec_t)]
2118-
def wasmtime_moduletype_imports(arg0: Any, out: Any) -> None:
2119-
return _wasmtime_moduletype_imports(arg0, out) # type: ignore
2120-
2121-
_wasmtime_moduletype_exports = dll.wasmtime_moduletype_exports
2122-
_wasmtime_moduletype_exports.restype = None
2123-
_wasmtime_moduletype_exports.argtypes = [POINTER(wasmtime_moduletype_t), POINTER(wasm_exporttype_vec_t)]
2124-
def wasmtime_moduletype_exports(arg0: Any, out: Any) -> None:
2125-
return _wasmtime_moduletype_exports(arg0, out) # type: ignore
2126-
2127-
_wasmtime_moduletype_as_externtype = dll.wasmtime_moduletype_as_externtype
2128-
_wasmtime_moduletype_as_externtype.restype = POINTER(wasm_externtype_t)
2129-
_wasmtime_moduletype_as_externtype.argtypes = [POINTER(wasmtime_moduletype_t)]
2130-
def wasmtime_moduletype_as_externtype(arg0: Any) -> pointer:
2131-
return _wasmtime_moduletype_as_externtype(arg0) # type: ignore
2132-
2133-
_wasmtime_externtype_as_moduletype = dll.wasmtime_externtype_as_moduletype
2134-
_wasmtime_externtype_as_moduletype.restype = POINTER(wasmtime_moduletype_t)
2135-
_wasmtime_externtype_as_moduletype.argtypes = [POINTER(wasm_externtype_t)]
2136-
def wasmtime_externtype_as_moduletype(arg0: Any) -> pointer:
2137-
return _wasmtime_externtype_as_moduletype(arg0) # type: ignore
2138-
21392098
class wasmtime_module(Structure):
21402099
pass
21412100

@@ -2159,18 +2118,24 @@ def wasmtime_module_delete(m: Any) -> None:
21592118
def wasmtime_module_clone(m: Any) -> pointer:
21602119
return _wasmtime_module_clone(m) # type: ignore
21612120

2121+
_wasmtime_module_imports = dll.wasmtime_module_imports
2122+
_wasmtime_module_imports.restype = None
2123+
_wasmtime_module_imports.argtypes = [POINTER(wasmtime_module_t), POINTER(wasm_importtype_vec_t)]
2124+
def wasmtime_module_imports(module: Any, out: Any) -> None:
2125+
return _wasmtime_module_imports(module, out) # type: ignore
2126+
2127+
_wasmtime_module_exports = dll.wasmtime_module_exports
2128+
_wasmtime_module_exports.restype = None
2129+
_wasmtime_module_exports.argtypes = [POINTER(wasmtime_module_t), POINTER(wasm_exporttype_vec_t)]
2130+
def wasmtime_module_exports(module: Any, out: Any) -> None:
2131+
return _wasmtime_module_exports(module, out) # type: ignore
2132+
21622133
_wasmtime_module_validate = dll.wasmtime_module_validate
21632134
_wasmtime_module_validate.restype = POINTER(wasmtime_error_t)
21642135
_wasmtime_module_validate.argtypes = [POINTER(wasm_engine_t), POINTER(c_uint8), c_size_t]
21652136
def wasmtime_module_validate(engine: Any, wasm: Any, wasm_len: Any) -> pointer:
21662137
return _wasmtime_module_validate(engine, wasm, wasm_len) # type: ignore
21672138

2168-
_wasmtime_module_type = dll.wasmtime_module_type
2169-
_wasmtime_module_type.restype = POINTER(wasmtime_moduletype_t)
2170-
_wasmtime_module_type.argtypes = [POINTER(wasmtime_module_t)]
2171-
def wasmtime_module_type(arg0: Any) -> pointer:
2172-
return _wasmtime_module_type(arg0) # type: ignore
2173-
21742139
_wasmtime_module_serialize = dll.wasmtime_module_serialize
21752140
_wasmtime_module_serialize.restype = POINTER(wasmtime_error_t)
21762141
_wasmtime_module_serialize.argtypes = [POINTER(wasmtime_module_t), POINTER(wasm_byte_vec_t)]
@@ -2295,16 +2260,6 @@ class wasmtime_memory(Structure):
22952260

22962261
wasmtime_memory_t = wasmtime_memory
22972262

2298-
class wasmtime_instance(Structure):
2299-
_fields_ = [
2300-
("store_id", c_uint64),
2301-
("index", c_size_t),
2302-
]
2303-
store_id: int
2304-
index: int
2305-
2306-
wasmtime_instance_t = wasmtime_instance
2307-
23082263
class wasmtime_global(Structure):
23092264
_fields_ = [
23102265
("store_id", c_uint64),
@@ -2323,15 +2278,11 @@ class wasmtime_extern_union(Union):
23232278
("global_", wasmtime_global_t),
23242279
("table", wasmtime_table_t),
23252280
("memory", wasmtime_memory_t),
2326-
("instance", wasmtime_instance_t),
2327-
("module", POINTER(wasmtime_module_t)),
23282281
]
23292282
func: wasmtime_func_t
23302283
global_: wasmtime_global_t
23312284
table: wasmtime_table_t
23322285
memory: wasmtime_memory_t
2333-
instance: wasmtime_instance_t
2334-
module: pointer
23352286

23362287
wasmtime_extern_union_t = wasmtime_extern_union
23372288

@@ -2551,47 +2502,22 @@ def wasmtime_global_get(store: Any, arg1: Any, out: Any) -> None:
25512502
def wasmtime_global_set(store: Any, arg1: Any, val: Any) -> pointer:
25522503
return _wasmtime_global_set(store, arg1, val) # type: ignore
25532504

2554-
class wasmtime_instancetype(Structure):
2555-
pass
2556-
2557-
wasmtime_instancetype_t = wasmtime_instancetype
2558-
2559-
_wasmtime_instancetype_delete = dll.wasmtime_instancetype_delete
2560-
_wasmtime_instancetype_delete.restype = None
2561-
_wasmtime_instancetype_delete.argtypes = [POINTER(wasmtime_instancetype_t)]
2562-
def wasmtime_instancetype_delete(ty: Any) -> None:
2563-
return _wasmtime_instancetype_delete(ty) # type: ignore
2564-
2565-
_wasmtime_instancetype_exports = dll.wasmtime_instancetype_exports
2566-
_wasmtime_instancetype_exports.restype = None
2567-
_wasmtime_instancetype_exports.argtypes = [POINTER(wasmtime_instancetype_t), POINTER(wasm_exporttype_vec_t)]
2568-
def wasmtime_instancetype_exports(arg0: Any, out: Any) -> None:
2569-
return _wasmtime_instancetype_exports(arg0, out) # type: ignore
2570-
2571-
_wasmtime_instancetype_as_externtype = dll.wasmtime_instancetype_as_externtype
2572-
_wasmtime_instancetype_as_externtype.restype = POINTER(wasm_externtype_t)
2573-
_wasmtime_instancetype_as_externtype.argtypes = [POINTER(wasmtime_instancetype_t)]
2574-
def wasmtime_instancetype_as_externtype(arg0: Any) -> pointer:
2575-
return _wasmtime_instancetype_as_externtype(arg0) # type: ignore
2505+
class wasmtime_instance(Structure):
2506+
_fields_ = [
2507+
("store_id", c_uint64),
2508+
("index", c_size_t),
2509+
]
2510+
store_id: int
2511+
index: int
25762512

2577-
_wasmtime_externtype_as_instancetype = dll.wasmtime_externtype_as_instancetype
2578-
_wasmtime_externtype_as_instancetype.restype = POINTER(wasmtime_instancetype_t)
2579-
_wasmtime_externtype_as_instancetype.argtypes = [POINTER(wasm_externtype_t)]
2580-
def wasmtime_externtype_as_instancetype(arg0: Any) -> pointer:
2581-
return _wasmtime_externtype_as_instancetype(arg0) # type: ignore
2513+
wasmtime_instance_t = wasmtime_instance
25822514

25832515
_wasmtime_instance_new = dll.wasmtime_instance_new
25842516
_wasmtime_instance_new.restype = POINTER(wasmtime_error_t)
25852517
_wasmtime_instance_new.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_module_t), POINTER(wasmtime_extern_t), c_size_t, POINTER(wasmtime_instance_t), POINTER(POINTER(wasm_trap_t))]
25862518
def wasmtime_instance_new(store: Any, module: Any, imports: Any, nimports: Any, instance: Any, trap: Any) -> pointer:
25872519
return _wasmtime_instance_new(store, module, imports, nimports, instance, trap) # type: ignore
25882520

2589-
_wasmtime_instance_type = dll.wasmtime_instance_type
2590-
_wasmtime_instance_type.restype = POINTER(wasmtime_instancetype_t)
2591-
_wasmtime_instance_type.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_instance_t)]
2592-
def wasmtime_instance_type(store: Any, instance: Any) -> pointer:
2593-
return _wasmtime_instance_type(store, instance) # type: ignore
2594-
25952521
_wasmtime_instance_export_get = dll.wasmtime_instance_export_get
25962522
_wasmtime_instance_export_get.restype = c_bool
25972523
_wasmtime_instance_export_get.argtypes = [POINTER(wasmtime_context_t), POINTER(wasmtime_instance_t), POINTER(c_char), c_size_t, POINTER(wasmtime_extern_t)]

wasmtime/_config.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,6 @@ def wasm_multi_value(self, enable: bool) -> None:
9494
raise TypeError('expected a bool')
9595
ffi.wasmtime_config_wasm_multi_value_set(self._ptr, enable)
9696

97-
@setter_property
98-
def wasm_module_linking(self, enable: bool) -> None:
99-
"""
100-
Configures whether the wasm [module linking proposal] is enabled.
101-
102-
[module linking proposal]: https://github.com/webassembly/module-linking
103-
"""
104-
105-
if not isinstance(enable, bool):
106-
raise TypeError('expected a bool')
107-
ffi.wasmtime_config_wasm_module_linking_set(self._ptr, enable)
108-
10997
@setter_property
11098
def wasm_multi_memory(self, enable: bool) -> None:
11199
"""

wasmtime/_instance.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from . import _ffi as ffi
22
from ctypes import POINTER, byref
3-
from wasmtime import Module, WasmtimeError, Store, InstanceType
3+
from wasmtime import Module, WasmtimeError
44
from ._extern import wrap_extern, get_extern_ptr
55
from ._exportable import AsExtern
66
from typing import Sequence, Union, Optional, Mapping, Iterable
@@ -51,14 +51,6 @@ def _from_raw(cls, instance: ffi.wasmtime_instance_t) -> "Instance":
5151
ty._instance = instance
5252
return ty
5353

54-
def type(self, store: Store) -> InstanceType:
55-
"""
56-
Gets the type of this instance as an `InstanceType`
57-
"""
58-
59-
ptr = ffi.wasmtime_instance_type(store._context, byref(self._instance))
60-
return InstanceType._from_ptr(ptr, None)
61-
6254
def exports(self, store: Storelike) -> "InstanceExports":
6355
"""
6456
Returns the exports of this module

0 commit comments

Comments
 (0)