pumpkin-api-zig/tools/testdata/expected/wit/exports.zig
MegalithOfficial 28c3e929ca
Add Zig bindings for the Pumpkin plugin API
The bindings under src/wit are generated from the pumpkin-plugin-wit
submodule by tools/gen.zig. The canonical ABI is handled at comptime in
src/abi.zig, so plugins are plain wasm32-freestanding modules and only
need wasm-tools to become a component.

On top of that there is a small hand written layer: plugin registration,
typed event handlers, declarative commands (cmd), text components from
struct literals (msg) and std.log support.
2026-09-19 17:46:24 +02:00

60 lines
2.0 KiB
Zig

// Generated by tools/gen.zig, do not edit.
const std = @import("std");
const abi = @import("../abi.zig");
const host = @import("host.zig");
const types = @import("types.zig");
const guest = @import("guest.zig");
pub fn start(comptime impl: fn (host.Canvas) abi.Result(void, []const u8)) void {
const glue = struct {
fn call(p0: i32) callconv(.c) i32 {
const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{p0});
return abi.lowerReturn(abi.Result(void, []const u8), @call(.auto, impl, args));
}
fn post(_: i32) callconv(.c) void {
abi.endCall();
}
};
@export(&glue.call, .{ .name = "start" });
@export(&glue.post, .{ .name = "cabi_post_start" });
}
pub fn measure(comptime impl: fn (types.Shape, types.Pair) f32) void {
const glue = struct {
fn call(p0: i32, p1: i32, p2: i32, p3: i32, p4: f64) callconv(.c) f32 {
const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{ p0, p1, p2, p3, p4 });
defer abi.endCall();
return abi.lowerReturn(f32, @call(.auto, impl, args));
}
};
@export(&glue.call, .{ .name = "measure" });
}
pub fn stop(comptime impl: fn () void) void {
const glue = struct {
fn call() callconv(.c) void {
const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{});
defer abi.endCall();
return abi.lowerReturn(void, @call(.auto, impl, args));
}
};
@export(&glue.call, .{ .name = "stop" });
}
pub fn describe(comptime impl: fn () guest.Point) void {
const glue = struct {
fn call() callconv(.c) i32 {
const args = abi.liftArgs(std.meta.ArgsTuple(@TypeOf(impl)), .{});
return abi.lowerReturn(guest.Point, @call(.auto, impl, args));
}
fn post(_: i32) callconv(.c) void {
abi.endCall();
}
};
@export(&glue.call, .{ .name = "demo:gen/guest@1.2.0#describe" });
@export(&glue.post, .{ .name = "cabi_post_demo:gen/guest@1.2.0#describe" });
}