summaryrefslogtreecommitdiff
path: root/src/struct-sequence.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/struct-sequence.zig')
-rw-r--r--src/struct-sequence.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/struct-sequence.zig b/src/struct-sequence.zig
new file mode 100644
index 0000000..bc1b8e7
--- /dev/null
+++ b/src/struct-sequence.zig
@@ -0,0 +1,25 @@
+const c = @import("c");
+
+const zpy = @import("root.zig");
+
+pub const StructSequence = extern struct {
+ const Self = @This();
+
+ data: c.PyObject,
+
+ pub fn new(t: *zpy.Type) !*Self {
+ return @ptrCast(c.PyStructSequence_New(@ptrCast(@constCast(t))) orelse return error.Exception);
+ }
+
+ pub fn get(self: *Self, index: usize) *Self {
+ return @ptrCast(c.PyStructSequence_GetItem(@ptrCast(self), @intCast(index)));
+ }
+
+ pub fn set(self: *Self, index: usize, value: *zpy.Object) void {
+ c.PyStructSequence_SetItem(@ptrCast(self), @intCast(index), @ptrCast(value));
+ }
+
+ pub fn asObject(self: *Self) *zpy.Object {
+ return @ptrCast(self);
+ }
+};