Minor internal JS code/docs cleanups.

FossilOrigin-Name: 21331bdd36a91b07a687ffadce392dcf2ccd0fd824b35d9dd027d4289a40fc96
This commit is contained in:
stephan 2022-12-06 08:21:23 +00:00
parent f2bbef3951
commit b849832a79
6 changed files with 43 additions and 30 deletions

View File

@ -31,9 +31,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
heap: 0 ? wasm.memory : wasm.heap8u,
alloc: wasm.alloc,
dealloc: wasm.dealloc,
functionTable: wasm.functionTable,
bigIntEnabled: wasm.bigIntEnabled,
memberPrefix: '$'
memberPrefix: /* Never change this: this prefix is baked into any
amount of code and client-facing docs. */ '$'
});
delete self.Jaccwabyt;

View File

@ -943,10 +943,19 @@ self.WhWasmUtilInstaller = function(target){
const __allocCStr = function(jstr, returnWithLength, allocator, funcName){
__affirmAlloc(target, funcName);
if('string'!==typeof jstr) return null;
const n = target.jstrlen(jstr),
ptr = allocator(n+1);
target.jstrcpy(jstr, target.heap8u(), ptr, n+1, true);
return returnWithLength ? [ptr, n] : ptr;
if(0){/* older impl, possibly more widely compatible? */
const n = target.jstrlen(jstr),
ptr = allocator(n+1);
target.jstrcpy(jstr, target.heap8u(), ptr, n+1, true);
return returnWithLength ? [ptr, n] : ptr;
}else{/* newer, (probably) faster and (certainly) simpler impl */
const u = cache.utf8Encoder.encode(jstr),
ptr = allocator(u.length+1),
heap = heapWrappers().HEAP8U;
heap.set(u, ptr);
heap[ptr + u.length] = 0;
return returnWithLength ? [ptr, u.length] : ptr;
}
};
/**

View File

@ -61,7 +61,6 @@ self.Jaccwabyt = function StructBinderFactory(config){
BigInt = self['BigInt'],
BigInt64Array = self['BigInt64Array'],
/* Undocumented (on purpose) config options: */
functionTable = config.functionTable/*EXPERIMENTAL, undocumented*/,
ptrSizeof = config.ptrSizeof || 4,
ptrIR = config.ptrIR || 'i32'
;
@ -258,7 +257,7 @@ self.Jaccwabyt = function StructBinderFactory(config){
iterable: false, value: v}};
/** Allocates obj's memory buffer based on the size defined in
DEF.sizeof. */
ctor.structInfo.sizeof. */
const __allocStruct = function(ctor, obj, m){
let fill = !m;
if(m) Object.defineProperty(obj, xPtrPropName, rop(m));
@ -295,7 +294,7 @@ self.Jaccwabyt = function StructBinderFactory(config){
if tossIfNotFound is true, else returns undefined if not
found. The given name may be either the name of the
structInfo.members key (faster) or the key as modified by the
memberPrefix/memberSuffix settings.
memberPrefix and memberSuffix settings.
*/
const __lookupMember = function(structInfo, memberName, tossIfNotFound=true){
let m = structInfo.members[memberName];
@ -423,8 +422,9 @@ self.Jaccwabyt = function StructBinderFactory(config){
const mem = alloc(u.length+1);
if(!mem) toss("Allocation error while duplicating string:",str);
const h = heap();
let i = 0;
for( ; i < u.length; ++i ) h[mem + i] = u[i];
//let i = 0;
//for( ; i < u.length; ++i ) h[mem + i] = u[i];
h.set(u, mem);
h[mem + u.length] = 0;
//log("allocCString @",mem," =",u);
return mem;
@ -436,6 +436,10 @@ self.Jaccwabyt = function StructBinderFactory(config){
to free any prior memory, if appropriate. The newly-allocated
string is added to obj.ondispose so will be freed when the object
is disposed.
The given name may be either the name of the structInfo.members
key (faster) or the key as modified by the memberPrefix and
memberSuffix settings.
*/
const __setMemberCString = function(obj, memberName, str){
const m = __lookupMember(obj.structInfo, memberName, true);

View File

@ -205,7 +205,6 @@ simply look like:
The StructBinder factory function returns a function which can then be
used to create bindings for our structs.
<a name='step-2'></a>
Step 2: Create a Struct Description
------------------------------------------------------------
@ -606,14 +605,15 @@ legally be called on concrete struct instances unless noted otherwise:
- If it is a function, it is called with the struct object as its `this`.
That method must not throw - if it does, the exception will be
ignored.
- If it is an array, it may contain functions, pointers, and/or JS
strings. If an entry is a function, it is called as described
above. If it's a number, it's assumed to be a pointer and is
passed to the `dealloc()` function configured for the parent
[StructBinder][]. If it's a JS string, it's assumed to be a
helpful description of the next entry in the list and is simply
ignored. Strings are supported primarily for use as debugging
information.
- If it is an array, it may contain functions, pointers, other
[StructType] instances, and/or JS strings. If an entry is a
function, it is called as described above. If it's a number, it's
assumed to be a pointer and is passed to the `dealloc()` function
configured for the parent [StructBinder][]. If it's a
[StructType][] instance then its `dispose()` method is called. If
it's a JS string, it's assumed to be a helpful description of the
next entry in the list and is simply ignored. Strings are
supported primarily for use as debugging information.
- Some struct APIs will manipulate the `ondispose` member, creating
it as an array or converting it from a function to array as
needed.

View File

@ -1,5 +1,5 @@
C Merge\strunk\sinto\swasm-vtab\sbranch.
D 2022-12-06T06:21:02.190
C Minor\sinternal\sJS\scode/docs\scleanups.
D 2022-12-06T08:21:23.652
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -503,7 +503,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f9e91c1d5f
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
F ext/wasm/api/sqlite3-api-glue.js c3a11e1d0e6fd381f68f9e76ad01f3616a6b809fbf9f5aa8e323955c128a6811
F ext/wasm/api/sqlite3-api-glue.js 057c9ed555ee68ee795dc61e8d923862a0ddeb3d4cbad89866515cf5a1b77343
F ext/wasm/api/sqlite3-api-oo1.js b970787aaf0bdd3a3df59cf66aeb84d0decaaa0529aed7eaf45121087181245f
F ext/wasm/api/sqlite3-api-prologue.js 31cffd8ce212fad8d316a08decd864b0f614c5fce3686153707dffe40f8279e8
F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f
@ -521,7 +521,7 @@ F ext/wasm/c-pp.c 92285f7bce67ed7b7020b40fde8ed0982c442b63dc33df9dfd4b658d4a6c07
F ext/wasm/common/SqliteTestUtil.js d8bf97ecb0705a2299765c8fc9e11b1a5ac7f10988bbf375a6558b7ca287067b
F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
F ext/wasm/common/testing.css 0ff15602a3ab2bad8aef2c3bd120c7ee3fd1c2054ad2ace7e214187ae68d926f
F ext/wasm/common/whwasmutil.js 0de1e72494d52185d518892a3ac95d38b8e295d3699b64ddb36a3d46c11c8346
F ext/wasm/common/whwasmutil.js cedbdb2162db129fd95951025572e087066d5457adc27ffd8083610a26306fc9
F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
F ext/wasm/demo-123.js ebae30756585bca655b4ab2553ec9236a87c23ad24fc8652115dcedb06d28df6
@ -539,8 +539,8 @@ F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5
F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2
F ext/wasm/index-dist.html c806b6005145b71d64240606e9c6e0bf56878ee8829c66fe7486cebf34b0e6b1
F ext/wasm/index.html f151b7c7b5cfdc066567d556acd168e769efd4e982286dc5f849a5ee69ecd0ff
F ext/wasm/jaccwabyt/jaccwabyt.js f4fc93375e9c40ef60f56cbecca1b4dc8bf4f53fab2c3abc860ed34890c5d32d
F ext/wasm/jaccwabyt/jaccwabyt.md 4bf62f7519857cdd674594aba7436cc4fae177eefbfaabc00740e16d9a828bee
F ext/wasm/jaccwabyt/jaccwabyt.js 35c7eaa61ba4b875cd49da5a06a35d9935fd19121de65dd5f467cbe376359782
F ext/wasm/jaccwabyt/jaccwabyt.md 888aff20e486abb6c955d432f9a3af271e2cdd2cd99a92c6f87077116ca57091
F ext/wasm/module-symbols.html 980680c8acfa3c8ae6a5aa223512d1b8e78040ced20f8ba2c382129bc73ec028
F ext/wasm/scratchpad-wasmfs-main.html 20cf6f1a8f368e70d01e8c17200e3eaa90f1c8e1029186d836d14b83845fbe06
F ext/wasm/scratchpad-wasmfs-main.js 4c140457f4d6da9d646a49addd91edb6e9ad1643c6c48e3258b5bce24725dc18
@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P f902f3b2c79d6c699ead1efeb1426e1e0f4ac709afdff88be1de62f34f3d5ccc f41f18b1c3c950565ee3c237aebb51cfc3241813c6425813a8217e07aa0153a6
R 8bcaf9d3b9f238bc8e19a8bbe1bb65e6
P d106edb956bbe22bddc2c6e5bcdf4fb8f797794c725c2e359e3fa4b31d881843
R 9cc98a74b7c97dbae209498a8d29cfcb
U stephan
Z 78f5f82441cc43a02424eee016e46cb3
Z 5e0b6a6419517a5a90c958328ab9c938
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
d106edb956bbe22bddc2c6e5bcdf4fb8f797794c725c2e359e3fa4b31d881843
21331bdd36a91b07a687ffadce392dcf2ccd0fd824b35d9dd027d4289a40fc96