diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-26 16:00:59 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-26 16:00:59 +0100 |
| commit | 8dd8f96b24710dc4f2d29065928244a40a432379 (patch) | |
| tree | 192fcdbef2373a983673e929835bff64ad8edb48 /src/zilch/app/root.wasm.zig | |
| parent | feeedb0bf31314b182e7bbc135182f6e0bc859b2 (diff) | |
zilch: update App structure and split-up document and wasm logic
Diffstat (limited to 'src/zilch/app/root.wasm.zig')
| -rw-r--r-- | src/zilch/app/root.wasm.zig | 36 |
1 files changed, 36 insertions, 0 deletions
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(); + } + } + }; +} |