summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-08-31 23:05:16 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-08-31 23:05:16 +0200
commit804204db7cf1e8a28defd359d17fa72949e13eff (patch)
tree3536d961838d1a6640d1295d808768736bf2317b /src/main.zig
parent956cd84ca545f1d93e2218cbbdbb39c81a46bec8 (diff)
Implement with ptrCast to make it more transparent.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig
index cfd7704..fa6fe82 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -7,15 +7,28 @@ pub fn main() !void {
var py: zpy.Interpreter = try .init();
defer py.deinit();
- _ = try py.run("def hello(a, b): return a + b", .{ });
+ _ = try py.run("def hello(a, b): return a + b", .{});
var test_fn = py.globals.get(.{ .string = "hello" }) orelse unreachable;
defer test_fn.decref();
var result = try test_fn.call(try .pack(&.{
- (try zpy.Int.from(42)).object,
- (try zpy.Int.from(20)).object,
+ (try zpy.List.new(&.{
+ (try zpy.Int.from(5)).asObject(),
+ (try zpy.Int.from(6)).asObject(),
+ })).asObject(),
+ (try zpy.List.new(&.{
+ (try zpy.Int.from(2)).asObject(),
+ (try zpy.Int.from(3)).asObject(),
+ (try zpy.Int.from(9)).asObject(),
+ })).asObject(),
}), null);
defer result.decref();
- std.debug.print("hello() = {f}\n", .{result});
+ std.debug.print("hello = {f}\n", .{result});
+
+ var global_iterator = py.globals.iterator();
+
+ while (global_iterator.next()) |pair| {
+ std.debug.print("{f}\n", .{pair.key});
+ }
}