diff options
| -rw-r--r-- | build.zig | 100 | ||||
| -rw-r--r-- | c/loadable_extension.zig | 94 | ||||
| -rw-r--r-- | helpers.zig | 2 | ||||
| -rw-r--r-- | sqlite.zig | 54 | ||||
| -rw-r--r-- | vtab.zig | 82 |
5 files changed, 182 insertions, 150 deletions
| @@ -182,16 +182,19 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 182 | const use_bundled = b.option(bool, "use_bundled", "Use the bundled sqlite3 source instead of linking the system library (default false)"); | 182 | const use_bundled = b.option(bool, "use_bundled", "Use the bundled sqlite3 source instead of linking the system library (default false)"); |
| 183 | 183 | ||
| 184 | const target = b.standardTargetOptions(.{}); | 184 | const target = b.standardTargetOptions(.{}); |
| 185 | const mode = b.standardReleaseOptions(); | 185 | const optimize = b.standardOptimizeOption(.{}); |
| 186 | 186 | ||
| 187 | // Tool to preprocess the sqlite header files. | 187 | // Tool to preprocess the sqlite header files. |
| 188 | // | 188 | // |
| 189 | // Due to limitations of translate-c the standard header files can't be used for building loadable extensions | 189 | // Due to limitations of translate-c the standard header files can't be used for building loadable extensions |
| 190 | // so we have this tool which creates usable header files. | 190 | // so we have this tool which creates usable header files. |
| 191 | 191 | ||
| 192 | const preprocess_files_tool = b.addExecutable("preprocess-files", "tools/preprocess_files.zig"); | 192 | const preprocess_files_tool = b.addExecutable(.{ |
| 193 | preprocess_files_tool.setBuildMode(mode); | 193 | .name = "preprocess-files", |
| 194 | preprocess_files_tool.setTarget(getTarget(target, true)); | 194 | .root_source_file = .{ .path = "tools/preprocess_files.zig" }, |
| 195 | .target = getTarget(target, true), | ||
| 196 | .optimize = optimize, | ||
| 197 | }); | ||
| 195 | 198 | ||
| 196 | // Add a top-level step to run the preprocess-files tool | 199 | // Add a top-level step to run the preprocess-files tool |
| 197 | const preprocess_files_run = b.step("preprocess-files", "Run the preprocess-files tool"); | 200 | const preprocess_files_run = b.step("preprocess-files", "Run the preprocess-files tool"); |
| @@ -220,32 +223,38 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 220 | const bundled = use_bundled orelse test_target.bundled; | 223 | const bundled = use_bundled orelse test_target.bundled; |
| 221 | const cross_target = getTarget(test_target.target, bundled); | 224 | const cross_target = getTarget(test_target.target, bundled); |
| 222 | 225 | ||
| 223 | const tests = b.addTest("sqlite.zig"); | 226 | const tests = b.addTest(.{ |
| 227 | .target = cross_target, | ||
| 228 | .root_source_file = .{ .path = "sqlite.zig" }, | ||
| 229 | }); | ||
| 224 | 230 | ||
| 225 | if (bundled) { | 231 | if (bundled) { |
| 226 | const lib = b.addStaticLibrary("sqlite", null); | 232 | const lib = b.addStaticLibrary(.{ |
| 233 | .name = "sqlite", | ||
| 234 | .target = cross_target, | ||
| 235 | .optimize = optimize, | ||
| 236 | }); | ||
| 227 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); | 237 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); |
| 228 | lib.linkLibC(); | 238 | lib.linkLibC(); |
| 229 | lib.setTarget(cross_target); | ||
| 230 | lib.setBuildMode(mode); | ||
| 231 | sqlite3 = lib; | 239 | sqlite3 = lib; |
| 232 | } | 240 | } |
| 233 | 241 | ||
| 234 | const lib = b.addStaticLibrary("zig-sqlite", "sqlite.zig"); | 242 | const lib = b.addStaticLibrary(.{ |
| 243 | .name = "zig-sqlite", | ||
| 244 | .root_source_file = .{ .path = "sqlite.zig" }, | ||
| 245 | .target = cross_target, | ||
| 246 | .optimize = optimize, | ||
| 247 | }); | ||
| 235 | if (bundled) lib.addIncludePath("c"); | 248 | if (bundled) lib.addIncludePath("c"); |
| 236 | linkSqlite(lib); | 249 | linkSqlite(lib); |
| 237 | lib.setTarget(cross_target); | ||
| 238 | lib.setBuildMode(mode); | ||
| 239 | 250 | ||
| 240 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; | 251 | const single_threaded_txt = if (test_target.single_threaded) "single" else "multi"; |
| 241 | tests.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{ | 252 | tests.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{ |
| 242 | try cross_target.zigTriple(b.allocator), | 253 | try cross_target.zigTriple(b.allocator), |
| 243 | @tagName(mode), | 254 | @tagName(optimize), |
| 244 | single_threaded_txt, | 255 | single_threaded_txt, |
| 245 | })); | 256 | })); |
| 246 | tests.single_threaded = test_target.single_threaded; | 257 | tests.single_threaded = test_target.single_threaded; |
| 247 | tests.setBuildMode(mode); | ||
| 248 | tests.setTarget(cross_target); | ||
| 249 | if (bundled) tests.addIncludePath("c"); | 258 | if (bundled) tests.addIncludePath("c"); |
| 250 | linkSqlite(tests); | 259 | linkSqlite(tests); |
| 251 | 260 | ||
| @@ -260,26 +269,33 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 260 | 269 | ||
| 261 | // Fuzzing | 270 | // Fuzzing |
| 262 | 271 | ||
| 263 | const lib = b.addStaticLibrary("sqlite", null); | 272 | const lib = b.addStaticLibrary(.{ |
| 273 | .name = "sqlite", | ||
| 274 | .target = getTarget(target, true), | ||
| 275 | .optimize = optimize, | ||
| 276 | }); | ||
| 264 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); | 277 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); |
| 265 | lib.addIncludePath("c"); | 278 | lib.addIncludePath("c"); |
| 266 | lib.linkLibC(); | 279 | lib.linkLibC(); |
| 267 | lib.setBuildMode(mode); | ||
| 268 | lib.setTarget(getTarget(target, true)); | ||
| 269 | 280 | ||
| 270 | // The library | 281 | // The library |
| 271 | const fuzz_lib = b.addStaticLibrary("fuzz-lib", "fuzz/main.zig"); | 282 | const fuzz_lib = b.addStaticLibrary(.{ |
| 283 | .name = "fuzz-lib", | ||
| 284 | .root_source_file = .{ .path = "fuzz/main.zig" }, | ||
| 285 | .target = getTarget(target, true), | ||
| 286 | .optimize = optimize, | ||
| 287 | }); | ||
| 272 | fuzz_lib.addIncludePath("c"); | 288 | fuzz_lib.addIncludePath("c"); |
| 273 | fuzz_lib.setBuildMode(mode); | ||
| 274 | fuzz_lib.setTarget(getTarget(target, true)); | ||
| 275 | fuzz_lib.linkLibrary(lib); | 289 | fuzz_lib.linkLibrary(lib); |
| 276 | fuzz_lib.want_lto = true; | 290 | fuzz_lib.want_lto = true; |
| 277 | fuzz_lib.bundle_compiler_rt = true; | 291 | fuzz_lib.bundle_compiler_rt = true; |
| 278 | fuzz_lib.addPackagePath("sqlite", "sqlite.zig"); | 292 | fuzz_lib.addAnonymousModule("sqlite", .{ |
| 293 | .source_file = .{ .path = "sqlite.zig" }, | ||
| 294 | }); | ||
| 279 | 295 | ||
| 280 | // Setup the output name | 296 | // Setup the output name |
| 281 | const fuzz_executable_name = "fuzz"; | 297 | const fuzz_executable_name = "fuzz"; |
| 282 | const fuzz_exe_path = try std.fs.path.join(b.allocator, &.{ b.cache_root, fuzz_executable_name }); | 298 | const fuzz_exe_path = try b.cache_root.join(b.allocator, &.{fuzz_executable_name}); |
| 283 | 299 | ||
| 284 | // We want `afl-clang-lto -o path/to/output path/to/library` | 300 | // We want `afl-clang-lto -o path/to/output path/to/library` |
| 285 | const fuzz_compile = b.addSystemCommand(&.{ "afl-clang-lto", "-o", fuzz_exe_path }); | 301 | const fuzz_compile = b.addSystemCommand(&.{ "afl-clang-lto", "-o", fuzz_exe_path }); |
| @@ -296,12 +312,17 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 296 | fuzz_compile_run.dependOn(&fuzz_install.step); | 312 | fuzz_compile_run.dependOn(&fuzz_install.step); |
| 297 | 313 | ||
| 298 | // Compile a companion exe for debugging crashes | 314 | // Compile a companion exe for debugging crashes |
| 299 | const fuzz_debug_exe = b.addExecutable("fuzz-debug", "fuzz/main.zig"); | 315 | const fuzz_debug_exe = b.addExecutable(.{ |
| 316 | .name = "fuzz-debug", | ||
| 317 | .root_source_file = .{ .path = "fuzz/main.zig" }, | ||
| 318 | .target = getTarget(target, true), | ||
| 319 | .optimize = optimize, | ||
| 320 | }); | ||
| 300 | fuzz_debug_exe.addIncludePath("c"); | 321 | fuzz_debug_exe.addIncludePath("c"); |
| 301 | fuzz_debug_exe.setBuildMode(mode); | ||
| 302 | fuzz_debug_exe.setTarget(getTarget(target, true)); | ||
| 303 | fuzz_debug_exe.linkLibrary(lib); | 322 | fuzz_debug_exe.linkLibrary(lib); |
| 304 | fuzz_debug_exe.addPackagePath("sqlite", "sqlite.zig"); | 323 | fuzz_debug_exe.addAnonymousModule("sqlite", .{ |
| 324 | .source_file = .{ .path = "sqlite.zig" }, | ||
| 325 | }); | ||
| 305 | 326 | ||
| 306 | // Only install fuzz-debug when the fuzz step is run | 327 | // Only install fuzz-debug when the fuzz step is run |
| 307 | const install_fuzz_debug_exe = b.addInstallArtifact(fuzz_debug_exe); | 328 | const install_fuzz_debug_exe = b.addInstallArtifact(fuzz_debug_exe); |
| @@ -315,21 +336,32 @@ pub fn build(b: *std.build.Builder) !void { | |||
| 315 | // | 336 | // |
| 316 | // This builds an example shared library with the extension and a binary that tests it. | 337 | // This builds an example shared library with the extension and a binary that tests it. |
| 317 | 338 | ||
| 318 | const zigcrypto_loadable_ext = b.addSharedLibrary("zigcrypto", "examples/zigcrypto.zig", .unversioned); | 339 | const zigcrypto_loadable_ext = b.addSharedLibrary(.{ |
| 340 | .name = "zigcrypto", | ||
| 341 | .root_source_file = .{ .path = "examples/zigcrypto.zig" }, | ||
| 342 | .version = null, | ||
| 343 | .target = getTarget(target, true), | ||
| 344 | .optimize = optimize, | ||
| 345 | }); | ||
| 319 | zigcrypto_loadable_ext.force_pic = true; | 346 | zigcrypto_loadable_ext.force_pic = true; |
| 320 | zigcrypto_loadable_ext.addIncludePath("c"); | 347 | zigcrypto_loadable_ext.addIncludePath("c"); |
| 321 | zigcrypto_loadable_ext.setBuildMode(mode); | 348 | zigcrypto_loadable_ext.addAnonymousModule("sqlite", .{ |
| 322 | zigcrypto_loadable_ext.setTarget(getTarget(target, true)); | 349 | .source_file = .{ .path = "sqlite.zig" }, |
| 323 | zigcrypto_loadable_ext.addPackagePath("sqlite", "sqlite.zig"); | 350 | }); |
| 324 | zigcrypto_loadable_ext.linkLibrary(lib); | 351 | zigcrypto_loadable_ext.linkLibrary(lib); |
| 325 | 352 | ||
| 326 | const install_zigcrypto_loadable_ext = b.addInstallArtifact(zigcrypto_loadable_ext); | 353 | const install_zigcrypto_loadable_ext = b.addInstallArtifact(zigcrypto_loadable_ext); |
| 327 | 354 | ||
| 328 | const zigcrypto_test = b.addExecutable("zigcrypto-test", "examples/zigcrypto_test.zig"); | 355 | const zigcrypto_test = b.addExecutable(.{ |
| 356 | .name = "zigcrypto-test", | ||
| 357 | .root_source_file = .{ .path = "examples/zigcrypto_test.zig" }, | ||
| 358 | .target = getTarget(target, true), | ||
| 359 | .optimize = optimize, | ||
| 360 | }); | ||
| 329 | zigcrypto_test.addIncludePath("c"); | 361 | zigcrypto_test.addIncludePath("c"); |
| 330 | zigcrypto_test.setBuildMode(mode); | 362 | zigcrypto_test.addAnonymousModule("sqlite", .{ |
| 331 | zigcrypto_test.setTarget(getTarget(target, true)); | 363 | .source_file = .{ .path = "sqlite.zig" }, |
| 332 | zigcrypto_test.addPackagePath("sqlite", "sqlite.zig"); | 364 | }); |
| 333 | zigcrypto_test.linkLibrary(lib); | 365 | zigcrypto_test.linkLibrary(lib); |
| 334 | 366 | ||
| 335 | const install_zigcrypto_test = b.addInstallArtifact(zigcrypto_test); | 367 | const install_zigcrypto_test = b.addInstallArtifact(zigcrypto_test); |
diff --git a/c/loadable_extension.zig b/c/loadable_extension.zig index 95fd215..0b95806 100644 --- a/c/loadable_extension.zig +++ b/c/loadable_extension.zig | |||
| @@ -25,7 +25,7 @@ pub const sqlite3_str_vappendf = @compileError("sqlite3_str_vappendf can't be im | |||
| 25 | pub export fn sqlite3_aggregate_context(p: ?*c.sqlite3_context, nBytes: c_int) callconv(.C) ?*anyopaque { | 25 | pub export fn sqlite3_aggregate_context(p: ?*c.sqlite3_context, nBytes: c_int) callconv(.C) ?*anyopaque { |
| 26 | return sqlite3_api.*.aggregate_context.?(p, nBytes); | 26 | return sqlite3_api.*.aggregate_context.?(p, nBytes); |
| 27 | } | 27 | } |
| 28 | pub export fn sqlite3_bind_blob(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) c_int { | 28 | pub export fn sqlite3_bind_blob(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 29 | return sqlite3_api.*.bind_blob.?(pStmt, i, zData, nData, xDel); | 29 | return sqlite3_api.*.bind_blob.?(pStmt, i, zData, nData, xDel); |
| 30 | } | 30 | } |
| 31 | pub export fn sqlite3_bind_double(pStmt: ?*c.sqlite3_stmt, i: c_int, rValue: f64) callconv(.C) c_int { | 31 | pub export fn sqlite3_bind_double(pStmt: ?*c.sqlite3_stmt, i: c_int, rValue: f64) callconv(.C) c_int { |
| @@ -49,16 +49,16 @@ pub export fn sqlite3_bind_parameter_index(pStmt: ?*c.sqlite3_stmt, zName: [*c]c | |||
| 49 | pub export fn sqlite3_bind_parameter_name(pStmt: ?*c.sqlite3_stmt, i: c_int) [*c]const u8 { | 49 | pub export fn sqlite3_bind_parameter_name(pStmt: ?*c.sqlite3_stmt, i: c_int) [*c]const u8 { |
| 50 | return sqlite3_api.*.bind_parameter_name.?(pStmt, i); | 50 | return sqlite3_api.*.bind_parameter_name.?(pStmt, i); |
| 51 | } | 51 | } |
| 52 | pub export fn sqlite3_bind_text(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) c_int { | 52 | pub export fn sqlite3_bind_text(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 53 | return sqlite3_api.*.bind_text.?(pStmt, i, zData, nData, xDel); | 53 | return sqlite3_api.*.bind_text.?(pStmt, i, zData, nData, xDel); |
| 54 | } | 54 | } |
| 55 | pub export fn sqlite3_bind_text16(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) c_int { | 55 | pub export fn sqlite3_bind_text16(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 56 | return sqlite3_api.*.bind_text16.?(pStmt, i, zData, nData, xDel); | 56 | return sqlite3_api.*.bind_text16.?(pStmt, i, zData, nData, xDel); |
| 57 | } | 57 | } |
| 58 | pub export fn sqlite3_bind_value(pStmt: ?*c.sqlite3_stmt, i: c_int, pValue: ?*const c.sqlite3_value) c_int { | 58 | pub export fn sqlite3_bind_value(pStmt: ?*c.sqlite3_stmt, i: c_int, pValue: ?*const c.sqlite3_value) c_int { |
| 59 | return sqlite3_api.*.bind_value.?(pStmt, i, pValue); | 59 | return sqlite3_api.*.bind_value.?(pStmt, i, pValue); |
| 60 | } | 60 | } |
| 61 | pub export fn sqlite3_busy_handler(db: ?*c.sqlite3, xBusy: ?fn (?*anyopaque, c_int) callconv(.C) c_int, pArg: ?*anyopaque) c_int { | 61 | pub export fn sqlite3_busy_handler(db: ?*c.sqlite3, xBusy: ?*const fn (?*anyopaque, c_int) callconv(.C) c_int, pArg: ?*anyopaque) c_int { |
| 62 | return sqlite3_api.*.busy_handler.?(db, xBusy, pArg); | 62 | return sqlite3_api.*.busy_handler.?(db, xBusy, pArg); |
| 63 | } | 63 | } |
| 64 | pub export fn sqlite3_busy_timeout(db: ?*c.sqlite3, ms: c_int) c_int { | 64 | pub export fn sqlite3_busy_timeout(db: ?*c.sqlite3, ms: c_int) c_int { |
| @@ -70,10 +70,10 @@ pub export fn sqlite3_changes(db: ?*c.sqlite3) c_int { | |||
| 70 | pub export fn sqlite3_close(db: ?*c.sqlite3) c_int { | 70 | pub export fn sqlite3_close(db: ?*c.sqlite3) c_int { |
| 71 | return sqlite3_api.*.close.?(db); | 71 | return sqlite3_api.*.close.?(db); |
| 72 | } | 72 | } |
| 73 | pub export fn sqlite3_collation_needed(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded: ?fn (?*anyopaque, ?*c.sqlite3, c_int, [*c]const u8) callconv(.C) void) c_int { | 73 | pub export fn sqlite3_collation_needed(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded: ?*const fn (?*anyopaque, ?*c.sqlite3, c_int, [*c]const u8) callconv(.C) void) c_int { |
| 74 | return sqlite3_api.*.collation_needed.?(db, pCollNeededArg, xCollNeeded); | 74 | return sqlite3_api.*.collation_needed.?(db, pCollNeededArg, xCollNeeded); |
| 75 | } | 75 | } |
| 76 | pub export fn sqlite3_collation_needed16(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded16: ?fn (?*anyopaque, ?*c.sqlite3, c_int, ?*const anyopaque) callconv(.C) void) c_int { | 76 | pub export fn sqlite3_collation_needed16(db: ?*c.sqlite3, pCollNeededArg: ?*anyopaque, xCollNeeded16: ?*const fn (?*anyopaque, ?*c.sqlite3, c_int, ?*const anyopaque) callconv(.C) void) c_int { |
| 77 | return sqlite3_api.*.collation_needed16.?(db, pCollNeededArg, xCollNeeded16); | 77 | return sqlite3_api.*.collation_needed16.?(db, pCollNeededArg, xCollNeeded16); |
| 78 | } | 78 | } |
| 79 | pub export fn sqlite3_column_blob(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*const anyopaque { | 79 | pub export fn sqlite3_column_blob(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*const anyopaque { |
| @@ -139,7 +139,7 @@ pub export fn sqlite3_column_type(pStmt: ?*c.sqlite3_stmt, iCol: c_int) c_int { | |||
| 139 | pub export fn sqlite3_column_value(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*c.sqlite3_value { | 139 | pub export fn sqlite3_column_value(pStmt: ?*c.sqlite3_stmt, iCol: c_int) ?*c.sqlite3_value { |
| 140 | return sqlite3_api.*.column_value.?(pStmt, iCol); | 140 | return sqlite3_api.*.column_value.?(pStmt, iCol); |
| 141 | } | 141 | } |
| 142 | pub export fn sqlite3_commit_hook(db: ?*c.sqlite3, xCallback: ?fn (?*anyopaque) callconv(.C) c_int, pArg: ?*anyopaque) ?*anyopaque { | 142 | pub export fn sqlite3_commit_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque) callconv(.C) c_int, pArg: ?*anyopaque) ?*anyopaque { |
| 143 | return sqlite3_api.*.commit_hook.?(db, xCallback, pArg); | 143 | return sqlite3_api.*.commit_hook.?(db, xCallback, pArg); |
| 144 | } | 144 | } |
| 145 | pub export fn sqlite3_complete(sql: [*c]const u8) c_int { | 145 | pub export fn sqlite3_complete(sql: [*c]const u8) c_int { |
| @@ -148,22 +148,22 @@ pub export fn sqlite3_complete(sql: [*c]const u8) c_int { | |||
| 148 | pub export fn sqlite3_complete16(sql: ?*const anyopaque) c_int { | 148 | pub export fn sqlite3_complete16(sql: ?*const anyopaque) c_int { |
| 149 | return sqlite3_api.*.complete16.?(sql); | 149 | return sqlite3_api.*.complete16.?(sql); |
| 150 | } | 150 | } |
| 151 | pub export fn sqlite3_create_collation(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int) c_int { | 151 | pub export fn sqlite3_create_collation(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int) c_int { |
| 152 | return sqlite3_api.*.create_collation.?(db, zName, eTextRep, pArg, xCompare); | 152 | return sqlite3_api.*.create_collation.?(db, zName, eTextRep, pArg, xCompare); |
| 153 | } | 153 | } |
| 154 | pub export fn sqlite3_create_collation16(db: ?*c.sqlite3, zName: ?*const anyopaque, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int) c_int { | 154 | pub export fn sqlite3_create_collation16(db: ?*c.sqlite3, zName: ?*const anyopaque, eTextRep: c_int, pArg: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int) c_int { |
| 155 | return sqlite3_api.*.create_collation16.?(db, zName, eTextRep, pArg, xCompare); | 155 | return sqlite3_api.*.create_collation16.?(db, zName, eTextRep, pArg, xCompare); |
| 156 | } | 156 | } |
| 157 | pub export fn sqlite3_create_function(db: ?*c.sqlite3, zFunctionName: [*c]const u8, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xStep: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xFinal: ?fn (?*c.sqlite3_context) callconv(.C) void) c_int { | 157 | pub export fn sqlite3_create_function(db: ?*c.sqlite3, zFunctionName: [*c]const u8, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void) c_int { |
| 158 | return sqlite3_api.*.create_function.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); | 158 | return sqlite3_api.*.create_function.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); |
| 159 | } | 159 | } |
| 160 | pub export fn sqlite3_create_function16(db: ?*c.sqlite3, zFunctionName: ?*const anyopaque, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xStep: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xFinal: ?fn (?*c.sqlite3_context) callconv(.C) void) c_int { | 160 | pub export fn sqlite3_create_function16(db: ?*c.sqlite3, zFunctionName: ?*const anyopaque, nArg: c_int, eTextRep: c_int, pApp: ?*anyopaque, xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void) c_int { |
| 161 | return sqlite3_api.*.create_function16.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); | 161 | return sqlite3_api.*.create_function16.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal); |
| 162 | } | 162 | } |
| 163 | pub export fn sqlite3_create_module(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque) c_int { | 163 | pub export fn sqlite3_create_module(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque) c_int { |
| 164 | return sqlite3_api.*.create_module.?(db, zName, pModule, pAux); | 164 | return sqlite3_api.*.create_module.?(db, zName, pModule, pAux); |
| 165 | } | 165 | } |
| 166 | pub export fn sqlite3_create_module_v2(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque, xDestroy: ?fn (?*anyopaque) callconv(.C) void) c_int { | 166 | pub export fn sqlite3_create_module_v2(db: ?*c.sqlite3, zName: [*c]const u8, pModule: [*c]const c.sqlite3_module, pAux: ?*anyopaque, xDestroy: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 167 | return sqlite3_api.*.create_module_v2.?(db, zName, pModule, pAux, xDestroy); | 167 | return sqlite3_api.*.create_module_v2.?(db, zName, pModule, pAux, xDestroy); |
| 168 | } | 168 | } |
| 169 | pub export fn sqlite3_data_count(pStmt: ?*c.sqlite3_stmt) c_int { | 169 | pub export fn sqlite3_data_count(pStmt: ?*c.sqlite3_stmt) c_int { |
| @@ -188,7 +188,7 @@ pub export fn sqlite3_errmsg(db: ?*c.sqlite3) [*c]const u8 { | |||
| 188 | pub export fn sqlite3_errmsg16(db: ?*c.sqlite3) ?*const anyopaque { | 188 | pub export fn sqlite3_errmsg16(db: ?*c.sqlite3) ?*const anyopaque { |
| 189 | return sqlite3_api.*.errmsg16.?(db); | 189 | return sqlite3_api.*.errmsg16.?(db); |
| 190 | } | 190 | } |
| 191 | pub export fn sqlite3_exec(db: ?*c.sqlite3, zSql: [*c]const u8, xCallback: ?fn (?*anyopaque, c_int, [*c][*c]u8, [*c][*c]u8) callconv(.C) c_int, pArg: ?*anyopaque, pzErrMsg: [*c][*c]u8) c_int { | 191 | pub export fn sqlite3_exec(db: ?*c.sqlite3, zSql: [*c]const u8, xCallback: ?*const fn (?*anyopaque, c_int, [*c][*c]u8, [*c][*c]u8) callconv(.C) c_int, pArg: ?*anyopaque, pzErrMsg: [*c][*c]u8) c_int { |
| 192 | return sqlite3_api.*.exec.?(db, zSql, xCallback, pArg, pzErrMsg); | 192 | return sqlite3_api.*.exec.?(db, zSql, xCallback, pArg, pzErrMsg); |
| 193 | } | 193 | } |
| 194 | pub export fn sqlite3_finalize(pStmt: ?*c.sqlite3_stmt) c_int { | 194 | pub export fn sqlite3_finalize(pStmt: ?*c.sqlite3_stmt) c_int { |
| @@ -242,10 +242,10 @@ pub export fn sqlite3_prepare_v2(db: ?*c.sqlite3, zSql: [*c]const u8, nByte: c_i | |||
| 242 | pub export fn sqlite3_prepare16_v2(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { | 242 | pub export fn sqlite3_prepare16_v2(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { |
| 243 | return sqlite3_api.*.prepare16_v2.?(db, zSql, nByte, ppStmt, pzTail); | 243 | return sqlite3_api.*.prepare16_v2.?(db, zSql, nByte, ppStmt, pzTail); |
| 244 | } | 244 | } |
| 245 | pub export fn sqlite3_profile(db: ?*c.sqlite3, xProfile: ?fn (?*anyopaque, [*c]const u8, c.sqlite3_uint64) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 245 | pub export fn sqlite3_profile(db: ?*c.sqlite3, xProfile: ?*const fn (?*anyopaque, [*c]const u8, c.sqlite3_uint64) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { |
| 246 | return sqlite3_api.*.profile.?(db, xProfile, pArg); | 246 | return sqlite3_api.*.profile.?(db, xProfile, pArg); |
| 247 | } | 247 | } |
| 248 | pub export fn sqlite3_progress_handler(db: ?*c.sqlite3, nOps: c_int, xProgress: ?fn (?*anyopaque) callconv(.C) c_int, pArg: ?*anyopaque) void { | 248 | pub export fn sqlite3_progress_handler(db: ?*c.sqlite3, nOps: c_int, xProgress: ?*const fn (?*anyopaque) callconv(.C) c_int, pArg: ?*anyopaque) void { |
| 249 | return sqlite3_api.*.progress_handler.?(db, nOps, xProgress, pArg); | 249 | return sqlite3_api.*.progress_handler.?(db, nOps, xProgress, pArg); |
| 250 | } | 250 | } |
| 251 | pub export fn sqlite3_realloc(pOld: ?*anyopaque, n: c_int) ?*anyopaque { | 251 | pub export fn sqlite3_realloc(pOld: ?*anyopaque, n: c_int) ?*anyopaque { |
| @@ -254,7 +254,7 @@ pub export fn sqlite3_realloc(pOld: ?*anyopaque, n: c_int) ?*anyopaque { | |||
| 254 | pub export fn sqlite3_reset(pStmt: ?*c.sqlite3_stmt) c_int { | 254 | pub export fn sqlite3_reset(pStmt: ?*c.sqlite3_stmt) c_int { |
| 255 | return sqlite3_api.*.reset.?(pStmt); | 255 | return sqlite3_api.*.reset.?(pStmt); |
| 256 | } | 256 | } |
| 257 | pub export fn sqlite3_result_blob(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) void { | 257 | pub export fn sqlite3_result_blob(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 258 | return sqlite3_api.*.result_blob.?(pCtx, z, n, xDel); | 258 | return sqlite3_api.*.result_blob.?(pCtx, z, n, xDel); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| @@ -277,28 +277,28 @@ pub export fn sqlite3_result_int64(pCtx: ?*c.sqlite3_context, iVal: c.sqlite3_in | |||
| 277 | pub export fn sqlite3_result_null(pCtx: ?*c.sqlite3_context) void { | 277 | pub export fn sqlite3_result_null(pCtx: ?*c.sqlite3_context) void { |
| 278 | return sqlite3_api.*.result_null.?(pCtx); | 278 | return sqlite3_api.*.result_null.?(pCtx); |
| 279 | } | 279 | } |
| 280 | pub export fn sqlite3_result_text(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) void { | 280 | pub export fn sqlite3_result_text(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 281 | return sqlite3_api.*.result_text.?(pCtx, z, n, xDel); | 281 | return sqlite3_api.*.result_text.?(pCtx, z, n, xDel); |
| 282 | } | 282 | } |
| 283 | pub export fn sqlite3_result_text16(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) void { | 283 | pub export fn sqlite3_result_text16(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 284 | return sqlite3_api.*.result_text16.?(pCtx, z, n, xDel); | 284 | return sqlite3_api.*.result_text16.?(pCtx, z, n, xDel); |
| 285 | } | 285 | } |
| 286 | pub export fn sqlite3_result_text16be(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) void { | 286 | pub export fn sqlite3_result_text16be(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 287 | return sqlite3_api.*.result_text16be.?(pCtx, z, n, xDel); | 287 | return sqlite3_api.*.result_text16be.?(pCtx, z, n, xDel); |
| 288 | } | 288 | } |
| 289 | pub export fn sqlite3_result_text16le(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) void { | 289 | pub export fn sqlite3_result_text16le(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 290 | return sqlite3_api.*.result_text16le.?(pCtx, z, n, xDel); | 290 | return sqlite3_api.*.result_text16le.?(pCtx, z, n, xDel); |
| 291 | } | 291 | } |
| 292 | pub export fn sqlite3_result_value(pCtx: ?*c.sqlite3_context, pValue: ?*c.sqlite3_value) void { | 292 | pub export fn sqlite3_result_value(pCtx: ?*c.sqlite3_context, pValue: ?*c.sqlite3_value) void { |
| 293 | return sqlite3_api.*.result_value.?(pCtx, pValue); | 293 | return sqlite3_api.*.result_value.?(pCtx, pValue); |
| 294 | } | 294 | } |
| 295 | pub export fn sqlite3_rollback_hook(db: ?*c.sqlite3, xCallback: ?fn (?*anyopaque) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 295 | pub export fn sqlite3_rollback_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { |
| 296 | return sqlite3_api.*.rollback_hook.?(db, xCallback, pArg); | 296 | return sqlite3_api.*.rollback_hook.?(db, xCallback, pArg); |
| 297 | } | 297 | } |
| 298 | pub export fn sqlite3_set_authorizer(db: ?*c.sqlite3, xAuth: ?fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, [*c]const u8, [*c]const u8) callconv(.C) c_int, pArg: ?*anyopaque) c_int { | 298 | pub export fn sqlite3_set_authorizer(db: ?*c.sqlite3, xAuth: ?*const fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, [*c]const u8, [*c]const u8) callconv(.C) c_int, pArg: ?*anyopaque) c_int { |
| 299 | return sqlite3_api.*.set_authorizer.?(db, xAuth, pArg); | 299 | return sqlite3_api.*.set_authorizer.?(db, xAuth, pArg); |
| 300 | } | 300 | } |
| 301 | pub export fn sqlite3_set_auxdata(pCtx: ?*c.sqlite3_context, iArg: c_int, pAux: ?*anyopaque, xDelete: ?fn (?*anyopaque) callconv(.C) void) void { | 301 | pub export fn sqlite3_set_auxdata(pCtx: ?*c.sqlite3_context, iArg: c_int, pAux: ?*anyopaque, xDelete: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 302 | return sqlite3_api.*.set_auxdata.?(pCtx, iArg, pAux, xDelete); | 302 | return sqlite3_api.*.set_auxdata.?(pCtx, iArg, pAux, xDelete); |
| 303 | } | 303 | } |
| 304 | pub export fn sqlite3_step(pStmt: ?*c.sqlite3_stmt) c_int { | 304 | pub export fn sqlite3_step(pStmt: ?*c.sqlite3_stmt) c_int { |
| @@ -313,10 +313,10 @@ pub export fn sqlite3_thread_cleanup() void { | |||
| 313 | pub export fn sqlite3_total_changes(db: ?*c.sqlite3) c_int { | 313 | pub export fn sqlite3_total_changes(db: ?*c.sqlite3) c_int { |
| 314 | return sqlite3_api.*.total_changes.?(db); | 314 | return sqlite3_api.*.total_changes.?(db); |
| 315 | } | 315 | } |
| 316 | pub export fn sqlite3_trace(db: ?*c.sqlite3, xTrace: ?fn (?*anyopaque, [*c]const u8) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 316 | pub export fn sqlite3_trace(db: ?*c.sqlite3, xTrace: ?*const fn (?*anyopaque, [*c]const u8) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { |
| 317 | return sqlite3_api.*.trace.?(db, xTrace, pArg); | 317 | return sqlite3_api.*.trace.?(db, xTrace, pArg); |
| 318 | } | 318 | } |
| 319 | pub export fn sqlite3_update_hook(db: ?*c.sqlite3, xCallback: ?fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, c.sqlite3_int64) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { | 319 | pub export fn sqlite3_update_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, c_int, [*c]const u8, [*c]const u8, c.sqlite3_int64) callconv(.C) void, pArg: ?*anyopaque) ?*anyopaque { |
| 320 | return sqlite3_api.*.update_hook.?(db, xCallback, pArg); | 320 | return sqlite3_api.*.update_hook.?(db, xCallback, pArg); |
| 321 | } | 321 | } |
| 322 | pub export fn sqlite3_user_data(pCtx: ?*c.sqlite3_context) ?*anyopaque { | 322 | pub export fn sqlite3_user_data(pCtx: ?*c.sqlite3_context) ?*anyopaque { |
| @@ -382,7 +382,7 @@ pub export fn sqlite3_blob_read(pBlob: ?*c.sqlite3_blob, z: ?*anyopaque, n: c_in | |||
| 382 | pub export fn sqlite3_blob_write(pBlob: ?*c.sqlite3_blob, z: ?*const anyopaque, n: c_int, iOffset: c_int) c_int { | 382 | pub export fn sqlite3_blob_write(pBlob: ?*c.sqlite3_blob, z: ?*const anyopaque, n: c_int, iOffset: c_int) c_int { |
| 383 | return sqlite3_api.*.blob_write.?(pBlob, z, n, iOffset); | 383 | return sqlite3_api.*.blob_write.?(pBlob, z, n, iOffset); |
| 384 | } | 384 | } |
| 385 | pub export fn sqlite3_create_collation_v2(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pCtx: ?*anyopaque, xCompare: ?fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int, xDel: ?fn (?*anyopaque) callconv(.C) void) c_int { | 385 | pub export fn sqlite3_create_collation_v2(db: ?*c.sqlite3, zName: [*c]const u8, eTextRep: c_int, pCtx: ?*anyopaque, xCompare: ?*const fn (?*anyopaque, c_int, ?*const anyopaque, c_int, ?*const anyopaque) callconv(.C) c_int, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 386 | return sqlite3_api.*.create_collation_v2.?(db, zName, eTextRep, pCtx, xCompare, xDel); | 386 | return sqlite3_api.*.create_collation_v2.?(db, zName, eTextRep, pCtx, xCompare, xDel); |
| 387 | } | 387 | } |
| 388 | pub export fn sqlite3_file_control(db: ?*c.sqlite3, zDbName: [*c]const u8, op: c_int, pArg: ?*anyopaque) c_int { | 388 | pub export fn sqlite3_file_control(db: ?*c.sqlite3, zDbName: [*c]const u8, op: c_int, pArg: ?*anyopaque) c_int { |
| @@ -493,10 +493,10 @@ pub export fn sqlite3_create_function_v2( | |||
| 493 | nArg: c_int, | 493 | nArg: c_int, |
| 494 | eTextRep: c_int, | 494 | eTextRep: c_int, |
| 495 | pApp: ?*anyopaque, | 495 | pApp: ?*anyopaque, |
| 496 | xFunc: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 496 | xFunc: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, |
| 497 | xStep: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 497 | xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, |
| 498 | xFinal: ?fn (?*c.sqlite3_context) callconv(.C) void, | 498 | xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void, |
| 499 | xDestroy: ?fn (?*anyopaque) callconv(.C) void, | 499 | xDestroy: ?*const fn (?*anyopaque) callconv(.C) void, |
| 500 | ) c_int { | 500 | ) c_int { |
| 501 | return sqlite3_api.*.create_function_v2.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal, xDestroy); | 501 | return sqlite3_api.*.create_function_v2.?(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal, xDestroy); |
| 502 | } | 502 | } |
| @@ -521,7 +521,7 @@ pub export fn sqlite3_stmt_status(pStmt: ?*c.sqlite3_stmt, op: c_int, resetFlag: | |||
| 521 | pub export fn sqlite3_strnicmp(zLeft: [*c]const u8, zRight: [*c]const u8, N: c_int) c_int { | 521 | pub export fn sqlite3_strnicmp(zLeft: [*c]const u8, zRight: [*c]const u8, N: c_int) c_int { |
| 522 | return sqlite3_api.*.strnicmp.?(zLeft, zRight, N); | 522 | return sqlite3_api.*.strnicmp.?(zLeft, zRight, N); |
| 523 | } | 523 | } |
| 524 | pub export fn sqlite3_unlock_notify(pBlocked: ?*c.sqlite3, xNotify: ?fn ([*c]?*anyopaque, c_int) callconv(.C) void, pNotifyArg: ?*anyopaque) c_int { | 524 | pub export fn sqlite3_unlock_notify(pBlocked: ?*c.sqlite3, xNotify: ?*const fn ([*c]?*anyopaque, c_int) callconv(.C) void, pNotifyArg: ?*anyopaque) c_int { |
| 525 | return sqlite3_api.*.unlock_notify.?(pBlocked, xNotify, pNotifyArg); | 525 | return sqlite3_api.*.unlock_notify.?(pBlocked, xNotify, pNotifyArg); |
| 526 | } | 526 | } |
| 527 | pub export fn sqlite3_wal_autocheckpoint(db: ?*c.sqlite3, N: c_int) c_int { | 527 | pub export fn sqlite3_wal_autocheckpoint(db: ?*c.sqlite3, N: c_int) c_int { |
| @@ -530,7 +530,7 @@ pub export fn sqlite3_wal_autocheckpoint(db: ?*c.sqlite3, N: c_int) c_int { | |||
| 530 | pub export fn sqlite3_wal_checkpoint(db: ?*c.sqlite3, zDb: [*c]const u8) c_int { | 530 | pub export fn sqlite3_wal_checkpoint(db: ?*c.sqlite3, zDb: [*c]const u8) c_int { |
| 531 | return sqlite3_api.*.wal_checkpoint.?(db, zDb); | 531 | return sqlite3_api.*.wal_checkpoint.?(db, zDb); |
| 532 | } | 532 | } |
| 533 | pub export fn sqlite3_wal_hook(db: ?*c.sqlite3, xCallback: ?fn (?*anyopaque, ?*c.sqlite3, [*c]const u8, c_int) callconv(.C) c_int, pArg: ?*anyopaque) ?*anyopaque { | 533 | pub export fn sqlite3_wal_hook(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, ?*c.sqlite3, [*c]const u8, c_int) callconv(.C) c_int, pArg: ?*anyopaque) ?*anyopaque { |
| 534 | return sqlite3_api.*.wal_hook.?(db, xCallback, pArg); | 534 | return sqlite3_api.*.wal_hook.?(db, xCallback, pArg); |
| 535 | } | 535 | } |
| 536 | pub export fn sqlite3_blob_reopen(pBlob: ?*c.sqlite3_blob, iRow: c.sqlite3_int64) c_int { | 536 | pub export fn sqlite3_blob_reopen(pBlob: ?*c.sqlite3_blob, iRow: c.sqlite3_int64) c_int { |
| @@ -575,16 +575,16 @@ pub export fn sqlite3_uri_parameter(zFilename: [*c]const u8, zParam: [*c]const u | |||
| 575 | pub export fn sqlite3_wal_checkpoint_v2(db: ?*c.sqlite3, zDb: [*c]const u8, eMode: c_int, pnLog: [*c]c_int, pnCkpt: [*c]c_int) c_int { | 575 | pub export fn sqlite3_wal_checkpoint_v2(db: ?*c.sqlite3, zDb: [*c]const u8, eMode: c_int, pnLog: [*c]c_int, pnCkpt: [*c]c_int) c_int { |
| 576 | return sqlite3_api.*.wal_checkpoint_v2.?(db, zDb, eMode, pnLog, pnCkpt); | 576 | return sqlite3_api.*.wal_checkpoint_v2.?(db, zDb, eMode, pnLog, pnCkpt); |
| 577 | } | 577 | } |
| 578 | pub export fn sqlite3_auto_extension(xEntryPoint: ?fn () callconv(.C) void) c_int { | 578 | pub export fn sqlite3_auto_extension(xEntryPoint: ?*const fn () callconv(.C) void) c_int { |
| 579 | return sqlite3_api.*.auto_extension.?(xEntryPoint); | 579 | return sqlite3_api.*.auto_extension.?(xEntryPoint); |
| 580 | } | 580 | } |
| 581 | pub export fn sqlite3_bind_blob64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c.sqlite3_uint64, xDel: ?fn (?*anyopaque) callconv(.C) void) c_int { | 581 | pub export fn sqlite3_bind_blob64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: ?*const anyopaque, nData: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 582 | return sqlite3_api.*.bind_blob64.?(pStmt, i, zData, nData, xDel); | 582 | return sqlite3_api.*.bind_blob64.?(pStmt, i, zData, nData, xDel); |
| 583 | } | 583 | } |
| 584 | pub export fn sqlite3_bind_text64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c.sqlite3_uint64, xDel: ?fn (?*anyopaque) callconv(.C) void, encoding: u8) c_int { | 584 | pub export fn sqlite3_bind_text64(pStmt: ?*c.sqlite3_stmt, i: c_int, zData: [*c]const u8, nData: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void, encoding: u8) c_int { |
| 585 | return sqlite3_api.*.bind_text64.?(pStmt, i, zData, nData, xDel, encoding); | 585 | return sqlite3_api.*.bind_text64.?(pStmt, i, zData, nData, xDel, encoding); |
| 586 | } | 586 | } |
| 587 | pub export fn sqlite3_cancel_auto_extension(xEntryPoint: ?fn () callconv(.C) void) c_int { | 587 | pub export fn sqlite3_cancel_auto_extension(xEntryPoint: ?*const fn () callconv(.C) void) c_int { |
| 588 | return sqlite3_api.*.cancel_auto_extension.?(xEntryPoint); | 588 | return sqlite3_api.*.cancel_auto_extension.?(xEntryPoint); |
| 589 | } | 589 | } |
| 590 | pub export fn sqlite3_load_extension(db: ?*c.sqlite3, zFile: [*c]const u8, zProc: [*c]const u8, pzErrMsg: [*c][*c]u8) c_int { | 590 | pub export fn sqlite3_load_extension(db: ?*c.sqlite3, zFile: [*c]const u8, zProc: [*c]const u8, pzErrMsg: [*c][*c]u8) c_int { |
| @@ -602,10 +602,10 @@ pub export fn sqlite3_realloc64(pOld: ?*anyopaque, n: c.sqlite3_uint64) ?*anyopa | |||
| 602 | pub export fn sqlite3_reset_auto_extension() void { | 602 | pub export fn sqlite3_reset_auto_extension() void { |
| 603 | return sqlite3_api.*.reset_auto_extension.?(); | 603 | return sqlite3_api.*.reset_auto_extension.?(); |
| 604 | } | 604 | } |
| 605 | pub export fn sqlite3_result_blob64(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c.sqlite3_uint64, xDel: ?fn (?*anyopaque) callconv(.C) void) void { | 605 | pub export fn sqlite3_result_blob64(pCtx: ?*c.sqlite3_context, z: ?*const anyopaque, n: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 606 | return sqlite3_api.*.result_blob64.?(pCtx, z, n, xDel); | 606 | return sqlite3_api.*.result_blob64.?(pCtx, z, n, xDel); |
| 607 | } | 607 | } |
| 608 | pub export fn sqlite3_result_text64(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c.sqlite3_uint64, xDel: ?fn (?*anyopaque) callconv(.C) void, encoding: u8) void { | 608 | pub export fn sqlite3_result_text64(pCtx: ?*c.sqlite3_context, z: [*c]const u8, n: c.sqlite3_uint64, xDel: ?*const fn (?*anyopaque) callconv(.C) void, encoding: u8) void { |
| 609 | return sqlite3_api.*.result_text64.?(pCtx, z, n, xDel, encoding); | 609 | return sqlite3_api.*.result_text64.?(pCtx, z, n, xDel, encoding); |
| 610 | } | 610 | } |
| 611 | pub export fn sqlite3_strglob(zGlob: [*c]const u8, zStr: [*c]const u8) c_int { | 611 | pub export fn sqlite3_strglob(zGlob: [*c]const u8, zStr: [*c]const u8) c_int { |
| @@ -641,7 +641,7 @@ pub export fn sqlite3_db_cacheflush(db: ?*c.sqlite3) c_int { | |||
| 641 | pub export fn sqlite3_system_errno(db: ?*c.sqlite3) c_int { | 641 | pub export fn sqlite3_system_errno(db: ?*c.sqlite3) c_int { |
| 642 | return sqlite3_api.*.system_errno.?(db); | 642 | return sqlite3_api.*.system_errno.?(db); |
| 643 | } | 643 | } |
| 644 | pub export fn sqlite3_trace_v2(db: ?*c.sqlite3, uMask: c_uint, xCallback: ?fn (c_uint, ?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) c_int, pCtx: ?*anyopaque) c_int { | 644 | pub export fn sqlite3_trace_v2(db: ?*c.sqlite3, uMask: c_uint, xCallback: ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) c_int, pCtx: ?*anyopaque) c_int { |
| 645 | return sqlite3_api.*.trace_v2.?(db, uMask, xCallback, pCtx); | 645 | return sqlite3_api.*.trace_v2.?(db, uMask, xCallback, pCtx); |
| 646 | } | 646 | } |
| 647 | pub export fn sqlite3_expanded_sql(pStmt: ?*c.sqlite3_stmt) [*c]u8 { | 647 | pub export fn sqlite3_expanded_sql(pStmt: ?*c.sqlite3_stmt) [*c]u8 { |
| @@ -656,10 +656,10 @@ pub export fn sqlite3_prepare_v3(db: ?*c.sqlite3, zSql: [*c]const u8, nByte: c_i | |||
| 656 | pub export fn sqlite3_prepare16_v3(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, prepFlags: c_uint, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { | 656 | pub export fn sqlite3_prepare16_v3(db: ?*c.sqlite3, zSql: ?*const anyopaque, nByte: c_int, prepFlags: c_uint, ppStmt: [*c]?*c.sqlite3_stmt, pzTail: [*c]?*const anyopaque) c_int { |
| 657 | return sqlite3_api.*.prepare16_v3.?(db, zSql, nByte, prepFlags, ppStmt, pzTail); | 657 | return sqlite3_api.*.prepare16_v3.?(db, zSql, nByte, prepFlags, ppStmt, pzTail); |
| 658 | } | 658 | } |
| 659 | pub export fn sqlite3_bind_pointer(pStmt: ?*c.sqlite3_stmt, i: c_int, pPtr: ?*anyopaque, zPTtype: [*c]const u8, xDestructor: ?fn (?*anyopaque) callconv(.C) void) c_int { | 659 | pub export fn sqlite3_bind_pointer(pStmt: ?*c.sqlite3_stmt, i: c_int, pPtr: ?*anyopaque, zPTtype: [*c]const u8, xDestructor: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 660 | return sqlite3_api.*.bind_pointer.?(pStmt, i, pPtr, zPTtype, xDestructor); | 660 | return sqlite3_api.*.bind_pointer.?(pStmt, i, pPtr, zPTtype, xDestructor); |
| 661 | } | 661 | } |
| 662 | pub export fn sqlite3_result_pointer(pCtx: ?*c.sqlite3_context, pPtr: ?*anyopaque, zPType: [*c]const u8, xDestructor: ?fn (?*anyopaque) callconv(.C) void) void { | 662 | pub export fn sqlite3_result_pointer(pCtx: ?*c.sqlite3_context, pPtr: ?*anyopaque, zPType: [*c]const u8, xDestructor: ?*const fn (?*anyopaque) callconv(.C) void) void { |
| 663 | return sqlite3_api.*.result_pointer.?(pCtx, pPtr, zPType, xDestructor); | 663 | return sqlite3_api.*.result_pointer.?(pCtx, pPtr, zPType, xDestructor); |
| 664 | } | 664 | } |
| 665 | pub export fn sqlite3_value_pointer(pVal: ?*c.sqlite3_value, zPType: [*c]const u8) ?*anyopaque { | 665 | pub export fn sqlite3_value_pointer(pVal: ?*c.sqlite3_value, zPType: [*c]const u8) ?*anyopaque { |
| @@ -716,11 +716,11 @@ pub export fn sqlite3_create_window_function( | |||
| 716 | nArg: c_int, | 716 | nArg: c_int, |
| 717 | eTextRep: c_int, | 717 | eTextRep: c_int, |
| 718 | pArg: ?*anyopaque, | 718 | pArg: ?*anyopaque, |
| 719 | xStep: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 719 | xStep: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, |
| 720 | xFinal: ?fn (?*c.sqlite3_context) callconv(.C) void, | 720 | xFinal: ?*const fn (?*c.sqlite3_context) callconv(.C) void, |
| 721 | xValue: ?fn (?*c.sqlite3_context) callconv(.C) void, | 721 | xValue: ?*const fn (?*c.sqlite3_context) callconv(.C) void, |
| 722 | xInverse: ?fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, | 722 | xInverse: ?*const fn (?*c.sqlite3_context, c_int, [*c]?*c.sqlite3_value) callconv(.C) void, |
| 723 | xDestroy: ?fn (?*anyopaque) callconv(.C) void, | 723 | xDestroy: ?*const fn (?*anyopaque) callconv(.C) void, |
| 724 | ) c_int { | 724 | ) c_int { |
| 725 | return sqlite3_api.*.create_window_function.?( | 725 | return sqlite3_api.*.create_window_function.?( |
| 726 | db, | 726 | db, |
| @@ -777,7 +777,7 @@ pub export fn sqlite3_changes64(db: ?*c.sqlite3) c.sqlite3_int64 { | |||
| 777 | pub export fn sqlite3_total_changes64(db: ?*c.sqlite3) c.sqlite3_int64 { | 777 | pub export fn sqlite3_total_changes64(db: ?*c.sqlite3) c.sqlite3_int64 { |
| 778 | return sqlite3_api.*.total_changes64.?(db); | 778 | return sqlite3_api.*.total_changes64.?(db); |
| 779 | } | 779 | } |
| 780 | pub export fn sqlite3_autovacuum_pages(db: ?*c.sqlite3, xCallback: ?fn (?*anyopaque, [*c]const u8, c_uint, c_uint, c_uint) callconv(.C) c_uint, pArg: ?*anyopaque, xDestructor: ?fn (?*anyopaque) callconv(.C) void) c_int { | 780 | pub export fn sqlite3_autovacuum_pages(db: ?*c.sqlite3, xCallback: ?*const fn (?*anyopaque, [*c]const u8, c_uint, c_uint, c_uint) callconv(.C) c_uint, pArg: ?*anyopaque, xDestructor: ?*const fn (?*anyopaque) callconv(.C) void) c_int { |
| 781 | return sqlite3_api.*.autovacuum_pages.?(db, xCallback, pArg, xDestructor); | 781 | return sqlite3_api.*.autovacuum_pages.?(db, xCallback, pArg, xDestructor); |
| 782 | } | 782 | } |
| 783 | pub export fn sqlite3_error_offset(db: ?*c.sqlite3) c_int { | 783 | pub export fn sqlite3_error_offset(db: ?*c.sqlite3) c_int { |
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, 0..) |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 | } |
| @@ -1395,7 +1395,7 @@ pub fn Iterator(comptime Type: type) type { | |||
| 1395 | 1395 | ||
| 1396 | var value: Type = undefined; | 1396 | var value: Type = undefined; |
| 1397 | 1397 | ||
| 1398 | inline for (@typeInfo(Type).Struct.fields) |field, _i| { | 1398 | inline for (@typeInfo(Type).Struct.fields, 0..) |field, _i| { |
| 1399 | const i = @as(usize, _i); | 1399 | const i = @as(usize, _i); |
| 1400 | 1400 | ||
| 1401 | const ret = try self.readField(field.type, options, i); | 1401 | const ret = try self.readField(field.type, options, i); |
| @@ -1721,7 +1721,7 @@ pub const DynamicStatement = struct { | |||
| 1721 | 1721 | ||
| 1722 | switch (@typeInfo(Type)) { | 1722 | switch (@typeInfo(Type)) { |
| 1723 | .Struct => |StructTypeInfo| { | 1723 | .Struct => |StructTypeInfo| { |
| 1724 | inline for (StructTypeInfo.fields) |struct_field, struct_field_i| { | 1724 | inline for (StructTypeInfo.fields, 0..) |struct_field, struct_field_i| { |
| 1725 | const field_value = @field(values, struct_field.name); | 1725 | const field_value = @field(values, struct_field.name); |
| 1726 | 1726 | ||
| 1727 | const i = sqlite3BindParameterIndex(self.stmt, struct_field.name); | 1727 | const i = sqlite3BindParameterIndex(self.stmt, struct_field.name); |
| @@ -1735,7 +1735,7 @@ pub const DynamicStatement = struct { | |||
| 1735 | .Pointer => |PointerTypeInfo| { | 1735 | .Pointer => |PointerTypeInfo| { |
| 1736 | switch (PointerTypeInfo.size) { | 1736 | switch (PointerTypeInfo.size) { |
| 1737 | .Slice => { | 1737 | .Slice => { |
| 1738 | for (values) |value_to_bind, index| { | 1738 | for (values, 0..) |value_to_bind, index| { |
| 1739 | try self.bindField(PointerTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); | 1739 | try self.bindField(PointerTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); |
| 1740 | } | 1740 | } |
| 1741 | }, | 1741 | }, |
| @@ -1743,7 +1743,7 @@ pub const DynamicStatement = struct { | |||
| 1743 | } | 1743 | } |
| 1744 | }, | 1744 | }, |
| 1745 | .Array => |ArrayTypeInfo| { | 1745 | .Array => |ArrayTypeInfo| { |
| 1746 | for (values) |value_to_bind, index| { | 1746 | for (values, 0..) |value_to_bind, index| { |
| 1747 | try self.bindField(ArrayTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); | 1747 | try self.bindField(ArrayTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); |
| 1748 | } | 1748 | } |
| 1749 | }, | 1749 | }, |
| @@ -2025,7 +2025,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: anytype) type | |||
| 2025 | })); | 2025 | })); |
| 2026 | } | 2026 | } |
| 2027 | 2027 | ||
| 2028 | inline for (StructTypeInfo.fields) |struct_field, _i| { | 2028 | inline for (StructTypeInfo.fields, 0..) |struct_field, _i| { |
| 2029 | const bind_marker = query.bind_markers[_i]; | 2029 | const bind_marker = query.bind_markers[_i]; |
| 2030 | if (bind_marker.typed) |typ| { | 2030 | if (bind_marker.typed) |typ| { |
| 2031 | const FieldTypeInfo = @typeInfo(struct_field.type); | 2031 | const FieldTypeInfo = @typeInfo(struct_field.type); |
| @@ -2497,7 +2497,7 @@ test "sqlite: read all users into a struct" { | |||
| 2497 | 2497 | ||
| 2498 | var rows = try stmt.all(TestUser, allocator, .{}, .{}); | 2498 | var rows = try stmt.all(TestUser, allocator, .{}, .{}); |
| 2499 | try testing.expectEqual(@as(usize, 3), rows.len); | 2499 | try testing.expectEqual(@as(usize, 3), rows.len); |
| 2500 | for (rows) |row, i| { | 2500 | for (rows, 0..) |row, i| { |
| 2501 | const exp = test_users[i]; | 2501 | const exp = test_users[i]; |
| 2502 | try testing.expectEqual(exp.id, row.id); | 2502 | try testing.expectEqual(exp.id, row.id); |
| 2503 | try testing.expectEqualStrings(exp.name, row.name); | 2503 | try testing.expectEqualStrings(exp.name, row.name); |
| @@ -2623,7 +2623,7 @@ test "sqlite: read a single text value" { | |||
| 2623 | const res = mem.sliceTo(&name.?, sentinel); | 2623 | const res = mem.sliceTo(&name.?, sentinel); |
| 2624 | try testing.expectEqualStrings("Vincent", res); | 2624 | try testing.expectEqualStrings("Vincent", res); |
| 2625 | } else { | 2625 | } else { |
| 2626 | const res = mem.span(&name.?); | 2626 | const res: []const u8 = &name.?; |
| 2627 | try testing.expectEqualStrings("Vincent", res); | 2627 | try testing.expectEqualStrings("Vincent", res); |
| 2628 | }, | 2628 | }, |
| 2629 | else => @compileError("invalid type " ++ @typeName(typ)), | 2629 | else => @compileError("invalid type " ++ @typeName(typ)), |
| @@ -2828,7 +2828,7 @@ test "sqlite: bind pointer" { | |||
| 2828 | var stmt = try db.prepare(query); | 2828 | var stmt = try db.prepare(query); |
| 2829 | defer stmt.deinit(); | 2829 | defer stmt.deinit(); |
| 2830 | 2830 | ||
| 2831 | for (test_users) |test_user, i| { | 2831 | for (test_users, 0..) |test_user, i| { |
| 2832 | stmt.reset(); | 2832 | stmt.reset(); |
| 2833 | 2833 | ||
| 2834 | const name = try stmt.oneAlloc([]const u8, allocator, .{}, .{&test_user.id}); | 2834 | const name = try stmt.oneAlloc([]const u8, allocator, .{}, .{&test_user.id}); |
| @@ -2864,7 +2864,7 @@ test "sqlite: read pointers" { | |||
| 2864 | ); | 2864 | ); |
| 2865 | 2865 | ||
| 2866 | try testing.expectEqual(@as(usize, 3), rows.len); | 2866 | try testing.expectEqual(@as(usize, 3), rows.len); |
| 2867 | for (rows) |row, i| { | 2867 | for (rows, 0..) |row, i| { |
| 2868 | const exp = test_users[i]; | 2868 | const exp = test_users[i]; |
| 2869 | try testing.expectEqual(exp.id, row.id.*); | 2869 | try testing.expectEqual(exp.id, row.id.*); |
| 2870 | try testing.expectEqualStrings(exp.name, row.name.*); | 2870 | try testing.expectEqualStrings(exp.name, row.name.*); |
| @@ -2998,7 +2998,7 @@ test "sqlite: statement iterator" { | |||
| 2998 | // Check the data | 2998 | // Check the data |
| 2999 | try testing.expectEqual(expected_rows.items.len, rows.items.len); | 2999 | try testing.expectEqual(expected_rows.items.len, rows.items.len); |
| 3000 | 3000 | ||
| 3001 | for (rows.items) |row, j| { | 3001 | for (rows.items, 0..) |row, j| { |
| 3002 | const exp_row = expected_rows.items[j]; | 3002 | const exp_row = expected_rows.items[j]; |
| 3003 | try testing.expectEqualStrings(exp_row.name, mem.sliceTo(&row.name, 0)); | 3003 | try testing.expectEqualStrings(exp_row.name, mem.sliceTo(&row.name, 0)); |
| 3004 | try testing.expectEqual(exp_row.age, row.age); | 3004 | try testing.expectEqual(exp_row.age, row.age); |
| @@ -3025,7 +3025,7 @@ test "sqlite: statement iterator" { | |||
| 3025 | // Check the data | 3025 | // Check the data |
| 3026 | try testing.expectEqual(expected_rows.items.len, rows.items.len); | 3026 | try testing.expectEqual(expected_rows.items.len, rows.items.len); |
| 3027 | 3027 | ||
| 3028 | for (rows.items) |row, j| { | 3028 | for (rows.items, 0..) |row, j| { |
| 3029 | const exp_row = expected_rows.items[j]; | 3029 | const exp_row = expected_rows.items[j]; |
| 3030 | try testing.expectEqualStrings(exp_row.name, row.name.data); | 3030 | try testing.expectEqualStrings(exp_row.name, row.name.data); |
| 3031 | try testing.expectEqual(exp_row.age, row.age); | 3031 | try testing.expectEqual(exp_row.age, row.age); |
| @@ -3386,7 +3386,7 @@ test "sqlite: bind custom type" { | |||
| 3386 | const rows = try stmt.all(Article, arena.allocator(), .{}, .{}); | 3386 | const rows = try stmt.all(Article, arena.allocator(), .{}, .{}); |
| 3387 | try testing.expectEqual(@as(usize, 20), rows.len); | 3387 | try testing.expectEqual(@as(usize, 20), rows.len); |
| 3388 | 3388 | ||
| 3389 | for (rows) |row, i| { | 3389 | for (rows, 0..) |row, i| { |
| 3390 | var exp_data: MyData = undefined; | 3390 | var exp_data: MyData = undefined; |
| 3391 | mem.set(u8, &exp_data.data, @intCast(u8, i)); | 3391 | mem.set(u8, &exp_data.data, @intCast(u8, i)); |
| 3392 | 3392 | ||
| @@ -207,7 +207,7 @@ pub const BestIndexBuilder = struct { | |||
| 207 | .id = .{}, | 207 | .id = .{}, |
| 208 | }; | 208 | }; |
| 209 | 209 | ||
| 210 | for (res.constraints) |*constraint, i| { | 210 | for (res.constraints, 0..) |*constraint, i| { |
| 211 | const raw_constraint = index_info.aConstraint[i]; | 211 | const raw_constraint = index_info.aConstraint[i]; |
| 212 | 212 | ||
| 213 | constraint.column = @intCast(isize, raw_constraint.iColumn); | 213 | constraint.column = @intCast(isize, raw_constraint.iColumn); |
| @@ -233,7 +233,7 @@ pub const BestIndexBuilder = struct { | |||
| 233 | 233 | ||
| 234 | // Populate the constraint usage | 234 | // Populate the constraint usage |
| 235 | var constraint_usage: []c.sqlite3_index_constraint_usage = index_info.aConstraintUsage[0..self.constraints.len]; | 235 | var constraint_usage: []c.sqlite3_index_constraint_usage = index_info.aConstraintUsage[0..self.constraints.len]; |
| 236 | for (self.constraints) |constraint, i| { | 236 | for (self.constraints, 0..) |constraint, i| { |
| 237 | constraint_usage[i].argvIndex = constraint.usage.argv_index; | 237 | constraint_usage[i].argvIndex = constraint.usage.argv_index; |
| 238 | constraint_usage[i].omit = if (constraint.usage.omit) 1 else 0; | 238 | constraint_usage[i].omit = if (constraint.usage.omit) 1 else 0; |
| 239 | } | 239 | } |
| @@ -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 | ||
| @@ -541,7 +541,7 @@ fn parseModuleArguments(allocator: mem.Allocator, argc: c_int, argv: [*c]const [ | |||
| 541 | var res = try allocator.alloc(ModuleArgument, @intCast(usize, argc)); | 541 | var res = try allocator.alloc(ModuleArgument, @intCast(usize, argc)); |
| 542 | errdefer allocator.free(res); | 542 | errdefer allocator.free(res); |
| 543 | 543 | ||
| 544 | for (res) |*marg, i| { | 544 | for (res, 0..) |*marg, i| { |
| 545 | // The documentation of sqlite says each string in argv is null-terminated | 545 | // The documentation of sqlite says each string in argv is null-terminated |
| 546 | const arg = mem.sliceTo(argv[i], 0); | 546 | const arg = mem.sliceTo(argv[i], 0); |
| 547 | 547 | ||
| @@ -840,7 +840,7 @@ pub fn VirtualTable( | |||
| 840 | const size = @intCast(usize, argc); | 840 | const size = @intCast(usize, argc); |
| 841 | 841 | ||
| 842 | var res = try allocator.alloc(FilterArg, size); | 842 | var res = try allocator.alloc(FilterArg, size); |
| 843 | for (res) |*item, i| { | 843 | for (res, 0..) |*item, i| { |
| 844 | item.* = .{ | 844 | item.* = .{ |
| 845 | .value = argv[i], | 845 | .value = argv[i], |
| 846 | }; | 846 | }; |
| @@ -1276,7 +1276,7 @@ test "parse module arguments" { | |||
| 1276 | const allocator = arena.allocator(); | 1276 | const allocator = arena.allocator(); |
| 1277 | 1277 | ||
| 1278 | var args = try allocator.alloc([*c]const u8, 20); | 1278 | var args = try allocator.alloc([*c]const u8, 20); |
| 1279 | for (args) |*arg, i| { | 1279 | for (args, 0..) |*arg, i| { |
| 1280 | const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i}); | 1280 | const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i}); |
| 1281 | arg.* = @ptrCast([*c]const u8, tmp); | 1281 | arg.* = @ptrCast([*c]const u8, tmp); |
| 1282 | } | 1282 | } |
| @@ -1288,7 +1288,7 @@ test "parse module arguments" { | |||
| 1288 | ); | 1288 | ); |
| 1289 | try testing.expectEqual(@as(usize, 20), res.len); | 1289 | try testing.expectEqual(@as(usize, 20), res.len); |
| 1290 | 1290 | ||
| 1291 | for (res) |arg, i| { | 1291 | for (res, 0..) |arg, i| { |
| 1292 | try testing.expectEqualStrings("arg", arg.kv.key); | 1292 | try testing.expectEqualStrings("arg", arg.kv.key); |
| 1293 | try testing.expectEqual(i, try fmt.parseInt(usize, arg.kv.value, 10)); | 1293 | try testing.expectEqual(i, try fmt.parseInt(usize, arg.kv.value, 10)); |
| 1294 | } | 1294 | } |