const c = @import("c"); const zpy = @import("root.zig"); pub const Number = extern struct { const Self = @This(); data: c.PyObject, pub fn add(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Add(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn sub(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Subtract(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn mul(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Multiply(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn matrixMultiply(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_MatrixMultiply(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn floorDiv(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_floorDivide(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn div(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_TrueDivide(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn remainder(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Remainder(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn divmod(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Divmod(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn power(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Power(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn negative(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Negative(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn positive(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Positive(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn absolute(self: *Self) !*Self { return @ptrCast(c.PyNumber_Absolute(@ptrCast(self)) orelse return error.Exception); } pub fn invert(self: *Self) !*Self { return @ptrCast(c.PyNumber_Invert(@ptrCast(self)) orelse return error.Exception); } pub fn lshift(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Lshift(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn rshift(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Rshift(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn @"and"(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_And(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn xor(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Xor(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn @"or"(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_Or(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceAdd(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceAdd(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceSub(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceSubtract(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceMul(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceMultiply(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceMatrixMultiply(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceMatrixMultiply(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceFloorDiv(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlacefloorDivide(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceDiv(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceTrueDivide(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceRemainder(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceRemainder(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceDivmod(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceDivmod(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlacePower(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlacePower(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceLshift(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceLshift(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceRshift(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceRshift(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceAnd(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceAnd(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceXor(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceXor(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn inPlaceOr(self: *Self, other: *Self) !*Self { return @ptrCast(c.PyNumber_InPlaceOr(@ptrCast(self), @ptrCast(other)) orelse return error.Exception); } pub fn toInt(self: *Self) !*zpy.Int { return @ptrCast(c.PyNumber_Long(@ptrCast(self)) orelse return error.Exception); } pub fn toFloat(self: *Self) !*zpy.Float { return @ptrCast(c.PyNumber_Float(@ptrCast(self)) orelse return error.Exception); } pub fn toBase(self: *Self, n: usize) !*zpy.Str { return @ptrCast(c.PyNumber_ToBase(@ptrCast(self), @intCast(n)) orelse return error.Exception); } pub fn as(self: *Self, T: type) T { return @intCast(c.PyNumber_AsSize_t(@ptrCast(self), null)); } pub fn asObject(self: *Self) !*zpy.Object { return @ptrCast(self); } };