From 30b15ec78390c31b4456e9b600ccabe7481cc5ea Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Mon, 26 Dec 2022 11:00:59 +0100 Subject: fix for latest zig --- helpers.zig | 2 +- sqlite.zig | 30 +++++++++++++------------- vtab.zig | 70 ++++++++++++++++++++++++++++++------------------------------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/helpers.zig b/helpers.zig index aa04f54..7bcbabe 100644 --- a/helpers.zig +++ b/helpers.zig @@ -84,5 +84,5 @@ fn sliceFromValue(sqlite_value: *c.sqlite3_value) []const u8 { const value = c.sqlite3_value_text(sqlite_value); debug.assert(value != null); // TODO(vincent): how do we handle this properly ? - return value.?[0..size]; + return value[0..size]; } diff --git a/sqlite.zig b/sqlite.zig index d39f44b..db6ce0d 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -640,19 +640,19 @@ pub const Db = struct { .Fn => |fn_info| fn_info, else => @compileError("cannot use func, expecting a function"), }; - if (finalize_fn_info.args.len != 1) @compileError("finalize function must take exactly one argument"); + if (finalize_fn_info.params.len != 1) @compileError("finalize function must take exactly one argument"); if (finalize_fn_info.is_generic) @compileError("finalize function can't be generic"); if (finalize_fn_info.is_var_args) @compileError("finalize function can't be variadic"); - if (step_fn_info.args[0].arg_type.? != finalize_fn_info.args[0].arg_type.?) { + if (step_fn_info.params[0].type.? != finalize_fn_info.params[0].type.?) { @compileError("both step and finalize functions must have the same first argument and it must be a FunctionContext"); } - if (step_fn_info.args[0].arg_type.? != FunctionContext) { + if (step_fn_info.params[0].type.? != FunctionContext) { @compileError("both step and finalize functions must have a first argument of type FunctionContext"); } // subtract the context argument - const real_args_len = step_fn_info.args.len - 1; + const real_args_len = step_fn_info.params.len - 1; // @@ -669,7 +669,7 @@ pub const Db = struct { fn xStep(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { debug.assert(argc == real_args_len); - const sqlite_args = argv.?[0..real_args_len]; + const sqlite_args = argv[0..real_args_len]; var args: std.meta.ArgsTuple(@TypeOf(step_func)) = undefined; @@ -679,14 +679,14 @@ pub const Db = struct { comptime var i: usize = 0; inline while (i < real_args_len) : (i += 1) { // Remember the firt argument is always the function context - const arg = step_fn_info.args[i + 1]; + const arg = step_fn_info.params[i + 1]; const arg_ptr = &args[i + 1]; - const ArgType = arg.arg_type.?; + const ArgType = arg.type.?; helpers.setTypeFromValue(ArgType, arg_ptr, sqlite_args[i].?); } - @call(.{}, step_func, args); + @call(.auto, step_func, args); } }.xStep, struct { @@ -696,7 +696,7 @@ pub const Db = struct { // Pass the function context args[0] = FunctionContext{ .ctx = ctx }; - const result = @call(.{}, finalize_func, args); + const result = @call(.auto, finalize_func, args); helpers.setResult(ctx, result); } @@ -738,22 +738,22 @@ pub const Db = struct { const result = c.sqlite3_create_function_v2( self.db, func_name, - fn_info.args.len, + fn_info.params.len, flags, null, struct { fn xFunc(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { - debug.assert(argc == fn_info.args.len); + debug.assert(argc == fn_info.params.len); - const sqlite_args = argv.?[0..fn_info.args.len]; + const sqlite_args = argv[0..fn_info.params.len]; var fn_args: ArgTuple = undefined; - inline for (fn_info.args) |arg, i| { - const ArgType = arg.arg_type.?; + inline for (fn_info.params) |arg, i| { + const ArgType = arg.type.?; helpers.setTypeFromValue(ArgType, &fn_args[i], sqlite_args[i].?); } - const result = @call(.{}, func, fn_args); + const result = @call(.auto, func, fn_args); helpers.setResult(ctx, result); } diff --git a/vtab.zig b/vtab.zig index 2c3e329..aef1b40 100644 --- a/vtab.zig +++ b/vtab.zig @@ -315,9 +315,9 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.init)).Fn; - if (info.args.len != 2) @compileError(error_message); - if (info.args[0].arg_type.? != mem.Allocator) @compileError(error_message); - if (info.args[1].arg_type.? != *Table) @compileError(error_message); + if (info.params.len != 2) @compileError(error_message); + if (info.params[0].type.? != mem.Allocator) @compileError(error_message); + if (info.params[1].type.? != *Table) @compileError(error_message); if (info.return_type.? != Cursor.InitError!*Cursor) @compileError(error_message); } @@ -333,8 +333,8 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.deinit)).Fn; - if (info.args.len != 1) @compileError(error_message); - if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); + if (info.params.len != 1) @compileError(error_message); + if (info.params[0].type.? != *Cursor) @compileError(error_message); if (info.return_type.? != void) @compileError(error_message); } @@ -354,9 +354,9 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.next)).Fn; - if (info.args.len != 2) @compileError(error_message); - if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); + if (info.params.len != 2) @compileError(error_message); + if (info.params[0].type.? != *Cursor) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); if (info.return_type.? != Cursor.NextError!void) @compileError(error_message); } @@ -376,9 +376,9 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.hasNext)).Fn; - if (info.args.len != 2) @compileError(error_message); - if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); + if (info.params.len != 2) @compileError(error_message); + if (info.params[0].type.? != *Cursor) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); if (info.return_type.? != Cursor.HasNextError!bool) @compileError(error_message); } @@ -398,11 +398,11 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.filter)).Fn; - if (info.args.len != 4) @compileError(error_message); - if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); - if (info.args[2].arg_type.? != IndexIdentifier) @compileError(error_message); - if (info.args[3].arg_type.? != []FilterArg) @compileError(error_message); + if (info.params.len != 4) @compileError(error_message); + if (info.params[0].type.? != *Cursor) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); + if (info.params[2].type.? != IndexIdentifier) @compileError(error_message); + if (info.params[3].type.? != []FilterArg) @compileError(error_message); if (info.return_type.? != Cursor.FilterError!void) @compileError(error_message); } @@ -425,10 +425,10 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.column)).Fn; - if (info.args.len != 3) @compileError(error_message); - if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); - if (info.args[2].arg_type.? != i32) @compileError(error_message); + if (info.params.len != 3) @compileError(error_message); + if (info.params[0].type.? != *Cursor) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); + if (info.params[2].type.? != i32) @compileError(error_message); if (info.return_type.? != Cursor.ColumnError!Cursor.Column) @compileError(error_message); } @@ -448,9 +448,9 @@ fn validateCursorType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Cursor.rowId)).Fn; - if (info.args.len != 2) @compileError(error_message); - if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); + if (info.params.len != 2) @compileError(error_message); + if (info.params[0].type.? != *Cursor) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); if (info.return_type.? != Cursor.RowIDError!i64) @compileError(error_message); } } @@ -473,11 +473,11 @@ fn validateTableType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Table.init)).Fn; - if (info.args.len != 3) @compileError(error_message); - if (info.args[0].arg_type.? != mem.Allocator) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); - // TODO(vincent): maybe allow a signature without the args since a table can do withoout them - if (info.args[2].arg_type.? != []const ModuleArgument) @compileError(error_message); + if (info.params.len != 3) @compileError(error_message); + if (info.params[0].type.? != mem.Allocator) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); + // TODO(vincent): maybe allow a signature without the params since a table can do withoout them + if (info.params[2].type.? != []const ModuleArgument) @compileError(error_message); if (info.return_type.? != Table.InitError!*Table) @compileError(error_message); } @@ -493,9 +493,9 @@ fn validateTableType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Table.deinit)).Fn; - if (info.args.len != 2) @compileError(error_message); - if (info.args[0].arg_type.? != *Table) @compileError(error_message); - if (info.args[1].arg_type.? != mem.Allocator) @compileError(error_message); + if (info.params.len != 2) @compileError(error_message); + if (info.params[0].type.? != *Table) @compileError(error_message); + if (info.params[1].type.? != mem.Allocator) @compileError(error_message); if (info.return_type.? != void) @compileError(error_message); } @@ -515,10 +515,10 @@ fn validateTableType(comptime Table: type) void { const info = @typeInfo(@TypeOf(Table.buildBestIndex)).Fn; - if (info.args.len != 3) @compileError(error_message); - if (info.args[0].arg_type.? != *Table) @compileError(error_message); - if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); - if (info.args[2].arg_type.? != *BestIndexBuilder) @compileError(error_message); + if (info.params.len != 3) @compileError(error_message); + if (info.params[0].type.? != *Table) @compileError(error_message); + if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); + if (info.params[2].type.? != *BestIndexBuilder) @compileError(error_message); if (info.return_type.? != Table.BuildBestIndexError!void) @compileError(error_message); } -- cgit v1.2.3