Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var -> const to be compatible with zig master #257

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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