Skip to content

Commit

Permalink
save progress --
Browse files Browse the repository at this point in the history
This is a massive commit since it seems impossible to incrementally convert TableInfo.
  • Loading branch information
tantaman committed Sep 14, 2023
1 parent 5d19dd9 commit 1819007
Show file tree
Hide file tree
Showing 23 changed files with 209 additions and 1,267 deletions.
2 changes: 0 additions & 2 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,11 @@ TARGET_TEST_ASAN=$(prefix)/test-asan
# js/browser/wa-sqlite/Makefile, deps/sqlite/GNUMakefile, core/binding.gyp, core/Makefile
ext_files=src/crsqlite.c \
src/util.c \
src/tableinfo.c \
src/changes-vtab.c \
src/ext-data.c \
src/get-table.c
ext_headers=src/crsqlite.h \
src/util.h \
src/tableinfo.h \
src/changes-vtab.h \
src/ext-data.h

Expand Down
24 changes: 7 additions & 17 deletions core/rs/core/src/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use core::ffi::{c_char, c_int, CStr};
use core::{
ffi::{c_char, c_int, CStr},
mem::{self, ManuallyDrop},
};

use crate::{c::crsql_TableInfo, consts};
use crate::{consts, tableinfo::TableInfo};
use alloc::{ffi::CString, format};
use core::slice;
use sqlite::{sqlite3, Connection, Destructor, ResultCode};
Expand Down Expand Up @@ -192,25 +195,12 @@ fn maybe_update_db_inner(
*
* @param tableInfo
*/
#[no_mangle]
pub extern "C" fn crsql_create_clock_table(
db: *mut sqlite3,
table_info: *mut crsql_TableInfo,
err: *mut *mut c_char,
) -> c_int {
match create_clock_table(db, table_info, err) {
Ok(_) => ResultCode::OK as c_int,
Err(code) => code as c_int,
}
}

pub fn create_clock_table(
db: *mut sqlite3,
table_info: *mut crsql_TableInfo,
table_info: &TableInfo,
_err: *mut *mut c_char,
) -> Result<ResultCode, ResultCode> {
let columns = sqlite::args!((*table_info).pksLen, (*table_info).pks);
let pk_list = crate::util::as_identifier_list(columns, None)?;
let pk_list = crate::util::as_identifier_list(&table_info.pks, None)?;
let table_name = unsafe { CStr::from_ptr((*table_info).tblName).to_str() }?;

db.exec_safe(&format!(
Expand Down
Loading

0 comments on commit 1819007

Please sign in to comment.