aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.zig
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2023-10-27 18:29:26 +0000
committers-ol <s+removethis@s-ol.nu>2023-10-29 22:43:58 +0000
commita250d5bbe6eb215e345de4900e784140dfe73161 (patch)
tree3a9f3aa116f7d0ac2faca30b6ceab6a110d6eef2 /src/config.zig
parentupdate for zig 0.9.0 (diff)
downloadglsl-view-a250d5bbe6eb215e345de4900e784140dfe73161.tar.gz
glsl-view-a250d5bbe6eb215e345de4900e784140dfe73161.zip
update for zig 0.11.0
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/config.zig b/src/config.zig
index 09008f1..166fdf4 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -52,7 +52,7 @@ pub const Config = struct {
parameters: []const ParameterConfig,
osc: OSCConfig,
- pub fn parse(allocator: *std.mem.Allocator, filename: []const u8) !Config {
+ pub fn parse(allocator: *const std.mem.Allocator, filename: []const u8) !Config {
var parser: c.yaml_parser_t = undefined;
_ = c.yaml_parser_initialize(&parser);
defer c.yaml_parser_delete(&parser);
@@ -100,12 +100,12 @@ pub const Config = struct {
} else if (std.mem.eql(u8, key, "osc")) {
config.osc = try parseOSC(&parser, allocator);
} else {
- debug.warn("unknown key: '{s}'\n", .{key});
+ debug.print("unknown key: '{s}'\n", .{key});
try skipAny(&parser);
}
},
else => {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
},
}
@@ -126,21 +126,21 @@ fn expectEvent(parser: *c.yaml_parser_t, expectedType: c.yaml_event_type_t) !voi
defer c.yaml_event_delete(&event);
if (event.type != expectedType) {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
}
}
-fn parseStringEvent(event: *c.yaml_event_t, allocator: *std.mem.Allocator) ![]const u8 {
+fn parseStringEvent(event: *c.yaml_event_t, allocator: *const std.mem.Allocator) ![]const u8 {
if (event.type != c.YAML_SCALAR_EVENT)
return error.InvalidType;
const data = event.data.scalar;
const value: []const u8 = data.value[0..data.length];
- return try std.mem.dupe(allocator, u8, value);
+ return try allocator.dupe(u8, value);
}
-fn parseString(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]const u8 {
+fn parseString(parser: *c.yaml_parser_t, allocator: *const std.mem.Allocator) ![]const u8 {
var event: c.yaml_event_t = undefined;
if (c.yaml_parser_parse(parser, &event) != 1)
return error.YAMLParserError;
@@ -200,7 +200,7 @@ fn parseBool(parser: *c.yaml_parser_t) !bool {
return std.mem.eql(u8, value, "true") or std.mem.eql(u8, value, "1");
}
-fn parseOutputs(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]OutputConfig {
+fn parseOutputs(parser: *c.yaml_parser_t, allocator: *const std.mem.Allocator) ![]OutputConfig {
try expectEvent(parser, c.YAML_SEQUENCE_START_EVENT);
var outputs = try allocator.alloc(OutputConfig, 1024);
@@ -241,12 +241,12 @@ fn parseOutputs(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]Outp
} else if (std.mem.eql(u8, key, "fullscreen")) {
output.*.fullscreen = try parseBool(parser);
} else {
- debug.warn("unknown key: '{s}'\n", .{key});
+ debug.print("unknown key: '{s}'\n", .{key});
try skipAny(parser);
}
},
else => {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
},
}
@@ -255,7 +255,7 @@ fn parseOutputs(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]Outp
output_count += 1;
},
else => {
- debug.warn("unexpected event: {}\n", .{seqEvent.type});
+ debug.print("unexpected event: {}\n", .{seqEvent.type});
return error.InvalidConfiguration;
},
}
@@ -265,7 +265,7 @@ fn parseOutputs(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]Outp
return outputs[0..output_count];
}
-fn parseParameters(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]ParameterConfig {
+fn parseParameters(parser: *c.yaml_parser_t, allocator: *const std.mem.Allocator) ![]ParameterConfig {
try expectEvent(parser, c.YAML_SEQUENCE_START_EVENT);
var parameters = try allocator.alloc(ParameterConfig, 1024);
@@ -303,26 +303,26 @@ fn parseParameters(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]P
param.*.type = try parseString(parser, allocator);
have_type = true;
} else {
- debug.warn("unknown key: '{s}'\n", .{key});
+ debug.print("unknown key: '{s}'\n", .{key});
try skipAny(parser);
}
},
else => {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
},
}
}
if (!(have_name and have_type)) {
- debug.warn("name and type are mandatory for parameters.\n", .{});
+ debug.print("name and type are mandatory for parameters.\n", .{});
return error.InvalidConfiguration;
}
param_count += 1;
},
else => {
- debug.warn("unexpected event: {}\n", .{seqEvent.type});
+ debug.print("unexpected event: {}\n", .{seqEvent.type});
return error.InvalidConfiguration;
},
}
@@ -332,7 +332,7 @@ fn parseParameters(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]P
return parameters[0..param_count];
}
-fn parseOSC(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) !OSCConfig {
+fn parseOSC(parser: *c.yaml_parser_t, allocator: *const std.mem.Allocator) !OSCConfig {
var event: c.yaml_event_t = undefined;
if (c.yaml_parser_parse(parser, &event) != 1)
return error.YAMLParserError;
@@ -342,7 +342,7 @@ fn parseOSC(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) !OSCConfig
const url = try parseStringEvent(&event, allocator);
return OSCConfig{ .URL = url };
} else if (event.type != c.YAML_MAPPING_START_EVENT) {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
}
@@ -364,12 +364,12 @@ fn parseOSC(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) !OSCConfig
} else if (std.mem.eql(u8, key, "port")) {
config.Manual.port = try parseInt(parser, u16);
} else {
- debug.warn("unknown key: '{s}'\n", .{key});
+ debug.print("unknown key: '{s}'\n", .{key});
try skipAny(parser);
}
},
else => {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
},
}
@@ -406,7 +406,7 @@ fn skipAny(parser: *c.yaml_parser_t) !void {
},
else => {
- debug.warn("unexpected event: {}\n", .{event.type});
+ debug.print("unexpected event: {}\n", .{event.type});
return error.InvalidConfiguration;
},
}