diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e6d8b8f..bfddaca 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -25,9 +25,9 @@ jobs: uses: actions/checkout@v3 - name: Setup Pages uses: actions/configure-pages@v5 - - uses: mlugg/setup-zig@v1 + - uses: mlugg/setup-zig@v2 with: - version: 0.15.0-dev.441+c1649d586 + version: master - run: make docs - name: Upload artifact uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ee63b42..3dd1e5d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,6 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - zig: ["0.14.0", "0.15.0-dev.441+c1649d586"] runs-on: ${{matrix.os}} @@ -20,9 +19,9 @@ jobs: uses: actions/checkout@v3 - name: Setup Zig - uses: mlugg/setup-zig@v1 + uses: mlugg/setup-zig@v2 with: - version: ${{ matrix.zig }} + version: master - name: Run tests run: make test @@ -31,7 +30,6 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - zig: ["0.14.0", "0.15.0-dev.441+c1649d586"] runs-on: ${{matrix.os}} @@ -40,9 +38,9 @@ jobs: uses: actions/checkout@v3 - name: Setup Zig - uses: mlugg/setup-zig@v1 + uses: mlugg/setup-zig@v2 with: - version: ${{ matrix.zig }} + version: master - name: Run tests - run: make test_cross \ No newline at end of file + run: make test_cross diff --git a/build.zig b/build.zig index ea4f151..9dec502 100644 --- a/build.zig +++ b/build.zig @@ -99,9 +99,11 @@ pub fn build(b: *Build) void { // Tests const tests = b.addTest(.{ - .root_source_file = b.path("src/tests.zig"), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path("src/tests.zig"), + .target = target, + .optimize = optimize, + }), }); tests.root_module.addImport("zlua", zlua); @@ -123,9 +125,11 @@ pub fn build(b: *Build) void { for (examples) |example| { const exe = b.addExecutable(.{ .name = example[0], - .root_source_file = b.path(example[1]), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path(example[1]), + .target = target, + .optimize = optimize, + }), }); exe.root_module.addImport("zlua", zlua); @@ -143,9 +147,11 @@ pub fn build(b: *Build) void { const docs = b.addObject(.{ .name = "ziglua", - .root_source_file = b.path("src/lib.zig"), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path("src/lib.zig"), + .target = target, + .optimize = optimize, + }), }); const install_docs = b.addInstallDirectory(.{ @@ -159,9 +165,11 @@ pub fn build(b: *Build) void { // definitions example const def_exe = b.addExecutable(.{ - .root_source_file = b.path("examples/define-exe.zig"), .name = "define-zig-types", - .target = target, + .root_module = b.createModule(.{ + .root_source_file = b.path("examples/define-exe.zig"), + .target = target, + }), }); def_exe.root_module.addImport("zlua", zlua); var run_def_exe = b.addRunArtifact(def_exe); diff --git a/build/lua.zig b/build/lua.zig index d7a2b61..f0880a8 100644 --- a/build/lua.zig +++ b/build/lua.zig @@ -41,20 +41,16 @@ pub fn configure( else => unreachable, }; - const lib = if (shared) - b.addSharedLibrary(.{ - .name = library_name, - .target = target, - .optimize = optimize, - .version = version, - }) - else - b.addStaticLibrary(.{ - .name = library_name, - .target = target, - .optimize = optimize, - .version = version, - }); + const lib = b.createModule(.{ + .target = target, + .optimize = optimize, + }); + const library = b.addLibrary(.{ + .name = library_name, + .version = version, + .linkage = if (shared) .dynamic else .static, + .root_module = lib, + }); lib.addIncludePath(upstream.path("src")); @@ -102,24 +98,24 @@ pub fn configure( if (lang == .lua51) { const patched = applyPatchToFile(b, b.graph.host, upstream.path("src/ldo.c"), b.path("build/lua-5.1.patch"), "ldo.c"); - lib.step.dependOn(&patched.run.step); + library.step.dependOn(&patched.run.step); lib.addCSourceFile(.{ .file = patched.output, .flags = &flags }); } - lib.linkLibC(); + library.linkLibC(); - lib.installHeader(upstream.path("src/lua.h"), "lua.h"); - lib.installHeader(upstream.path("src/lualib.h"), "lualib.h"); - lib.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h"); - lib.installHeader(upstream.path("src/luaconf.h"), "luaconf.h"); + library.installHeader(upstream.path("src/lua.h"), "lua.h"); + library.installHeader(upstream.path("src/lualib.h"), "lualib.h"); + library.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h"); + library.installHeader(upstream.path("src/luaconf.h"), "luaconf.h"); if (lua_user_h) |user_h| { - lib.addIncludePath(user_h.dirname()); - lib.installHeader(user_h, user_header); + library.addIncludePath(user_h.dirname()); + library.installHeader(user_h, user_header); } - return lib; + return library; } const lua_base_source_files = [_][]const u8{ diff --git a/build/luajit.zig b/build/luajit.zig index f355ebd..504f3d3 100644 --- a/build/luajit.zig +++ b/build/luajit.zig @@ -8,27 +8,26 @@ const applyPatchToFile = @import("utils.zig").applyPatchToFile; pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, shared: bool) *Step.Compile { // TODO: extract this to the main build function because it is shared between all specialized build functions - const lib: *Step.Compile = if (shared) - b.addSharedLibrary(.{ - .name = "lua", - .target = target, - .optimize = optimize, - .unwind_tables = .sync, - }) - else - b.addStaticLibrary(.{ - .name = "lua", - .target = target, - .optimize = optimize, - .unwind_tables = .sync, - }); + const lib = b.createModule(.{ + .target = target, + .optimize = optimize, + .unwind_tables = .sync, + }); + const library = b.addLibrary(.{ + .name = "lua", + .root_module = lib, + .linkage = if (shared) .dynamic else .static, + }); // Compile minilua interpreter used at build time to generate files - const minilua = b.addExecutable(.{ - .name = "minilua", + const minilua_mod = b.createModule(.{ .target = b.graph.host, // Use host target for cross build .optimize = .ReleaseSafe, }); + const minilua = b.addExecutable(.{ + .name = "minilua", + .root_module = minilua_mod, + }); minilua.linkLibC(); // FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped const builtin = @import("builtin"); @@ -106,11 +105,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin. const luajit_h = genversion_run.addOutputFileArg("luajit.h"); // Compile the buildvm executable used to generate other files - const buildvm = b.addExecutable(.{ - .name = "buildvm", + const vm_mod = b.createModule(.{ .target = b.graph.host, // Use host target for cross build .optimize = .ReleaseSafe, }); + const buildvm = b.addExecutable(.{ + .name = "buildvm", + .root_module = vm_mod, + }); buildvm.linkLibC(); // FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) { @@ -197,27 +199,27 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin. } // Finally build LuaJIT after generating all the files - lib.step.dependOn(&genversion_run.step); - lib.step.dependOn(&buildvm_bcdef.step); - lib.step.dependOn(&buildvm_ffdef.step); - lib.step.dependOn(&buildvm_libdef.step); - lib.step.dependOn(&buildvm_recdef.step); - lib.step.dependOn(&buildvm_folddef.step); - lib.step.dependOn(&buildvm_ljvm.step); + library.step.dependOn(&genversion_run.step); + library.step.dependOn(&buildvm_bcdef.step); + library.step.dependOn(&buildvm_ffdef.step); + library.step.dependOn(&buildvm_libdef.step); + library.step.dependOn(&buildvm_recdef.step); + library.step.dependOn(&buildvm_folddef.step); + library.step.dependOn(&buildvm_ljvm.step); - lib.linkLibC(); + library.linkLibC(); - lib.root_module.addCMacro("LUAJIT_UNWIND_EXTERNAL", ""); + lib.addCMacro("LUAJIT_UNWIND_EXTERNAL", ""); - lib.linkSystemLibrary("unwind"); + lib.linkSystemLibrary("unwind", .{}); - lib.addIncludePath(upstream.path("src")); - lib.addIncludePath(luajit_h.dirname()); - lib.addIncludePath(bcdef_header.dirname()); - lib.addIncludePath(ffdef_header.dirname()); - lib.addIncludePath(libdef_header.dirname()); - lib.addIncludePath(recdef_header.dirname()); - lib.addIncludePath(folddef_header.dirname()); + library.addIncludePath(upstream.path("src")); + library.addIncludePath(luajit_h.dirname()); + library.addIncludePath(bcdef_header.dirname()); + library.addIncludePath(ffdef_header.dirname()); + library.addIncludePath(libdef_header.dirname()); + library.addIncludePath(recdef_header.dirname()); + library.addIncludePath(folddef_header.dirname()); lib.addCSourceFiles(.{ .root = .{ .dependency = .{ @@ -229,18 +231,18 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin. // FIXME: remove branch when zig-0.15 is released and 0.14 can be dropped if (builtin.zig_version.major == 0 and builtin.zig_version.minor < 15) { - lib.root_module.sanitize_c = false; + lib.sanitize_c = false; } else { - lib.root_module.sanitize_c = .off; + lib.sanitize_c = .off; } - lib.installHeader(upstream.path("src/lua.h"), "lua.h"); - lib.installHeader(upstream.path("src/lualib.h"), "lualib.h"); - lib.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h"); - lib.installHeader(upstream.path("src/luaconf.h"), "luaconf.h"); - lib.installHeader(luajit_h, "luajit.h"); + library.installHeader(upstream.path("src/lua.h"), "lua.h"); + library.installHeader(upstream.path("src/lualib.h"), "lualib.h"); + library.installHeader(upstream.path("src/lauxlib.h"), "lauxlib.h"); + library.installHeader(upstream.path("src/luaconf.h"), "luaconf.h"); + library.installHeader(luajit_h, "luajit.h"); - return lib; + return library; } const luajit_lib = [_][]const u8{ diff --git a/build/luau.zig b/build/luau.zig index 15ee5c8..c4a3dd0 100644 --- a/build/luau.zig +++ b/build/luau.zig @@ -4,11 +4,15 @@ const Build = std.Build; const Step = std.Build.Step; pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, upstream: *Build.Dependency, luau_use_4_vector: bool) *Step.Compile { - const lib = b.addStaticLibrary(.{ - .name = "luau", + const lib = b.createModule(.{ .target = target, .optimize = optimize, + }); + const library = b.addLibrary(.{ + .name = "luau", + .linkage = .static, .version = std.SemanticVersion{ .major = 0, .minor = 653, .patch = 0 }, + .root_module = lib, }); lib.addIncludePath(upstream.path("Common/include")); @@ -33,14 +37,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin. .flags = &flags, }); lib.addCSourceFile(.{ .file = b.path("src/luau.cpp"), .flags = &flags }); - lib.linkLibCpp(); + library.linkLibCpp(); - lib.installHeader(upstream.path("VM/include/lua.h"), "lua.h"); - lib.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h"); - lib.installHeader(upstream.path("VM/include/luaconf.h"), "luaconf.h"); - lib.installHeader(upstream.path("Compiler/include/luacode.h"), "luacode.h"); + library.installHeader(upstream.path("VM/include/lua.h"), "lua.h"); + library.installHeader(upstream.path("VM/include/lualib.h"), "lualib.h"); + library.installHeader(upstream.path("VM/include/luaconf.h"), "luaconf.h"); + library.installHeader(upstream.path("Compiler/include/luacode.h"), "luacode.h"); - return lib; + return library; } const luau_source_files = [_][]const u8{ diff --git a/build/patch.zig b/build/patch.zig index 89ec515..cc20693 100644 --- a/build/patch.zig +++ b/build/patch.zig @@ -14,15 +14,22 @@ pub fn main() !void { const patch_file_path = args[2]; const output_path = args[3]; - const patch_file = try std.fs.openFileAbsolute(patch_file_path, .{ .mode = .read_only }); - defer patch_file.close(); - const chunk_details = Chunk.next(allocator, patch_file) orelse @panic("No chunk data found"); + const patch_file = patch_file: { + const patch_file = try std.fs.cwd().openFile(patch_file_path, .{ .mode = .read_only }); + defer patch_file.close(); + break :patch_file try patch_file.readToEndAlloc(allocator, std.math.maxInt(usize)); + }; + const chunk_details = Chunk.init(allocator, patch_file, 0) orelse @panic("No chunk data found"); - const file = try std.fs.openFileAbsolute(file_path, .{ .mode = .read_only }); + const file = try std.fs.cwd().openFile(file_path, .{ .mode = .read_only }); defer file.close(); + var in_buf: [4096]u8 = undefined; + var reader = file.reader(&in_buf); - const output = try std.fs.createFileAbsolute(output_path, .{}); + const output = try std.fs.cwd().createFile(output_path, .{}); defer output.close(); + var out_buf: [4096]u8 = undefined; + var writer = output.writer(&out_buf); var state: State = .copy; @@ -32,26 +39,32 @@ pub fn main() !void { switch (state) { .copy => { - const line = getLine(allocator, file) orelse return; - _ = try output.write(line); - _ = try output.write("\n"); + _ = reader.interface.streamDelimiter(&writer.interface, '\n') catch |err| switch (err) { + error.EndOfStream => { + try writer.end(); + return; + }, + else => return err, + }; + reader.interface.toss(1); + try writer.interface.writeByte('\n'); }, .chunk => { const chunk = chunk_details.lines[line_number - chunk_details.src]; switch (chunk.action) { .remove => { - const line = getLine(allocator, file) orelse return; + const line = try reader.interface.takeDelimiterExclusive('\n'); if (!std.mem.eql(u8, chunk.buf, line)) @panic("Failed to apply patch"); }, .keep => { - const line = getLine(allocator, file) orelse return; + const line = try reader.interface.takeDelimiterExclusive('\n'); if (!std.mem.eql(u8, chunk.buf, line)) @panic("Failed to apply patch"); - _ = try output.write(line); - _ = try output.write("\n"); + try writer.interface.writeAll(line); + try writer.interface.writeByte('\n'); }, .add => { - _ = try output.write(chunk.buf); - _ = try output.write("\n"); + try writer.interface.writeAll(chunk.buf); + try writer.interface.writeByte('\n'); }, } @@ -61,13 +74,6 @@ pub fn main() !void { } } -fn getLine(allocator: Allocator, file: File) ?[]u8 { - return file.reader().readUntilDelimiterAlloc(allocator, '\n', std.math.maxInt(usize)) catch |err| switch (err) { - error.EndOfStream => return null, - else => @panic("Error"), - }; -} - const State = enum { copy, chunk }; const Chunk = struct { @@ -82,9 +88,9 @@ const Chunk = struct { buf: []const u8, }; - fn next(allocator: Allocator, file: File) ?Chunk { - while (true) { - const line = getLine(allocator, file) orelse return null; + fn init(arena: std.mem.Allocator, contents: []const u8, pos: usize) ?Chunk { + var it = std.mem.tokenizeScalar(u8, contents[pos..], '\n'); + while (it.next()) |line| { if (std.mem.startsWith(u8, line, "@@")) { const end = std.mem.indexOfPosLinear(u8, line, 3, "@@").?; const details = line[4 .. end - 2]; @@ -95,7 +101,7 @@ const Chunk = struct { var lines: std.ArrayListUnmanaged(Line) = .empty; while (true) { - const diff_line = getLine(allocator, file) orelse break; + const diff_line = it.next() orelse break; if (std.mem.startsWith(u8, diff_line, "@@")) break; const action: Line.Action = switch (diff_line[0]) { @@ -105,16 +111,17 @@ const Chunk = struct { else => @panic("Bad patch file"), }; - lines.append(allocator, .{ .action = action, .buf = diff_line[1..] }) catch unreachable; + lines.append(arena, .{ .action = action, .buf = diff_line[1..] }) catch unreachable; } return .{ - .lines = lines.toOwnedSlice(allocator) catch unreachable, + .lines = lines.toOwnedSlice(arena) catch unreachable, .src = src, .dst = dst, }; } } + return null; } fn getLineNumber(buf: []const u8) usize { diff --git a/build/utils.zig b/build/utils.zig index eddf5ce..16637de 100644 --- a/build/utils.zig +++ b/build/utils.zig @@ -17,8 +17,10 @@ pub fn applyPatchToFile( ) PatchFile { const patch = b.addExecutable(.{ .name = "patch", - .root_source_file = b.path("build/patch.zig"), - .target = target, + .root_module = b.createModule(.{ + .root_source_file = b.path("build/patch.zig"), + .target = target, + }), }); const patch_run = b.addRunArtifact(patch); diff --git a/examples/interpreter.zig b/examples/interpreter.zig index 235982c..e219431 100644 --- a/examples/interpreter.zig +++ b/examples/interpreter.zig @@ -20,15 +20,19 @@ pub fn main() anyerror!void { // Open all Lua standard libraries lua.openLibs(); - var stdin = std.io.getStdIn().reader(); - var stdout = std.io.getStdOut().writer(); + var in_buf: [4096]u8 = undefined; + var out_buf: [4096]u8 = undefined; + var stdin_file = std.fs.File.stdin().reader(&in_buf); + const stdin = &stdin_file.interface; + var stdout_file = std.fs.File.stdout().writer(&out_buf); + const stdout = &stdout_file.interface; var buffer: [256]u8 = undefined; while (true) { - _ = try stdout.write("> "); + _ = try stdout.writeAll("> "); // Read a line of input - const len = try stdin.read(&buffer); + const len = try stdin.readSliceShort(&buffer); if (len == 0) break; // EOF if (len >= buffer.len - 1) { try stdout.print("error: line too long!\n", .{}); diff --git a/src/lib.zig b/src/lib.zig index 64d97ab..53df4c1 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -76,7 +76,7 @@ pub const ArithOperator = switch (lang) { /// Type for C functions /// See https://www.lua.org/manual/5.4/manual.html#lua_CFunction for the protocol -pub const CFn = *const fn (state: ?*LuaState) callconv(.C) c_int; +pub const CFn = *const fn (state: ?*LuaState) callconv(.c) c_int; /// Operations supported by `Lua.compare()` pub const CompareOperator = enum(u2) { @@ -86,13 +86,13 @@ pub const CompareOperator = enum(u2) { }; /// Type for C userdata destructors -pub const CUserdataDtorFn = *const fn (userdata: *anyopaque) callconv(.C) void; +pub const CUserdataDtorFn = *const fn (userdata: *anyopaque) callconv(.c) void; /// Type for C interrupt callback -pub const CInterruptCallbackFn = *const fn (state: ?*LuaState, gc: c_int) callconv(.C) void; +pub const CInterruptCallbackFn = *const fn (state: ?*LuaState, gc: c_int) callconv(.c) void; /// Type for C useratom callback -pub const CUserAtomCallbackFn = *const fn (str: [*c]const u8, len: usize) callconv(.C) i16; +pub const CUserAtomCallbackFn = *const fn (str: [*c]const u8, len: usize) callconv(.c) i16; /// The internal Lua debug structure const Debug = c.lua_Debug; @@ -357,7 +357,7 @@ pub const FnReg = struct { pub const globals_index = c.LUA_GLOBALSINDEX; /// Type for debugging hook functions -pub const CHookFn = *const fn (state: ?*LuaState, ar: ?*Debug) callconv(.C) void; +pub const CHookFn = *const fn (state: ?*LuaState, ar: ?*Debug) callconv(.c) void; /// Specifies on which events the hook will be called pub const HookMask = packed struct { @@ -401,7 +401,7 @@ pub const Integer = c.lua_Integer; pub const Context = isize; /// Type for continuation functions -pub const CContFn = *const fn (state: ?*LuaState, status: c_int, ctx: Context) callconv(.C) c_int; +pub const CContFn = *const fn (state: ?*LuaState, status: c_int, ctx: Context) callconv(.c) c_int; pub const Libs51 = packed struct { base: bool = false, @@ -499,7 +499,7 @@ pub const mult_return = c.LUA_MULTRET; pub const Number = c.lua_Number; /// The type of the reader function used by `Lua.load()` -pub const CReaderFn = *const fn (state: ?*LuaState, data: ?*anyopaque, size: [*c]usize) callconv(.C) [*c]const u8; +pub const CReaderFn = *const fn (state: ?*LuaState, data: ?*anyopaque, size: [*c]usize) callconv(.c) [*c]const u8; /// The possible status of a call to `Lua.resumeThread` pub const ResumeStatus = enum(u1) { @@ -563,12 +563,12 @@ pub const Unsigned = c.lua_Unsigned; /// The type of warning functions used by Lua to emit warnings pub const CWarnFn = switch (lang) { - .lua54 => *const fn (data: ?*anyopaque, msg: [*c]const u8, to_cont: c_int) callconv(.C) void, + .lua54 => *const fn (data: ?*anyopaque, msg: [*c]const u8, to_cont: c_int) callconv(.c) void, else => @compileError("CWarnFn not defined"), }; /// The type of the writer function used by `Lua.dump()` -pub const CWriterFn = *const fn (state: ?*LuaState, buf: ?*const anyopaque, size: usize, data: ?*anyopaque) callconv(.C) c_int; +pub const CWriterFn = *const fn (state: ?*LuaState, buf: ?*const anyopaque, size: usize, data: ?*anyopaque) callconv(.c) c_int; /// For bundling a parsed value with an arena allocator /// Copied from std.json.Parsed @@ -592,7 +592,7 @@ pub const Lua = opaque { /// Allows Lua to allocate memory using a Zig allocator passed in via data. /// See https://www.lua.org/manual/5.4/manual.html#lua_Alloc for more details - fn alloc(data: ?*anyopaque, ptr: ?*anyopaque, osize: usize, nsize: usize) callconv(.C) ?*align(alignment) anyopaque { + fn alloc(data: ?*anyopaque, ptr: ?*anyopaque, osize: usize, nsize: usize) callconv(.c) ?*align(alignment) anyopaque { // just like malloc() returns a pointer "which is suitably aligned for any built-in type", // the memory allocated by this function should also be aligned for any type that Lua may // desire to allocate. use the largest alignment for the target @@ -5163,7 +5163,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CFn Tuple(&.{*Lua}) => { return struct { - fn inner(state: ?*LuaState) callconv(.C) c_int { + fn inner(state: ?*LuaState) callconv(.c) c_int { // this is called by Lua, state should never be null var lua: *Lua = @ptrCast(state.?); if (has_error_union) { @@ -5179,7 +5179,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CHookFn Tuple(&.{ *Lua, Event, *DebugInfo }) => { return struct { - fn inner(state: ?*LuaState, ar: ?*Debug) callconv(.C) void { + fn inner(state: ?*LuaState, ar: ?*Debug) callconv(.c) void { // this is called by Lua, state should never be null var lua: *Lua = @ptrCast(state.?); var debug_info: DebugInfo = .{ @@ -5202,7 +5202,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CContFn Tuple(&.{ *Lua, Status, Context }) => { return struct { - fn inner(state: ?*LuaState, status: c_int, ctx: Context) callconv(.C) c_int { + fn inner(state: ?*LuaState, status: c_int, ctx: Context) callconv(.c) c_int { // this is called by Lua, state should never be null var lua: *Lua = @ptrCast(state.?); if (has_error_union) { @@ -5218,7 +5218,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CReaderFn Tuple(&.{ *Lua, *anyopaque }) => { return struct { - fn inner(state: ?*LuaState, data: ?*anyopaque, size: [*c]usize) callconv(.C) [*c]const u8 { + fn inner(state: ?*LuaState, data: ?*anyopaque, size: [*c]usize) callconv(.c) [*c]const u8 { // this is called by Lua, state should never be null var lua: *Lua = @ptrCast(state.?); if (has_error_union) { @@ -5247,7 +5247,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CUserdataDtorFn Tuple(&.{*anyopaque}) => { return struct { - fn inner(userdata: *anyopaque) callconv(.C) void { + fn inner(userdata: *anyopaque) callconv(.c) void { return @call(.always_inline, function, .{userdata}); } }.inner; @@ -5255,7 +5255,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CInterruptCallbackFn Tuple(&.{ *Lua, i32 }) => { return struct { - fn inner(state: ?*LuaState, gc: c_int) callconv(.C) void { + fn inner(state: ?*LuaState, gc: c_int) callconv(.c) void { // this is called by Lua, state should never be null var lua: *Lua = @ptrCast(state.?); if (has_error_union) { @@ -5271,7 +5271,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CUserAtomCallbackFn Tuple(&.{[]const u8}) => { return struct { - fn inner(str: [*c]const u8, len: usize) callconv(.C) i16 { + fn inner(str: [*c]const u8, len: usize) callconv(.c) i16 { if (str) |s| { const buf = s[0..len]; return @call(.always_inline, function, .{buf}); @@ -5283,7 +5283,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CWarnFn Tuple(&.{ ?*anyopaque, []const u8, bool }) => { return struct { - fn inner(data: ?*anyopaque, msg: [*c]const u8, to_cont: c_int) callconv(.C) void { + 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 const message = std.mem.span(@as([*:0]const u8, @ptrCast(msg))); @call(.always_inline, function, .{ data, message, to_cont != 0 }); @@ -5293,7 +5293,7 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) { // CWriterFn Tuple(&.{ *Lua, []const u8, *anyopaque }) => { return struct { - fn inner(state: ?*LuaState, buf: ?*const anyopaque, size: usize, data: ?*anyopaque) callconv(.C) c_int { + fn inner(state: ?*LuaState, buf: ?*const anyopaque, size: usize, data: ?*anyopaque) callconv(.c) c_int { // this is called by Lua, state should never be null var lua: *Lua = @ptrCast(state.?); const buffer = @as([*]const u8, @ptrCast(buf))[0..size]; @@ -5382,7 +5382,7 @@ pub fn exportFn(comptime name: []const u8, comptime func: anytype) CFn { if (lang == .luau) @compileError("Luau does not support compiling or loading shared modules"); return struct { - fn luaopen(state: ?*LuaState) callconv(.C) c_int { + fn luaopen(state: ?*LuaState) callconv(.c) c_int { const declaration = comptime wrap(func); return @call(.always_inline, declaration, .{state});