diff options
| author | 2022-12-26 11:00:59 +0100 | |
|---|---|---|
| committer | 2022-12-26 11:00:59 +0100 | |
| commit | 30b15ec78390c31b4456e9b600ccabe7481cc5ea (patch) | |
| tree | 20b5419c17f779a87a2798eba96eb7ae84e57300 | |
| parent | stop using removed ascii functions (diff) | |
| download | zig-sqlite-30b15ec78390c31b4456e9b600ccabe7481cc5ea.tar.gz zig-sqlite-30b15ec78390c31b4456e9b600ccabe7481cc5ea.tar.xz zig-sqlite-30b15ec78390c31b4456e9b600ccabe7481cc5ea.zip | |
fix for latest zig
| -rw-r--r-- | helpers.zig | 2 | ||||
| -rw-r--r-- | sqlite.zig | 30 | ||||
| -rw-r--r-- | 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 { | |||
| 84 | const value = c.sqlite3_value_text(sqlite_value); | 84 | const value = c.sqlite3_value_text(sqlite_value); |
| 85 | debug.assert(value != null); // TODO(vincent): how do we handle this properly ? | 85 | debug.assert(value != null); // TODO(vincent): how do we handle this properly ? |
| 86 | 86 | ||
| 87 | return value.?[0..size]; | 87 | return value[0..size]; |
| 88 | } | 88 | } |
| @@ -640,19 +640,19 @@ pub const Db = struct { | |||
| 640 | .Fn => |fn_info| fn_info, | 640 | .Fn => |fn_info| fn_info, |
| 641 | else => @compileError("cannot use func, expecting a function"), | 641 | else => @compileError("cannot use func, expecting a function"), |
| 642 | }; | 642 | }; |
| 643 | if (finalize_fn_info.args.len != 1) @compileError("finalize function must take exactly one argument"); | 643 | if (finalize_fn_info.params.len != 1) @compileError("finalize function must take exactly one argument"); |
| 644 | if (finalize_fn_info.is_generic) @compileError("finalize function can't be generic"); | 644 | if (finalize_fn_info.is_generic) @compileError("finalize function can't be generic"); |
| 645 | if (finalize_fn_info.is_var_args) @compileError("finalize function can't be variadic"); | 645 | if (finalize_fn_info.is_var_args) @compileError("finalize function can't be variadic"); |
| 646 | 646 | ||
| 647 | if (step_fn_info.args[0].arg_type.? != finalize_fn_info.args[0].arg_type.?) { | 647 | if (step_fn_info.params[0].type.? != finalize_fn_info.params[0].type.?) { |
| 648 | @compileError("both step and finalize functions must have the same first argument and it must be a FunctionContext"); | 648 | @compileError("both step and finalize functions must have the same first argument and it must be a FunctionContext"); |
| 649 | } | 649 | } |
| 650 | if (step_fn_info.args[0].arg_type.? != FunctionContext) { | 650 | if (step_fn_info.params[0].type.? != FunctionContext) { |
| 651 | @compileError("both step and finalize functions must have a first argument of type FunctionContext"); | 651 | @compileError("both step and finalize functions must have a first argument of type FunctionContext"); |
| 652 | } | 652 | } |
| 653 | 653 | ||
| 654 | // subtract the context argument | 654 | // subtract the context argument |
| 655 | const real_args_len = step_fn_info.args.len - 1; | 655 | const real_args_len = step_fn_info.params.len - 1; |
| 656 | 656 | ||
| 657 | // | 657 | // |
| 658 | 658 | ||
| @@ -669,7 +669,7 @@ pub const Db = struct { | |||
| 669 | fn xStep(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { | 669 | fn xStep(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { |
| 670 | debug.assert(argc == real_args_len); | 670 | debug.assert(argc == real_args_len); |
| 671 | 671 | ||
| 672 | const sqlite_args = argv.?[0..real_args_len]; | 672 | const sqlite_args = argv[0..real_args_len]; |
| 673 | 673 | ||
| 674 | var args: std.meta.ArgsTuple(@TypeOf(step_func)) = undefined; | 674 | var args: std.meta.ArgsTuple(@TypeOf(step_func)) = undefined; |
| 675 | 675 | ||
| @@ -679,14 +679,14 @@ pub const Db = struct { | |||
| 679 | comptime var i: usize = 0; | 679 | comptime var i: usize = 0; |
| 680 | inline while (i < real_args_len) : (i += 1) { | 680 | inline while (i < real_args_len) : (i += 1) { |
| 681 | // Remember the firt argument is always the function context | 681 | // Remember the firt argument is always the function context |
| 682 | const arg = step_fn_info.args[i + 1]; | 682 | const arg = step_fn_info.params[i + 1]; |
| 683 | const arg_ptr = &args[i + 1]; | 683 | const arg_ptr = &args[i + 1]; |
| 684 | 684 | ||
| 685 | const ArgType = arg.arg_type.?; | 685 | const ArgType = arg.type.?; |
| 686 | helpers.setTypeFromValue(ArgType, arg_ptr, sqlite_args[i].?); | 686 | helpers.setTypeFromValue(ArgType, arg_ptr, sqlite_args[i].?); |
| 687 | } | 687 | } |
| 688 | 688 | ||
| 689 | @call(.{}, step_func, args); | 689 | @call(.auto, step_func, args); |
| 690 | } | 690 | } |
| 691 | }.xStep, | 691 | }.xStep, |
| 692 | struct { | 692 | struct { |
| @@ -696,7 +696,7 @@ pub const Db = struct { | |||
| 696 | // Pass the function context | 696 | // Pass the function context |
| 697 | args[0] = FunctionContext{ .ctx = ctx }; | 697 | args[0] = FunctionContext{ .ctx = ctx }; |
| 698 | 698 | ||
| 699 | const result = @call(.{}, finalize_func, args); | 699 | const result = @call(.auto, finalize_func, args); |
| 700 | 700 | ||
| 701 | helpers.setResult(ctx, result); | 701 | helpers.setResult(ctx, result); |
| 702 | } | 702 | } |
| @@ -738,22 +738,22 @@ pub const Db = struct { | |||
| 738 | const result = c.sqlite3_create_function_v2( | 738 | const result = c.sqlite3_create_function_v2( |
| 739 | self.db, | 739 | self.db, |
| 740 | func_name, | 740 | func_name, |
| 741 | fn_info.args.len, | 741 | fn_info.params.len, |
| 742 | flags, | 742 | flags, |
| 743 | null, | 743 | null, |
| 744 | struct { | 744 | struct { |
| 745 | fn xFunc(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { | 745 | fn xFunc(ctx: ?*c.sqlite3_context, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) void { |
| 746 | debug.assert(argc == fn_info.args.len); | 746 | debug.assert(argc == fn_info.params.len); |
| 747 | 747 | ||
| 748 | const sqlite_args = argv.?[0..fn_info.args.len]; | 748 | const sqlite_args = argv[0..fn_info.params.len]; |
| 749 | 749 | ||
| 750 | var fn_args: ArgTuple = undefined; | 750 | var fn_args: ArgTuple = undefined; |
| 751 | inline for (fn_info.args) |arg, i| { | 751 | inline for (fn_info.params) |arg, i| { |
| 752 | const ArgType = arg.arg_type.?; | 752 | const ArgType = arg.type.?; |
| 753 | helpers.setTypeFromValue(ArgType, &fn_args[i], sqlite_args[i].?); | 753 | helpers.setTypeFromValue(ArgType, &fn_args[i], sqlite_args[i].?); |
| 754 | } | 754 | } |
| 755 | 755 | ||
| 756 | const result = @call(.{}, func, fn_args); | 756 | const result = @call(.auto, func, fn_args); |
| 757 | 757 | ||
| 758 | helpers.setResult(ctx, result); | 758 | helpers.setResult(ctx, result); |
| 759 | } | 759 | } |
| @@ -315,9 +315,9 @@ fn validateCursorType(comptime Table: type) void { | |||
| 315 | 315 | ||
| 316 | const info = @typeInfo(@TypeOf(Cursor.init)).Fn; | 316 | const info = @typeInfo(@TypeOf(Cursor.init)).Fn; |
| 317 | 317 | ||
| 318 | if (info.args.len != 2) @compileError(error_message); | 318 | if (info.params.len != 2) @compileError(error_message); |
| 319 | if (info.args[0].arg_type.? != mem.Allocator) @compileError(error_message); | 319 | if (info.params[0].type.? != mem.Allocator) @compileError(error_message); |
| 320 | if (info.args[1].arg_type.? != *Table) @compileError(error_message); | 320 | if (info.params[1].type.? != *Table) @compileError(error_message); |
| 321 | if (info.return_type.? != Cursor.InitError!*Cursor) @compileError(error_message); | 321 | if (info.return_type.? != Cursor.InitError!*Cursor) @compileError(error_message); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| @@ -333,8 +333,8 @@ fn validateCursorType(comptime Table: type) void { | |||
| 333 | 333 | ||
| 334 | const info = @typeInfo(@TypeOf(Cursor.deinit)).Fn; | 334 | const info = @typeInfo(@TypeOf(Cursor.deinit)).Fn; |
| 335 | 335 | ||
| 336 | if (info.args.len != 1) @compileError(error_message); | 336 | if (info.params.len != 1) @compileError(error_message); |
| 337 | if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); | 337 | if (info.params[0].type.? != *Cursor) @compileError(error_message); |
| 338 | if (info.return_type.? != void) @compileError(error_message); | 338 | if (info.return_type.? != void) @compileError(error_message); |
| 339 | } | 339 | } |
| 340 | 340 | ||
| @@ -354,9 +354,9 @@ fn validateCursorType(comptime Table: type) void { | |||
| 354 | 354 | ||
| 355 | const info = @typeInfo(@TypeOf(Cursor.next)).Fn; | 355 | const info = @typeInfo(@TypeOf(Cursor.next)).Fn; |
| 356 | 356 | ||
| 357 | if (info.args.len != 2) @compileError(error_message); | 357 | if (info.params.len != 2) @compileError(error_message); |
| 358 | if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); | 358 | if (info.params[0].type.? != *Cursor) @compileError(error_message); |
| 359 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 359 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 360 | if (info.return_type.? != Cursor.NextError!void) @compileError(error_message); | 360 | if (info.return_type.? != Cursor.NextError!void) @compileError(error_message); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| @@ -376,9 +376,9 @@ fn validateCursorType(comptime Table: type) void { | |||
| 376 | 376 | ||
| 377 | const info = @typeInfo(@TypeOf(Cursor.hasNext)).Fn; | 377 | const info = @typeInfo(@TypeOf(Cursor.hasNext)).Fn; |
| 378 | 378 | ||
| 379 | if (info.args.len != 2) @compileError(error_message); | 379 | if (info.params.len != 2) @compileError(error_message); |
| 380 | if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); | 380 | if (info.params[0].type.? != *Cursor) @compileError(error_message); |
| 381 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 381 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 382 | if (info.return_type.? != Cursor.HasNextError!bool) @compileError(error_message); | 382 | if (info.return_type.? != Cursor.HasNextError!bool) @compileError(error_message); |
| 383 | } | 383 | } |
| 384 | 384 | ||
| @@ -398,11 +398,11 @@ fn validateCursorType(comptime Table: type) void { | |||
| 398 | 398 | ||
| 399 | const info = @typeInfo(@TypeOf(Cursor.filter)).Fn; | 399 | const info = @typeInfo(@TypeOf(Cursor.filter)).Fn; |
| 400 | 400 | ||
| 401 | if (info.args.len != 4) @compileError(error_message); | 401 | if (info.params.len != 4) @compileError(error_message); |
| 402 | if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); | 402 | if (info.params[0].type.? != *Cursor) @compileError(error_message); |
| 403 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 403 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 404 | if (info.args[2].arg_type.? != IndexIdentifier) @compileError(error_message); | 404 | if (info.params[2].type.? != IndexIdentifier) @compileError(error_message); |
| 405 | if (info.args[3].arg_type.? != []FilterArg) @compileError(error_message); | 405 | if (info.params[3].type.? != []FilterArg) @compileError(error_message); |
| 406 | if (info.return_type.? != Cursor.FilterError!void) @compileError(error_message); | 406 | if (info.return_type.? != Cursor.FilterError!void) @compileError(error_message); |
| 407 | } | 407 | } |
| 408 | 408 | ||
| @@ -425,10 +425,10 @@ fn validateCursorType(comptime Table: type) void { | |||
| 425 | 425 | ||
| 426 | const info = @typeInfo(@TypeOf(Cursor.column)).Fn; | 426 | const info = @typeInfo(@TypeOf(Cursor.column)).Fn; |
| 427 | 427 | ||
| 428 | if (info.args.len != 3) @compileError(error_message); | 428 | if (info.params.len != 3) @compileError(error_message); |
| 429 | if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); | 429 | if (info.params[0].type.? != *Cursor) @compileError(error_message); |
| 430 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 430 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 431 | if (info.args[2].arg_type.? != i32) @compileError(error_message); | 431 | if (info.params[2].type.? != i32) @compileError(error_message); |
| 432 | if (info.return_type.? != Cursor.ColumnError!Cursor.Column) @compileError(error_message); | 432 | if (info.return_type.? != Cursor.ColumnError!Cursor.Column) @compileError(error_message); |
| 433 | } | 433 | } |
| 434 | 434 | ||
| @@ -448,9 +448,9 @@ fn validateCursorType(comptime Table: type) void { | |||
| 448 | 448 | ||
| 449 | const info = @typeInfo(@TypeOf(Cursor.rowId)).Fn; | 449 | const info = @typeInfo(@TypeOf(Cursor.rowId)).Fn; |
| 450 | 450 | ||
| 451 | if (info.args.len != 2) @compileError(error_message); | 451 | if (info.params.len != 2) @compileError(error_message); |
| 452 | if (info.args[0].arg_type.? != *Cursor) @compileError(error_message); | 452 | if (info.params[0].type.? != *Cursor) @compileError(error_message); |
| 453 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 453 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 454 | if (info.return_type.? != Cursor.RowIDError!i64) @compileError(error_message); | 454 | if (info.return_type.? != Cursor.RowIDError!i64) @compileError(error_message); |
| 455 | } | 455 | } |
| 456 | } | 456 | } |
| @@ -473,11 +473,11 @@ fn validateTableType(comptime Table: type) void { | |||
| 473 | 473 | ||
| 474 | const info = @typeInfo(@TypeOf(Table.init)).Fn; | 474 | const info = @typeInfo(@TypeOf(Table.init)).Fn; |
| 475 | 475 | ||
| 476 | if (info.args.len != 3) @compileError(error_message); | 476 | if (info.params.len != 3) @compileError(error_message); |
| 477 | if (info.args[0].arg_type.? != mem.Allocator) @compileError(error_message); | 477 | if (info.params[0].type.? != mem.Allocator) @compileError(error_message); |
| 478 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 478 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 479 | // TODO(vincent): maybe allow a signature without the args since a table can do withoout them | 479 | // TODO(vincent): maybe allow a signature without the params since a table can do withoout them |
| 480 | if (info.args[2].arg_type.? != []const ModuleArgument) @compileError(error_message); | 480 | if (info.params[2].type.? != []const ModuleArgument) @compileError(error_message); |
| 481 | if (info.return_type.? != Table.InitError!*Table) @compileError(error_message); | 481 | if (info.return_type.? != Table.InitError!*Table) @compileError(error_message); |
| 482 | } | 482 | } |
| 483 | 483 | ||
| @@ -493,9 +493,9 @@ fn validateTableType(comptime Table: type) void { | |||
| 493 | 493 | ||
| 494 | const info = @typeInfo(@TypeOf(Table.deinit)).Fn; | 494 | const info = @typeInfo(@TypeOf(Table.deinit)).Fn; |
| 495 | 495 | ||
| 496 | if (info.args.len != 2) @compileError(error_message); | 496 | if (info.params.len != 2) @compileError(error_message); |
| 497 | if (info.args[0].arg_type.? != *Table) @compileError(error_message); | 497 | if (info.params[0].type.? != *Table) @compileError(error_message); |
| 498 | if (info.args[1].arg_type.? != mem.Allocator) @compileError(error_message); | 498 | if (info.params[1].type.? != mem.Allocator) @compileError(error_message); |
| 499 | if (info.return_type.? != void) @compileError(error_message); | 499 | if (info.return_type.? != void) @compileError(error_message); |
| 500 | } | 500 | } |
| 501 | 501 | ||
| @@ -515,10 +515,10 @@ fn validateTableType(comptime Table: type) void { | |||
| 515 | 515 | ||
| 516 | const info = @typeInfo(@TypeOf(Table.buildBestIndex)).Fn; | 516 | const info = @typeInfo(@TypeOf(Table.buildBestIndex)).Fn; |
| 517 | 517 | ||
| 518 | if (info.args.len != 3) @compileError(error_message); | 518 | if (info.params.len != 3) @compileError(error_message); |
| 519 | if (info.args[0].arg_type.? != *Table) @compileError(error_message); | 519 | if (info.params[0].type.? != *Table) @compileError(error_message); |
| 520 | if (info.args[1].arg_type.? != *VTabDiagnostics) @compileError(error_message); | 520 | if (info.params[1].type.? != *VTabDiagnostics) @compileError(error_message); |
| 521 | if (info.args[2].arg_type.? != *BestIndexBuilder) @compileError(error_message); | 521 | if (info.params[2].type.? != *BestIndexBuilder) @compileError(error_message); |
| 522 | if (info.return_type.? != Table.BuildBestIndexError!void) @compileError(error_message); | 522 | if (info.return_type.? != Table.BuildBestIndexError!void) @compileError(error_message); |
| 523 | } | 523 | } |
| 524 | 524 | ||