Compare commits
No commits in common. "849dbff420b71ab0780eda93ca15b49384d106eb" and "dad8d46e9bdad6e7451db32aba9ba42bca7ee778" have entirely different histories.
849dbff420
...
dad8d46e9b
|
@ -23,11 +23,11 @@ static Napi::Object RowIterator(const Napi::CallbackInfo& args) {
|
||||||
free(next);
|
free(next);
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
auto cleanup = [=](const Napi::CallbackInfo& a){
|
auto free_iter = [=](const Napi::CallbackInfo& a){
|
||||||
FreeIter(iter);
|
FreeIter(iter);
|
||||||
};
|
};
|
||||||
it.Set("next", Napi::Function::New(env, next_row));
|
it.Set("next", Napi::Function::New(env, next_row));
|
||||||
it.Set("cleanup", Napi::Function::New(env, cleanup));
|
it.Set("free", Napi::Function::New(env, free_iter));
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
binding/makefile
Normal file
5
binding/makefile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
build-lib:
|
||||||
|
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o ../lib/libdal-arm64.dylib -buildmode=c-shared ./dal.go
|
||||||
|
for arch in amd64 arm64; do\
|
||||||
|
CC=x86_64-unknown-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=$${arch} go build -o ../lib/libdal-$${arch}.so -buildmode=c-shared ./dal.go;\
|
||||||
|
done
|
|
@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
type RowIterator = {
|
type RowIterator = {
|
||||||
next: () => Buffer;
|
next: () => Buffer;
|
||||||
cleanup: () => void;
|
free: () => void;
|
||||||
};
|
};
|
||||||
type SQLite = {
|
type SQLite = {
|
||||||
initSQLite: (pragmas: Buffer) => void;
|
initSQLite: (pragmas: Buffer) => void;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import { dlopen, FFIType, suffix, ptr, toBuffer } from "bun:ffi";
|
import { dlopen, FFIType, suffix, ptr, toBuffer } from "bun:ffi";
|
||||||
|
|
||||||
const libname = `../clib/clib.${suffix}`;
|
const libname = `lib/clib.${suffix}`;
|
||||||
const libpath = libname;
|
const libpath = libname;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -35,8 +35,9 @@ const {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function initSQLite(pragmas: Buffer) {
|
function initSQLite(pragmas: string) {
|
||||||
InitSQLite(ptr(pragmas));
|
const buf = Buffer.from(pragmas);
|
||||||
|
InitSQLite(ptr(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowIterator(buf: Buffer) {
|
function rowIterator(buf: Buffer) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default class CBuilder<
|
||||||
const response = iter.next();
|
const response = iter.next();
|
||||||
const rows = decodeRows(response);
|
const rows = decodeRows(response);
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
iter.cleanup();
|
iter.free();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"fmt": "prettier --write .",
|
"fmt": "prettier --write .",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"prepublish": "tsc",
|
"prepublish": "tsc",
|
||||||
"preinstall": "cd binding && go build -buildmode=c-archive -o dal.a ./dal.go && cd ../clib && go build -o ./clib.dylib -buildmode=c-shared ./main.go",
|
"preinstall": "cd binding && go build -buildmode=c-archive -o dal.a ./dal.go",
|
||||||
"postinstall": "node-gyp configure build"
|
"postinstall": "node-gyp configure build"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue