MCPcopy
hub / github.com/sql-js/sql.js / ccall

Function ccall

js/sql-debug.js:501–522  ·  view source on GitHub ↗
(ident, returnType, argTypes, args, opts)

Source from the content-addressed store, hash-verified

499
500// C calling interface.
501function ccall (ident, returnType, argTypes, args, opts) {
502 var func = getCFunc(ident);
503 var cArgs = [];
504 var stack = 0;
505 if (args) {
506 for (var i = 0; i < args.length; i++) {
507 var converter = toC[argTypes[i]];
508 if (converter) {
509 if (stack === 0) stack = stackSave();
510 cArgs[i] = converter(args[i]);
511 } else {
512 cArgs[i] = args[i];
513 }
514 }
515 }
516 var ret = func.apply(null, cArgs);
517 if (returnType === 'string') ret = Pointer_stringify(ret);
518 if (stack !== 0) {
519 stackRestore(stack);
520 }
521 return ret;
522}
523
524function cwrap (ident, returnType, argTypes) {
525 argTypes = argTypes || [];

Callers 1

cwrapFunction · 0.70

Calls 4

stackSaveFunction · 0.85
stackRestoreFunction · 0.85
getCFuncFunction · 0.70
Pointer_stringifyFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…