blob: ea041925f9ef64d25833159cddbe3c0e70488c7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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();
}
}
};
}
|