A SpaceTraders Agent

update zig

altagos.dev e8f6f30d a02c4cef

verified
+22 -12
+3
README.md
··· 1 + # Space 2 + 3 + A client for the [SpaceTraders](https://spacetraders.io/) API.
+1 -1
src/main.zig
··· 49 49 defer io_impl.deinit(); 50 50 const io = io_impl.io(); 51 51 52 - std.log.debug("Io threads: {}", .{try io_impl.cpu_count}); 52 + std.log.debug("Io threads: {}", .{io_impl.concurrent_limit.toInt() orelse 0}); 53 53 54 54 const config = try agent.config.load(io, allocator); 55 55 defer agent.config.free(allocator, config);
+2 -2
src/meta/fmt.zig
··· 66 66 tty.setColor(w, .reset) catch {}; 67 67 }, 68 68 .text => { 69 - tty.setColor(w, .italic) catch {}; 69 + // tty.setColor(w, .italic) catch {}; 70 70 tty.setColor(w, .dim) catch {}; 71 71 tty.setColor(w, .blue) catch {}; 72 72 }, ··· 74 74 tty.setColor(w, .green) catch {}; 75 75 }, 76 76 .value => { 77 - tty.setColor(w, .italic) catch {}; 77 + // tty.setColor(w, .italic) catch {}; 78 78 tty.setColor(w, .blue) catch {}; 79 79 }, 80 80 }
+16 -9
src/meta/root.zig
··· 3 3 pub const pretty = fmt.pretty; 4 4 5 5 pub fn CombinedEnum(comptime parent: type) type { 6 - const std = @import("std"); 7 6 const parent_info = @typeInfo(parent).@"struct"; 8 7 9 8 var num_fields = 0; ··· 25 24 T: type, 26 25 }; 27 26 28 - var combined: [num_fields]std.builtin.Type.EnumField = undefined; 27 + var combined: [num_fields][:0]const u8 = undefined; 28 + var combined_values: [num_fields]u8 = undefined; 29 29 var conv_map: [num_enums]ConversionMap = undefined; 30 30 31 31 var idx = 0; ··· 41 41 }; 42 42 43 43 for (e.fields) |field| { 44 - combined[i] = .{ .name = field.name, .value = field.value }; 44 + combined[i] = field.name; 45 + combined_values[i] = field.value; 45 46 i += 1; 46 47 } 47 48 ··· 51 52 } 52 53 } 53 54 54 - const combined_enum = @Type(std.builtin.Type{ .@"enum" = .{ 55 - .decls = &.{}, 56 - .fields = &combined, 57 - .tag_type = u8, 58 - .is_exhaustive = true, 59 - } }); 55 + // const combined_enum = @Enum(std.builtin.Type{ .@"enum" = .{ 56 + // .decls = &.{}, 57 + // .fields = &combined, 58 + // .tag_type = u8, 59 + // .is_exhaustive = true, 60 + // } }); 61 + const combined_enum = @Enum( 62 + u8, 63 + .nonexhaustive, 64 + &combined, 65 + &combined_values, 66 + ); 60 67 61 68 const combined_enums = num_enums; 62 69 const conv_map_const = conv_map;