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

[RFC] support build with custom (non-standard) functions#320

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
brody4hire wants to merge1 commit intosql-js:master
base:master
Choose a base branch
Loading
frombrody4hire:custom-functions
Draft
Show file tree
Hide file tree
Changes fromall commits
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
6 changes: 5 additions & 1 deletionMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,7 @@ EMFLAGS_DEBUG = \
-s ASSERTIONS=1 \
-O1

BITCODE_FILES = out/sqlite3.bc out/extension-functions.bc
BITCODE_FILES = out/sqlite3.bc out/extension-functions.bc out/custom_extensions.bc

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

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

out/custom_extensions.bc: src/custom_extensions/custom_extensions.c
mkdir -p out
$(EMCC) $(CFLAGS) -Isqlite-src/$(SQLITE_AMALGAMATION) -s LINKABLE=1 $^ -o $@

# TODO: This target appears to be unused. If we re-instatate it, we'll need to add more files inside of the JS folder
# module.tar.gz: test package.json AUTHORS README.md dist/sql-asm.js
# tar --create --gzip $^ > $@
Expand Down
6 changes: 6 additions & 0 deletionssrc/api.coffee
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -240,9 +240,13 @@ class Database
constructor: (data) ->
@filename = 'dbfile_' + (0xffffffff*Math.random()>>>0)
if data? then FS.createDataFile '/', @filename, data, true, true
# open the database and register extension functions
@handleError sqlite3_open @filename, apiTemp
@db = getValue(apiTemp, 'i32')
# register built-in extension functions:
RegisterExtensionFunctions(@db)
# register any custom (non-standard) extension functions:
custom_extensions(@db)
@statements = {} # A list of all prepared statements of the database
@functions = {} # A list of all user function of the database (created by create_function call)

Expand DownExpand Up@@ -404,6 +408,8 @@ class Database
@functions={}
@handleError sqlite3_close_v2 @db
binaryDb = FS.readFile @filename, encoding:'binary'
# just open the database
# (no need to register extension functions)
@handleError sqlite3_open @filename, apiTemp
@db = getValue apiTemp, 'i32'
binaryDb
Expand Down
8 changes: 8 additions & 0 deletionssrc/custom_extensions/custom_extensions.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
#include "sqlite3.h"

/** FUTURE TBD Build this module with any custom extension module(s) included */

int custom_extensions(sqlite3 * db)
{
return SQLITE_OK;
}
1 change: 1 addition & 0 deletionssrc/exported_functions.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,5 +38,6 @@
"_sqlite3_result_int",
"_sqlite3_result_int64",
"_sqlite3_result_error",
"_custom_extensions",
"_RegisterExtensionFunctions"
]
3 changes: 3 additions & 0 deletionssrc/exports.coffee
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,6 +59,9 @@ sqlite3_result_int64 = Module['cwrap'] 'sqlite3_result_int64', '', ['number', 'n
sqlite3_result_error = Module['cwrap'] 'sqlite3_result_error', '', ['number', 'string', 'number']
RegisterExtensionFunctions = Module['cwrap'] 'RegisterExtensionFunctions', 'number', ['number']

## Support custom db extensions
custom_extensions = Module['cwrap'] 'custom_extensions', 'number', ['number']

# Export the API
this['SQL'] = {'Database':Database}
Module[i] = this['SQL'][i] for i of this['SQL']

[8]ページ先頭

©2009-2025 Movatter.jp