Skip to content

Commit ed3c1a3

Browse files
committed
Update to reflect wasm-zig changes
1 parent eb2720d commit ed3c1a3

File tree

7 files changed

+14
-12
lines changed

7 files changed

+14
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ zig-cache
33
*.swp
44
.gyro
55
gyro.lock
6+
zig-out
7+
deps.zig

examples/gcd.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn main() !void {
2727
defer instance.deinit();
2828
std.debug.print("Instance initialized...\n", .{});
2929

30-
if (instance.getExportFunc("gcd")) |f| {
30+
if (instance.getExportFunc(module, "gcd")) |f| {
3131
std.debug.print("Calling export...\n", .{});
3232
const result = try f.call(i32, .{ @as(i32, 6), @as(i32, 27) });
3333
std.debug.print("Result: {d}\n", .{result});

examples/interrupt.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn main() !void {
4040

4141
const thread = try std.Thread.spawn(interrupt, handle);
4242

43-
if (instance.getExportFunc("run")) |f| {
43+
if (instance.getExportFunc(module, "run")) |f| {
4444
std.debug.print("Calling export...\n", .{});
4545
f.call(void, .{}) catch |err| switch (err) {
4646
error.Trap => std.debug.print("Trap was hit!\n", .{}),

examples/linking.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn main() !void {
9595
std.debug.print("Instance initialized...\n", .{});
9696
std.debug.print("Wasm linking completed...\n", .{});
9797

98-
if (instance.?.getExportFunc("run")) |f| {
98+
if (instance.?.getExportFunc(module.inner, "run")) |f| {
9999
std.debug.print("Calling export...\n", .{});
100100
try f.call(void, .{});
101101
} else {

examples/memory.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ pub fn main() !void {
2828
defer instance.deinit();
2929
std.debug.print("Instance initialized...\n", .{});
3030

31-
const memory = instance.getExportMem("memory").?;
31+
const memory = instance.getExportMem(module, "memory").?;
3232
defer memory.deinit();
3333

34-
const size_func = instance.getExportFunc("size").?;
35-
const load_func = instance.getExportFunc("load").?;
36-
const store_func = instance.getExportFunc("store").?;
34+
const size_func = instance.getExportFunc(module, "size").?;
35+
const load_func = instance.getExportFunc(module, "load").?;
36+
const store_func = instance.getExportFunc(module, "store").?;
3737

3838
// verify initial memory
3939
assert(memory.pages() == 2);

examples/simple.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn main() !void {
3535
defer instance.deinit();
3636
std.debug.print("Instance initialized...\n", .{});
3737

38-
if (instance.getExportFunc("run")) |f| {
38+
if (instance.getExportFunc(module, "run")) |f| {
3939
std.debug.print("Calling export...\n", .{});
4040
try f.call(void, .{});
4141
} else {

src/main.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ pub const Instance = struct {
272272
};
273273
}
274274

275-
pub fn getExportFunc(self: Instance, name: []const u8) ?Func {
276-
var inner = self.inner.getExportFunc(name) orelse return null;
275+
pub fn getExportFunc(self: Instance, module: Module, name: []const u8) ?Func {
276+
var inner = self.inner.getExportFunc(module.inner, name) orelse return null;
277277
return Func{ .inner = inner };
278278
}
279279

280-
pub fn getExportMem(self: Instance, name: []const u8) ?*Memory {
281-
return self.inner.getExportMem(name);
280+
pub fn getExportMem(self: Instance, module: Module, name: []const u8) ?*Memory {
281+
return self.inner.getExportMem(module.inner, name);
282282
}
283283

284284
pub fn deinit(self: Instance) void {

0 commit comments

Comments
 (0)