@datagrok/eda 1.0.3
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 +3 -0
- package/detectors.js +9 -0
- package/dist/111.js +2 -0
- package/dist/146.js +2 -0
- package/dist/155.js +2 -0
- package/dist/355.js +2 -0
- package/dist/584.js +2 -0
- package/dist/604.js +2 -0
- package/dist/632.js +2 -0
- package/dist/645.js +2 -0
- package/dist/93.js +2 -0
- package/dist/d711f70338306e5bddc4.wasm +0 -0
- package/dist/package-test.js +2 -0
- package/dist/package.js +2 -0
- package/package.json +49 -0
- package/package.png +0 -0
- package/scripts/command.txt +1 -0
- package/scripts/exportForTS.py +862 -0
- package/scripts/exportForTSConstants.py +93 -0
- package/scripts/func.json +1 -0
- package/scripts/module.json +11 -0
- package/src/EDAtools.ts +46 -0
- package/src/EDAui.ts +118 -0
- package/src/dataGenerators.ts +74 -0
- package/src/demos.ts +38 -0
- package/src/package-test.ts +12 -0
- package/src/package.ts +248 -0
- package/src/svm.ts +485 -0
- package/src/utils.ts +51 -0
- package/tsconfig.json +71 -0
- package/wasm/EDA.js +443 -0
- package/wasm/EDA.wasm +0 -0
- package/wasm/EDAAPI.js +131 -0
- package/wasm/EDAForWebWorker.js +21 -0
- package/wasm/PCA/PCA.cpp +151 -0
- package/wasm/PCA/PCA.h +48 -0
- package/wasm/PLS/PLS.h +64 -0
- package/wasm/PLS/pls.cpp +393 -0
- package/wasm/callWasm.js +475 -0
- package/wasm/callWasmForWebWorker.js +706 -0
- package/wasm/dataGenerators.h +169 -0
- package/wasm/dataMining.h +116 -0
- package/wasm/pcaExport.cpp +64 -0
- package/wasm/plsExport.cpp +75 -0
- package/wasm/svm.h +608 -0
- package/wasm/svmApi.cpp +323 -0
- package/wasm/workers/errorWorker.js +13 -0
- package/wasm/workers/generateDatasetWorker.js +13 -0
- package/wasm/workers/normalizeDatasetWorker.js +13 -0
- package/wasm/workers/partialLeastSquareRegressionWorker.js +13 -0
- package/wasm/workers/predictByLSSVMWorker.js +13 -0
- package/wasm/workers/principalComponentAnalysisWorker.js +13 -0
- package/wasm/workers/trainAndAnalyzeLSSVMWorker.js +13 -0
- package/wasm/workers/trainLSSVMWorker.js +13 -0
- package/webpack.config.js +37 -0
package/wasm/callWasm.js
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
// Runtime system for exported C/C++-functions call.
|
|
2
|
+
// It was previousely developed and does NOT provide call wasm-functions in WebWorkers.
|
|
3
|
+
|
|
4
|
+
// type-to-heap correspondence
|
|
5
|
+
const heapMap = {"i32": "HEAP32", // Int32Array
|
|
6
|
+
"f32": "HEAPF32" // Float32Array
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// type signature to typed array ,app
|
|
10
|
+
const typeMap = {"i32": Int32Array, // Int32Array
|
|
11
|
+
"f32": Float32Array // Float32Array
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// type-to-shift map
|
|
15
|
+
const shiftMap = {"i32": 2, // Int32Array
|
|
16
|
+
"f32": 2 // Float32Array
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// type-to-column_creator map
|
|
20
|
+
const typeToColumnCreatorMap = {"i32": DG.Column.fromInt32Array,
|
|
21
|
+
"f32": DG.Column.fromFloat32Array};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// CLASSES THAT ARE USED BY CPP-WRAPPER
|
|
25
|
+
|
|
26
|
+
// simple argument: a number
|
|
27
|
+
class Arg{
|
|
28
|
+
|
|
29
|
+
constructor(data) {
|
|
30
|
+
this.data = data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
complementArrOfParams(arrOfParams) {
|
|
34
|
+
arrOfParams.push(this.data);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
complementArrOfTypes(arrOfTypes) {
|
|
38
|
+
arrOfTypes.push('number');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
allocateMemoryForBuffer(module) {}
|
|
42
|
+
|
|
43
|
+
isMemoryForBufferAllocated(){
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
putDataToBuffer(module) {}
|
|
48
|
+
|
|
49
|
+
getDataFromBuffer(module) {}
|
|
50
|
+
|
|
51
|
+
freeBuffer(module) {}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// column argument
|
|
55
|
+
class ArgColumn extends Arg {
|
|
56
|
+
|
|
57
|
+
constructor(data, targetType, toUpdate = false) {
|
|
58
|
+
super(data);
|
|
59
|
+
this.type = targetType;
|
|
60
|
+
this.toUpdate = toUpdate;
|
|
61
|
+
this.buf = 0;
|
|
62
|
+
this.numOfRows = data.length;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
complementArrOfParams(arrOfParams) {
|
|
66
|
+
arrOfParams.push(this.buf);
|
|
67
|
+
arrOfParams.push(this.numOfRows);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
complementArrOfTypes(arrOfTypes) {
|
|
71
|
+
arrOfTypes.push('number');
|
|
72
|
+
arrOfTypes.push('number');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
allocateMemoryForBuffer(module) {
|
|
76
|
+
this.buf = module._malloc(this.numOfRows * typeMap[this.type].BYTES_PER_ELEMENT);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
isMemoryForBufferAllocated(){
|
|
80
|
+
return (this.buf != 0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
putDataToBuffer(module) {
|
|
84
|
+
if(this.isMemoryForBufferAllocated()) {
|
|
85
|
+
let type = this.type;
|
|
86
|
+
let shift = shiftMap[type];
|
|
87
|
+
let heap = module[heapMap[type]];
|
|
88
|
+
let array = null;
|
|
89
|
+
let col = this.data;
|
|
90
|
+
|
|
91
|
+
if(((col.type == 'int') && (type == 'i32'))
|
|
92
|
+
|| ((col.type == 'double') && (type == 'f32')))
|
|
93
|
+
array = col.getRawData();
|
|
94
|
+
else
|
|
95
|
+
array = new typeMap[type](col.getRawData());
|
|
96
|
+
|
|
97
|
+
if(array)
|
|
98
|
+
heap.set(array, this.buf >> shift);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
getDataFromBuffer(module) {
|
|
103
|
+
if(this.toUpdate && this.isMemoryForBufferAllocated()) {
|
|
104
|
+
let type = this.type;
|
|
105
|
+
let heap = module[heapMap[type]];
|
|
106
|
+
let buffer = this.buf;
|
|
107
|
+
let bytes = typeMap[type].BYTES_PER_ELEMENT;
|
|
108
|
+
let array = this.data.getRawData();
|
|
109
|
+
|
|
110
|
+
for(let i = 0; i < this.numOfRows; i++)
|
|
111
|
+
array[i] = heap[buffer / bytes + i];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
freeBuffer(module) {
|
|
116
|
+
if(this.isMemoryForBufferAllocated()) {
|
|
117
|
+
module._free(this.buf);
|
|
118
|
+
this.buf = 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// new column argument: a new column is created
|
|
125
|
+
class ArgNewColumn extends ArgColumn {
|
|
126
|
+
constructor(targetType, numOfRows) {
|
|
127
|
+
super([], targetType, true);
|
|
128
|
+
this.numOfRows = numOfRows;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
putDataToBuffer(module) {}
|
|
132
|
+
|
|
133
|
+
getDataFromBuffer(module) {
|
|
134
|
+
if(this.toUpdate && this.isMemoryForBufferAllocated()) {
|
|
135
|
+
let type = this.type;
|
|
136
|
+
let heap = module[heapMap[type]];
|
|
137
|
+
let buf = this.buf;
|
|
138
|
+
|
|
139
|
+
let columnCreator = typeToColumnCreatorMap[type];
|
|
140
|
+
|
|
141
|
+
let arr = new typeMap[type](this.numOfRows);
|
|
142
|
+
|
|
143
|
+
for(let i = 0; i < arr.length; i++)
|
|
144
|
+
arr[i] = heap[buf / arr.BYTES_PER_ELEMENT + i];
|
|
145
|
+
|
|
146
|
+
this.data = columnCreator('name', arr);
|
|
147
|
+
|
|
148
|
+
//console.log(arr);
|
|
149
|
+
|
|
150
|
+
// This makes mistake, when this.numOfRows = 5 (TODO: investigate why)
|
|
151
|
+
//this.data = columnCreator('name', new typeMap[type](heap.buffer, this.buf, this.numOfRows));
|
|
152
|
+
|
|
153
|
+
//console.log(this.data.getRawData());
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// an array of columns argument
|
|
159
|
+
class ArgColumns extends Arg {
|
|
160
|
+
|
|
161
|
+
constructor(data, targetType, toUpdate = false) {
|
|
162
|
+
super(data);
|
|
163
|
+
this.type = targetType;
|
|
164
|
+
this.toUpdate = toUpdate;
|
|
165
|
+
this.buf = 0;
|
|
166
|
+
this.numOfColumns = data.length;
|
|
167
|
+
this.numOfRows = data[0].length;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
complementArrOfParams(arrOfParams) {
|
|
171
|
+
arrOfParams.push(this.buf);
|
|
172
|
+
arrOfParams.push(this.numOfRows);
|
|
173
|
+
arrOfParams.push(this.numOfColumns);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
complementArrOfTypes(arrOfTypes) {
|
|
177
|
+
arrOfTypes.push('number');
|
|
178
|
+
arrOfTypes.push('number');
|
|
179
|
+
arrOfTypes.push('number');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
allocateMemoryForBuffer(module) {
|
|
183
|
+
this.buf = module._malloc(this.numOfRows * this.numOfColumns
|
|
184
|
+
* typeMap[this.type].BYTES_PER_ELEMENT);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
isMemoryForBufferAllocated(){
|
|
188
|
+
return (this.buf != 0);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
putDataToBuffer(module) {
|
|
192
|
+
if(this.isMemoryForBufferAllocated()) {
|
|
193
|
+
let type = this.type;
|
|
194
|
+
let shift = shiftMap[type];
|
|
195
|
+
let heap = module[heapMap[type]];
|
|
196
|
+
let numOfBytes = typeMap[type].BYTES_PER_ELEMENT;
|
|
197
|
+
|
|
198
|
+
// put columns data to buffer
|
|
199
|
+
for(let i = 0; i < this.numOfColumns; i++) {
|
|
200
|
+
let array = null;
|
|
201
|
+
let col = this.data[i];
|
|
202
|
+
|
|
203
|
+
if(((col.type == 'int') && (type == 'i32'))
|
|
204
|
+
|| ((col.type == 'double') && (type == 'f32')))
|
|
205
|
+
array = col.getRawData();
|
|
206
|
+
else
|
|
207
|
+
array = new typeMap[type](col.getRawData());
|
|
208
|
+
|
|
209
|
+
// check data array
|
|
210
|
+
if(array != null)
|
|
211
|
+
heap.set(array, (this.buf + i * this.numOfRows * numOfBytes) >> shift);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
getDataFromBuffer(module) {
|
|
217
|
+
if(this.toUpdate && this.isMemoryForBufferAllocated()) {
|
|
218
|
+
let type = this.type;
|
|
219
|
+
let heap = module[heapMap[type]];
|
|
220
|
+
let numOfRows = this.numOfRows;
|
|
221
|
+
let numOfCols = this.numOfColumns;
|
|
222
|
+
let arr = new typeMap[type](heap.buffer, this.buf, numOfRows * numOfCols);
|
|
223
|
+
|
|
224
|
+
for(let i = 0; i < numOfCols; i++) {
|
|
225
|
+
let colData = this.data[i].getRawData();
|
|
226
|
+
for(let j = 0; j < numOfRows; j++)
|
|
227
|
+
colData[j] = arr[j + i * numOfRows];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
freeBuffer(module) {
|
|
233
|
+
if(this.isMemoryForBufferAllocated()) {
|
|
234
|
+
module._free(this.buf);
|
|
235
|
+
this.buf = 0;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// an array of new columns: new columns are created
|
|
242
|
+
class ArgNewColumns extends ArgColumns {
|
|
243
|
+
|
|
244
|
+
constructor(targetType, numOfRows, numOfColumns) {
|
|
245
|
+
super([[]], targetType, true);
|
|
246
|
+
this.data = [];
|
|
247
|
+
this.numOfColumns = numOfColumns;
|
|
248
|
+
this.numOfRows = numOfRows;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
putDataToBuffer(module) { }
|
|
252
|
+
|
|
253
|
+
getDataFromBuffer(module) {
|
|
254
|
+
if(this.toUpdate && this.isMemoryForBufferAllocated()) {
|
|
255
|
+
let type = this.type;
|
|
256
|
+
let heap = module[heapMap[type]];
|
|
257
|
+
let numOfRows = this.numOfRows;
|
|
258
|
+
let numOfCols = this.numOfColumns;
|
|
259
|
+
let numOfBytes = typeMap[type].BYTES_PER_ELEMENT;
|
|
260
|
+
let columnCreator = typeToColumnCreatorMap[type];
|
|
261
|
+
let buf = this.buf;
|
|
262
|
+
|
|
263
|
+
for(let i = 0; i < numOfCols; i++) {
|
|
264
|
+
let arr = new typeMap[type](numOfRows);
|
|
265
|
+
|
|
266
|
+
for(let j = 0; j < numOfRows; j++)
|
|
267
|
+
arr[j] = heap[buf / numOfBytes + j + i * numOfRows];
|
|
268
|
+
|
|
269
|
+
this.data.push(columnCreator((i + 1).toString(), arr));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// create columns: here, may be a problem when numOfRows = 5
|
|
273
|
+
/*for(let i = 0; i < numOfCols; i++)
|
|
274
|
+
this.data.push(columnCreator((i + 1).toString(), new typeMap[type](heap.buffer,
|
|
275
|
+
this.buf + i * numOfRows * numOfBytes, numOfRows)));*/
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// a wrapper for exported C/C++-function call
|
|
281
|
+
function cppFuncWrapper(module, cFuncName, returnType, args)
|
|
282
|
+
{
|
|
283
|
+
let result;
|
|
284
|
+
|
|
285
|
+
// allocate memory for buffers
|
|
286
|
+
for(let arg of args)
|
|
287
|
+
arg.allocateMemoryForBuffer(module);
|
|
288
|
+
|
|
289
|
+
let isEnoughOfMemoryAllocated = true;
|
|
290
|
+
|
|
291
|
+
// check memory allocation
|
|
292
|
+
for(let arg of args)
|
|
293
|
+
isEnoughOfMemoryAllocated &= arg.isMemoryForBufferAllocated();
|
|
294
|
+
|
|
295
|
+
// run exported function if enough of memory is allocated
|
|
296
|
+
if(isEnoughOfMemoryAllocated) {
|
|
297
|
+
|
|
298
|
+
let params = []; // arguments that are put to the exported function
|
|
299
|
+
let types = []; // their types
|
|
300
|
+
|
|
301
|
+
// prepare data that is put to exported function
|
|
302
|
+
for(let arg of args) {
|
|
303
|
+
arg.complementArrOfParams(params);
|
|
304
|
+
arg.complementArrOfTypes(types);
|
|
305
|
+
arg.putDataToBuffer(module);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
let extendedTypeOfReturn = (returnType == 'num') ? 'number' : null;
|
|
309
|
+
|
|
310
|
+
// call exported function
|
|
311
|
+
if(extendedTypeOfReturn)
|
|
312
|
+
result = module.ccall(cFuncName, extendedTypeOfReturn, types, params);
|
|
313
|
+
else
|
|
314
|
+
result = module.ccall(cFuncName, extendedTypeOfReturn, types, params);
|
|
315
|
+
|
|
316
|
+
// update and get data from buffers if required
|
|
317
|
+
for(let arg of args)
|
|
318
|
+
arg.getDataFromBuffer(module);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// clear buffers
|
|
322
|
+
for(let arg of args)
|
|
323
|
+
arg.freeBuffer(module);
|
|
324
|
+
|
|
325
|
+
if(result != undefined)
|
|
326
|
+
return result;
|
|
327
|
+
} // cppFuncWrapper
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
// A LAYER BETWEEN JS AND CPP-WRAPPER
|
|
331
|
+
|
|
332
|
+
// Parameters creator
|
|
333
|
+
let Param = {
|
|
334
|
+
intColumn (column) {
|
|
335
|
+
return new ArgColumn(column, 'i32');
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
newIntColumn (numOfRows) {
|
|
339
|
+
return new ArgNewColumn('i32', numOfRows);
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
intColumns(columns){
|
|
343
|
+
return new ArgColumns(columns.toList(), 'i32');
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
newIntColumns(numOfRows, numOfColumns) {
|
|
347
|
+
return new ArgNewColumns('i32', numOfRows, numOfColumns);
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
floatColumn (column) {
|
|
351
|
+
return new ArgColumn(column, 'f32');
|
|
352
|
+
},
|
|
353
|
+
|
|
354
|
+
newFloatColumn (numOfRows) {
|
|
355
|
+
return new ArgNewColumn('f32', numOfRows);
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
floatColumns(columns){
|
|
359
|
+
return new ArgColumns(columns.toList(), 'f32');
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
newFloatColumns(numOfRows, numOfColumns) {
|
|
363
|
+
return new ArgNewColumns('f32', numOfRows, numOfColumns);
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
int(number) {
|
|
367
|
+
return new Arg(number);
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
num(number) {
|
|
371
|
+
return new Arg(number);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// Return value creator
|
|
376
|
+
let Return = {
|
|
377
|
+
tableFromColumns(argColumns) {
|
|
378
|
+
return DG.DataFrame.fromColumns(argColumns.data);
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
num(number) {
|
|
382
|
+
return number;
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
int(number) {
|
|
386
|
+
return number;
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
double(number) {
|
|
390
|
+
return number;
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
column(argColumn) {
|
|
394
|
+
return argColumn.data;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// The main tool that combines all together
|
|
399
|
+
export function callWasm(module, funcName, inputs) {
|
|
400
|
+
|
|
401
|
+
let start = new Date().getTime();
|
|
402
|
+
|
|
403
|
+
// get specification of exported C/C++-function
|
|
404
|
+
let funcSpecification = module[funcName];
|
|
405
|
+
|
|
406
|
+
// get argumnets
|
|
407
|
+
let args = funcSpecification.arguments;
|
|
408
|
+
|
|
409
|
+
// array of arguments that further are used by cpp-wrapper
|
|
410
|
+
let cppFuncInput = [];
|
|
411
|
+
|
|
412
|
+
// complete an input for cpp
|
|
413
|
+
let i = 0;
|
|
414
|
+
for(let key in args){
|
|
415
|
+
let arg = args[key];
|
|
416
|
+
|
|
417
|
+
// skip auxiliry element
|
|
418
|
+
if(key == '_callResult')
|
|
419
|
+
continue;
|
|
420
|
+
|
|
421
|
+
// create an argument
|
|
422
|
+
switch(arg.type){
|
|
423
|
+
case 'floatColumns':
|
|
424
|
+
case 'int':
|
|
425
|
+
case 'num':
|
|
426
|
+
case 'floatColumn':
|
|
427
|
+
case 'intColumn':
|
|
428
|
+
case 'intColumns':
|
|
429
|
+
arg.data = Param[arg.type](inputs[i]);
|
|
430
|
+
i++;
|
|
431
|
+
break;
|
|
432
|
+
case 'newFloatColumns':
|
|
433
|
+
case 'newIntColumns':
|
|
434
|
+
let val1 = args[ arg['numOfRows']['ref'] ].data[arg['numOfRows']['value']];
|
|
435
|
+
let val2 = args[ arg['numOfColumns']['ref'] ].data[arg['numOfColumns']['value']];
|
|
436
|
+
arg.data = Param[arg.type](val1, val2);
|
|
437
|
+
break;
|
|
438
|
+
case 'newFloatColumn':
|
|
439
|
+
case 'newIntColumn':
|
|
440
|
+
let val = args[ arg['numOfRows']['ref'] ].data[arg['numOfRows']['value']];
|
|
441
|
+
arg.data = Param[arg.type](val);
|
|
442
|
+
break;
|
|
443
|
+
} // switch
|
|
444
|
+
|
|
445
|
+
cppFuncInput.push(args[key].data);
|
|
446
|
+
|
|
447
|
+
} // for key
|
|
448
|
+
|
|
449
|
+
// CALL EXPORTED CPP-FUNCTION
|
|
450
|
+
let callResult = cppFuncWrapper(module, funcName, 'num', cppFuncInput);
|
|
451
|
+
|
|
452
|
+
console.log('C++-function call result: ' + callResult);
|
|
453
|
+
|
|
454
|
+
// store result that is returned by exported cpp-function
|
|
455
|
+
args._callResult = Param.num(callResult);
|
|
456
|
+
|
|
457
|
+
// create output
|
|
458
|
+
let output = funcSpecification.output;
|
|
459
|
+
|
|
460
|
+
let finish = new Date().getTime();
|
|
461
|
+
|
|
462
|
+
console.log(`Time for C/C++-function is ${finish - start} ms.`)
|
|
463
|
+
|
|
464
|
+
// if a single object must be returned
|
|
465
|
+
if(output['type'] != 'objects')
|
|
466
|
+
return Return[output['type']](args[output['source']].data);
|
|
467
|
+
|
|
468
|
+
let arrayToReturn = [];
|
|
469
|
+
|
|
470
|
+
// push data of the required arguments
|
|
471
|
+
for(let name of output['source'])
|
|
472
|
+
arrayToReturn.push(args[name].data.data);
|
|
473
|
+
|
|
474
|
+
return arrayToReturn;
|
|
475
|
+
} // callWasm
|