summaryrefslogtreecommitdiff
path: root/src/main.zig
blob: 0cd2ec57047bf87884ac1b6035a9015f301cfb73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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(&.{
        zpy.Str.fromString("hello").object,
        zpy.Str.fromString("world").object,
    }), null);
    defer result.decref();

    std.debug.print("globals = {f}\n", .{py.globals.object});
    std.debug.print("hello() = {f}\n", .{result});
}