Skip to content

Commit 8b281f5

Browse files
committed
modernize code
1 parent 49f8f1e commit 8b281f5

5 files changed

Lines changed: 75 additions & 81 deletions

File tree

Cargo.lock

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

crates/core/src/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ impl<'a, B: Bindgen> Generator<'a, B> {
17721772
}
17731773
TypeDefKind::Unknown => unreachable!(),
17741774
TypeDefKind::FixedSizeList(ty, size) => {
1775-
let temp = flat_types(self.resolve, ty).unwrap();
1775+
let temp = flat_types(self.resolve, ty, None).unwrap();
17761776
let flat_per_elem = temp.to_vec().len();
17771777
let flatsize = flat_per_elem * (*size as usize);
17781778
let mut lowered_args = self

crates/csharp/src/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ impl Bindgen for FunctionBindgen<'_, '_> {
13931393
| Instruction::DropHandle { .. }
13941394
| Instruction::FixedSizeListLift { .. }
13951395
| Instruction::FixedSizeListLower { .. }
1396-
| Instruction::FixedSizeListLowerBlock { .. }
1396+
| Instruction::FixedSizeListLowerMemory { .. }
13971397
=> {
13981398
dbg!(inst);
13991399
todo!()

tests/runtime/fixed-size-list/runner.rs

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,71 @@ include!(env!("BINDINGS"));
22

33
use test::fixed_size_lists::to_test::*;
44

5-
fn main() {
6-
list_param([1, 2, 3, 4]);
7-
list_param2([[1, 2], [3, 4]]);
8-
list_param3([
9-
-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20,
10-
]);
11-
{
12-
let result = list_result();
13-
assert_eq!(result, [b'0', b'1', b'A', b'B', b'a', b'b', 128, 255]);
14-
}
15-
{
16-
let result = list_minmax16([0, 1024, 32768, 65535], [1, 2048, -32767, -2]);
17-
assert_eq!(result, ([0, 1024, 32768, 65535], [1, 2048, -32767, -2]));
18-
}
19-
{
20-
let result = list_minmax_float([2.0, -42.0], [0.25, -0.125]);
21-
assert_eq!(result, ([2.0, -42.0], [0.25, -0.125]));
22-
}
23-
{
24-
let result = list_roundtrip([b'a', b'b', b'c', b'd', 0, 1, 2, 3, b'A', b'B', b'Y', b'Z']);
25-
assert_eq!(
26-
result,
27-
[b'a', b'b', b'c', b'd', 0, 1, 2, 3, b'A', b'B', b'Y', b'Z']
28-
);
29-
}
30-
{
31-
let result = nested_roundtrip([[1, 5], [42, 1_000_000]], [[-1, 3], [-2_000_000, 4711]]);
32-
assert_eq!(
33-
result,
34-
([[1, 5], [42, 1_000_000]], [[-1, 3], [-2_000_000, 4711]])
35-
);
36-
}
37-
{
38-
let result = large_roundtrip(
39-
[[1, 5], [42, 1_000_000]],
40-
[
41-
[-1, 3, -2, 4],
42-
[-2_000_000, 4711, 99_999, -5],
43-
[-6, 7, 8, -9],
44-
[50, -5, 500, -5000],
45-
],
46-
);
47-
assert_eq!(
48-
result,
49-
(
5+
struct Component;
6+
7+
export!(Component);
8+
9+
impl Guest for Component {
10+
fn run() {
11+
list_param([1, 2, 3, 4]);
12+
list_param2([[1, 2], [3, 4]]);
13+
list_param3([
14+
-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20,
15+
]);
16+
{
17+
let result = list_result();
18+
assert_eq!(result, [b'0', b'1', b'A', b'B', b'a', b'b', 128, 255]);
19+
}
20+
{
21+
let result = list_minmax16([0, 1024, 32768, 65535], [1, 2048, -32767, -2]);
22+
assert_eq!(result, ([0, 1024, 32768, 65535], [1, 2048, -32767, -2]));
23+
}
24+
{
25+
let result = list_minmax_float([2.0, -42.0], [0.25, -0.125]);
26+
assert_eq!(result, ([2.0, -42.0], [0.25, -0.125]));
27+
}
28+
{
29+
let result =
30+
list_roundtrip([b'a', b'b', b'c', b'd', 0, 1, 2, 3, b'A', b'B', b'Y', b'Z']);
31+
assert_eq!(
32+
result,
33+
[b'a', b'b', b'c', b'd', 0, 1, 2, 3, b'A', b'B', b'Y', b'Z']
34+
);
35+
}
36+
{
37+
let result = nested_roundtrip([[1, 5], [42, 1_000_000]], [[-1, 3], [-2_000_000, 4711]]);
38+
assert_eq!(
39+
result,
40+
([[1, 5], [42, 1_000_000]], [[-1, 3], [-2_000_000, 4711]])
41+
);
42+
}
43+
{
44+
let result = large_roundtrip(
5045
[[1, 5], [42, 1_000_000]],
5146
[
5247
[-1, 3, -2, 4],
5348
[-2_000_000, 4711, 99_999, -5],
5449
[-6, 7, 8, -9],
55-
[50, -5, 500, -5000]
56-
]
57-
)
58-
);
59-
}
60-
{
61-
let result = nightmare_on_cpp([Nested { l: [1, -1] }, Nested { l: [2, -2] }]);
62-
assert_eq!(result[0].l, [1, -1]);
63-
assert_eq!(result[1].l, [2, -2]);
50+
[50, -5, 500, -5000],
51+
],
52+
);
53+
assert_eq!(
54+
result,
55+
(
56+
[[1, 5], [42, 1_000_000]],
57+
[
58+
[-1, 3, -2, 4],
59+
[-2_000_000, 4711, 99_999, -5],
60+
[-6, 7, 8, -9],
61+
[50, -5, 500, -5000]
62+
]
63+
)
64+
);
65+
}
66+
{
67+
let result = nightmare_on_cpp([Nested { l: [1, -1] }, Nested { l: [2, -2] }]);
68+
assert_eq!(result[0].l, [1, -1]);
69+
assert_eq!(result[1].l, [2, -2]);
70+
}
6471
}
6572
}

tests/runtime/fixed-size-list/test.wit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ world test {
3030

3131
world runner {
3232
import to-test;
33+
34+
export run: func();
3335
}

0 commit comments

Comments
 (0)