-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathStringParameter.Import.js
More file actions
69 lines (65 loc) · 2.55 KB
/
StringParameter.Import.js
File metadata and controls
69 lines (65 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// NOTICE: This is auto-generated code by BridgeJS from JavaScriptKit,
// DO NOT EDIT.
//
// To update this file, just rebuild your project or run
// `swift package bridge-js`.
export async function createInstantiator(options, swift) {
let instance;
let memory;
const textDecoder = new TextDecoder("utf-8");
const textEncoder = new TextEncoder("utf-8");
let tmpRetString;
let tmpRetBytes;
return {
/** @param {WebAssembly.Imports} importObject */
addImports: (importObject) => {
const bjs = {};
importObject["bjs"] = bjs;
bjs["return_string"] = function(ptr, len) {
const bytes = new Uint8Array(memory.buffer, ptr, len);
tmpRetString = textDecoder.decode(bytes);
}
bjs["init_memory"] = function(sourceId, bytesPtr) {
const source = swift.memory.getObject(sourceId);
const bytes = new Uint8Array(memory.buffer, bytesPtr);
bytes.set(source);
}
bjs["make_jsstring"] = function(ptr, len) {
const bytes = new Uint8Array(memory.buffer, ptr, len);
return swift.memory.retain(textDecoder.decode(bytes));
}
bjs["init_memory_with_result"] = function(ptr, len) {
const target = new Uint8Array(memory.buffer, ptr, len);
target.set(tmpRetBytes);
tmpRetBytes = undefined;
}
bjs["swift_js_retain"] = function(id) {
return swift.memory.retainByRef(id);
}
bjs["swift_js_release"] = function(id) {
swift.memory.release(id);
}
const TestModule = importObject["TestModule"] = {};
TestModule["bjs_checkString"] = function bjs_checkString(a) {
const aObject = swift.memory.getObject(a);
swift.memory.release(a);
options.imports.checkString(aObject);
}
TestModule["bjs_checkStringWithLength"] = function bjs_checkStringWithLength(a, b) {
const aObject = swift.memory.getObject(a);
swift.memory.release(a);
options.imports.checkStringWithLength(aObject, b);
}
},
setInstance: (i) => {
instance = i;
memory = instance.exports.memory;
},
/** @param {WebAssembly.Instance} instance */
createExports: (instance) => {
const js = swift.memory.heap;
return {
};
},
}
}