chore: switch from zig-toml to tomlz
This commit is contained in:
parent
ddc54e2977
commit
5989f05faf
|
@ -10,6 +10,6 @@
|
||||||
[submodule "lib/zig-datetime"]
|
[submodule "lib/zig-datetime"]
|
||||||
path = lib/zig-datetime
|
path = lib/zig-datetime
|
||||||
url = https://github.com/frmdstryr/zig-datetime
|
url = https://github.com/frmdstryr/zig-datetime
|
||||||
[submodule "lib/zig-toml"]
|
[submodule "lib/tomlz"]
|
||||||
path = lib/zig-toml
|
path = lib/tomlz
|
||||||
url = https://github.com/aeronavery/zig-toml
|
url = https://github.com/mattyhall/tomlz
|
||||||
|
|
|
@ -31,14 +31,13 @@ pub fn build(b: *std.build.Builder) void {
|
||||||
exe.addPackagePath("datetime", "lib/zig-datetime/src/main.zig");
|
exe.addPackagePath("datetime", "lib/zig-datetime/src/main.zig");
|
||||||
|
|
||||||
// Bitfield type from FlorenceOS: https://github.com/FlorenceOS/
|
// Bitfield type from FlorenceOS: https://github.com/FlorenceOS/
|
||||||
// exe.addPackage(.{ .name = "bitfield", .path = .{ .path = "lib/util/bitfield.zig" } });
|
|
||||||
exe.addPackagePath("bitfield", "lib/util/bitfield.zig");
|
exe.addPackagePath("bitfield", "lib/util/bitfield.zig");
|
||||||
|
|
||||||
// Argument Parsing Library
|
// Argument Parsing Library
|
||||||
exe.addPackagePath("clap", "lib/zig-clap/clap.zig");
|
exe.addPackagePath("clap", "lib/zig-clap/clap.zig");
|
||||||
|
|
||||||
// TOML Library
|
// TOML Library
|
||||||
exe.addPackagePath("toml", "lib/zig-toml/src/toml.zig");
|
exe.addPackagePath("tomlz", "lib/tomlz/src/main.zig");
|
||||||
|
|
||||||
// OpenGL 3.3 Bindings
|
// OpenGL 3.3 Bindings
|
||||||
exe.addPackagePath("gl", "lib/gl.zig");
|
exe.addPackagePath("gl", "lib/gl.zig");
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit c1537005e3426dbba8f8f3e524e7879b283d0326
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 016b8bcf98e50ae9408f6a9606bbec5a9bc6f677
|
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const toml = @import("toml");
|
const tomlz = @import("tomlz");
|
||||||
|
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
|
@ -58,29 +58,25 @@ pub fn load(allocator: Allocator, file_path: []const u8) !void {
|
||||||
const contents = try config_file.readToEndAlloc(allocator, try config_file.getEndPos());
|
const contents = try config_file.readToEndAlloc(allocator, try config_file.getEndPos());
|
||||||
defer allocator.free(contents);
|
defer allocator.free(contents);
|
||||||
|
|
||||||
var parser = try toml.parseFile(allocator, file_path);
|
var table = try tomlz.parse(allocator, contents);
|
||||||
defer parser.deinit();
|
defer table.deinit(allocator);
|
||||||
|
|
||||||
const table = try parser.parse();
|
|
||||||
defer table.deinit();
|
|
||||||
|
|
||||||
// TODO: Report unknown config options
|
// TODO: Report unknown config options
|
||||||
|
if (table.getTable("Host")) |host| {
|
||||||
if (table.keys.get("Host")) |host| {
|
if (host.getInteger("win_scale")) |scale| state.host.win_scale = scale;
|
||||||
if (host.Table.keys.get("win_scale")) |scale| state.host.win_scale = scale.Integer;
|
if (host.getBool("vsync")) |vsync| state.host.vsync = vsync;
|
||||||
if (host.Table.keys.get("vsync")) |vsync| state.host.vsync = vsync.Boolean;
|
if (host.getBool("mute")) |mute| state.host.mute = mute;
|
||||||
if (host.Table.keys.get("mute")) |mute| state.host.mute = mute.Boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table.keys.get("Guest")) |guest| {
|
if (table.getTable("Guest")) |guest| {
|
||||||
if (guest.Table.keys.get("audio_sync")) |sync| state.guest.audio_sync = sync.Boolean;
|
if (guest.getBool("audio_sync")) |sync| state.guest.audio_sync = sync;
|
||||||
if (guest.Table.keys.get("video_sync")) |sync| state.guest.video_sync = sync.Boolean;
|
if (guest.getBool("video_sync")) |sync| state.guest.video_sync = sync;
|
||||||
if (guest.Table.keys.get("force_rtc")) |forced| state.guest.force_rtc = forced.Boolean;
|
if (guest.getBool("force_rtc")) |forced| state.guest.force_rtc = forced;
|
||||||
if (guest.Table.keys.get("skip_bios")) |skip| state.guest.skip_bios = skip.Boolean;
|
if (guest.getBool("skip_bios")) |skip| state.guest.skip_bios = skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table.keys.get("Debug")) |debug| {
|
if (table.getTable("Debug")) |debug| {
|
||||||
if (debug.Table.keys.get("cpu_trace")) |trace| state.debug.cpu_trace = trace.Boolean;
|
if (debug.getBool("cpu_trace")) |trace| state.debug.cpu_trace = trace;
|
||||||
if (debug.Table.keys.get("unhandled_io")) |unhandled| state.debug.unhandled_io = unhandled.Boolean;
|
if (debug.getBool("unhandled_io")) |unhandled| state.debug.unhandled_io = unhandled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue