From 6c2e06ed20cdea1a67629554d8aa1d5fcda030f9 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 2 Sep 2026 08:17:42 +0200 Subject: Implement sequences and tuples --- src/struct-sequence.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/struct-sequence.zig (limited to 'src/struct-sequence.zig') 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); + } +}; -- cgit v1.2.3-70-g09d2