From 804204db7cf1e8a28defd359d17fa72949e13eff Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Mon, 31 Aug 2026 23:05:16 +0200 Subject: Implement with ptrCast to make it more transparent. --- src/main.zig | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/main.zig') 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}); + } } -- cgit v1.2.3-70-g09d2