diff options
| author | 2022-12-26 11:00:59 +0100 | |
|---|---|---|
| committer | 2022-12-26 11:00:59 +0100 | |
| commit | 30b15ec78390c31b4456e9b600ccabe7481cc5ea (patch) | |
| tree | 20b5419c17f779a87a2798eba96eb7ae84e57300 /sqlite.zig | |
| 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
Diffstat (limited to '')
| -rw-r--r-- | sqlite.zig | 30 |
1 files changed, 15 insertions, 15 deletions
| @@ -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 | } |