summaryrefslogtreecommitdiff
path: root/src/tuple.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/tuple.zig')
-rw-r--r--src/tuple.zig19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/tuple.zig b/src/tuple.zig
index ba82003..4e53d3f 100644
--- a/src/tuple.zig
+++ b/src/tuple.zig
@@ -22,24 +22,37 @@ pub const Tuple = extern struct {
}
pub fn size(self: *const Self) usize {
- return c.PyTuple_GET_SIZE(self.object.ptr);
+ return c.PyTuple_GET_SIZE(@ptrCast(self));
}
- pub fn get(self: *Self, index: usize) !*zpy.Object {
+ pub fn get(self: *const Self, index: usize) !*zpy.Object {
return @ptrCast(
c.PyTuple_GetItem(
- self.object.ptr,
+ @ptrCast(self),
@intCast(index),
) orelse return error.Exception,
);
}
+ pub fn getUnchecked(self: *Self, index: usize) *zpy.Object {
+ return @ptrCast(c.PyTuple.GET_ITEM(
+ @ptrCast(self),
+ @intCast(index),
+ ));
+ }
+
pub fn set(self: *Self, index: usize, value: *zpy.Object) !void {
if (c.PyTuple_SetItem(@ptrCast(self), @intCast(index), @ptrCast(value)) == -1) {
return error.Exception;
}
}
+ pub fn resize(self: *Self, newlen: usize) !void {
+ if (c._PyTuple_Resize(@ptrCast(&self), @intCast(newlen)) == -1) {
+ return error.Exception;
+ }
+ }
+
pub fn asObject(self: *Self) *zpy.Object {
return @ptrCast(self);
}