Skip to content

Commit 904de66

Browse files
committed
feat: Update code to Pyo3 0.14.
1 parent fec0d80 commit 904de66

28 files changed

+204
-191
lines changed

Cargo.lock

Lines changed: 91 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/wasmer/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ <h2 id="example">Example</h2>
135135
<pre><code class="language-py">from wasmer import Memory, MemoryType, Store
136136

137137
store = Store()
138-
memory = Memory(store, MemoryType(128, shared=False))
138+
memory = Memory(store, MemoryType(minimum=128))
139139

140140
# Let's write data with a `Int8Array` view for example.
141141
int8 = memory.int8_view()
@@ -579,7 +579,7 @@ <h2 id="example">Example</h2>
579579
&quot;&quot;&quot;
580580
)
581581

582-
memory = Memory(store, MemoryType(1, shared=False))
582+
memory = Memory(store, MemoryType(minimum=1))
583583
view = memory.uint8_view(offset=0)
584584

585585
import_object = ImportObject()
@@ -668,7 +668,7 @@ <h2 id="example">Example</h2>
668668
&quot;env&quot;,
669669
{
670670
&quot;sum&quot;: Function(store, sum),
671-
&quot;memory&quot;: Memory(store, MemoryType(1, shared=False))
671+
&quot;memory&quot;: Memory(store, MemoryType(minimum=1))
672672
}
673673
)
674674
</code></pre></div>
@@ -964,7 +964,7 @@ <h2 id="example">Example</h2>
964964
<pre><code class="language-py">from wasmer import Store, Memory, MemoryType
965965

966966
store = Store()
967-
memory_type = MemoryType(3, shared=False)
967+
memory_type = MemoryType(minimum=3)
968968
memory = Memory(store, memory_type)
969969

970970
assert memory.size == 3
@@ -989,7 +989,7 @@ <h2 id="example">Example</h2>
989989
<pre><code class="language-py">from wasmer import Store, Memory, MemoryType, Buffer
990990

991991
store = Store()
992-
memory_type = MemoryType(3, shared=False)
992+
memory_type = MemoryType(minimum=3)
993993
memory = Memory(store, memory_type)
994994

995995
assert isinstance(memory.buffer, Buffer)
@@ -1002,7 +1002,7 @@ <h2 id="example">Example</h2>
10021002
<pre><code class="language-py">from wasmer import Store, Memory, MemoryType
10031003

10041004
store = Store()
1005-
memory_type = MemoryType(3, shared=False)
1005+
memory_type = MemoryType(minimum=3)
10061006
memory = Memory(store, memory_type)
10071007

10081008
assert memory.data_size == 196608
@@ -1015,7 +1015,7 @@ <h2 id="example">Example</h2>
10151015
<pre><code class="language-py">from wasmer import Store, Memory, MemoryType
10161016

10171017
store = Store()
1018-
memory_type = MemoryType(3, shared=False)
1018+
memory_type = MemoryType(minimum=3)
10191019
memory = Memory(store, memory_type)
10201020

10211021
assert memory.size == 3
@@ -1049,7 +1049,7 @@ <h2 id="example">Example</h2>
10491049
<pre><code class="language-py">from wasmer import Store, Memory, MemoryType
10501050

10511051
store = Store()
1052-
memory_type = MemoryType(3, shared=False)
1052+
memory_type = MemoryType(minimum=3)
10531053
memory = Memory(store, memory_type)
10541054

10551055
assert memory.size == 3
@@ -1110,7 +1110,7 @@ <h2 id="examples">Examples</h2>
11101110
<pre><code class="language-py">from wasmer import Store, Memory, MemoryType, Uint8Array
11111111

11121112
store = Store()
1113-
memory_type = MemoryType(3, shared=False)
1113+
memory_type = MemoryType(minimum=3)
11141114
memory = Memory(store, memory_type)
11151115

11161116
assert isinstance(memory.uint8_view(offset=42), Uint8Array)
@@ -1120,7 +1120,7 @@ <h2 id="examples">Examples</h2>
11201120
</dd>
11211121
<dt id="wasmer.MemoryType"><code class="flex name class">
11221122
<span>class <span class="ident">MemoryType</span></span>
1123-
<span>(</span><span>minimum, maximum, shared)</span>
1123+
<span>(</span><span>minimum, /, maximum, shared)</span>
11241124
</code></dt>
11251125
<dd>
11261126
<div class="desc"><p>A descriptor for a WebAssembly memory type.</p>

packages/api/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ crate-type = ["cdylib"]
1717

1818
[dependencies]
1919
wasmer = { version = "2.0", default-features = false, features = ["wat", "universal", "dylib", "compiler"] }
20-
wasmer_engines = { path = "../engines/" }
20+
wasmer-engines = { path = "../engines/" }
2121
wasmer-types = "2.0"
2222
wasmer-wasi = "2.0"
2323
pyo3 = { version = "0.14", features = ["extension-module"] }
2424
wat = "1.0"
2525
wasmprinter = "0.2"
2626
cfg-if = "1.0"
2727

28+
[build-dependencies]
29+
pyo3-build-config = "0.14"
30+
2831
[package.metadata.maturin]
2932
classifier = [
3033
"Programming Language :: Python",

packages/api/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ fn main() {
33
"cargo:rustc-env=WASMER_VERSION={}",
44
env!("CARGO_PKG_VERSION")
55
);
6+
pyo3_build_config::add_extension_module_link_args();
67
}

packages/api/src/engines.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pub use wasmer_engines::{Dylib, Universal};
1+
pub use crate::wasmer_inner::wasmer_engines::{Dylib, Universal};
22
// Deprecated engines.
3-
pub use wasmer_engines::{Native, JIT};
3+
pub use crate::wasmer_inner::wasmer_engines::{Native, JIT};

packages/api/src/externals/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use std::{io, sync::Arc};
9191
/// function = Function(store, sum, FunctionType([Type.I32, Type.I32], [Type.I32]))
9292
/// ```
9393
#[pyclass(unsendable)]
94-
#[text_signature = "(store, function, function_type)"]
94+
#[pyo3(text_signature = "(store, function, function_type)")]
9595
pub struct Function {
9696
inner: wasmer::Function,
9797
}

packages/api/src/externals/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use pyo3::{
3939
/// assert global_.mutable == True
4040
/// ```
4141
#[pyclass(unsendable)]
42-
#[text_signature = "(store, value, mutable)"]
42+
#[pyo3(text_signature = "(store, value, mutable)")]
4343
pub struct Global {
4444
inner: wasmer::Global,
4545
}

packages/api/src/externals/memory.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use pyo3::{exceptions::PyRuntimeError, prelude::*};
3131
/// from wasmer import Store, Memory, MemoryType
3232
///
3333
/// store = Store()
34-
/// memory_type = MemoryType(3, shared=False)
34+
/// memory_type = MemoryType(minimum=3)
3535
/// memory = Memory(store, memory_type)
3636
///
3737
/// assert memory.size == 3
@@ -50,7 +50,7 @@ use pyo3::{exceptions::PyRuntimeError, prelude::*};
5050
/// assert isinstance(memory, Memory)
5151
/// ```
5252
#[pyclass(unsendable)]
53-
#[text_signature = "(store, memory_type)"]
53+
#[pyo3(text_signature = "(store, memory_type)")]
5454
pub struct Memory {
5555
inner: wasmer::Memory,
5656
}
@@ -83,7 +83,7 @@ impl Memory {
8383
/// from wasmer import Store, Memory, MemoryType
8484
///
8585
/// store = Store()
86-
/// memory_type = MemoryType(3, shared=False)
86+
/// memory_type = MemoryType(minimum=3)
8787
/// memory = Memory(store, memory_type)
8888
///
8989
/// assert memory.size == 3
@@ -101,7 +101,7 @@ impl Memory {
101101
/// from wasmer import Store, Memory, MemoryType
102102
///
103103
/// store = Store()
104-
/// memory_type = MemoryType(3, shared=False)
104+
/// memory_type = MemoryType(minimum=3)
105105
/// memory = Memory(store, memory_type)
106106
///
107107
/// assert memory.data_size == 196608
@@ -119,7 +119,7 @@ impl Memory {
119119
/// from wasmer import Store, Memory, MemoryType
120120
///
121121
/// store = Store()
122-
/// memory_type = MemoryType(3, shared=False)
122+
/// memory_type = MemoryType(minimum=3)
123123
/// memory = Memory(store, memory_type)
124124
///
125125
/// assert memory.size == 3
@@ -128,7 +128,7 @@ impl Memory {
128128
///
129129
/// assert memory.size == 5
130130
/// ```
131-
#[text_signature = "($self, number_of_pages)"]
131+
#[pyo3(text_signature = "($self, number_of_pages)")]
132132
fn grow(&self, number_of_pages: u32) -> PyResult<u32> {
133133
self.inner
134134
.grow(number_of_pages)
@@ -145,7 +145,7 @@ impl Memory {
145145
/// from wasmer import Store, Memory, MemoryType, Buffer
146146
///
147147
/// store = Store()
148-
/// memory_type = MemoryType(3, shared=False)
148+
/// memory_type = MemoryType(minimum=3)
149149
/// memory = Memory(store, memory_type)
150150
///
151151
/// assert isinstance(memory.buffer, Buffer)
@@ -165,12 +165,12 @@ impl Memory {
165165
/// from wasmer import Store, Memory, MemoryType, Uint8Array
166166
///
167167
/// store = Store()
168-
/// memory_type = MemoryType(3, shared=False)
168+
/// memory_type = MemoryType(minimum=3)
169169
/// memory = Memory(store, memory_type)
170170
///
171171
/// assert isinstance(memory.uint8_view(offset=42), Uint8Array)
172172
/// ```
173-
#[text_signature = "($self, /, offset=0)"]
173+
#[pyo3(text_signature = "($self, /, offset=0)")]
174174
#[args(offset = 0)]
175175
fn uint8_view(&self, offset: usize) -> Uint8Array {
176176
Uint8Array {
@@ -182,7 +182,7 @@ impl Memory {
182182
/// Creates a read-and-write over the memory data where elements
183183
/// are of kind `int8`. See the `Int8Array` view to learn more,
184184
/// and the `Memory.uint8_view` method to see an example.
185-
#[text_signature = "($self, /, offset=0)"]
185+
#[pyo3(text_signature = "($self, /, offset=0)")]
186186
#[args(offset = 0)]
187187
fn int8_view(&self, offset: usize) -> Int8Array {
188188
Int8Array {
@@ -194,7 +194,7 @@ impl Memory {
194194
/// Creates a read-and-write over the memory data where elements
195195
/// are of kind `uint16`. See the `Uint16Array` view to learn
196196
/// more, and the `Memory.uint8_view` method to see an example.
197-
#[text_signature = "($self, /, offset=0)"]
197+
#[pyo3(text_signature = "($self, /, offset=0)")]
198198
#[args(offset = 0)]
199199
fn uint16_view(&self, offset: usize) -> Uint16Array {
200200
Uint16Array {
@@ -206,7 +206,7 @@ impl Memory {
206206
/// Creates a read-and-write over the memory data where elements
207207
/// are of kind `int16`. See the `Int16Array` view to learn more,
208208
/// and the `Memory.uint8_view` method to see an example.
209-
#[text_signature = "($self, /, offset=0)"]
209+
#[pyo3(text_signature = "($self, /, offset=0)")]
210210
#[args(offset = 0)]
211211
fn int16_view(&self, offset: usize) -> Int16Array {
212212
Int16Array {
@@ -218,7 +218,7 @@ impl Memory {
218218
/// Creates a read-and-write over the memory data where elements
219219
/// are of kind `uint32`. See the `Uint32Array` view to learn
220220
/// more, and the `Memory.uint8_view` method to see an example.
221-
#[text_signature = "($self, /, offset=0)"]
221+
#[pyo3(text_signature = "($self, /, offset=0)")]
222222
#[args(offset = 0)]
223223
fn uint32_view(&self, offset: usize) -> Uint32Array {
224224
Uint32Array {
@@ -230,7 +230,7 @@ impl Memory {
230230
/// Creates a read-and-write over the memory data where elements
231231
/// are of kind `int32`. See the `Int32Array` view to learn more,
232232
/// and the `Memory.uint8_view` method to see an example.
233-
#[text_signature = "($self, /, offset=0)"]
233+
#[pyo3(text_signature = "($self, /, offset=0)")]
234234
#[args(offset = 0)]
235235
fn int32_view(&self, offset: usize) -> Int32Array {
236236
Int32Array {

packages/api/src/externals/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use pyo3::{exceptions::PyRuntimeError, prelude::*};
1313
///
1414
/// Specification: https://webassembly.github.io/spec/core/exec/runtime.html#table-instances
1515
#[pyclass(unsendable)]
16-
#[text_signature = "(store, table_type, initial_value)"]
16+
#[pyo3(text_signature = "(store, table_type, initial_value)")]
1717
pub struct Table {
1818
inner: wasmer::Table,
1919
}

packages/api/src/import_object.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use pyo3::{
7070
/// """
7171
/// )
7272
///
73-
/// memory = Memory(store, MemoryType(1, shared=False))
73+
/// memory = Memory(store, MemoryType(minimum=1))
7474
/// view = memory.uint8_view(offset=0)
7575
///
7676
/// import_object = ImportObject()
@@ -130,7 +130,7 @@ use pyo3::{
130130
///
131131
/// etc.
132132
#[pyclass(unsendable)]
133-
#[text_signature = "()"]
133+
#[pyo3(text_signature = "()")]
134134
pub struct ImportObject {
135135
inner: wasmer::ImportObject,
136136
}
@@ -163,7 +163,7 @@ impl ImportObject {
163163
///
164164
/// assert import_object.contains_namespace("foo") == False
165165
/// ```
166-
#[text_signature = "($self, namespace_name)"]
166+
#[pyo3(text_signature = "($self, namespace_name)")]
167167
fn contains_namespace(&self, namespace_name: &str) -> bool {
168168
self.inner.contains_namespace(namespace_name)
169169
}
@@ -186,11 +186,11 @@ impl ImportObject {
186186
/// "env",
187187
/// {
188188
/// "sum": Function(store, sum),
189-
/// "memory": Memory(store, MemoryType(1, shared=False))
189+
/// "memory": Memory(store, MemoryType(minimum=1))
190190
/// }
191191
/// )
192192
/// ```
193-
#[text_signature = "($self, namespace_name, namespace)"]
193+
#[pyo3(text_signature = "($self, namespace_name, namespace)")]
194194
fn register(&mut self, namespace_name: &str, namespace: &PyDict) -> PyResult<()> {
195195
let mut wasmer_namespace = wasmer::Exports::new();
196196

packages/api/src/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use pyo3::{exceptions::PyRuntimeError, prelude::*};
8383
/// assert instance.exports.add_one(41) == 42
8484
/// ```
8585
#[pyclass(unsendable)]
86-
#[text_signature = "(module, import_object)"]
86+
#[pyo3(text_signature = "(module, import_object)")]
8787
pub struct Instance {
8888
#[allow(unused)]
8989
inner: wasmer::Instance,

0 commit comments

Comments
 (0)