Revert "testing strings instead of vec<u8>"

This reverts commit 8dcc587c45.
master
frederic wagner 2022-11-06 07:56:54 +01:00
parent 8dcc587c45
commit d8ca24c817
3 changed files with 8 additions and 11 deletions

View File

@ -2,9 +2,9 @@
/* eslint-disable */
/**
* @param {string} input_str
* @returns {string}
* @returns {Uint8Array}
*/
export function convert_gpx_strings(input_str: string): string;
export function convert_gpx_strings(input_str: string): Uint8Array;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

View File

@ -74,16 +74,12 @@ function getInt32Memory0() {
return cachedInt32Memory0;
}
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**
* @param {string} input_str
* @returns {string}
* @returns {Uint8Array}
*/
export function convert_gpx_strings(input_str) {
try {
@ -93,10 +89,11 @@ export function convert_gpx_strings(input_str) {
wasm.convert_gpx_strings(retptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
return getStringFromWasm0(r0, r1);
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(r0, r1);
}
}