diff options
Diffstat (limited to 'helpers.zig')
| -rw-r--r-- | helpers.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/helpers.zig b/helpers.zig index 7bb695e..b9a6131 100644 --- a/helpers.zig +++ b/helpers.zig | |||
| @@ -13,8 +13,8 @@ pub fn setResult(ctx: ?*c.sqlite3_context, result: anytype) void { | |||
| 13 | const ResultType = @TypeOf(result); | 13 | const ResultType = @TypeOf(result); |
| 14 | 14 | ||
| 15 | switch (ResultType) { | 15 | switch (ResultType) { |
| 16 | Text => c.sqlite3_result_text(ctx, result.data.ptr, @intCast(result.data.len), c.SQLITE_TRANSIENT), | 16 | Text => c.sqlite3_result_text(ctx, result.data.ptr, @intCast(result.data.len), c.sqliteTransientAsDestructor()), |
| 17 | Blob => c.sqlite3_result_blob(ctx, result.data.ptr, @intCast(result.data.len), c.SQLITE_TRANSIENT), | 17 | Blob => c.sqlite3_result_blob(ctx, result.data.ptr, @intCast(result.data.len), c.sqliteTransientAsDestructor()), |
| 18 | else => switch (@typeInfo(ResultType)) { | 18 | else => switch (@typeInfo(ResultType)) { |
| 19 | .Int => |info| if ((info.bits + if (info.signedness == .unsigned) 1 else 0) <= 32) { | 19 | .Int => |info| if ((info.bits + if (info.signedness == .unsigned) 1 else 0) <= 32) { |
| 20 | c.sqlite3_result_int(ctx, result); | 20 | c.sqlite3_result_int(ctx, result); |
| @@ -26,12 +26,12 @@ pub fn setResult(ctx: ?*c.sqlite3_context, result: anytype) void { | |||
| 26 | .Float => c.sqlite3_result_double(ctx, result), | 26 | .Float => c.sqlite3_result_double(ctx, result), |
| 27 | .Bool => c.sqlite3_result_int(ctx, if (result) 1 else 0), | 27 | .Bool => c.sqlite3_result_int(ctx, if (result) 1 else 0), |
| 28 | .Array => |arr| switch (arr.child) { | 28 | .Array => |arr| switch (arr.child) { |
| 29 | u8 => c.sqlite3_result_blob(ctx, &result, arr.len, c.SQLITE_TRANSIENT), | 29 | u8 => c.sqlite3_result_blob(ctx, &result, arr.len, c.sqliteTransientAsDestructor()), |
| 30 | else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), | 30 | else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), |
| 31 | }, | 31 | }, |
| 32 | .Pointer => |ptr| switch (ptr.size) { | 32 | .Pointer => |ptr| switch (ptr.size) { |
| 33 | .Slice => switch (ptr.child) { | 33 | .Slice => switch (ptr.child) { |
| 34 | u8 => c.sqlite3_result_text(ctx, result.ptr, @intCast(result.len), c.SQLITE_TRANSIENT), | 34 | u8 => c.sqlite3_result_text(ctx, result.ptr, @intCast(result.len), c.sqliteTransientAsDestructor()), |
| 35 | else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), | 35 | else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), |
| 36 | }, | 36 | }, |
| 37 | else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), | 37 | else => @compileError("cannot use a result of type " ++ @typeName(ResultType)), |