Skip to content

[WIP]Add support for NODEFS #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add nodefs to makefile
  • Loading branch information
Boyi committed Mar 1, 2021
commit 0a783474bcfe1bb01defc5627688c30147f7631d
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ EMFLAGS = \
-s EXTRA_EXPORTED_RUNTIME_METHODS=@src/exported_runtime_methods.json \
-s SINGLE_FILE=0 \
-s NODEJS_CATCH_EXIT=0 \
-s NODEJS_CATCH_REJECTION=0
-s NODEJS_CATCH_REJECTION=0 \
-l nodefs.js

EMFLAGS_ASM = \
-s WASM=0
Expand Down
18 changes: 18 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,24 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
this.functions = {};
}

/** Create database instance
@param {string} fn filename for database file
@return {Database} the created database instance
*/
Database.open = function(fn) {
var obj = Object.create(Database.prototype);
obj.filename = fn;
obj.handleError(sqlite3_open(obj.filename, apiTemp));
obj.db = getValue(apiTemp, "i32");
registerExtensionFunctions(obj.db);
// A list of all prepared statements of the database
obj.statements = {};
// A list of all user function of the database
// (created by create_function call)
obj.functions = {};
return obj;
}

/** Execute an SQL query, ignoring the rows it returns.
@param {string} sql a string containing some SQL text to execute
@param {Statement.BindParams} [params] When the SQL statement contains
Expand Down
2 changes: 2 additions & 0 deletions src/exported_runtime_methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"stackAlloc",
"stackSave",
"stackRestore",
"FS",
"NODEFS",
"UTF8ToString"
]