Improve api, standardize conversions between types, finish extension

This commit is contained in:
PThorpe92 2025-01-12 16:35:56 -05:00
parent 6e05258d36
commit 3099e5c9ba
No known key found for this signature in database
GPG key ID: 66DB3FBACBDD05CC
5 changed files with 92 additions and 40 deletions

View file

@ -1,8 +1,6 @@
use crate::{function::ExternalFunc, Database};
pub use limbo_extension::{
Blob as ExtBlob, TextValue as ExtTextValue, Value as ExtValue, ValueType as ExtValueType,
};
use limbo_extension::{ExtensionApi, ResultCode, ScalarFunction, RESULT_ERROR, RESULT_OK};
pub use limbo_extension::{Value as ExtValue, ValueType as ExtValueType};
use std::{
ffi::{c_char, c_void, CStr},
rc::Rc,
@ -18,6 +16,9 @@ extern "C" fn register_scalar_function(
Ok(s) => s.to_string(),
Err(_) => return RESULT_ERROR,
};
if ctx.is_null() {
return RESULT_ERROR;
}
let db = unsafe { &*(ctx as *const Database) };
db.register_scalar_function_impl(name_str, func)
}