LN Liberda: 8 Zig 0.14: Here we go again Zig 0.14: Annotate API function spec types with MepoFnSpec Zig 0.14: Rename Mepo.config to Mepo.config_contents Zig 0.14: More type annotations for API Zig 0.14: std.posix.sigaction does not error Zig 0.14: QueueHashMap.pop() might pop nothing Zig 0.14: std.mem.split -> std.mem.splitSequence Zig 0.14: std.mem.tokenize -> std.mem.tokenizeSequence 46 files changed, 67 insertions(+), 59 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~mil/mepo-devel/patches/57969/mbox | git am -3Learn more about email & git
--- src/main.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index c6fafbb..39ea01d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -12,8 +12,8 @@ const utildbg = @import("./util/utildbg.zig"); pub fn main() !void { comptime { const v = builtin.zig_version; - if (v.major != 0 or v.minor != 13) - @panic("Must be built against Zig 0.13.x"); + if (v.major != 0 or v.minor != 14) + @panic("Must be built against Zig 0.14.x"); } const allocator = std.heap.c_allocator; -- 2.48.1
--- src/api/bind_button.zig | 2 +- src/api/bind_click.zig | 2 +- src/api/bind_gesture.zig | 2 +- src/api/bind_key.zig | 2 +- src/api/bind_quit.zig | 2 +- src/api/bind_signal.zig | 2 +- src/api/bind_timer.zig | 2 +- src/api/cache_dlbbox.zig | 2 +- src/api/cache_dlradius.zig | 2 +- src/api/cache_queueclear.zig | 2 +- src/api/center_on_mouse.zig | 2 +- src/api/center_on_pin.zig | 2 +- src/api/clipcopy.zig | 2 +- src/api/clippaste.zig | 2 +- src/api/filedump.zig | 2 +- src/api/fileload.zig | 2 +- src/api/move_relative.zig | 2 +- src/api/pin_activate.zig | 2 +- src/api/pin_add.zig | 2 +- src/api/pin_cycle.zig | 2 +- src/api/pin_deactivate.zig | 2 +- src/api/pin_delete.zig | 2 +- src/api/pin_groupactivate.zig | 2 +- src/api/pin_meta.zig | 2 +- src/api/pin_purge.zig | 2 +- src/api/pin_transfer.zig | 2 +- src/api/prefinc.zig | 2 +- src/api/prefset_n.zig | 2 +- src/api/prefset_t.zig | 2 +- src/api/preftoggle.zig | 2 +- src/api/quit.zig | 2 +- src/api/shellpipe_async.zig | 2 +- src/api/shellpipe_sync.zig | 2 +- src/api/zoom_relative.zig | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/api/bind_button.zig b/src/api/bind_button.zig index 97a41df..d26dcd6 100644 --- a/src/api/bind_button.zig +++ b/src/api/bind_button.zig @@ -4,7 +4,7 @@ const std = @import("std"); const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_button", .desc = "Create a UI button which executes a JSON commands. UI buttons appear aligned in the bottom right of the screen or the top left alongside the pin details overlay (see first argument).", .args = &.{ diff --git a/src/api/bind_click.zig b/src/api/bind_click.zig index 0a01e48..d571ed8 100644 --- a/src/api/bind_click.zig +++ b/src/api/bind_click.zig @@ -4,7 +4,7 @@ const std = @import("std"); const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_click", .desc = "Bind a particular number of successive clicks to run a JSON API expressions.", .args = &.{ diff --git a/src/api/bind_gesture.zig b/src/api/bind_gesture.zig index 66fc2a2..83e79c7 100644 --- a/src/api/bind_gesture.zig +++ b/src/api/bind_gesture.zig @@ -4,7 +4,7 @@ const std = @import("std"); const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_gesture", .desc = "Bind a multitouch gesture event to execute JSON API expressions.", .args = &.{ diff --git a/src/api/bind_key.zig b/src/api/bind_key.zig index 2c00aea..01cc8b3 100644 --- a/src/api/bind_key.zig +++ b/src/api/bind_key.zig @@ -4,7 +4,7 @@ const std = @import("std"); const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_key", .desc = "Bind a key combination to execute a JSON API expressions.", .args = &.{ diff --git a/src/api/bind_quit.zig b/src/api/bind_quit.zig index 90eacbe..16d2ae5 100644 --- a/src/api/bind_quit.zig +++ b/src/api/bind_quit.zig @@ -4,7 +4,7 @@ const std = @import("std"); const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_quit", .desc = "Bind JSON API expressions to run on quitting the application.", .args = &.{ diff --git a/src/api/bind_signal.zig b/src/api/bind_signal.zig index 99e5296..9f70c00 100644 --- a/src/api/bind_signal.zig +++ b/src/api/bind_signal.zig @@ -5,7 +5,7 @@ const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); const utilsdl = @import("../util/utilsdl.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_signal", .desc = "Bind a signal to execute JSON API expressions.", .args = &.{ diff --git a/src/api/bind_timer.zig b/src/api/bind_timer.zig index 00c242f..88046af 100644 --- a/src/api/bind_timer.zig +++ b/src/api/bind_timer.zig @@ -5,7 +5,7 @@ const sdl = @import("../sdlshim.zig"); const utildbg = @import("../util/utildbg.zig"); const utilsdl = @import("../util/utilsdl.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "bind_timer", .desc = "Bind a timer to execute JSON API expressions at the given interval.", .args = &.{ diff --git a/src/api/cache_dlbbox.zig b/src/api/cache_dlbbox.zig index 9585c93..9a1bc86 100644 --- a/src/api/cache_dlbbox.zig +++ b/src/api/cache_dlbbox.zig @@ -6,7 +6,7 @@ const utilconversion = @import("../util/utilconversion.zig"); const utildbg = @import("../util/utildbg.zig"); const config = @import("../config.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "cache_dlbbox", .desc = "Queue tiles for a bounding box to download to the cache in the background for the given zoom levels. Writes directly to filesystem cache (path determined by `tile_cache_dir` preference) as tiles are downloaded.", .args = &.{ diff --git a/src/api/cache_dlradius.zig b/src/api/cache_dlradius.zig index dd98b3e..afbf404 100644 --- a/src/api/cache_dlradius.zig +++ b/src/api/cache_dlradius.zig @@ -6,7 +6,7 @@ const utilconversion = @import("../util/utilconversion.zig"); const utildbg = @import("../util/utildbg.zig"); const config = @import("../config.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "cache_dlradius", .desc = "Queue tiles for a bounding box to download to the cache in the background for the given zoom levels. Writes directly to filesystem cache (path determined by `tile_cache_dir` preference) as tiles are downloaded.", .args = &.{ diff --git a/src/api/cache_queueclear.zig b/src/api/cache_queueclear.zig index 661406e..922d3f5 100644 --- a/src/api/cache_queueclear.zig +++ b/src/api/cache_queueclear.zig @@ -5,7 +5,7 @@ const utilconversion = @import("../util/utilconversion.zig"); const utildbg = @import("../util/utildbg.zig"); const config = @import("../config.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "cache_queueclear", .desc = "Clear any queued background downloading process queued with `cache_dlbbox` or `cache_dlradius`. Note this does not remove filesystem tiles, but simply stops in-progress downloading.", .args = &.{}, diff --git a/src/api/center_on_mouse.zig b/src/api/center_on_mouse.zig index 4df40fe..ca5921f 100644 --- a/src/api/center_on_mouse.zig +++ b/src/api/center_on_mouse.zig @@ -4,7 +4,7 @@ const std = @import("std"); const sdl = @import("../sdlshim.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "center_on_mouse", .desc = "Center the map on the current position of the mouse.", .args = &.{}, diff --git a/src/api/center_on_pin.zig b/src/api/center_on_pin.zig index e69302e..6ac1710 100644 --- a/src/api/center_on_pin.zig +++ b/src/api/center_on_pin.zig @@ -3,7 +3,7 @@ const types = @import("../types.zig"); const std = @import("std"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "center_on_pin", .desc = "Center the map on the currently active pin.", .args = &.{}, diff --git a/src/api/clipcopy.zig b/src/api/clipcopy.zig index 99182f1..e932217 100644 --- a/src/api/clipcopy.zig +++ b/src/api/clipcopy.zig @@ -6,7 +6,7 @@ const utildbg = @import("../util/utildbg.zig"); const utilsdl = @import("../util/utilsdl.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "clipcopy", .desc = "Copy the current map coordinates to the clipboard; will be in format: `lat lon`.", .args = &.{}, diff --git a/src/api/clippaste.zig b/src/api/clippaste.zig index 34edac8..70acf16 100644 --- a/src/api/clippaste.zig +++ b/src/api/clippaste.zig @@ -6,7 +6,7 @@ const utildbg = @import("../util/utildbg.zig"); const utilsdl = @import("../util/utilsdl.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "clippaste", .desc = "Extract clipboard contents and either center on coordinate (if clipboard content matches `lat lon` format); otherwise run clipboard contents as JSON API expressions.", .args = &.{}, diff --git a/src/api/filedump.zig b/src/api/filedump.zig index 245587a..e36cb0a 100644 --- a/src/api/filedump.zig +++ b/src/api/filedump.zig @@ -7,7 +7,7 @@ const utilfile = @import("../util/utilfile.zig"); const utilsdl = @import("../util/utilsdl.zig"); const utilprefs = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "filedump", .desc = "Save the current state of pins and/or preferences to a file as JSON API expressions.", .args = &.{ diff --git a/src/api/fileload.zig b/src/api/fileload.zig index 396b1a8..9683bce 100644 --- a/src/api/fileload.zig +++ b/src/api/fileload.zig @@ -3,7 +3,7 @@ const types = @import("../types.zig"); const std = @import("std"); const utilfile = @import("../util/utilfile.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "fileload", .desc = "Load JSON API expressions from an arbitrary filesystem file.", .args = &.{ diff --git a/src/api/move_relative.zig b/src/api/move_relative.zig index 771d81a..6b15f91 100644 --- a/src/api/move_relative.zig +++ b/src/api/move_relative.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "move_relative", .desc = "Move the map by a relative x/y amount.", .args = &.{ diff --git a/src/api/pin_activate.zig b/src/api/pin_activate.zig index 323fa36..9cb9444 100644 --- a/src/api/pin_activate.zig +++ b/src/api/pin_activate.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_activate", .desc = "Activate a pin by its handle.", .args = &.{ diff --git a/src/api/pin_add.zig b/src/api/pin_add.zig index bc5f870..badd648 100644 --- a/src/api/pin_add.zig +++ b/src/api/pin_add.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_add", .desc = "Add a pin to the map.", .args = &.{ diff --git a/src/api/pin_cycle.zig b/src/api/pin_cycle.zig index 24ff857..83f4bb6 100644 --- a/src/api/pin_cycle.zig +++ b/src/api/pin_cycle.zig @@ -3,7 +3,7 @@ const types = @import("../types.zig"); const std = @import("std"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_cycle", .desc = "Cycle the currently focused pin group pin.", .args = &.{ diff --git a/src/api/pin_deactivate.zig b/src/api/pin_deactivate.zig index b20567d..be5b8cf 100644 --- a/src/api/pin_deactivate.zig +++ b/src/api/pin_deactivate.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_deactivate", .desc = "Deactivate currently active pin.", .args = &.{}, diff --git a/src/api/pin_delete.zig b/src/api/pin_delete.zig index 5bd9902..e254605 100644 --- a/src/api/pin_delete.zig +++ b/src/api/pin_delete.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_delete", .desc = "Delete a pin by its handle.", .args = &.{ diff --git a/src/api/pin_groupactivate.zig b/src/api/pin_groupactivate.zig index 3164860..1c8f44a 100644 --- a/src/api/pin_groupactivate.zig +++ b/src/api/pin_groupactivate.zig @@ -3,7 +3,7 @@ const types = @import("../types.zig"); const std = @import("std"); const pin_cycle = @import("pin_cycle.zig").pin_cycle; -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_groupactivate", .desc = "Activate the pin group specified.", .args = &.{ diff --git a/src/api/pin_meta.zig b/src/api/pin_meta.zig index 2748006..5d33e46 100644 --- a/src/api/pin_meta.zig +++ b/src/api/pin_meta.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_meta", .desc = "Update a pin's metadata.", .args = &.{ diff --git a/src/api/pin_purge.zig b/src/api/pin_purge.zig index 4c9464a..2f8921c 100644 --- a/src/api/pin_purge.zig +++ b/src/api/pin_purge.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_purge", .desc = "Purge all pins in the currently active pin group.", .args = &.{}, diff --git a/src/api/pin_transfer.zig b/src/api/pin_transfer.zig index 1229aca..ee07599 100644 --- a/src/api/pin_transfer.zig +++ b/src/api/pin_transfer.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "pin_transfer", .desc = "Transfer a pin from one group to another.", .args = &.{ diff --git a/src/api/prefinc.zig b/src/api/prefinc.zig index befb120..2ff2cc6 100644 --- a/src/api/prefinc.zig +++ b/src/api/prefinc.zig @@ -4,7 +4,7 @@ const std = @import("std"); const utildbg = @import("../util/utildbg.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "prefinc", .desc = "Increase or decrease a preference by the given delta value.", .args = &.{ diff --git a/src/api/prefset_n.zig b/src/api/prefset_n.zig index dfad93a..ad492d2 100644 --- a/src/api/prefset_n.zig +++ b/src/api/prefset_n.zig @@ -4,7 +4,7 @@ const std = @import("std"); const utildbg = @import("../util/utildbg.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "prefset_n", .desc = "Set a preference number value.", .args = &.{ diff --git a/src/api/prefset_t.zig b/src/api/prefset_t.zig index 926f01b..cfd231d 100644 --- a/src/api/prefset_t.zig +++ b/src/api/prefset_t.zig @@ -4,7 +4,7 @@ const std = @import("std"); const utildbg = @import("../util/utildbg.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "prefset_t", .desc = "Set a preference text value.", .args = &.{ diff --git a/src/api/preftoggle.zig b/src/api/preftoggle.zig index c80575a..bdb54c3 100644 --- a/src/api/preftoggle.zig +++ b/src/api/preftoggle.zig @@ -4,7 +4,7 @@ const std = @import("std"); const utildbg = @import("../util/utildbg.zig"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "preftoggle", .desc = "Toggle a boolean number preference between `1` and `0`.", .args = &.{ diff --git a/src/api/quit.zig b/src/api/quit.zig index 2ae97cc..a660501 100644 --- a/src/api/quit.zig +++ b/src/api/quit.zig @@ -2,7 +2,7 @@ const Mepo = @import("../Mepo.zig"); const types = @import("../types.zig"); const std = @import("std"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "quit", .desc = "Quit the application.", .args = &.{}, diff --git a/src/api/shellpipe_async.zig b/src/api/shellpipe_async.zig index 2e64acd..add34a7 100644 --- a/src/api/shellpipe_async.zig +++ b/src/api/shellpipe_async.zig @@ -15,7 +15,7 @@ const AsyncShellpipeRequest = struct { cmd: []const u8, }; -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "shellpipe_async", .desc = "Run a system (shell) command and pipe asynchronously; STDOUT returned from command will be executed back as a jsonapi expression.", .args = &.{ diff --git a/src/api/shellpipe_sync.zig b/src/api/shellpipe_sync.zig index 84a59a1..5c2b1c4 100644 --- a/src/api/shellpipe_sync.zig +++ b/src/api/shellpipe_sync.zig @@ -7,7 +7,7 @@ const sdl = @import("../sdlshim.zig"); const filedump = @import("./filedump.zig"); const run_shellpipe = @import("shellpipe_async.zig").run_shellpipe; -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "shellpipe_sync", .desc = "Run a system (shell) command synchronously and pipe; STDOUT returned from command will be executed back as a JSON API expressions. Note state of application can be introspected by examining ENV vars (documented in API doc) and also state is saved as JSON API commands to $XDG_CACHE_HOME/mepo/shellpipe_savestate.json", .args = &.{ diff --git a/src/api/zoom_relative.zig b/src/api/zoom_relative.zig index 9319d63..7f29b79 100644 --- a/src/api/zoom_relative.zig +++ b/src/api/zoom_relative.zig @@ -3,7 +3,7 @@ const types = @import("../types.zig"); const std = @import("std"); const p = @import("../util/utilprefs.zig"); -pub const spec = .{ +pub const spec: types.MepoFnSpec = .{ .name = "zoom_relative", .desc = "Update the map's zoom level by a relative delta.", .args = &.{ -- 2.48.1
The field name conflicts with the import of config.zig --- src/Mepo.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index d8c28d6..88c66f1 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -18,7 +18,7 @@ const FnTable = @import("./api/_FnTable.zig"); const Self = @This(); allocator: std.mem.Allocator, blit_pinlayer_cache: datastructure.EvictionHashMap(types.XYZ, *sdl.SDL_Texture, evict_texture, &config.MaxTextures), -config: []const u8, +config_contents: []const u8, debug_message: ?[]const u8 = null, drag: ?struct { begin_ticks: u32, @@ -341,8 +341,8 @@ fn jsonapi_execute_parseargs( map: std.json.ArrayHashMap(std.json.Value), ) anyerror![types.MepoFnNargs]types.MepoArg { var args: [types.MepoFnNargs]types.MepoArg = .{ - .{.Number = 0}, .{.Number = 0}, .{.Number = 0}, - .{.Number = 0}, .{.Number = 0}, .{.Number = 0}, + .{ .Number = 0 }, .{ .Number = 0 }, .{ .Number = 0 }, + .{ .Number = 0 }, .{ .Number = 0 }, .{ .Number = 0 }, }; for (fn_spec_args, 0..) |spec_arg, i| { if (map.map.get(spec_arg.name)) |arg| { @@ -493,7 +493,7 @@ pub fn init_video_and_sdl_stdin_loop(mepo: *Self, enable_stdin_jsonapi_repl: boo fn mepo_sdl_loop_thread_boot(userdata: ?*anyopaque) callconv(.C) c_int { const mepo: *Self = @alignCast(@ptrCast(userdata.?)); video_init(mepo) catch unreachable; - mepo.jsonapi_execute(mepo.config) catch unreachable; + mepo.jsonapi_execute(mepo.config_contents) catch unreachable; mepo.initialized_video.set(); sdl_event_loop(mepo) catch unreachable; return 0; @@ -790,7 +790,7 @@ pub fn init(allocator: std.mem.Allocator, tile_cache: *TileCache, use_config: [] &config.MaxTextures, ).init(allocator), .shellpipe_async_threads = datastructure.QueueHashMap(i8, sdl.SDL_threadID).init(allocator), - .config = use_config, + .config_contents = use_config, .fonts_normal = try init_create_fonts_array(false), .fonts_bold = try init_create_fonts_array(true), .fingers = std.ArrayList(sdl.SDL_FingerID).init(allocator), -- 2.48.1
--- src/Mepo.zig | 2 +- src/api/bind_click.zig | 2 +- src/api/bind_gesture.zig | 2 +- src/blit/blit.zig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index 88c66f1..2cb640d 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -457,7 +457,7 @@ fn dispatch_check_timers(mepo: *Self) !void { const timer_jsonapi = kv.value_ptr.*; if (sdl.SDL_GetTicks() > timer_input.created_at_ticks + (timer_input.interval_seconds * 1000)) { mepo.jsonapi_execute(timer_jsonapi) catch unreachable; - const new_timer = .{ + const new_timer: types.TimerInput = .{ .created_at_ticks = sdl.SDL_GetTicks(), .interval_seconds = timer_input.interval_seconds, }; diff --git a/src/api/bind_click.zig b/src/api/bind_click.zig index d571ed8..5eac5cc 100644 --- a/src/api/bind_click.zig +++ b/src/api/bind_click.zig @@ -23,7 +23,7 @@ fn bind_click(mepo: *Mepo, button: u8, clicks: i8, expression: []const u8) !void utildbg.log("Binding click: button={d} clicks={d} to expression {s}\n", .{ button, clicks, expression }); const sdl_button: u8 = if (button == 1) sdl.SDL_BUTTON_LEFT else sdl.SDL_BUTTON_RIGHT; - const click = .{ .button = sdl_button, .clicks = clicks }; + const click: types.ClickInput = .{ .button = sdl_button, .clicks = clicks }; if (mepo.table_clicks.get(click)) |heap_str| { mepo.allocator.free(heap_str); diff --git a/src/api/bind_gesture.zig b/src/api/bind_gesture.zig index 83e79c7..18074d7 100644 --- a/src/api/bind_gesture.zig +++ b/src/api/bind_gesture.zig @@ -27,7 +27,7 @@ fn execute(mepo: *Mepo, args: [types.MepoFnNargs]types.MepoArg) !void { fn bind_gesture(mepo: *Mepo, action: types.GestureInputAction, fingers: u8, direction: types.GestureInputDirection, expression: []const u8) !void { utildbg.log("Binding gesture: fingers={} action={} direction={} to expression {s}\n", .{ fingers, action, direction, expression }); - const gest = .{ + const gest: types.GestureInput = .{ .n_fingers = fingers, .action = action, .direction = direction, diff --git a/src/blit/blit.zig b/src/blit/blit.zig index 9102df8..c470ecc 100644 --- a/src/blit/blit.zig +++ b/src/blit/blit.zig @@ -419,7 +419,7 @@ fn blit_pin(mepo: *Mepo, pin: *types.Pin, prev_pin: ?*types.Pin, pin_group: u8, const pin_label_bg_value: u24 = if (is_active) 0xe8e8e8 else 0xffffff; const pin_label_bg: types.Color = .{ .value = pin_label_bg_value }; const pin_label_border_value: u24 = if (is_active) 0x000000 else 0xe8e8e8; - const pin_label_border = .{ .value = pin_label_border_value }; + const pin_label_border: types.Color = .{ .value = pin_label_border_value }; const label_color: u24 = 0x000000; const label = lab: { -- 2.48.1
--- src/api/bind_signal.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/bind_signal.zig b/src/api/bind_signal.zig index 9f70c00..34cfd2b 100644 --- a/src/api/bind_signal.zig +++ b/src/api/bind_signal.zig @@ -45,7 +45,7 @@ fn bind_signal(mepo: *Mepo, signo_str: [:0]const u8, expression: []const u8) !vo .flags = 0, }; - std.posix.sigaction(signal_name, &signal_action, null) catch return error.FailedToSetupSighandler; + std.posix.sigaction(signal_name, &signal_action, null); if (mepo.table_signals.get(signal_name)) |heap_str| { mepo.allocator.free(heap_str); -- 2.48.1
--- src/TileCache.zig | 18 ++++++++++++------ src/datastructure/QueueHashMap.zig | 8 +++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/TileCache.zig b/src/TileCache.zig index 4744a48..3bb969e 100644 --- a/src/TileCache.zig +++ b/src/TileCache.zig @@ -82,15 +82,21 @@ pub fn download_loop(tile_cache: *Self, graphical_mode: bool) !void { } // 2. Transfer from UI LIFO into transfers - while (tile_cache.queue_lifo_ui.count() > 0 and tile_cache.transfer_map.count() < p.get(p.pref.tile_cache_max_n_transfers).u) { - const coords = tile_cache.queue_lifo_ui.pop(); - try tile_cache.curl_add_to_multi_and_register_transfer(coords.key, true); + while (tile_cache.transfer_map.count() < p.get(p.pref.tile_cache_max_n_transfers).u) { + if (tile_cache.queue_lifo_ui.pop()) |coords| { + try tile_cache.curl_add_to_multi_and_register_transfer(coords.key, true); + } else { + break; + } } // 3. Transfer from BG LIFO into transfers - while (tile_cache.queue_lifo_bg.count() > 0 and tile_cache.transfer_map.count() < p.get(p.pref.tile_cache_max_n_transfers).u) { - const coords = tile_cache.queue_lifo_bg.pop(); - try tile_cache.curl_add_to_multi_and_register_transfer(coords.key, false); + while (tile_cache.transfer_map.count() < p.get(p.pref.tile_cache_max_n_transfers).u) { + if (tile_cache.queue_lifo_bg.pop()) |coords| { + try tile_cache.curl_add_to_multi_and_register_transfer(coords.key, false); + } else { + break; + } } // 4. Print status message if non graphical diff --git a/src/datastructure/QueueHashMap.zig b/src/datastructure/QueueHashMap.zig index 9cb7996..103fa63 100644 --- a/src/datastructure/QueueHashMap.zig +++ b/src/datastructure/QueueHashMap.zig @@ -35,12 +35,14 @@ pub fn QueueHashMap(comptime key_type: type, comptime metadata_type: type) type return self.array_hash_map.getPtr(key); } - pub fn pop(self: *Self) struct { key: key_type, value: metadata_type } { + pub fn pop(self: *Self) ?struct { key: key_type, value: metadata_type } { self.mutex.lock(); defer self.mutex.unlock(); - const popped = self.array_hash_map.pop(); - return .{ .key = popped.key, .value = popped.value }; + if (self.array_hash_map.pop()) |popped| { + return .{ .key = popped.key, .value = popped.value }; + } + return null; } pub fn getIndex(self: *Self, key: key_type) ?usize { -- 2.48.1
--- src/api/clippaste.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/clippaste.zig b/src/api/clippaste.zig index 70acf16..2ce3d63 100644 --- a/src/api/clippaste.zig +++ b/src/api/clippaste.zig @@ -23,7 +23,7 @@ fn execute(mepo: *Mepo, _: [types.MepoFnNargs]types.MepoArg) !void { // trim commas, and see if can parse as floats; if so assume lat/lon // if not - break out and run whatever is in clipboard as jsonapi parse_lat_lon: { - var it = std.mem.split(u8, text, " "); + var it = std.mem.splitSequence(u8, text, " "); var lat: ?f64 = null; var lon: ?f64 = null; -- 2.48.1
--- src/Downloader.zig | 2 +- src/blit/blit.zig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Downloader.zig b/src/Downloader.zig index 4136bf7..327a294 100644 --- a/src/Downloader.zig +++ b/src/Downloader.zig @@ -58,7 +58,7 @@ fn parse_download_request(download_request_str: []const u8) !TileCache.DownloadB var zoom_min: i32 = undefined; var zoom_max: i32 = undefined; - var tokens_it = std.mem.tokenize(u8, download_request_str, ","); + var tokens_it = std.mem.tokenizeSequence(u8, download_request_str, ","); var i: usize = 0; while (tokens_it.next()) |token| { switch (i) { diff --git a/src/blit/blit.zig b/src/blit/blit.zig index c470ecc..45a7a38 100644 --- a/src/blit/blit.zig +++ b/src/blit/blit.zig @@ -213,7 +213,7 @@ fn blit_tile_pinlayer(mepo: *Mepo, tile_x: u32, tile_y: u32, zoom: u8, x_off: i3 const is_ordered = p.get(p.pingroup_prop(pin_group_i, .Ordered)).b; break :is_active_path (pin_group_i == mepo.pin_group_active and mepo.pin_group_active_item != null and ((is_ordered and is_active_path_track) or - (!is_ordered and mepo.pin_group_active_item.? == pin_i))); + (!is_ordered and mepo.pin_group_active_item.? == pin_i))); }; is_active_path_track = track: { const has_active_pg_item = mepo.pin_group_active_item != null; @@ -663,7 +663,7 @@ fn blit_multiline_text( var textures_array: [50]*sdl.SDL_Texture = undefined; var textures_array_size: usize = 0; - var lines_it = std.mem.tokenize(u8, msg, "\n"); + var lines_it = std.mem.tokenizeSequence(u8, msg, "\n"); while (lines_it.next()) |line| { if (textures_array_size + 1 > textures_array.len - 1) break; -- 2.48.1