render_blank
Function parameters
Parameters
- gpa:std.mem.Allocator
- bw:*Writer
- defines:std.StringArrayHashMap(Value)
- include_path:[]const u8
- include_guard_override:?[]const u8
Type definitions in this namespace
Types
Functions in this namespace
Functions
- getOutput
- Deprecated; use `getOutputFile`.
= .config_header
Values
- base_id
- = .config_header
Source
Implementation
fn render_blank(
gpa: std.mem.Allocator,
bw: *Writer,
defines: std.StringArrayHashMap(Value),
include_path: []const u8,
include_guard_override: ?[]const u8,
) !void {
const include_guard_name = include_guard_override orelse blk: {
const name = try gpa.dupe(u8, include_path);
for (name) |*byte| {
switch (byte.*) {
'a'...'z' => byte.* = byte.* - 'a' + 'A',
'A'...'Z', '0'...'9' => continue,
else => byte.* = '_',
}
}
break :blk name;
};
defer if (include_guard_override == null) gpa.free(include_guard_name);
try bw.print(
\\#ifndef {[0]s}
\\#define {[0]s}
\\
, .{include_guard_name});
const values = defines.values();
for (defines.keys(), 0..) |name, i| try renderValueC(bw, name, values[i]);
try bw.print(
\\#endif /* {s} */
\\
, .{include_guard_name});
}