Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a20a45

Browse files
author
Christopher J. Brody
committed
add custom_extensions function in a new module
for custom (non-standard) SQLite3 extension functions that may beadded in the futurewith some additional explanatory comments added to the CoffeeScript
1 parent091395f commit6a20a45

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

‎Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ EMFLAGS_DEBUG = \
5858
-s ASSERTIONS=1\
5959
-O1
6060

61-
BITCODE_FILES = out/sqlite3.bc out/extension-functions.bc
61+
BITCODE_FILES = out/sqlite3.bc out/extension-functions.bc out/custom_extensions.bc
6262

6363
OUTPUT_WRAPPER_FILES = src/shell-pre.js src/shell-post.js
6464

@@ -160,6 +160,10 @@ out/extension-functions.bc: sqlite-src/$(SQLITE_AMALGAMATION)/$(EXTENSION_FUNCTI
160160
mkdir -p out
161161
$(EMCC)$(CFLAGS) -s LINKABLE=1 sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o$@
162162

163+
out/custom_extensions.bc: src/custom_extensions/custom_extensions.c
164+
mkdir -p out
165+
$(EMCC)$(CFLAGS) -Isqlite-src/$(SQLITE_AMALGAMATION) -s LINKABLE=1$^ -o$@
166+
163167
# TODO: This target appears to be unused. If we re-instatate it, we'll need to add more files inside of the JS folder
164168
# module.tar.gz: test package.json AUTHORS README.md dist/sql-asm.js
165169
# tar --create --gzip $^ > $@

‎src/api.coffee‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,13 @@ class Database
240240
constructor: (data)->
241241
@filename='dbfile_'+ (0xffffffff*Math.random()>>>0)
242242
if data?thenFS.createDataFile'/',@filename, data,true,true
243+
# open the database and register extension functions
243244
@handleErrorsqlite3_open@filename, apiTemp
244245
@db=getValue(apiTemp,'i32')
246+
# register built-in extension functions:
245247
RegisterExtensionFunctions(@db)
248+
# register any custom (non-standard) extension functions:
249+
custom_extensions(@db)
246250
@statements= {}# A list of all prepared statements of the database
247251
@functions= {}# A list of all user function of the database (created by create_function call)
248252

@@ -404,6 +408,8 @@ class Database
404408
@functions={}
405409
@handleErrorsqlite3_close_v2@db
406410
binaryDb=FS.readFile@filename,encoding:'binary'
411+
# just open the database
412+
# (no need to register extension functions)
407413
@handleErrorsqlite3_open@filename, apiTemp
408414
@db=getValue apiTemp,'i32'
409415
binaryDb
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include"sqlite3.h"
2+
3+
/** FUTURE TBD Build this module with any custom extension module(s) included */
4+
5+
intcustom_extensions(sqlite3*db)
6+
{
7+
returnSQLITE_OK;
8+
}

‎src/exported_functions.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"_sqlite3_result_int",
3939
"_sqlite3_result_int64",
4040
"_sqlite3_result_error",
41+
"_custom_extensions",
4142
"_RegisterExtensionFunctions"
4243
]

‎src/exports.coffee‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ sqlite3_result_int64 = Module['cwrap'] 'sqlite3_result_int64', '', ['number', 'n
5959
sqlite3_result_error= Module['cwrap']'sqlite3_result_error','', ['number','string','number']
6060
RegisterExtensionFunctions= Module['cwrap']'RegisterExtensionFunctions','number', ['number']
6161

62+
## Support custom db extensions
63+
custom_extensions= Module['cwrap']'custom_extensions','number', ['number']
64+
6265
# Export the API
6366
this['SQL']= {'Database':Database}
6467
Module[i]=this['SQL'][i]for iofthis['SQL']

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp