From 8dd8f96b24710dc4f2d29065928244a40a432379 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Mon, 26 Oct 2026 16:00:59 +0100 Subject: zilch: update App structure and split-up document and wasm logic --- src/zilch/app/root.wasm.zig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/zilch/app/root.wasm.zig (limited to 'src/zilch/app/root.wasm.zig') diff --git a/src/zilch/app/root.wasm.zig b/src/zilch/app/root.wasm.zig new file mode 100644 index 0000000..ea04192 --- /dev/null +++ b/src/zilch/app/root.wasm.zig @@ -0,0 +1,36 @@ +const std = @import("std"); + +const Options = @import("Options.zig"); + +pub fn App(comptime options: Options) type { + var names: [options.globals.len][]const u8 = undefined; + var types: [options.globals.len]type = undefined; + var attrs: [options.globals.len]std.builtin.Type.StructField.Attributes = undefined; + + for (options.globals, 0..) |field, index| { + names[index] = field.name; + types[index] = field.type; + attrs[index] = .{}; + } + + const G = @Struct(.auto, null, &names, &types, &attrs); + return struct { + globals: G = g: { + var gl: G = undefined; + + for (options.globals, 1..) |field, id| { + @field(gl, field.name) = @ptrFromInt(id); + } + + break :g gl; + }, + + pub const init: @This() = .{}; + + comptime { + for (options.components) |component| { + component.exportLinks(); + } + } + }; +} -- cgit v1.2.3-70-g09d2