From 19e6aa82a64862b123e2f932ab07ab4b8667f91c Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Tue, 3 Mar 2026 23:24:51 -0500 Subject: [PATCH] make C constants values --- sqlite/capi.kk | 15 ++++++++++----- sqlite/sqlite3.kk | 10 +++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sqlite/capi.kk b/sqlite/capi.kk index ff91e4a..e7c7c79 100644 --- a/sqlite/capi.kk +++ b/sqlite/capi.kk @@ -53,11 +53,16 @@ pub extern column-count(^stmt: any): int pub extern column-type(^stmt: any, col: int32): int32 c "kk_sqlite3_column_type" -pub extern int32/integer(): int32 { c inline "SQLITE_INTEGER" } -pub extern int32/float(): int32 { c inline "SQLITE_FLOAT" } -pub extern int32/blob(): int32 { c inline "SQLITE_BLOB" } -pub extern int32/null(): int32 { c inline "SQLITE_NULL" } -pub extern int32/text(): int32 { c inline "SQLITE_TEXT" } +extern make-sqlite-integer(): int32 { c inline "SQLITE_INTEGER" } +pub val int32/integer = make-sqlite-integer() +extern make-sqlite-float(): int32 { c inline "SQLITE_FLOAT" } +pub val int32/float = make-sqlite-float() +extern make-sqlite-blob(): int32 { c inline "SQLITE_BLOB" } +pub val int32/blob = make-sqlite-blob() +extern make-sqlite-null(): int32 { c inline "SQLITE_NULL" } +pub val int32/null = make-sqlite-null() +extern make-sqlite-text(): int32 { c inline "SQLITE_TEXT" } +pub val int32/text = make-sqlite-text() //TODO(zephyr): waiting on a proper bytes type in koka // pub extern column-blob(^stmt: any, col: int32): maybe diff --git a/sqlite/sqlite3.kk b/sqlite/sqlite3.kk index 50e9645..81429f3 100644 --- a/sqlite/sqlite3.kk +++ b/sqlite/sqlite3.kk @@ -1,7 +1,7 @@ // Low level wrapper around a modern subset of the SQLite3 API. // // Using this module involves manual resource management. -// +// Statements must be finalized and databases must be closed. module sqlite/sqlite3 import sqlite/capi @@ -143,10 +143,10 @@ pub type sqlite3-type // The leftmost column is numbered 0. pub fun statment/column-type(stmt: statement, col: int): sqlite3-type val t = capi/column-type(stmt.cref, col.int32) - if t == int32/integer() then Integer - else if t == int32/float() then Float - else if t == int32/blob() then Blob - else if t == int32/text() then Text + if t == capi/int32/integer then Integer + else if t == capi/int32/float then Float + else if t == capi/int32/blob then Blob + else if t == capi/int32/text then Text // If the DB gives us something unimaginable, pretend it's nothing. else Null