summaryrefslogtreecommitdiff
path: root/src/Object.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Object.zig')
-rw-r--r--src/Object.zig40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/Object.zig b/src/Object.zig
deleted file mode 100644
index 018d8b3..0000000
--- a/src/Object.zig
+++ /dev/null
@@ -1,40 +0,0 @@
-const std = @import("std");
-const c = @import("c");
-const zpy = @import("root.zig");
-
-const Self = @This();
-
-ptr: *c.PyObject,
-
-pub fn fromPtr(ptr: *c.PyObject) Self {
- return .{ .ptr = ptr };
-}
-
-
-pub fn fromC(ptr: [*c]c.PyObject) ?Self {
- return if (ptr) |p| .fromPtr(p) else null;
-}
-
-pub fn decref(self: *Self) void {
- c.Py_DecRef(self.ptr);
-}
-
-pub fn repr(self: *const Self) zpy.Str {
- return .{ .object = .fromPtr(c.PyObject_Repr(self.ptr)) };
-}
-
-pub fn call(self: *Self, args: zpy.Tuple, kwargs: ?zpy.Dict) zpy.Error!zpy.Object {
- const kwargs_ptr: ?*c.PyObject = if (kwargs) |kw| kw.object.ptr else null;
- if (c.PyObject_Call(self.ptr, args.object.ptr, kwargs_ptr)) |object| {
- return .fromPtr(object);
- }
-
- return error.Exception;
-}
-
-pub fn format(self: *const Self, writer: *std.Io.Writer) !void {
- var str = self.repr();
- defer str.deinit();
-
- try writer.print("{s}", .{str.asUtf8() catch return error.WriteFailed});
-}