blob: fa6fe82aa937ce7c22de74239b5b2a97b0d6643c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const std = @import("std");
const Io = std.Io;
const zpy = @import("zpy");
pub fn main() !void {
var py: zpy.Interpreter = try .init();
defer py.deinit();
_ = 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.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});
var global_iterator = py.globals.iterator();
while (global_iterator.next()) |pair| {
std.debug.print("{f}\n", .{pair.key});
}
}
|