teptris 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/teptris.mjs +1 -1
- package/dist/teptris.wasm +0 -0
- package/package.json +2 -1
- package/src/index.js +39 -1
- package/src/teptris_wasm.c +71 -0
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# teptris (JavaScript/TypeScript)
|
|
2
2
|
|
|
3
|
+
[](https://github.com/leptris/teptris-ts/actions/workflows/ci.yml)
|
|
4
|
+
|
|
3
5
|
**Mission: be the best TOML parser and builder ever made — in C, Ruby,
|
|
4
6
|
Rust, and JS — measured, not claimed.** The bar and the family ledger:
|
|
5
7
|
[BEST-EVER.md](https://github.com/leptris/teptris/blob/main/BEST-EVER.md).
|
package/dist/teptris.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var Module = (() => {
|
|
|
6
6
|
async function(moduleArg = {}) {
|
|
7
7
|
var moduleRtn;
|
|
8
8
|
|
|
9
|
-
var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");let dirname=import.meta.url;if(dirname.startsWith("data:")){dirname="/"}var require=createRequire(dirname)}var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(!import.meta.url.startsWith("data:")){scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");function findWasmBinary(){if(Module["locateFile"]){var f="teptris.wasm";if(!isDataURI(f)){return locateFile(f)}return f}return new URL("teptris.wasm",import.meta.url).href}var wasmBinaryFile;function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["c"];updateMemoryViews();addOnInit(wasmExports["d"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);receiveInstantiationResult(result);return result}catch(e){readyPromiseReject(e);return}}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var noExitRuntime=Module["noExitRuntime"]||true;var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var wasmImports={a:___assert_fail,b:_emscripten_resize_heap};var wasmExports;createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["d"])();var _teptris_wasm_load=Module["_teptris_wasm_load"]=(a0,a1)=>(_teptris_wasm_load=Module["_teptris_wasm_load"]=wasmExports["e"])(a0,a1);var _teptris_wasm_last_error=Module["_teptris_wasm_last_error"]=()=>(_teptris_wasm_last_error=Module["_teptris_wasm_last_error"]=wasmExports["f"])();var _teptris_wasm_last_error_line=Module["_teptris_wasm_last_error_line"]=()=>(_teptris_wasm_last_error_line=Module["_teptris_wasm_last_error_line"]=wasmExports["g"])();var _teptris_wasm_last_error_column=Module["_teptris_wasm_last_error_column"]=()=>(_teptris_wasm_last_error_column=Module["_teptris_wasm_last_error_column"]=wasmExports["h"])();var _teptris_wasm_json=Module["_teptris_wasm_json"]=()=>(_teptris_wasm_json=Module["_teptris_wasm_json"]=wasmExports["i"])();var _teptris_wasm_json_len=Module["_teptris_wasm_json_len"]=()=>(_teptris_wasm_json_len=Module["_teptris_wasm_json_len"]=wasmExports["j"])();var _teptris_wasm_free=Module["_teptris_wasm_free"]=a0=>(_teptris_wasm_free=Module["_teptris_wasm_free"]=wasmExports["k"])(a0);var _teptris_wasm_alloc=Module["_teptris_wasm_alloc"]=a0=>(_teptris_wasm_alloc=Module["_teptris_wasm_alloc"]=wasmExports["l"])(a0);var _teptris_wasm_builder_new=Module["_teptris_wasm_builder_new"]=()=>(_teptris_wasm_builder_new=Module["_teptris_wasm_builder_new"]=wasmExports["m"])();var _teptris_wasm_builder_free=Module["_teptris_wasm_builder_free"]=a0=>(_teptris_wasm_builder_free=Module["_teptris_wasm_builder_free"]=wasmExports["n"])(a0);var _teptris_wasm_builder_put_string=Module["_teptris_wasm_builder_put_string"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_string=Module["_teptris_wasm_builder_put_string"]=wasmExports["o"])(a0,a1,a2);var _teptris_wasm_builder_put_integer=Module["_teptris_wasm_builder_put_integer"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_integer=Module["_teptris_wasm_builder_put_integer"]=wasmExports["p"])(a0,a1,a2);var _teptris_wasm_builder_put_float=Module["_teptris_wasm_builder_put_float"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_float=Module["_teptris_wasm_builder_put_float"]=wasmExports["q"])(a0,a1,a2);var _teptris_wasm_builder_put_boolean=Module["_teptris_wasm_builder_put_boolean"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_boolean=Module["_teptris_wasm_builder_put_boolean"]=wasmExports["r"])(a0,a1,a2);var _teptris_wasm_builder_put_datetime=Module["_teptris_wasm_builder_put_datetime"]=(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)=>(_teptris_wasm_builder_put_datetime=Module["_teptris_wasm_builder_put_datetime"]=wasmExports["s"])(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);var _teptris_wasm_builder_open_table=Module["_teptris_wasm_builder_open_table"]=(a0,a1)=>(_teptris_wasm_builder_open_table=Module["_teptris_wasm_builder_open_table"]=wasmExports["t"])(a0,a1);var _teptris_wasm_builder_open_array=Module["_teptris_wasm_builder_open_array"]=(a0,a1)=>(_teptris_wasm_builder_open_array=Module["_teptris_wasm_builder_open_array"]=wasmExports["u"])(a0,a1);var _teptris_wasm_builder_close=Module["_teptris_wasm_builder_close"]=a0=>(_teptris_wasm_builder_close=Module["_teptris_wasm_builder_close"]=wasmExports["v"])(a0);var _teptris_wasm_dump_ops=Module["_teptris_wasm_dump_ops"]=(a0,a1)=>(_teptris_wasm_dump_ops=Module["_teptris_wasm_dump_ops"]=wasmExports["w"])(a0,a1);var _teptris_wasm_builder_finish=Module["_teptris_wasm_builder_finish"]=a0=>(_teptris_wasm_builder_finish=Module["_teptris_wasm_builder_finish"]=wasmExports["x"])(a0);var _teptris_wasm_builder_finish_json_natural=Module["_teptris_wasm_builder_finish_json_natural"]=a0=>(_teptris_wasm_builder_finish_json_natural=Module["_teptris_wasm_builder_finish_json_natural"]=wasmExports["y"])(a0);var _teptris_wasm_toml=Module["_teptris_wasm_toml"]=()=>(_teptris_wasm_toml=Module["_teptris_wasm_toml"]=wasmExports["z"])();var _teptris_wasm_toml_len=Module["_teptris_wasm_toml_len"]=()=>(_teptris_wasm_toml_len=Module["_teptris_wasm_toml_len"]=wasmExports["A"])();var _teptris_wasm_plan_build=Module["_teptris_wasm_plan_build"]=(a0,a1,a2,a3,a4,a5)=>(_teptris_wasm_plan_build=Module["_teptris_wasm_plan_build"]=wasmExports["B"])(a0,a1,a2,a3,a4,a5);var _teptris_wasm_plan_free=Module["_teptris_wasm_plan_free"]=a0=>(_teptris_wasm_plan_free=Module["_teptris_wasm_plan_free"]=wasmExports["C"])(a0);var _teptris_wasm_poke_u32=Module["_teptris_wasm_poke_u32"]=(a0,a1,a2)=>(_teptris_wasm_poke_u32=Module["_teptris_wasm_poke_u32"]=wasmExports["D"])(a0,a1,a2);var _teptris_wasm_poke_u8=Module["_teptris_wasm_poke_u8"]=(a0,a1,a2)=>(_teptris_wasm_poke_u8=Module["_teptris_wasm_poke_u8"]=wasmExports["E"])(a0,a1,a2);var _teptris_wasm_plan_walk=Module["_teptris_wasm_plan_walk"]=(a0,a1,a2)=>(_teptris_wasm_plan_walk=Module["_teptris_wasm_plan_walk"]=wasmExports["F"])(a0,a1,a2);var _teptris_version_string=Module["_teptris_version_string"]=()=>(_teptris_version_string=Module["_teptris_version_string"]=wasmExports["H"])();Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise;
|
|
9
|
+
var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");let dirname=import.meta.url;if(dirname.startsWith("data:")){dirname="/"}var require=createRequire(dirname)}var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(!import.meta.url.startsWith("data:")){scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");function findWasmBinary(){if(Module["locateFile"]){var f="teptris.wasm";if(!isDataURI(f)){return locateFile(f)}return f}return new URL("teptris.wasm",import.meta.url).href}var wasmBinaryFile;function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){return{a:wasmImports}}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["c"];updateMemoryViews();addOnInit(wasmExports["d"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}wasmBinaryFile??=findWasmBinary();try{var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);receiveInstantiationResult(result);return result}catch(e){readyPromiseReject(e);return}}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var noExitRuntime=Module["noExitRuntime"]||true;var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var wasmImports={a:___assert_fail,b:_emscripten_resize_heap};var wasmExports;createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["d"])();var _teptris_wasm_load=Module["_teptris_wasm_load"]=(a0,a1)=>(_teptris_wasm_load=Module["_teptris_wasm_load"]=wasmExports["e"])(a0,a1);var _teptris_wasm_last_error=Module["_teptris_wasm_last_error"]=()=>(_teptris_wasm_last_error=Module["_teptris_wasm_last_error"]=wasmExports["f"])();var _teptris_wasm_last_error_line=Module["_teptris_wasm_last_error_line"]=()=>(_teptris_wasm_last_error_line=Module["_teptris_wasm_last_error_line"]=wasmExports["g"])();var _teptris_wasm_last_error_column=Module["_teptris_wasm_last_error_column"]=()=>(_teptris_wasm_last_error_column=Module["_teptris_wasm_last_error_column"]=wasmExports["h"])();var _teptris_wasm_json=Module["_teptris_wasm_json"]=()=>(_teptris_wasm_json=Module["_teptris_wasm_json"]=wasmExports["i"])();var _teptris_wasm_json_len=Module["_teptris_wasm_json_len"]=()=>(_teptris_wasm_json_len=Module["_teptris_wasm_json_len"]=wasmExports["j"])();var _teptris_wasm_free=Module["_teptris_wasm_free"]=a0=>(_teptris_wasm_free=Module["_teptris_wasm_free"]=wasmExports["k"])(a0);var _teptris_wasm_alloc=Module["_teptris_wasm_alloc"]=a0=>(_teptris_wasm_alloc=Module["_teptris_wasm_alloc"]=wasmExports["l"])(a0);var _teptris_wasm_builder_new=Module["_teptris_wasm_builder_new"]=()=>(_teptris_wasm_builder_new=Module["_teptris_wasm_builder_new"]=wasmExports["m"])();var _teptris_wasm_builder_free=Module["_teptris_wasm_builder_free"]=a0=>(_teptris_wasm_builder_free=Module["_teptris_wasm_builder_free"]=wasmExports["n"])(a0);var _teptris_wasm_builder_put_string=Module["_teptris_wasm_builder_put_string"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_string=Module["_teptris_wasm_builder_put_string"]=wasmExports["o"])(a0,a1,a2);var _teptris_wasm_builder_put_integer=Module["_teptris_wasm_builder_put_integer"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_integer=Module["_teptris_wasm_builder_put_integer"]=wasmExports["p"])(a0,a1,a2);var _teptris_wasm_builder_put_float=Module["_teptris_wasm_builder_put_float"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_float=Module["_teptris_wasm_builder_put_float"]=wasmExports["q"])(a0,a1,a2);var _teptris_wasm_builder_put_boolean=Module["_teptris_wasm_builder_put_boolean"]=(a0,a1,a2)=>(_teptris_wasm_builder_put_boolean=Module["_teptris_wasm_builder_put_boolean"]=wasmExports["r"])(a0,a1,a2);var _teptris_wasm_builder_put_datetime=Module["_teptris_wasm_builder_put_datetime"]=(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)=>(_teptris_wasm_builder_put_datetime=Module["_teptris_wasm_builder_put_datetime"]=wasmExports["s"])(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);var _teptris_wasm_builder_open_table=Module["_teptris_wasm_builder_open_table"]=(a0,a1)=>(_teptris_wasm_builder_open_table=Module["_teptris_wasm_builder_open_table"]=wasmExports["t"])(a0,a1);var _teptris_wasm_builder_open_array=Module["_teptris_wasm_builder_open_array"]=(a0,a1)=>(_teptris_wasm_builder_open_array=Module["_teptris_wasm_builder_open_array"]=wasmExports["u"])(a0,a1);var _teptris_wasm_builder_close=Module["_teptris_wasm_builder_close"]=a0=>(_teptris_wasm_builder_close=Module["_teptris_wasm_builder_close"]=wasmExports["v"])(a0);var _teptris_wasm_load_doc=Module["_teptris_wasm_load_doc"]=(a0,a1)=>(_teptris_wasm_load_doc=Module["_teptris_wasm_load_doc"]=wasmExports["w"])(a0,a1);var _teptris_wasm_dump_doc=Module["_teptris_wasm_dump_doc"]=()=>(_teptris_wasm_dump_doc=Module["_teptris_wasm_dump_doc"]=wasmExports["x"])();var _teptris_wasm_dump_ops=Module["_teptris_wasm_dump_ops"]=(a0,a1)=>(_teptris_wasm_dump_ops=Module["_teptris_wasm_dump_ops"]=wasmExports["y"])(a0,a1);var _teptris_wasm_builder_finish=Module["_teptris_wasm_builder_finish"]=a0=>(_teptris_wasm_builder_finish=Module["_teptris_wasm_builder_finish"]=wasmExports["z"])(a0);var _teptris_wasm_builder_finish_json_natural=Module["_teptris_wasm_builder_finish_json_natural"]=a0=>(_teptris_wasm_builder_finish_json_natural=Module["_teptris_wasm_builder_finish_json_natural"]=wasmExports["A"])(a0);var _teptris_wasm_toml=Module["_teptris_wasm_toml"]=()=>(_teptris_wasm_toml=Module["_teptris_wasm_toml"]=wasmExports["B"])();var _teptris_wasm_toml_len=Module["_teptris_wasm_toml_len"]=()=>(_teptris_wasm_toml_len=Module["_teptris_wasm_toml_len"]=wasmExports["C"])();var _teptris_wasm_plan_build=Module["_teptris_wasm_plan_build"]=(a0,a1,a2,a3,a4,a5)=>(_teptris_wasm_plan_build=Module["_teptris_wasm_plan_build"]=wasmExports["D"])(a0,a1,a2,a3,a4,a5);var _teptris_wasm_plan_free=Module["_teptris_wasm_plan_free"]=a0=>(_teptris_wasm_plan_free=Module["_teptris_wasm_plan_free"]=wasmExports["E"])(a0);var _teptris_wasm_poke_u32=Module["_teptris_wasm_poke_u32"]=(a0,a1,a2)=>(_teptris_wasm_poke_u32=Module["_teptris_wasm_poke_u32"]=wasmExports["F"])(a0,a1,a2);var _teptris_wasm_poke_u8=Module["_teptris_wasm_poke_u8"]=(a0,a1,a2)=>(_teptris_wasm_poke_u8=Module["_teptris_wasm_poke_u8"]=wasmExports["G"])(a0,a1,a2);var _teptris_wasm_plan_walk=Module["_teptris_wasm_plan_walk"]=(a0,a1,a2)=>(_teptris_wasm_plan_walk=Module["_teptris_wasm_plan_walk"]=wasmExports["H"])(a0,a1,a2);var _teptris_version_string=Module["_teptris_version_string"]=()=>(_teptris_version_string=Module["_teptris_version_string"]=wasmExports["J"])();Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
return moduleRtn;
|
package/dist/teptris.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teptris",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "TOML for JavaScript/TypeScript at libteptris speed (WebAssembly, no fallback) - version tracks the engine ({engine}.{iteration}; npm semver is 3-part)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"types": "src/index.d.ts",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@iarna/toml": "^2.2.5",
|
|
32
|
+
"@ltd/j-toml": "^1.38.0",
|
|
32
33
|
"smol-toml": "^1.9.1"
|
|
33
34
|
}
|
|
34
35
|
}
|
package/src/index.js
CHANGED
|
@@ -343,6 +343,44 @@ export function initApi(mod) {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
// native-doc API: the retained document. loadsDoc parses and HOLDS
|
|
347
|
+
// the engine document in the module (a later loadsDoc replaces it -
|
|
348
|
+
// single slot); dumpDoc emits it with the C emitter. The roundtrip
|
|
349
|
+
// dumpDoc(loadsDoc(s)) runs at C speed, no JS objects materialized.
|
|
350
|
+
let docHeld = false;
|
|
351
|
+
function loadsDoc(toml) {
|
|
352
|
+
if (typeof toml !== "string") {
|
|
353
|
+
throw new TypeError("loadsDoc expects a string");
|
|
354
|
+
}
|
|
355
|
+
const ptr = cstr(mod, toml);
|
|
356
|
+
const st = mod._teptris_wasm_load_doc(ptr, lengthBytesUTF8(toml));
|
|
357
|
+
freeCstr(mod, ptr);
|
|
358
|
+
if (st !== 0) {
|
|
359
|
+
docHeld = false;
|
|
360
|
+
const e = new Error(
|
|
361
|
+
`${UTF8ToString(mod._teptris_wasm_last_error())} (line ` +
|
|
362
|
+
`${mod._teptris_wasm_last_error_line()}, column ` +
|
|
363
|
+
`${mod._teptris_wasm_last_error_column()})`);
|
|
364
|
+
e.line = mod._teptris_wasm_last_error_line();
|
|
365
|
+
e.column = mod._teptris_wasm_last_error_column();
|
|
366
|
+
throw e;
|
|
367
|
+
}
|
|
368
|
+
docHeld = true;
|
|
369
|
+
return { toString() { return "[teptris doc]"; } };
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function dumpDoc(doc) {
|
|
373
|
+
if (!docHeld || doc == null || typeof doc !== "object") {
|
|
374
|
+
throw new Error("dumpDoc expects the document from loadsDoc " +
|
|
375
|
+
"(a later loadsDoc replaces it - single slot)");
|
|
376
|
+
}
|
|
377
|
+
const st = mod._teptris_wasm_dump_doc();
|
|
378
|
+
if (st !== 0) {
|
|
379
|
+
throw new Error(UTF8ToString(mod._teptris_wasm_last_error()));
|
|
380
|
+
}
|
|
381
|
+
return readOut(mod._teptris_wasm_toml());
|
|
382
|
+
}
|
|
383
|
+
|
|
346
384
|
function engineVersion() {
|
|
347
385
|
return UTF8ToString(mod._teptris_version_string());
|
|
348
386
|
}
|
|
@@ -469,7 +507,7 @@ export function initApi(mod) {
|
|
|
469
507
|
mod._teptris_wasm_plan_free(plan);
|
|
470
508
|
}
|
|
471
509
|
|
|
472
|
-
return { loads, dump, dumpJson, planBuild, planWalk, planFree, engineVersion };
|
|
510
|
+
return { loads, dump, dumpJson, planBuild, planWalk, planFree, loadsDoc, dumpDoc, engineVersion };
|
|
473
511
|
}
|
|
474
512
|
|
|
475
513
|
// The consumer entry: instantiate the engine once, get the API.
|
package/src/teptris_wasm.c
CHANGED
|
@@ -134,6 +134,77 @@ int teptris_wasm_builder_close(void *b) {
|
|
|
134
134
|
static char *g_toml;
|
|
135
135
|
static size_t g_toml_len;
|
|
136
136
|
|
|
137
|
+
/* native-doc API: the retained DOM. loads_doc parses and HOLDS the
|
|
138
|
+
* engine document in a single slot (a later load replaces and frees
|
|
139
|
+
* it); dump_doc emits it with the C emitter. The roundtrip
|
|
140
|
+
* dumpDoc(loadsDoc(s)) runs at C speed - no JS objects materialized.
|
|
141
|
+
* Single-threaded, single-slot by contract. */
|
|
142
|
+
static teptris_document *g_doc;
|
|
143
|
+
/* the doc's keys/values are VIEWS into its parse input - the input
|
|
144
|
+
* buffer must live as long as the retained document */
|
|
145
|
+
static char *g_doc_input;
|
|
146
|
+
|
|
147
|
+
EMSCRIPTEN_KEEPALIVE
|
|
148
|
+
int teptris_wasm_load_doc(const char *data, size_t len) {
|
|
149
|
+
if (g_doc != NULL) {
|
|
150
|
+
teptris_document_free(g_doc);
|
|
151
|
+
g_doc = NULL;
|
|
152
|
+
}
|
|
153
|
+
if (g_doc_input != NULL) {
|
|
154
|
+
free(g_doc_input);
|
|
155
|
+
g_doc_input = NULL;
|
|
156
|
+
}
|
|
157
|
+
/* copy the input FIRST: the doc's keys/values are views into it,
|
|
158
|
+
* and the caller's buffer is transient */
|
|
159
|
+
char *input = malloc(len);
|
|
160
|
+
if (input == NULL) {
|
|
161
|
+
snprintf(last_error, sizeof last_error, "alloc failed");
|
|
162
|
+
return (int)TEPTRIS_ERR_ALLOC;
|
|
163
|
+
}
|
|
164
|
+
memcpy(input, data, len);
|
|
165
|
+
teptris_document *doc = NULL;
|
|
166
|
+
teptris_status st = teptris_parse(input, len, NULL, &doc);
|
|
167
|
+
if (st != TEPTRIS_OK || doc == NULL) {
|
|
168
|
+
free(input);
|
|
169
|
+
if (doc != NULL) {
|
|
170
|
+
const teptris_error *e = teptris_document_error(doc);
|
|
171
|
+
snprintf(last_error, sizeof last_error, "%s", e->message);
|
|
172
|
+
last_error_line = (int)e->line;
|
|
173
|
+
last_error_column = (int)e->column;
|
|
174
|
+
teptris_document_free(doc);
|
|
175
|
+
} else {
|
|
176
|
+
snprintf(last_error, sizeof last_error, "parse failed");
|
|
177
|
+
}
|
|
178
|
+
return (int)st;
|
|
179
|
+
}
|
|
180
|
+
g_doc_input = input;
|
|
181
|
+
g_doc = doc;
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
EMSCRIPTEN_KEEPALIVE
|
|
186
|
+
int teptris_wasm_dump_doc(void) {
|
|
187
|
+
if (g_doc == NULL) {
|
|
188
|
+
snprintf(last_error, sizeof last_error,
|
|
189
|
+
"no retained document (loadsDoc first)");
|
|
190
|
+
return (int)TEPTRIS_ERR_STATE;
|
|
191
|
+
}
|
|
192
|
+
char *buf = NULL;
|
|
193
|
+
size_t len = 0;
|
|
194
|
+
teptris_status st = teptris_document_emit(g_doc, &buf, &len);
|
|
195
|
+
if (st != TEPTRIS_OK) {
|
|
196
|
+
snprintf(last_error, sizeof last_error, "%s",
|
|
197
|
+
teptris_status_string(st));
|
|
198
|
+
return (int)st;
|
|
199
|
+
}
|
|
200
|
+
/* no free(g_toml) here: the JS readOut() frees the pointer it
|
|
201
|
+
* read (the builder_finish convention) - freeing it here too is a
|
|
202
|
+
* double free */
|
|
203
|
+
g_toml = buf;
|
|
204
|
+
g_toml_len = len;
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
137
208
|
/* fused dumps: the JS side encodes one op-stream (writer grammar),
|
|
138
209
|
* this builds TOML in one crossing - no per-value builder calls, no
|
|
139
210
|
* DOM */
|