---
drop unused slices import, s/void/opaque/, and fix a non-exhaustive
switch
sqlite/handle.ha | 12 ++++++------
sqlite/statement.ha | 46 ++++++++++++++++++++++-----------------------
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/sqlite/handle.ha b/sqlite/handle.ha
index 2052450..7178534 100644
--- a/sqlite/handle.ha
+++ b/sqlite/handle.ha
@@ -3,10 +3,10 @@ use types::c;
// handle holds a reference to an underlying SQLite database
export type handle = struct {
- sqlite: *void,
+ sqlite: *opaque,
};
-@symbol("sqlite3_open") fn _open(filename: const *c::char, sqlite: *nullable *void) int;
+@symbol("sqlite3_open") fn _open(filename: const *c::char, sqlite: *nullable *opaque) int;
// opens a handle to a SQLite database file which wraps:
//
// https://sqlite.org/c3ref/open.html
@@ -14,12 +14,12 @@ export fn open(filename: str) (handle | error) = {
let _filename = c::fromstr(filename);
defer free(_filename);
- let db: nullable *void = null;
+ let db: nullable *opaque = null;
wrapvoid(_open(_filename, &db))?;
- return handle { sqlite = db as *void };
+ return handle { sqlite = db as *opaque };
};
-@symbol("sqlite3_exec") fn _exec(sqlite: nullable *void, sql: const *c::char, callback: nullable *void, args: nullable *void, errs: nullable **c::char) int;
+@symbol("sqlite3_exec") fn _exec(sqlite: nullable *opaque, sql: const *c::char, callback: nullable *opaque, args: nullable *opaque, errs: nullable **c::char) int;
// executes a SQL statement which wraps:
//
// https://sqlite.org/c3ref/exec.html
@@ -30,7 +30,7 @@ export fn exec(h: handle, sql: str) (void | error) = {
return wrapvoid(_exec(h.sqlite, _sql, null, null, null));
};
-@symbol("sqlite3_close") fn _close(sqlite: nullable *void) int;
+@symbol("sqlite3_close") fn _close(sqlite: nullable *opaque) int;
// closes the SQLite database file and frees the [[handle]] which wraps:
//
// https://sqlite.org/c3ref/close.html
diff --git a/sqlite/statement.ha b/sqlite/statement.ha
index 6470cef..5d42a26 100644
--- a/sqlite/statement.ha
+++ b/sqlite/statement.ha
@@ -1,6 +1,5 @@
use fmt;
use hare::types;
-use slices;
use types::c;
def SQLITE_INTEGER: int = 1;
@@ -36,10 +35,10 @@ export fn columntypestr(ct: columntype) str = {
// statement holds a reference to an underlying SQLite statement
export type statement = struct {
- stmt: *void,
+ stmt: *opaque,
};
-@symbol("sqlite3_prepare_v2") fn _prepare(sqlite: nullable *void, sql: const *c::char, n: int, stmt: nullable *void, tail: nullable *void) int;
+@symbol("sqlite3_prepare_v2") fn _prepare(sqlite: nullable *opaque, sql: const *c::char, n: int, stmt: nullable *opaque, tail: nullable *opaque) int;
// prepares a new [[statement]] with the specified SQL statement which wraps:
//
// https://sqlite.org/c3ref/prepare.html
@@ -47,14 +46,14 @@ export fn prepare(h: handle, sql: str) (statement | error) = {
let _sql = c::fromstr(sql);
defer free(_sql);
- let stmt: nullable *void = null;
+ let stmt: nullable *opaque = null;
wrapvoid(_prepare(h.sqlite, _sql, -1, &stmt, null))?;
- return statement { stmt = stmt as *void };
+ return statement { stmt = stmt as *opaque };
};
-@symbol("sqlite3_bind_double") fn _bind_float(sqlite: nullable *void, col: int, val: f64) int;
+@symbol("sqlite3_bind_double") fn _bind_float(sqlite: nullable *opaque, col: int, val: f64) int;
// binds a `f64` to the parameter at `col` index which wraps:
//
// https://www.sqlite.org/c3ref/bind_blob.html
@@ -62,7 +61,7 @@ export fn bind_float(s: statement, col: int, val: f64) (void | error) = {
return wrapvoid(_bind_float(s.stmt, col, val));
};
-@symbol("sqlite3_bind_int") fn _bind_int(sqlite: nullable *void, col: int, val: int) int;
+@symbol("sqlite3_bind_int") fn _bind_int(sqlite: nullable *opaque, col: int, val: int) int;
// binds a `int` to the parameter at `col` index which wraps:
//
// https://www.sqlite.org/c3ref/bind_blob.html
@@ -70,20 +69,20 @@ export fn bind_int(s: statement, col: int, val: int) (void | error) = {
return wrapvoid(_bind_int(s.stmt, col, val));
};
-@symbol("sqlite3_bind_text") fn _bind_str(sqlite: nullable *void, col: int, val: const *c::char, bytelen: int, callback: nullable *fn(*void) void) int;
+@symbol("sqlite3_bind_text") fn _bind_str(sqlite: nullable *opaque, col: int, val: const *c::char, bytelen: int, callback: nullable *fn(*opaque) void) int;
// binds a `str` to the parameter at `col` index which wraps:
//
// https://www.sqlite.org/c3ref/bind_blob.html
export fn bind_str(s: statement, col: int, val: str) (void | error) = {
const val = c::fromstr(val);
- return wrapvoid(_bind_str(s.stmt, col, val, -1, &freecstr: *fn(*void) void));
+ return wrapvoid(_bind_str(s.stmt, col, val, -1, &freecstr: *fn(*opaque) void));
};
fn freecstr(cstr: *const c::char) void = {
free(cstr);
};
-@symbol("sqlite3_bind_null") fn _bind_null(sqlite: nullable *void, col: int) int;
+@symbol("sqlite3_bind_null") fn _bind_null(sqlite: nullable *opaque, col: int) int;
// binds null to the parameter at `col` index which wraps:
//
// https://www.sqlite.org/c3ref/bind_blob.html
@@ -91,7 +90,7 @@ export fn bind_null(s: statement, col: int) (void | error) = {
return wrapvoid(_bind_null(s.stmt, col));
};
-@symbol("sqlite3_step") fn _step(stmt: nullable *void) int;
+@symbol("sqlite3_step") fn _step(stmt: nullable *opaque) int;
// steps through a [[statement]] to iterate through rows which wraps:
//
// https://sqlite.org/c3ref/step.html
@@ -99,7 +98,7 @@ export fn step(s: statement) (result | error) = {
return wrapint(_step(s.stmt));
};
-@symbol("sqlite3_reset") fn _reset(stmt: nullable *void) int;
+@symbol("sqlite3_reset") fn _reset(stmt: nullable *opaque) int;
// resets a [[statement]] which wraps:
//
// https://sqlite.org/c3ref/step.html
@@ -107,7 +106,7 @@ export fn reset(s: statement) (result | error) = {
return wrapint(_reset(s.stmt));
};
-@symbol("sqlite3_finalize") fn _finalize(stmt: nullable *void) int;
+@symbol("sqlite3_finalize") fn _finalize(stmt: nullable *opaque) int;
// finalizes a [[statement]] and frees [[statement]] to free the resourcs which wraps:
//
// https://sqlite.org/c3ref/prepare.html
@@ -116,7 +115,7 @@ export fn finalize(s: statement) (void | error) = {
return;
};
-@symbol("sqlite3_column_name") fn _column_name(stmt: nullable *void, col: int) const *c::char;
+@symbol("sqlite3_column_name") fn _column_name(stmt: nullable *opaque, col: int) const *c::char;
// gets the column's name at position `col` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_name.html
@@ -124,7 +123,7 @@ export fn column_name(s: statement, col: int) str = {
return c::tostr(_column_name(s.stmt, col))!;
};
-@symbol("sqlite3_column_type") fn _column_type(stmt: nullable *void, col: int) int;
+@symbol("sqlite3_column_type") fn _column_type(stmt: nullable *opaque, col: int) int;
// gets the column's type at position `col` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_type.html
@@ -140,10 +139,11 @@ export fn column_type(s: statement, col: int) columntype = {
return columntype::NULL;
case SQLITE_TEXT =>
return columntype::TEXT;
+ case => abort();
};
};
-@symbol("sqlite3_column_int") fn _column_int(stmt: nullable *void, col: int) int;
+@symbol("sqlite3_column_int") fn _column_int(stmt: nullable *opaque, col: int) int;
// return an int for position `col` of type `INTEGER` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_blob.html
@@ -151,7 +151,7 @@ export fn column_int(s: statement, col: int) int = {
return _column_int(s.stmt, col);
};
-@symbol("sqlite3_column_double") fn _column_float(stmt: nullable *void, col: int) f64;
+@symbol("sqlite3_column_double") fn _column_float(stmt: nullable *opaque, col: int) f64;
// return an f64 for position `col` of type `REAL` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_blob.html
@@ -159,7 +159,7 @@ export fn column_float(s: statement, col: int) f64 = {
return _column_float(s.stmt, col);
};
-@symbol("sqlite3_column_text") fn _column_str(stmt: nullable *void, col: int) const *c::char;
+@symbol("sqlite3_column_text") fn _column_str(stmt: nullable *opaque, col: int) const *c::char;
// return a str for position `col` of type `TEXT` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_blob.html
@@ -167,13 +167,13 @@ export fn column_str(s: statement, col: int) str = {
return c::tostr(_column_str(s.stmt, col))!;
};
-@symbol("sqlite3_column_blob") fn _column_blob(stmt: nullable *void, col: int) const *void;
-// return a *void for position `col` of type `BLOB` for the [[statement]] which wraps:
+@symbol("sqlite3_column_blob") fn _column_blob(stmt: nullable *opaque, col: int) const *opaque;
+// return a *opaque for position `col` of type `BLOB` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_blob.html
-export fn column_blob(s: statement, col: int) nullable *void = _column_blob(s.stmt, col);
+export fn column_blob(s: statement, col: int) nullable *opaque = _column_blob(s.stmt, col);
-@symbol("sqlite3_column_bytes") fn _column_bytes(stmt: nullable *void, col: int) int;
+@symbol("sqlite3_column_bytes") fn _column_bytes(stmt: nullable *opaque, col: int) int;
// return the number of bytes as a size for position `col` for the [[statement]] which wraps:
//
// https://sqlite.org/c3ref/column_blob.html
@@ -187,4 +187,4 @@ export fn column_byte_slice(s: statement, col: int) []u8 = {
let buf: []u8 = blob[..sz];
return buf;
-};
\ No newline at end of file
+};
--
2.42.1