Given a zig file file_with_test.zig
in a subdirectory:
.
├── example_package
│ └── file_with_test.zig
└── outer_thing.zig
Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
Play this game by pasting the script in http://www.puzzlescript.net/editor.html |
/// Module that wraps up the zig json system for use in playdate | |
const std = @import("std"); | |
const pdapi = @import("playdate_api_definitions.zig"); | |
pub fn read_from_json_str( | |
input: []const u8, | |
comptime thing_to_read: type, | |
allocator: std.mem.Allocator, | |
) !thing_to_read |
/// function for automatically building an imgui (via zgui) UI based | |
/// on struct fields. Really useful when you're moving quickly and | |
/// have a debug flags/fields struct | |
pub fn draw_zgui_ui( | |
for_thing: anytype | |
) !bool | |
{ | |
var buf:[1024:0]u8 = undefined; | |
@memset(&buf, 0); |
const std = @import("std"); | |
const c_args = [_][]const u8{ | |
"-std=c++17", | |
"-fno-sanitize=undefined", | |
}; | |
// Although this function looks imperative, note that its job is to | |
// declaratively construct a build graph that will be executed by an external | |
// runner. |
const std = @import("std"); | |
fn print_string_contents(buffer: anytype) void { | |
std.debug.print("string print: '{s}'\n", .{ buffer }); | |
std.debug.print("char print:\n", .{}); | |
for (buffer) |b, ind| { | |
std.debug.print(" {d}: {d} {s}", .{ ind, b, buffer[ind..ind+1] }); | |
} |
One pattern that seems to fall out of my brain when I return to Zig is having a struct with one array field that I want to assign to later. For example:
const StateData = struct {
// I realize this is wrong, this is what my brain always wants to try first
order: []burger=undefined,
};
The otioconvert
program that ships with OpenTimelineIO has a handy feature that lets you pass arguments to adapters:
> otioconvert --help
...
-a ADAPTER_ARG, --adapter-arg ADAPTER_ARG