Skip to content

Commit

Permalink
docs(wasm-api-schedule): update readme (callconv, code examples)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 22, 2024
1 parent de8f1c9 commit 5198927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/wasm-api-schedule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const schedule = @import("wasm-api-schedule");
try schedule.init(customAllocator);
// user callback function
fn exampleCallback(raw: ?*anyopaque) void {
fn exampleCallback(raw: ?*anyopaque) callconv(.C) void {
if (wasm.ptrCast(*u32, raw)) |state| {
// do something ...
}
Expand All @@ -72,6 +72,10 @@ const listenerID = try schedule.schedule(
schedule.cancel(listenerID);
```

**IMPORTANT: In Zig v0.12+ all event handlers must explicitly specify
`callconv(.C)`** [See docs for more
reference](https://docs.thi.ng/umbrella/wasm-api-bindgen/interfaces/FuncPointer.html).

Also see the
[zig-counter](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-counter/)
and
Expand Down
6 changes: 5 additions & 1 deletion packages/wasm-api-schedule/tpl.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const schedule = @import("wasm-api-schedule");
try schedule.init(customAllocator);
// user callback function
fn exampleCallback(raw: ?*anyopaque) void {
fn exampleCallback(raw: ?*anyopaque) callconv(.C) void {
if (wasm.ptrCast(*u32, raw)) |state| {
// do something ...
}
Expand All @@ -51,6 +51,10 @@ const listenerID = try schedule.schedule(
schedule.cancel(listenerID);
```

**IMPORTANT: In Zig v0.12+ all event handlers must explicitly specify
`callconv(.C)`** [See docs for more
reference](https://docs.thi.ng/umbrella/wasm-api-bindgen/interfaces/FuncPointer.html).

Also see the
[zig-counter](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-counter/)
and
Expand Down

0 comments on commit 5198927

Please sign in to comment.