diff options
Diffstat (limited to 'src/sequence/fast.zig')
| -rw-r--r-- | src/sequence/fast.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sequence/fast.zig b/src/sequence/fast.zig new file mode 100644 index 0000000..07f5de6 --- /dev/null +++ b/src/sequence/fast.zig @@ -0,0 +1,20 @@ +const c = @import("c"); +const zpy = @import("../root.zig"); + +pub const Fast = extern struct { + const Self = @This(); + + data: c.PyObject, + + pub fn size(self: *Self) !usize { + return @intCast(c.PySequence_Fast_GET_SIZE(@ptrCast(self))); + } + + pub fn get(self: *Self, index: usize) *zpy.Object { + return @ptrCast(c.PySequence_Fast_GET_ITEM(@ptrCast(self), @intCast(index)) orelse return error.Exception); + } + + pub fn items(self: *Self) [*:null][*c]zpy.Object { + return @ptrCast(c.PySequence_Fast_ITEMS(@ptrCast(self))); + } +}; |