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

Be able to compile with latest zig #28

Merged
merged 2 commits into from
Nov 28, 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
1 change: 1 addition & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.name = "ziglua",
.description = "Zig bindings for the Lua C API",
.version = "0.1.0",
.paths = .{ "" },
}
2 changes: 1 addition & 1 deletion src/ziglua-5.1/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub const Lua = struct {
pub fn init(allocator: Allocator) !Lua {
// the userdata passed to alloc needs to be a pointer with a consistent address
// so we allocate an Allocator struct to hold a copy of the allocator's data
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
allocator_ptr.* = allocator;

const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.1/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ test "dump and load" {
const reader = struct {
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
_ = l;
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
return arr.items;
}
}.inner;
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.2/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub const Lua = struct {
pub fn init(allocator: Allocator) !Lua {
// the userdata passed to alloc needs to be a pointer with a consistent address
// so we allocate an Allocator struct to hold a copy of the allocator's data
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
allocator_ptr.* = allocator;

const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.2/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ test "dump and load" {
const reader = struct {
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
_ = l;
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
return arr.items;
}
}.inner;
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.3/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub const Lua = struct {
// the userdata passed to alloc needs to be a pointer with a consistent address
// so we allocate an Allocator struct to hold a copy of the allocator's data
// TODO: could we just pass a pointer to the init function?
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
allocator_ptr.* = allocator;

const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;
Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.3/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ test "extra space" {
var lua = try Lua.init(testing.allocator);
defer lua.deinit();

var space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
const space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
space.* = 1024;
// each new thread is initialized with a copy of the extra space from the main thread
var thread = lua.newThread();
Expand Down Expand Up @@ -714,7 +714,7 @@ test "dump and load" {
const reader = struct {
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
_ = l;
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
return arr.items;
}
}.inner;
Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.4/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ pub const Lua = struct {
pub fn init(allocator: Allocator) !Lua {
// the userdata passed to alloc needs to be a pointer with a consistent address
// so we allocate an Allocator struct to hold a copy of the allocator's data
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
allocator_ptr.* = allocator;

const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;
Expand Down Expand Up @@ -2122,7 +2122,7 @@ fn wrapZigWarnFn(comptime f: ZigWarnFn) CWarnFn {
return struct {
fn inner(data: ?*anyopaque, msg: [*c]const u8, to_cont: c_int) callconv(.C) void {
// warning messages emitted from Lua should be null-terminated for display
var message = std.mem.span(@as([*:0]const u8, @ptrCast(msg)));
const message = std.mem.span(@as([*:0]const u8, @ptrCast(msg)));
@call(.always_inline, f, .{ data, message, to_cont != 0 });
}
}.inner;
Expand Down
4 changes: 2 additions & 2 deletions src/ziglua-5.4/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ test "extra space" {
var lua = try Lua.init(testing.allocator);
defer lua.deinit();

var space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
const space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
space.* = 1024;
// each new thread is initialized with a copy of the extra space from the main thread
var thread = lua.newThread();
Expand Down Expand Up @@ -755,7 +755,7 @@ test "dump and load" {
const reader = struct {
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
_ = l;
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
return arr.items;
}
}.inner;
Expand Down