Skip to content

Commit

Permalink
var -> const to be compatible with zig master (#257)
Browse files Browse the repository at this point in the history
compatibility with 0.12.0-dev.1664+8ca4a5240
  • Loading branch information
lwwmanning authored Nov 21, 2023
1 parent 3a8d5d7 commit 27044b1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pydust/src/modules.zig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn Module(comptime name: [:0]const u8, comptime definition: type) type {

/// A function to initialize the Python module from its definition.
pub fn init() !py.PyObject {
var pyModuleDef = try py.allocator.create(ffi.PyModuleDef);
const pyModuleDef = try py.allocator.create(ffi.PyModuleDef);
pyModuleDef.* = ffi.PyModuleDef{
.m_base = ffi.PyModuleDef_Base{
.ob_base = ffi.PyObject{
Expand Down
6 changes: 3 additions & 3 deletions pydust/src/pytypes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ fn GC(comptime definition: type) type {
}

fn tp_clear(pyself: *ffi.PyObject) callconv(.C) c_int {
var self: *PyTypeStruct(definition) = @ptrCast(pyself);
const self: *PyTypeStruct(definition) = @ptrCast(pyself);
clearFields(self.state);
return 0;
}
Expand Down Expand Up @@ -562,7 +562,7 @@ fn GC(comptime definition: type) type {
}

inline fn pyClear(obj: *ffi.PyObject) void {
var objRef = @constCast(&obj);
const objRef = @constCast(&obj);
const objOld = objRef.*;
objRef.* = undefined;
py.decref(objOld);
Expand Down Expand Up @@ -665,7 +665,7 @@ fn Members(comptime definition: type) type {

// We compute the offset of the attribute within the type, and then the value field within the attribute.
// Although the value within the attribute should always be 0 since it's the only field.
var offset = @offsetOf(PyTypeStruct(definition), "state") + @offsetOf(definition, field.name) + @offsetOf(field.type, "value");
const offset = @offsetOf(PyTypeStruct(definition), "state") + @offsetOf(definition, field.name) + @offsetOf(field.type, "value");

const T = @typeInfo(field.type).Struct.fields[0].type;

Expand Down
2 changes: 1 addition & 1 deletion pydust/src/types/bytes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test "PyBytes" {
var ps = try PyBytes.create(a);
defer ps.decref();

var ps_slice = try ps.asSlice();
const ps_slice = try ps.asSlice();
try testing.expectEqual(a.len, ps_slice.len);
try testing.expectEqual(a.len, try ps.length());
try testing.expectEqual(@as(u8, 0), ps_slice[ps_slice.len]);
Expand Down
2 changes: 1 addition & 1 deletion pydust/src/types/str.zig
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test "PyString" {
ps = try ps.appendSlice(b);
defer ps.decref();

var ps_slice = try ps.asSlice();
const ps_slice = try ps.asSlice();

// Null-terminated strings have len == non-null bytes, but are guaranteed to have a null byte
// when indexed by their length.
Expand Down

0 comments on commit 27044b1

Please sign in to comment.