wasm-webp 0.0.2 → 0.1.0
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 +23 -6
- package/dist/cjs/index.js +19 -13
- package/dist/cjs/webp-wasm.js +1133 -325
- package/dist/cjs/webp-wasm.wasm +0 -0
- package/dist/esm/index.js +12 -11
- package/dist/esm/webp-wasm.js +1128 -324
- package/dist/esm/webp-wasm.wasm +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/esm/webp-wasm.js
CHANGED
|
@@ -1360,128 +1360,884 @@ function dbg(...args) {
|
|
|
1360
1360
|
};
|
|
1361
1361
|
|
|
1362
1362
|
|
|
1363
|
-
var emval_freelist = [];
|
|
1364
1363
|
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1364
|
+
var shallowCopyInternalPointer = (o) => {
|
|
1365
|
+
return {
|
|
1366
|
+
count: o.count,
|
|
1367
|
+
deleteScheduled: o.deleteScheduled,
|
|
1368
|
+
preservePointerOnDelete: o.preservePointerOnDelete,
|
|
1369
|
+
ptr: o.ptr,
|
|
1370
|
+
ptrType: o.ptrType,
|
|
1371
|
+
smartPtr: o.smartPtr,
|
|
1372
|
+
smartPtrType: o.smartPtrType,
|
|
1373
|
+
};
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
var throwInstanceAlreadyDeleted = (obj) => {
|
|
1377
|
+
function getInstanceTypeName(handle) {
|
|
1378
|
+
return handle.$$.ptrType.registeredClass.name;
|
|
1379
|
+
}
|
|
1380
|
+
throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
var finalizationRegistry = false;
|
|
1384
|
+
|
|
1385
|
+
var detachFinalizer = (handle) => {};
|
|
1386
|
+
|
|
1387
|
+
var runDestructor = ($$) => {
|
|
1388
|
+
if ($$.smartPtr) {
|
|
1389
|
+
$$.smartPtrType.rawDestructor($$.smartPtr);
|
|
1390
|
+
} else {
|
|
1391
|
+
$$.ptrType.registeredClass.rawDestructor($$.ptr);
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
var releaseClassHandle = ($$) => {
|
|
1395
|
+
$$.count.value -= 1;
|
|
1396
|
+
var toDelete = 0 === $$.count.value;
|
|
1397
|
+
if (toDelete) {
|
|
1398
|
+
runDestructor($$);
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
var downcastPointer = (ptr, ptrClass, desiredClass) => {
|
|
1403
|
+
if (ptrClass === desiredClass) {
|
|
1404
|
+
return ptr;
|
|
1405
|
+
}
|
|
1406
|
+
if (undefined === desiredClass.baseClass) {
|
|
1407
|
+
return null; // no conversion
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);
|
|
1411
|
+
if (rv === null) {
|
|
1412
|
+
return null;
|
|
1413
|
+
}
|
|
1414
|
+
return desiredClass.downcast(rv);
|
|
1415
|
+
};
|
|
1416
|
+
|
|
1417
|
+
var registeredPointers = {
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
var getInheritedInstanceCount = () => Object.keys(registeredInstances).length;
|
|
1421
|
+
|
|
1422
|
+
var getLiveInheritedInstances = () => {
|
|
1423
|
+
var rv = [];
|
|
1424
|
+
for (var k in registeredInstances) {
|
|
1425
|
+
if (registeredInstances.hasOwnProperty(k)) {
|
|
1426
|
+
rv.push(registeredInstances[k]);
|
|
1427
|
+
}
|
|
1371
1428
|
}
|
|
1429
|
+
return rv;
|
|
1372
1430
|
};
|
|
1373
1431
|
|
|
1432
|
+
var deletionQueue = [];
|
|
1433
|
+
var flushPendingDeletes = () => {
|
|
1434
|
+
while (deletionQueue.length) {
|
|
1435
|
+
var obj = deletionQueue.pop();
|
|
1436
|
+
obj.$$.deleteScheduled = false;
|
|
1437
|
+
obj['delete']();
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
var delayFunction;
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
var setDelayFunction = (fn) => {
|
|
1445
|
+
delayFunction = fn;
|
|
1446
|
+
if (deletionQueue.length && delayFunction) {
|
|
1447
|
+
delayFunction(flushPendingDeletes);
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
var init_embind = () => {
|
|
1451
|
+
Module['getInheritedInstanceCount'] = getInheritedInstanceCount;
|
|
1452
|
+
Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
|
|
1453
|
+
Module['flushPendingDeletes'] = flushPendingDeletes;
|
|
1454
|
+
Module['setDelayFunction'] = setDelayFunction;
|
|
1455
|
+
};
|
|
1456
|
+
var registeredInstances = {
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
var getBasestPointer = (class_, ptr) => {
|
|
1460
|
+
if (ptr === undefined) {
|
|
1461
|
+
throwBindingError('ptr should not be undefined');
|
|
1462
|
+
}
|
|
1463
|
+
while (class_.baseClass) {
|
|
1464
|
+
ptr = class_.upcast(ptr);
|
|
1465
|
+
class_ = class_.baseClass;
|
|
1466
|
+
}
|
|
1467
|
+
return ptr;
|
|
1468
|
+
};
|
|
1469
|
+
var getInheritedInstance = (class_, ptr) => {
|
|
1470
|
+
ptr = getBasestPointer(class_, ptr);
|
|
1471
|
+
return registeredInstances[ptr];
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
var makeClassHandle = (prototype, record) => {
|
|
1476
|
+
if (!record.ptrType || !record.ptr) {
|
|
1477
|
+
throwInternalError('makeClassHandle requires ptr and ptrType');
|
|
1478
|
+
}
|
|
1479
|
+
var hasSmartPtrType = !!record.smartPtrType;
|
|
1480
|
+
var hasSmartPtr = !!record.smartPtr;
|
|
1481
|
+
if (hasSmartPtrType !== hasSmartPtr) {
|
|
1482
|
+
throwInternalError('Both smartPtrType and smartPtr must be specified');
|
|
1483
|
+
}
|
|
1484
|
+
record.count = { value: 1 };
|
|
1485
|
+
return attachFinalizer(Object.create(prototype, {
|
|
1486
|
+
$$: {
|
|
1487
|
+
value: record,
|
|
1488
|
+
writable: true,
|
|
1489
|
+
},
|
|
1490
|
+
}));
|
|
1491
|
+
};
|
|
1492
|
+
/** @suppress {globalThis} */
|
|
1493
|
+
function RegisteredPointer_fromWireType(ptr) {
|
|
1494
|
+
// ptr is a raw pointer (or a raw smartpointer)
|
|
1495
|
+
|
|
1496
|
+
// rawPointer is a maybe-null raw pointer
|
|
1497
|
+
var rawPointer = this.getPointee(ptr);
|
|
1498
|
+
if (!rawPointer) {
|
|
1499
|
+
this.destructor(ptr);
|
|
1500
|
+
return null;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
|
|
1504
|
+
if (undefined !== registeredInstance) {
|
|
1505
|
+
// JS object has been neutered, time to repopulate it
|
|
1506
|
+
if (0 === registeredInstance.$$.count.value) {
|
|
1507
|
+
registeredInstance.$$.ptr = rawPointer;
|
|
1508
|
+
registeredInstance.$$.smartPtr = ptr;
|
|
1509
|
+
return registeredInstance['clone']();
|
|
1510
|
+
} else {
|
|
1511
|
+
// else, just increment reference count on existing object
|
|
1512
|
+
// it already has a reference to the smart pointer
|
|
1513
|
+
var rv = registeredInstance['clone']();
|
|
1514
|
+
this.destructor(ptr);
|
|
1515
|
+
return rv;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
function makeDefaultHandle() {
|
|
1520
|
+
if (this.isSmartPointer) {
|
|
1521
|
+
return makeClassHandle(this.registeredClass.instancePrototype, {
|
|
1522
|
+
ptrType: this.pointeeType,
|
|
1523
|
+
ptr: rawPointer,
|
|
1524
|
+
smartPtrType: this,
|
|
1525
|
+
smartPtr: ptr,
|
|
1526
|
+
});
|
|
1527
|
+
} else {
|
|
1528
|
+
return makeClassHandle(this.registeredClass.instancePrototype, {
|
|
1529
|
+
ptrType: this,
|
|
1530
|
+
ptr,
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
var actualType = this.registeredClass.getActualType(rawPointer);
|
|
1536
|
+
var registeredPointerRecord = registeredPointers[actualType];
|
|
1537
|
+
if (!registeredPointerRecord) {
|
|
1538
|
+
return makeDefaultHandle.call(this);
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
var toType;
|
|
1542
|
+
if (this.isConst) {
|
|
1543
|
+
toType = registeredPointerRecord.constPointerType;
|
|
1544
|
+
} else {
|
|
1545
|
+
toType = registeredPointerRecord.pointerType;
|
|
1546
|
+
}
|
|
1547
|
+
var dp = downcastPointer(
|
|
1548
|
+
rawPointer,
|
|
1549
|
+
this.registeredClass,
|
|
1550
|
+
toType.registeredClass);
|
|
1551
|
+
if (dp === null) {
|
|
1552
|
+
return makeDefaultHandle.call(this);
|
|
1553
|
+
}
|
|
1554
|
+
if (this.isSmartPointer) {
|
|
1555
|
+
return makeClassHandle(toType.registeredClass.instancePrototype, {
|
|
1556
|
+
ptrType: toType,
|
|
1557
|
+
ptr: dp,
|
|
1558
|
+
smartPtrType: this,
|
|
1559
|
+
smartPtr: ptr,
|
|
1560
|
+
});
|
|
1561
|
+
} else {
|
|
1562
|
+
return makeClassHandle(toType.registeredClass.instancePrototype, {
|
|
1563
|
+
ptrType: toType,
|
|
1564
|
+
ptr: dp,
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
var attachFinalizer = (handle) => {
|
|
1569
|
+
if ('undefined' === typeof FinalizationRegistry) {
|
|
1570
|
+
attachFinalizer = (handle) => handle;
|
|
1571
|
+
return handle;
|
|
1572
|
+
}
|
|
1573
|
+
// If the running environment has a FinalizationRegistry (see
|
|
1574
|
+
// https://github.com/tc39/proposal-weakrefs), then attach finalizers
|
|
1575
|
+
// for class handles. We check for the presence of FinalizationRegistry
|
|
1576
|
+
// at run-time, not build-time.
|
|
1577
|
+
finalizationRegistry = new FinalizationRegistry((info) => {
|
|
1578
|
+
console.warn(info.leakWarning.stack.replace(/^Error: /, ''));
|
|
1579
|
+
releaseClassHandle(info.$$);
|
|
1580
|
+
});
|
|
1581
|
+
attachFinalizer = (handle) => {
|
|
1582
|
+
var $$ = handle.$$;
|
|
1583
|
+
var hasSmartPtr = !!$$.smartPtr;
|
|
1584
|
+
if (hasSmartPtr) {
|
|
1585
|
+
// We should not call the destructor on raw pointers in case other code expects the pointee to live
|
|
1586
|
+
var info = { $$: $$ };
|
|
1587
|
+
// Create a warning as an Error instance in advance so that we can store
|
|
1588
|
+
// the current stacktrace and point to it when / if a leak is detected.
|
|
1589
|
+
// This is more useful than the empty stacktrace of `FinalizationRegistry`
|
|
1590
|
+
// callback.
|
|
1591
|
+
var cls = $$.ptrType.registeredClass;
|
|
1592
|
+
info.leakWarning = new Error(`Embind found a leaked C++ instance ${cls.name} <${ptrToString($$.ptr)}>.\n` +
|
|
1593
|
+
"We'll free it automatically in this case, but this functionality is not reliable across various environments.\n" +
|
|
1594
|
+
"Make sure to invoke .delete() manually once you're done with the instance instead.\n" +
|
|
1595
|
+
"Originally allocated"); // `.stack` will add "at ..." after this sentence
|
|
1596
|
+
if ('captureStackTrace' in Error) {
|
|
1597
|
+
Error.captureStackTrace(info.leakWarning, RegisteredPointer_fromWireType);
|
|
1598
|
+
}
|
|
1599
|
+
finalizationRegistry.register(handle, info, handle);
|
|
1600
|
+
}
|
|
1601
|
+
return handle;
|
|
1602
|
+
};
|
|
1603
|
+
detachFinalizer = (handle) => finalizationRegistry.unregister(handle);
|
|
1604
|
+
return attachFinalizer(handle);
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
var init_ClassHandle = () => {
|
|
1610
|
+
Object.assign(ClassHandle.prototype, {
|
|
1611
|
+
"isAliasOf"(other) {
|
|
1612
|
+
if (!(this instanceof ClassHandle)) {
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
if (!(other instanceof ClassHandle)) {
|
|
1616
|
+
return false;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
var leftClass = this.$$.ptrType.registeredClass;
|
|
1620
|
+
var left = this.$$.ptr;
|
|
1621
|
+
other.$$ = /** @type {Object} */ (other.$$);
|
|
1622
|
+
var rightClass = other.$$.ptrType.registeredClass;
|
|
1623
|
+
var right = other.$$.ptr;
|
|
1624
|
+
|
|
1625
|
+
while (leftClass.baseClass) {
|
|
1626
|
+
left = leftClass.upcast(left);
|
|
1627
|
+
leftClass = leftClass.baseClass;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
while (rightClass.baseClass) {
|
|
1631
|
+
right = rightClass.upcast(right);
|
|
1632
|
+
rightClass = rightClass.baseClass;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
return leftClass === rightClass && left === right;
|
|
1636
|
+
},
|
|
1637
|
+
|
|
1638
|
+
"clone"() {
|
|
1639
|
+
if (!this.$$.ptr) {
|
|
1640
|
+
throwInstanceAlreadyDeleted(this);
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
if (this.$$.preservePointerOnDelete) {
|
|
1644
|
+
this.$$.count.value += 1;
|
|
1645
|
+
return this;
|
|
1646
|
+
} else {
|
|
1647
|
+
var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
|
|
1648
|
+
$$: {
|
|
1649
|
+
value: shallowCopyInternalPointer(this.$$),
|
|
1650
|
+
}
|
|
1651
|
+
}));
|
|
1652
|
+
|
|
1653
|
+
clone.$$.count.value += 1;
|
|
1654
|
+
clone.$$.deleteScheduled = false;
|
|
1655
|
+
return clone;
|
|
1656
|
+
}
|
|
1657
|
+
},
|
|
1658
|
+
|
|
1659
|
+
"delete"() {
|
|
1660
|
+
if (!this.$$.ptr) {
|
|
1661
|
+
throwInstanceAlreadyDeleted(this);
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
|
1665
|
+
throwBindingError('Object already scheduled for deletion');
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
detachFinalizer(this);
|
|
1669
|
+
releaseClassHandle(this.$$);
|
|
1670
|
+
|
|
1671
|
+
if (!this.$$.preservePointerOnDelete) {
|
|
1672
|
+
this.$$.smartPtr = undefined;
|
|
1673
|
+
this.$$.ptr = undefined;
|
|
1674
|
+
}
|
|
1675
|
+
},
|
|
1676
|
+
|
|
1677
|
+
"isDeleted"() {
|
|
1678
|
+
return !this.$$.ptr;
|
|
1679
|
+
},
|
|
1680
|
+
|
|
1681
|
+
"deleteLater"() {
|
|
1682
|
+
if (!this.$$.ptr) {
|
|
1683
|
+
throwInstanceAlreadyDeleted(this);
|
|
1684
|
+
}
|
|
1685
|
+
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
|
1686
|
+
throwBindingError('Object already scheduled for deletion');
|
|
1687
|
+
}
|
|
1688
|
+
deletionQueue.push(this);
|
|
1689
|
+
if (deletionQueue.length === 1 && delayFunction) {
|
|
1690
|
+
delayFunction(flushPendingDeletes);
|
|
1691
|
+
}
|
|
1692
|
+
this.$$.deleteScheduled = true;
|
|
1693
|
+
return this;
|
|
1694
|
+
},
|
|
1695
|
+
});
|
|
1696
|
+
};
|
|
1697
|
+
/** @constructor */
|
|
1698
|
+
function ClassHandle() {
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
var createNamedFunction = (name, body) => Object.defineProperty(body, 'name', {
|
|
1702
|
+
value: name
|
|
1703
|
+
});
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
var ensureOverloadTable = (proto, methodName, humanName) => {
|
|
1707
|
+
if (undefined === proto[methodName].overloadTable) {
|
|
1708
|
+
var prevFunc = proto[methodName];
|
|
1709
|
+
// Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
|
|
1710
|
+
proto[methodName] = function(...args) {
|
|
1711
|
+
// TODO This check can be removed in -O3 level "unsafe" optimizations.
|
|
1712
|
+
if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
|
|
1713
|
+
throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
|
|
1714
|
+
}
|
|
1715
|
+
return proto[methodName].overloadTable[args.length].apply(this, args);
|
|
1716
|
+
};
|
|
1717
|
+
// Move the previous function into the overload table.
|
|
1718
|
+
proto[methodName].overloadTable = [];
|
|
1719
|
+
proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
/** @param {number=} numArguments */
|
|
1724
|
+
var exposePublicSymbol = (name, value, numArguments) => {
|
|
1725
|
+
if (Module.hasOwnProperty(name)) {
|
|
1726
|
+
if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
|
|
1727
|
+
throwBindingError(`Cannot register public name '${name}' twice`);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// We are exposing a function with the same name as an existing function. Create an overload table and a function selector
|
|
1731
|
+
// that routes between the two.
|
|
1732
|
+
ensureOverloadTable(Module, name, name);
|
|
1733
|
+
if (Module.hasOwnProperty(numArguments)) {
|
|
1734
|
+
throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
|
|
1735
|
+
}
|
|
1736
|
+
// Add the new function into the overload table.
|
|
1737
|
+
Module[name].overloadTable[numArguments] = value;
|
|
1738
|
+
}
|
|
1739
|
+
else {
|
|
1740
|
+
Module[name] = value;
|
|
1741
|
+
if (undefined !== numArguments) {
|
|
1742
|
+
Module[name].numArguments = numArguments;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
var char_0 = 48;
|
|
1748
|
+
|
|
1749
|
+
var char_9 = 57;
|
|
1750
|
+
var makeLegalFunctionName = (name) => {
|
|
1751
|
+
if (undefined === name) {
|
|
1752
|
+
return '_unknown';
|
|
1753
|
+
}
|
|
1754
|
+
name = name.replace(/[^a-zA-Z0-9_]/g, '$');
|
|
1755
|
+
var f = name.charCodeAt(0);
|
|
1756
|
+
if (f >= char_0 && f <= char_9) {
|
|
1757
|
+
return `_${name}`;
|
|
1758
|
+
}
|
|
1759
|
+
return name;
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
/** @constructor */
|
|
1764
|
+
function RegisteredClass(name,
|
|
1765
|
+
constructor,
|
|
1766
|
+
instancePrototype,
|
|
1767
|
+
rawDestructor,
|
|
1768
|
+
baseClass,
|
|
1769
|
+
getActualType,
|
|
1770
|
+
upcast,
|
|
1771
|
+
downcast) {
|
|
1772
|
+
this.name = name;
|
|
1773
|
+
this.constructor = constructor;
|
|
1774
|
+
this.instancePrototype = instancePrototype;
|
|
1775
|
+
this.rawDestructor = rawDestructor;
|
|
1776
|
+
this.baseClass = baseClass;
|
|
1777
|
+
this.getActualType = getActualType;
|
|
1778
|
+
this.upcast = upcast;
|
|
1779
|
+
this.downcast = downcast;
|
|
1780
|
+
this.pureVirtualFunctions = [];
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
var upcastPointer = (ptr, ptrClass, desiredClass) => {
|
|
1785
|
+
while (ptrClass !== desiredClass) {
|
|
1786
|
+
if (!ptrClass.upcast) {
|
|
1787
|
+
throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`);
|
|
1788
|
+
}
|
|
1789
|
+
ptr = ptrClass.upcast(ptr);
|
|
1790
|
+
ptrClass = ptrClass.baseClass;
|
|
1791
|
+
}
|
|
1792
|
+
return ptr;
|
|
1793
|
+
};
|
|
1794
|
+
/** @suppress {globalThis} */
|
|
1795
|
+
function constNoSmartPtrRawPointerToWireType(destructors, handle) {
|
|
1796
|
+
if (handle === null) {
|
|
1797
|
+
if (this.isReference) {
|
|
1798
|
+
throwBindingError(`null is not a valid ${this.name}`);
|
|
1799
|
+
}
|
|
1800
|
+
return 0;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
if (!handle.$$) {
|
|
1804
|
+
throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
|
|
1805
|
+
}
|
|
1806
|
+
if (!handle.$$.ptr) {
|
|
1807
|
+
throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
1808
|
+
}
|
|
1809
|
+
var handleClass = handle.$$.ptrType.registeredClass;
|
|
1810
|
+
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
1811
|
+
return ptr;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
|
|
1815
|
+
/** @suppress {globalThis} */
|
|
1816
|
+
function genericPointerToWireType(destructors, handle) {
|
|
1817
|
+
var ptr;
|
|
1818
|
+
if (handle === null) {
|
|
1819
|
+
if (this.isReference) {
|
|
1820
|
+
throwBindingError(`null is not a valid ${this.name}`);
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
if (this.isSmartPointer) {
|
|
1824
|
+
ptr = this.rawConstructor();
|
|
1825
|
+
if (destructors !== null) {
|
|
1826
|
+
destructors.push(this.rawDestructor, ptr);
|
|
1827
|
+
}
|
|
1828
|
+
return ptr;
|
|
1829
|
+
} else {
|
|
1830
|
+
return 0;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
if (!handle || !handle.$$) {
|
|
1835
|
+
throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
|
|
1836
|
+
}
|
|
1837
|
+
if (!handle.$$.ptr) {
|
|
1838
|
+
throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
1839
|
+
}
|
|
1840
|
+
if (!this.isConst && handle.$$.ptrType.isConst) {
|
|
1841
|
+
throwBindingError(`Cannot convert argument of type ${(handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name)} to parameter type ${this.name}`);
|
|
1842
|
+
}
|
|
1843
|
+
var handleClass = handle.$$.ptrType.registeredClass;
|
|
1844
|
+
ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
1845
|
+
|
|
1846
|
+
if (this.isSmartPointer) {
|
|
1847
|
+
// TODO: this is not strictly true
|
|
1848
|
+
// We could support BY_EMVAL conversions from raw pointers to smart pointers
|
|
1849
|
+
// because the smart pointer can hold a reference to the handle
|
|
1850
|
+
if (undefined === handle.$$.smartPtr) {
|
|
1851
|
+
throwBindingError('Passing raw pointer to smart pointer is illegal');
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
switch (this.sharingPolicy) {
|
|
1855
|
+
case 0: // NONE
|
|
1856
|
+
// no upcasting
|
|
1857
|
+
if (handle.$$.smartPtrType === this) {
|
|
1858
|
+
ptr = handle.$$.smartPtr;
|
|
1859
|
+
} else {
|
|
1860
|
+
throwBindingError(`Cannot convert argument of type ${(handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name)} to parameter type ${this.name}`);
|
|
1861
|
+
}
|
|
1862
|
+
break;
|
|
1863
|
+
|
|
1864
|
+
case 1: // INTRUSIVE
|
|
1865
|
+
ptr = handle.$$.smartPtr;
|
|
1866
|
+
break;
|
|
1867
|
+
|
|
1868
|
+
case 2: // BY_EMVAL
|
|
1869
|
+
if (handle.$$.smartPtrType === this) {
|
|
1870
|
+
ptr = handle.$$.smartPtr;
|
|
1871
|
+
} else {
|
|
1872
|
+
var clonedHandle = handle['clone']();
|
|
1873
|
+
ptr = this.rawShare(
|
|
1874
|
+
ptr,
|
|
1875
|
+
Emval.toHandle(() => clonedHandle['delete']())
|
|
1876
|
+
);
|
|
1877
|
+
if (destructors !== null) {
|
|
1878
|
+
destructors.push(this.rawDestructor, ptr);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
break;
|
|
1882
|
+
|
|
1883
|
+
default:
|
|
1884
|
+
throwBindingError('Unsupporting sharing policy');
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
return ptr;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
/** @suppress {globalThis} */
|
|
1892
|
+
function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
|
|
1893
|
+
if (handle === null) {
|
|
1894
|
+
if (this.isReference) {
|
|
1895
|
+
throwBindingError(`null is not a valid ${this.name}`);
|
|
1896
|
+
}
|
|
1897
|
+
return 0;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
if (!handle.$$) {
|
|
1901
|
+
throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
|
|
1902
|
+
}
|
|
1903
|
+
if (!handle.$$.ptr) {
|
|
1904
|
+
throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
|
|
1905
|
+
}
|
|
1906
|
+
if (handle.$$.ptrType.isConst) {
|
|
1907
|
+
throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`);
|
|
1908
|
+
}
|
|
1909
|
+
var handleClass = handle.$$.ptrType.registeredClass;
|
|
1910
|
+
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
1911
|
+
return ptr;
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
var init_RegisteredPointer = () => {
|
|
1918
|
+
Object.assign(RegisteredPointer.prototype, {
|
|
1919
|
+
getPointee(ptr) {
|
|
1920
|
+
if (this.rawGetPointee) {
|
|
1921
|
+
ptr = this.rawGetPointee(ptr);
|
|
1922
|
+
}
|
|
1923
|
+
return ptr;
|
|
1924
|
+
},
|
|
1925
|
+
destructor(ptr) {
|
|
1926
|
+
this.rawDestructor?.(ptr);
|
|
1927
|
+
},
|
|
1928
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
1929
|
+
'readValueFromPointer': readPointer,
|
|
1930
|
+
'fromWireType': RegisteredPointer_fromWireType,
|
|
1931
|
+
});
|
|
1932
|
+
};
|
|
1933
|
+
/** @constructor
|
|
1934
|
+
@param {*=} pointeeType,
|
|
1935
|
+
@param {*=} sharingPolicy,
|
|
1936
|
+
@param {*=} rawGetPointee,
|
|
1937
|
+
@param {*=} rawConstructor,
|
|
1938
|
+
@param {*=} rawShare,
|
|
1939
|
+
@param {*=} rawDestructor,
|
|
1940
|
+
*/
|
|
1941
|
+
function RegisteredPointer(
|
|
1942
|
+
name,
|
|
1943
|
+
registeredClass,
|
|
1944
|
+
isReference,
|
|
1945
|
+
isConst,
|
|
1946
|
+
|
|
1947
|
+
// smart pointer properties
|
|
1948
|
+
isSmartPointer,
|
|
1949
|
+
pointeeType,
|
|
1950
|
+
sharingPolicy,
|
|
1951
|
+
rawGetPointee,
|
|
1952
|
+
rawConstructor,
|
|
1953
|
+
rawShare,
|
|
1954
|
+
rawDestructor
|
|
1955
|
+
) {
|
|
1956
|
+
this.name = name;
|
|
1957
|
+
this.registeredClass = registeredClass;
|
|
1958
|
+
this.isReference = isReference;
|
|
1959
|
+
this.isConst = isConst;
|
|
1960
|
+
|
|
1961
|
+
// smart pointer properties
|
|
1962
|
+
this.isSmartPointer = isSmartPointer;
|
|
1963
|
+
this.pointeeType = pointeeType;
|
|
1964
|
+
this.sharingPolicy = sharingPolicy;
|
|
1965
|
+
this.rawGetPointee = rawGetPointee;
|
|
1966
|
+
this.rawConstructor = rawConstructor;
|
|
1967
|
+
this.rawShare = rawShare;
|
|
1968
|
+
this.rawDestructor = rawDestructor;
|
|
1969
|
+
|
|
1970
|
+
if (!isSmartPointer && registeredClass.baseClass === undefined) {
|
|
1971
|
+
if (isConst) {
|
|
1972
|
+
this['toWireType'] = constNoSmartPtrRawPointerToWireType;
|
|
1973
|
+
this.destructorFunction = null;
|
|
1974
|
+
} else {
|
|
1975
|
+
this['toWireType'] = nonConstNoSmartPtrRawPointerToWireType;
|
|
1976
|
+
this.destructorFunction = null;
|
|
1977
|
+
}
|
|
1978
|
+
} else {
|
|
1979
|
+
this['toWireType'] = genericPointerToWireType;
|
|
1980
|
+
// Here we must leave this.destructorFunction undefined, since whether genericPointerToWireType returns
|
|
1981
|
+
// a pointer that needs to be freed up is runtime-dependent, and cannot be evaluated at registration time.
|
|
1982
|
+
// TODO: Create an alternative mechanism that allows removing the use of var destructors = []; array in
|
|
1983
|
+
// craftInvokerFunction altogether.
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
/** @param {number=} numArguments */
|
|
1988
|
+
var replacePublicSymbol = (name, value, numArguments) => {
|
|
1989
|
+
if (!Module.hasOwnProperty(name)) {
|
|
1990
|
+
throwInternalError('Replacing nonexistent public symbol');
|
|
1991
|
+
}
|
|
1992
|
+
// If there's an overload table for this symbol, replace the symbol in the overload table instead.
|
|
1993
|
+
if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
|
|
1994
|
+
Module[name].overloadTable[numArguments] = value;
|
|
1995
|
+
}
|
|
1996
|
+
else {
|
|
1997
|
+
Module[name] = value;
|
|
1998
|
+
Module[name].argCount = numArguments;
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
var dynCallLegacy = (sig, ptr, args) => {
|
|
2005
|
+
assert(('dynCall_' + sig) in Module, `bad function pointer type - dynCall function not found for sig '${sig}'`);
|
|
2006
|
+
if (args?.length) {
|
|
2007
|
+
// j (64-bit integer) must be passed in as two numbers [low 32, high 32].
|
|
2008
|
+
assert(args.length === sig.substring(1).replace(/j/g, '--').length);
|
|
2009
|
+
} else {
|
|
2010
|
+
assert(sig.length == 1);
|
|
2011
|
+
}
|
|
2012
|
+
var f = Module['dynCall_' + sig];
|
|
2013
|
+
return f(ptr, ...args);
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2016
|
+
var wasmTableMirror = [];
|
|
2017
|
+
|
|
2018
|
+
var wasmTable;
|
|
2019
|
+
var getWasmTableEntry = (funcPtr) => {
|
|
2020
|
+
var func = wasmTableMirror[funcPtr];
|
|
2021
|
+
if (!func) {
|
|
2022
|
+
if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
|
|
2023
|
+
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
2024
|
+
}
|
|
2025
|
+
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
2026
|
+
return func;
|
|
2027
|
+
};
|
|
2028
|
+
|
|
2029
|
+
var dynCall = (sig, ptr, args = []) => {
|
|
2030
|
+
// Without WASM_BIGINT support we cannot directly call function with i64 as
|
|
2031
|
+
// part of their signature, so we rely on the dynCall functions generated by
|
|
2032
|
+
// wasm-emscripten-finalize
|
|
2033
|
+
if (sig.includes('j')) {
|
|
2034
|
+
return dynCallLegacy(sig, ptr, args);
|
|
2035
|
+
}
|
|
2036
|
+
assert(getWasmTableEntry(ptr), `missing table entry in dynCall: ${ptr}`);
|
|
2037
|
+
var rtn = getWasmTableEntry(ptr)(...args);
|
|
2038
|
+
return rtn;
|
|
2039
|
+
};
|
|
2040
|
+
var getDynCaller = (sig, ptr) => {
|
|
2041
|
+
assert(sig.includes('j') || sig.includes('p'), 'getDynCaller should only be called with i64 sigs')
|
|
2042
|
+
return (...args) => dynCall(sig, ptr, args);
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
|
|
2046
|
+
var embind__requireFunction = (signature, rawFunction) => {
|
|
2047
|
+
signature = readLatin1String(signature);
|
|
2048
|
+
|
|
2049
|
+
function makeDynCaller() {
|
|
2050
|
+
if (signature.includes('j')) {
|
|
2051
|
+
return getDynCaller(signature, rawFunction);
|
|
2052
|
+
}
|
|
2053
|
+
return getWasmTableEntry(rawFunction);
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
var fp = makeDynCaller();
|
|
2057
|
+
if (typeof fp != "function") {
|
|
2058
|
+
throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`);
|
|
2059
|
+
}
|
|
2060
|
+
return fp;
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
var extendError = (baseErrorType, errorName) => {
|
|
2066
|
+
var errorClass = createNamedFunction(errorName, function(message) {
|
|
2067
|
+
this.name = errorName;
|
|
2068
|
+
this.message = message;
|
|
2069
|
+
|
|
2070
|
+
var stack = (new Error(message)).stack;
|
|
2071
|
+
if (stack !== undefined) {
|
|
2072
|
+
this.stack = this.toString() + '\n' +
|
|
2073
|
+
stack.replace(/^Error(:[^\n]*)?\n/, '');
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
errorClass.prototype = Object.create(baseErrorType.prototype);
|
|
2077
|
+
errorClass.prototype.constructor = errorClass;
|
|
2078
|
+
errorClass.prototype.toString = function() {
|
|
2079
|
+
if (this.message === undefined) {
|
|
2080
|
+
return this.name;
|
|
2081
|
+
} else {
|
|
2082
|
+
return `${this.name}: ${this.message}`;
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2085
|
+
|
|
2086
|
+
return errorClass;
|
|
2087
|
+
};
|
|
2088
|
+
var UnboundTypeError;
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
var getTypeName = (type) => {
|
|
2093
|
+
var ptr = ___getTypeName(type);
|
|
2094
|
+
var rv = readLatin1String(ptr);
|
|
2095
|
+
_free(ptr);
|
|
2096
|
+
return rv;
|
|
2097
|
+
};
|
|
2098
|
+
var throwUnboundTypeError = (message, types) => {
|
|
2099
|
+
var unboundTypes = [];
|
|
2100
|
+
var seen = {};
|
|
2101
|
+
function visit(type) {
|
|
2102
|
+
if (seen[type]) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
if (registeredTypes[type]) {
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
if (typeDependencies[type]) {
|
|
2109
|
+
typeDependencies[type].forEach(visit);
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
unboundTypes.push(type);
|
|
2113
|
+
seen[type] = true;
|
|
2114
|
+
}
|
|
2115
|
+
types.forEach(visit);
|
|
2116
|
+
|
|
2117
|
+
throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
var __embind_register_class = (rawType,
|
|
2121
|
+
rawPointerType,
|
|
2122
|
+
rawConstPointerType,
|
|
2123
|
+
baseClassRawType,
|
|
2124
|
+
getActualTypeSignature,
|
|
2125
|
+
getActualType,
|
|
2126
|
+
upcastSignature,
|
|
2127
|
+
upcast,
|
|
2128
|
+
downcastSignature,
|
|
2129
|
+
downcast,
|
|
2130
|
+
name,
|
|
2131
|
+
destructorSignature,
|
|
2132
|
+
rawDestructor) => {
|
|
2133
|
+
name = readLatin1String(name);
|
|
2134
|
+
getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
|
|
2135
|
+
upcast &&= embind__requireFunction(upcastSignature, upcast);
|
|
2136
|
+
downcast &&= embind__requireFunction(downcastSignature, downcast);
|
|
2137
|
+
rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
|
|
2138
|
+
var legalFunctionName = makeLegalFunctionName(name);
|
|
2139
|
+
|
|
2140
|
+
exposePublicSymbol(legalFunctionName, function() {
|
|
2141
|
+
// this code cannot run if baseClassRawType is zero
|
|
2142
|
+
throwUnboundTypeError(`Cannot construct ${name} due to unbound types`, [baseClassRawType]);
|
|
2143
|
+
});
|
|
2144
|
+
|
|
2145
|
+
whenDependentTypesAreResolved(
|
|
2146
|
+
[rawType, rawPointerType, rawConstPointerType],
|
|
2147
|
+
baseClassRawType ? [baseClassRawType] : [],
|
|
2148
|
+
(base) => {
|
|
2149
|
+
base = base[0];
|
|
2150
|
+
|
|
2151
|
+
var baseClass;
|
|
2152
|
+
var basePrototype;
|
|
2153
|
+
if (baseClassRawType) {
|
|
2154
|
+
baseClass = base.registeredClass;
|
|
2155
|
+
basePrototype = baseClass.instancePrototype;
|
|
2156
|
+
} else {
|
|
2157
|
+
basePrototype = ClassHandle.prototype;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
var constructor = createNamedFunction(name, function(...args) {
|
|
2161
|
+
if (Object.getPrototypeOf(this) !== instancePrototype) {
|
|
2162
|
+
throw new BindingError("Use 'new' to construct " + name);
|
|
2163
|
+
}
|
|
2164
|
+
if (undefined === registeredClass.constructor_body) {
|
|
2165
|
+
throw new BindingError(name + " has no accessible constructor");
|
|
2166
|
+
}
|
|
2167
|
+
var body = registeredClass.constructor_body[args.length];
|
|
2168
|
+
if (undefined === body) {
|
|
2169
|
+
throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`);
|
|
2170
|
+
}
|
|
2171
|
+
return body.apply(this, args);
|
|
2172
|
+
});
|
|
1374
2173
|
|
|
2174
|
+
var instancePrototype = Object.create(basePrototype, {
|
|
2175
|
+
constructor: { value: constructor },
|
|
2176
|
+
});
|
|
1375
2177
|
|
|
2178
|
+
constructor.prototype = instancePrototype;
|
|
1376
2179
|
|
|
2180
|
+
var registeredClass = new RegisteredClass(name,
|
|
2181
|
+
constructor,
|
|
2182
|
+
instancePrototype,
|
|
2183
|
+
rawDestructor,
|
|
2184
|
+
baseClass,
|
|
2185
|
+
getActualType,
|
|
2186
|
+
upcast,
|
|
2187
|
+
downcast);
|
|
1377
2188
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
2189
|
+
if (registeredClass.baseClass) {
|
|
2190
|
+
// Keep track of class hierarchy. Used to allow sub-classes to inherit class functions.
|
|
2191
|
+
registeredClass.baseClass.__derivedClasses ??= [];
|
|
1381
2192
|
|
|
1382
|
-
|
|
1383
|
-
// reserve 0 and some special values. These never get de-allocated.
|
|
1384
|
-
emval_handles.push(
|
|
1385
|
-
0, 1,
|
|
1386
|
-
undefined, 1,
|
|
1387
|
-
null, 1,
|
|
1388
|
-
true, 1,
|
|
1389
|
-
false, 1,
|
|
1390
|
-
);
|
|
1391
|
-
assert(emval_handles.length === 5 * 2);
|
|
1392
|
-
Module['count_emval_handles'] = count_emval_handles;
|
|
1393
|
-
};
|
|
1394
|
-
var Emval = {
|
|
1395
|
-
toValue:(handle) => {
|
|
1396
|
-
if (!handle) {
|
|
1397
|
-
throwBindingError('Cannot use deleted val. handle = ' + handle);
|
|
1398
|
-
}
|
|
1399
|
-
// handle 2 is supposed to be `undefined`.
|
|
1400
|
-
assert(handle === 2 || emval_handles[handle] !== undefined && handle % 2 === 0, `invalid handle: ${handle}`);
|
|
1401
|
-
return emval_handles[handle];
|
|
1402
|
-
},
|
|
1403
|
-
toHandle:(value) => {
|
|
1404
|
-
switch (value) {
|
|
1405
|
-
case undefined: return 2;
|
|
1406
|
-
case null: return 4;
|
|
1407
|
-
case true: return 6;
|
|
1408
|
-
case false: return 8;
|
|
1409
|
-
default:{
|
|
1410
|
-
const handle = emval_freelist.pop() || emval_handles.length;
|
|
1411
|
-
emval_handles[handle] = value;
|
|
1412
|
-
emval_handles[handle + 1] = 1;
|
|
1413
|
-
return handle;
|
|
2193
|
+
registeredClass.baseClass.__derivedClasses.push(registeredClass);
|
|
1414
2194
|
}
|
|
1415
|
-
}
|
|
1416
|
-
},
|
|
1417
|
-
};
|
|
1418
2195
|
|
|
2196
|
+
var referenceConverter = new RegisteredPointer(name,
|
|
2197
|
+
registeredClass,
|
|
2198
|
+
true,
|
|
2199
|
+
false,
|
|
2200
|
+
false);
|
|
2201
|
+
|
|
2202
|
+
var pointerConverter = new RegisteredPointer(name + '*',
|
|
2203
|
+
registeredClass,
|
|
2204
|
+
false,
|
|
2205
|
+
false,
|
|
2206
|
+
false);
|
|
2207
|
+
|
|
2208
|
+
var constPointerConverter = new RegisteredPointer(name + ' const*',
|
|
2209
|
+
registeredClass,
|
|
2210
|
+
false,
|
|
2211
|
+
true,
|
|
2212
|
+
false);
|
|
2213
|
+
|
|
2214
|
+
registeredPointers[rawType] = {
|
|
2215
|
+
pointerType: pointerConverter,
|
|
2216
|
+
constPointerType: constPointerConverter
|
|
2217
|
+
};
|
|
1419
2218
|
|
|
1420
|
-
|
|
1421
|
-
name: 'emscripten::val',
|
|
1422
|
-
'fromWireType': (handle) => {
|
|
1423
|
-
var rv = Emval.toValue(handle);
|
|
1424
|
-
__emval_decref(handle);
|
|
1425
|
-
return rv;
|
|
1426
|
-
},
|
|
1427
|
-
'toWireType': (destructors, value) => Emval.toHandle(value),
|
|
1428
|
-
'argPackAdvance': GenericWireTypeSize,
|
|
1429
|
-
'readValueFromPointer': readPointer,
|
|
1430
|
-
destructorFunction: null, // This type does not need a destructor
|
|
2219
|
+
replacePublicSymbol(legalFunctionName, constructor);
|
|
1431
2220
|
|
|
1432
|
-
|
|
1433
|
-
|
|
2221
|
+
return [referenceConverter, pointerConverter, constPointerConverter];
|
|
2222
|
+
}
|
|
2223
|
+
);
|
|
1434
2224
|
};
|
|
1435
|
-
var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
|
|
1436
2225
|
|
|
1437
|
-
var
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
return v.toString();
|
|
1444
|
-
} else {
|
|
1445
|
-
return '' + v;
|
|
2226
|
+
var heap32VectorToArray = (count, firstElement) => {
|
|
2227
|
+
var array = [];
|
|
2228
|
+
for (var i = 0; i < count; i++) {
|
|
2229
|
+
// TODO(https://github.com/emscripten-core/emscripten/issues/17310):
|
|
2230
|
+
// Find a way to hoist the `>> 2` or `>> 3` out of this loop.
|
|
2231
|
+
array.push(HEAPU32[(((firstElement)+(i * 4))>>2)]);
|
|
1446
2232
|
}
|
|
2233
|
+
return array;
|
|
1447
2234
|
};
|
|
1448
2235
|
|
|
1449
|
-
var floatReadValueFromPointer = (name, width) => {
|
|
1450
|
-
switch (width) {
|
|
1451
|
-
case 4: return function(pointer) {
|
|
1452
|
-
return this['fromWireType'](HEAPF32[((pointer)>>2)]);
|
|
1453
|
-
};
|
|
1454
|
-
case 8: return function(pointer) {
|
|
1455
|
-
return this['fromWireType'](HEAPF64[((pointer)>>3)]);
|
|
1456
|
-
};
|
|
1457
|
-
default:
|
|
1458
|
-
throw new TypeError(`invalid float width (${width}): ${name}`);
|
|
1459
|
-
}
|
|
1460
|
-
};
|
|
1461
2236
|
|
|
1462
2237
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
name,
|
|
1467
|
-
'fromWireType': (value) => value,
|
|
1468
|
-
'toWireType': (destructors, value) => {
|
|
1469
|
-
if (typeof value != "number" && typeof value != "boolean") {
|
|
1470
|
-
throw new TypeError(`Cannot convert ${embindRepr(value)} to ${this.name}`);
|
|
1471
|
-
}
|
|
1472
|
-
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
1473
|
-
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
1474
|
-
return value;
|
|
1475
|
-
},
|
|
1476
|
-
'argPackAdvance': GenericWireTypeSize,
|
|
1477
|
-
'readValueFromPointer': floatReadValueFromPointer(name, size),
|
|
1478
|
-
destructorFunction: null, // This type does not need a destructor
|
|
1479
|
-
});
|
|
1480
|
-
};
|
|
1481
|
-
|
|
1482
|
-
var createNamedFunction = (name, body) => Object.defineProperty(body, 'name', {
|
|
1483
|
-
value: name
|
|
1484
|
-
});
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
1485
2241
|
|
|
1486
2242
|
|
|
1487
2243
|
|
|
@@ -1633,203 +2389,254 @@ function dbg(...args) {
|
|
|
1633
2389
|
var invokerFn = newFunc(Function, args)(...closureArgs);
|
|
1634
2390
|
return createNamedFunction(humanName, invokerFn);
|
|
1635
2391
|
}
|
|
2392
|
+
var __embind_register_class_constructor = (
|
|
2393
|
+
rawClassType,
|
|
2394
|
+
argCount,
|
|
2395
|
+
rawArgTypesAddr,
|
|
2396
|
+
invokerSignature,
|
|
2397
|
+
invoker,
|
|
2398
|
+
rawConstructor
|
|
2399
|
+
) => {
|
|
2400
|
+
assert(argCount > 0);
|
|
2401
|
+
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
2402
|
+
invoker = embind__requireFunction(invokerSignature, invoker);
|
|
2403
|
+
var args = [rawConstructor];
|
|
2404
|
+
var destructors = [];
|
|
1636
2405
|
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
var
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
}
|
|
1646
|
-
|
|
2406
|
+
whenDependentTypesAreResolved([], [rawClassType], (classType) => {
|
|
2407
|
+
classType = classType[0];
|
|
2408
|
+
var humanName = `constructor ${classType.name}`;
|
|
2409
|
+
|
|
2410
|
+
if (undefined === classType.registeredClass.constructor_body) {
|
|
2411
|
+
classType.registeredClass.constructor_body = [];
|
|
2412
|
+
}
|
|
2413
|
+
if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
|
|
2414
|
+
throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount-1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
|
|
2415
|
+
}
|
|
2416
|
+
classType.registeredClass.constructor_body[argCount - 1] = () => {
|
|
2417
|
+
throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`, rawArgTypes);
|
|
1647
2418
|
};
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
2419
|
+
|
|
2420
|
+
whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
|
|
2421
|
+
// Insert empty slot for context type (argTypes[1]).
|
|
2422
|
+
argTypes.splice(1, 0, null);
|
|
2423
|
+
classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
|
|
2424
|
+
return [];
|
|
2425
|
+
});
|
|
2426
|
+
return [];
|
|
2427
|
+
});
|
|
2428
|
+
};
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
|
|
2436
|
+
var getFunctionName = (signature) => {
|
|
2437
|
+
signature = signature.trim();
|
|
2438
|
+
const argsIndex = signature.indexOf("(");
|
|
2439
|
+
if (argsIndex !== -1) {
|
|
2440
|
+
assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
|
|
2441
|
+
return signature.substr(0, argsIndex);
|
|
2442
|
+
} else {
|
|
2443
|
+
return signature;
|
|
1651
2444
|
}
|
|
1652
2445
|
};
|
|
2446
|
+
var __embind_register_class_function = (rawClassType,
|
|
2447
|
+
methodName,
|
|
2448
|
+
argCount,
|
|
2449
|
+
rawArgTypesAddr, // [ReturnType, ThisType, Args...]
|
|
2450
|
+
invokerSignature,
|
|
2451
|
+
rawInvoker,
|
|
2452
|
+
context,
|
|
2453
|
+
isPureVirtual,
|
|
2454
|
+
isAsync) => {
|
|
2455
|
+
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
2456
|
+
methodName = readLatin1String(methodName);
|
|
2457
|
+
methodName = getFunctionName(methodName);
|
|
2458
|
+
rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);
|
|
2459
|
+
|
|
2460
|
+
whenDependentTypesAreResolved([], [rawClassType], (classType) => {
|
|
2461
|
+
classType = classType[0];
|
|
2462
|
+
var humanName = `${classType.name}.${methodName}`;
|
|
2463
|
+
|
|
2464
|
+
if (methodName.startsWith("@@")) {
|
|
2465
|
+
methodName = Symbol[methodName.substring(2)];
|
|
2466
|
+
}
|
|
1653
2467
|
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
if (Module.hasOwnProperty(name)) {
|
|
1657
|
-
if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
|
|
1658
|
-
throwBindingError(`Cannot register public name '${name}' twice`);
|
|
2468
|
+
if (isPureVirtual) {
|
|
2469
|
+
classType.registeredClass.pureVirtualFunctions.push(methodName);
|
|
1659
2470
|
}
|
|
1660
2471
|
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
ensureOverloadTable(Module, name, name);
|
|
1664
|
-
if (Module.hasOwnProperty(numArguments)) {
|
|
1665
|
-
throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
|
|
2472
|
+
function unboundTypesHandler() {
|
|
2473
|
+
throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`, rawArgTypes);
|
|
1666
2474
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
2475
|
+
|
|
2476
|
+
var proto = classType.registeredClass.instancePrototype;
|
|
2477
|
+
var method = proto[methodName];
|
|
2478
|
+
if (undefined === method || (undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2)) {
|
|
2479
|
+
// This is the first overload to be registered, OR we are replacing a
|
|
2480
|
+
// function in the base class with a function in the derived class.
|
|
2481
|
+
unboundTypesHandler.argCount = argCount - 2;
|
|
2482
|
+
unboundTypesHandler.className = classType.name;
|
|
2483
|
+
proto[methodName] = unboundTypesHandler;
|
|
2484
|
+
} else {
|
|
2485
|
+
// There was an existing function with the same name registered. Set up
|
|
2486
|
+
// a function overload routing table.
|
|
2487
|
+
ensureOverloadTable(proto, methodName, humanName);
|
|
2488
|
+
proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
|
|
1674
2489
|
}
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
2490
|
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
2491
|
+
whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
|
|
2492
|
+
var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync);
|
|
2493
|
+
|
|
2494
|
+
// Replace the initial unbound-handler-stub function with the
|
|
2495
|
+
// appropriate member function, now that all types are resolved. If
|
|
2496
|
+
// multiple overloads are registered for this function, the function
|
|
2497
|
+
// goes into an overload table.
|
|
2498
|
+
if (undefined === proto[methodName].overloadTable) {
|
|
2499
|
+
// Set argCount in case an overload is registered later
|
|
2500
|
+
memberFunction.argCount = argCount - 2;
|
|
2501
|
+
proto[methodName] = memberFunction;
|
|
2502
|
+
} else {
|
|
2503
|
+
proto[methodName].overloadTable[argCount - 2] = memberFunction;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
return [];
|
|
2507
|
+
});
|
|
2508
|
+
return [];
|
|
2509
|
+
});
|
|
1686
2510
|
};
|
|
2511
|
+
|
|
1687
2512
|
|
|
2513
|
+
var emval_freelist = [];
|
|
1688
2514
|
|
|
1689
|
-
|
|
1690
|
-
var
|
|
1691
|
-
if (
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
|
|
1696
|
-
Module[name].overloadTable[numArguments] = value;
|
|
1697
|
-
}
|
|
1698
|
-
else {
|
|
1699
|
-
Module[name] = value;
|
|
1700
|
-
Module[name].argCount = numArguments;
|
|
2515
|
+
var emval_handles = [];
|
|
2516
|
+
var __emval_decref = (handle) => {
|
|
2517
|
+
if (handle > 9 && 0 === --emval_handles[handle + 1]) {
|
|
2518
|
+
assert(emval_handles[handle] !== undefined, `Decref for unallocated handle.`);
|
|
2519
|
+
emval_handles[handle] = undefined;
|
|
2520
|
+
emval_freelist.push(handle);
|
|
1701
2521
|
}
|
|
1702
2522
|
};
|
|
1703
2523
|
|
|
1704
2524
|
|
|
1705
2525
|
|
|
1706
|
-
var dynCallLegacy = (sig, ptr, args) => {
|
|
1707
|
-
assert(('dynCall_' + sig) in Module, `bad function pointer type - dynCall function not found for sig '${sig}'`);
|
|
1708
|
-
if (args?.length) {
|
|
1709
|
-
// j (64-bit integer) must be passed in as two numbers [low 32, high 32].
|
|
1710
|
-
assert(args.length === sig.substring(1).replace(/j/g, '--').length);
|
|
1711
|
-
} else {
|
|
1712
|
-
assert(sig.length == 1);
|
|
1713
|
-
}
|
|
1714
|
-
var f = Module['dynCall_' + sig];
|
|
1715
|
-
return f(ptr, ...args);
|
|
1716
|
-
};
|
|
1717
2526
|
|
|
1718
|
-
var wasmTableMirror = [];
|
|
1719
2527
|
|
|
1720
|
-
var
|
|
1721
|
-
|
|
1722
|
-
var func = wasmTableMirror[funcPtr];
|
|
1723
|
-
if (!func) {
|
|
1724
|
-
if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
|
|
1725
|
-
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
1726
|
-
}
|
|
1727
|
-
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
1728
|
-
return func;
|
|
2528
|
+
var count_emval_handles = () => {
|
|
2529
|
+
return emval_handles.length / 2 - 5 - emval_freelist.length;
|
|
1729
2530
|
};
|
|
1730
2531
|
|
|
1731
|
-
var
|
|
1732
|
-
//
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
var getDynCaller = (sig, ptr) => {
|
|
1743
|
-
assert(sig.includes('j') || sig.includes('p'), 'getDynCaller should only be called with i64 sigs')
|
|
1744
|
-
return (...args) => dynCall(sig, ptr, args);
|
|
2532
|
+
var init_emval = () => {
|
|
2533
|
+
// reserve 0 and some special values. These never get de-allocated.
|
|
2534
|
+
emval_handles.push(
|
|
2535
|
+
0, 1,
|
|
2536
|
+
undefined, 1,
|
|
2537
|
+
null, 1,
|
|
2538
|
+
true, 1,
|
|
2539
|
+
false, 1,
|
|
2540
|
+
);
|
|
2541
|
+
assert(emval_handles.length === 5 * 2);
|
|
2542
|
+
Module['count_emval_handles'] = count_emval_handles;
|
|
1745
2543
|
};
|
|
2544
|
+
var Emval = {
|
|
2545
|
+
toValue:(handle) => {
|
|
2546
|
+
if (!handle) {
|
|
2547
|
+
throwBindingError('Cannot use deleted val. handle = ' + handle);
|
|
2548
|
+
}
|
|
2549
|
+
// handle 2 is supposed to be `undefined`.
|
|
2550
|
+
assert(handle === 2 || emval_handles[handle] !== undefined && handle % 2 === 0, `invalid handle: ${handle}`);
|
|
2551
|
+
return emval_handles[handle];
|
|
2552
|
+
},
|
|
2553
|
+
toHandle:(value) => {
|
|
2554
|
+
switch (value) {
|
|
2555
|
+
case undefined: return 2;
|
|
2556
|
+
case null: return 4;
|
|
2557
|
+
case true: return 6;
|
|
2558
|
+
case false: return 8;
|
|
2559
|
+
default:{
|
|
2560
|
+
const handle = emval_freelist.pop() || emval_handles.length;
|
|
2561
|
+
emval_handles[handle] = value;
|
|
2562
|
+
emval_handles[handle + 1] = 1;
|
|
2563
|
+
return handle;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
},
|
|
2567
|
+
};
|
|
1746
2568
|
|
|
1747
2569
|
|
|
1748
|
-
var
|
|
1749
|
-
|
|
2570
|
+
var EmValType = {
|
|
2571
|
+
name: 'emscripten::val',
|
|
2572
|
+
'fromWireType': (handle) => {
|
|
2573
|
+
var rv = Emval.toValue(handle);
|
|
2574
|
+
__emval_decref(handle);
|
|
2575
|
+
return rv;
|
|
2576
|
+
},
|
|
2577
|
+
'toWireType': (destructors, value) => Emval.toHandle(value),
|
|
2578
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2579
|
+
'readValueFromPointer': readPointer,
|
|
2580
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1750
2581
|
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
2582
|
+
// TODO: do we need a deleteObject here? write a test where
|
|
2583
|
+
// emval is passed into JS via an interface
|
|
2584
|
+
};
|
|
2585
|
+
var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
|
|
2586
|
+
|
|
2587
|
+
var embindRepr = (v) => {
|
|
2588
|
+
if (v === null) {
|
|
2589
|
+
return 'null';
|
|
1756
2590
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
2591
|
+
var t = typeof v;
|
|
2592
|
+
if (t === 'object' || t === 'array' || t === 'function') {
|
|
2593
|
+
return v.toString();
|
|
2594
|
+
} else {
|
|
2595
|
+
return '' + v;
|
|
1761
2596
|
}
|
|
1762
|
-
return fp;
|
|
1763
2597
|
};
|
|
1764
2598
|
|
|
2599
|
+
var floatReadValueFromPointer = (name, width) => {
|
|
2600
|
+
switch (width) {
|
|
2601
|
+
case 4: return function(pointer) {
|
|
2602
|
+
return this['fromWireType'](HEAPF32[((pointer)>>2)]);
|
|
2603
|
+
};
|
|
2604
|
+
case 8: return function(pointer) {
|
|
2605
|
+
return this['fromWireType'](HEAPF64[((pointer)>>3)]);
|
|
2606
|
+
};
|
|
2607
|
+
default:
|
|
2608
|
+
throw new TypeError(`invalid float width (${width}): ${name}`);
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
1765
2611
|
|
|
1766
2612
|
|
|
1767
|
-
var
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
2613
|
+
var __embind_register_float = (rawType, name, size) => {
|
|
2614
|
+
name = readLatin1String(name);
|
|
2615
|
+
registerType(rawType, {
|
|
2616
|
+
name,
|
|
2617
|
+
'fromWireType': (value) => value,
|
|
2618
|
+
'toWireType': (destructors, value) => {
|
|
2619
|
+
if (typeof value != "number" && typeof value != "boolean") {
|
|
2620
|
+
throw new TypeError(`Cannot convert ${embindRepr(value)} to ${this.name}`);
|
|
2621
|
+
}
|
|
2622
|
+
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
2623
|
+
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
2624
|
+
return value;
|
|
2625
|
+
},
|
|
2626
|
+
'argPackAdvance': GenericWireTypeSize,
|
|
2627
|
+
'readValueFromPointer': floatReadValueFromPointer(name, size),
|
|
2628
|
+
destructorFunction: null, // This type does not need a destructor
|
|
1777
2629
|
});
|
|
1778
|
-
errorClass.prototype = Object.create(baseErrorType.prototype);
|
|
1779
|
-
errorClass.prototype.constructor = errorClass;
|
|
1780
|
-
errorClass.prototype.toString = function() {
|
|
1781
|
-
if (this.message === undefined) {
|
|
1782
|
-
return this.name;
|
|
1783
|
-
} else {
|
|
1784
|
-
return `${this.name}: ${this.message}`;
|
|
1785
|
-
}
|
|
1786
|
-
};
|
|
1787
|
-
|
|
1788
|
-
return errorClass;
|
|
1789
2630
|
};
|
|
1790
|
-
|
|
2631
|
+
|
|
2632
|
+
|
|
2633
|
+
|
|
1791
2634
|
|
|
1792
2635
|
|
|
1793
2636
|
|
|
1794
|
-
var getTypeName = (type) => {
|
|
1795
|
-
var ptr = ___getTypeName(type);
|
|
1796
|
-
var rv = readLatin1String(ptr);
|
|
1797
|
-
_free(ptr);
|
|
1798
|
-
return rv;
|
|
1799
|
-
};
|
|
1800
|
-
var throwUnboundTypeError = (message, types) => {
|
|
1801
|
-
var unboundTypes = [];
|
|
1802
|
-
var seen = {};
|
|
1803
|
-
function visit(type) {
|
|
1804
|
-
if (seen[type]) {
|
|
1805
|
-
return;
|
|
1806
|
-
}
|
|
1807
|
-
if (registeredTypes[type]) {
|
|
1808
|
-
return;
|
|
1809
|
-
}
|
|
1810
|
-
if (typeDependencies[type]) {
|
|
1811
|
-
typeDependencies[type].forEach(visit);
|
|
1812
|
-
return;
|
|
1813
|
-
}
|
|
1814
|
-
unboundTypes.push(type);
|
|
1815
|
-
seen[type] = true;
|
|
1816
|
-
}
|
|
1817
|
-
types.forEach(visit);
|
|
1818
2637
|
|
|
1819
|
-
throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
|
|
1820
|
-
};
|
|
1821
2638
|
|
|
1822
2639
|
|
|
1823
|
-
var getFunctionName = (signature) => {
|
|
1824
|
-
signature = signature.trim();
|
|
1825
|
-
const argsIndex = signature.indexOf("(");
|
|
1826
|
-
if (argsIndex !== -1) {
|
|
1827
|
-
assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
|
|
1828
|
-
return signature.substr(0, argsIndex);
|
|
1829
|
-
} else {
|
|
1830
|
-
return signature;
|
|
1831
|
-
}
|
|
1832
|
-
};
|
|
1833
2640
|
var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync) => {
|
|
1834
2641
|
var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
1835
2642
|
name = readLatin1String(name);
|
|
@@ -1948,6 +2755,10 @@ function dbg(...args) {
|
|
|
1948
2755
|
});
|
|
1949
2756
|
};
|
|
1950
2757
|
|
|
2758
|
+
var __embind_register_optional = (rawOptionalType, rawType) => {
|
|
2759
|
+
__embind_register_emval(rawOptionalType);
|
|
2760
|
+
};
|
|
2761
|
+
|
|
1951
2762
|
|
|
1952
2763
|
|
|
1953
2764
|
|
|
@@ -2442,32 +3253,6 @@ function dbg(...args) {
|
|
|
2442
3253
|
});
|
|
2443
3254
|
};
|
|
2444
3255
|
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
var requireRegisteredType = (rawType, humanName) => {
|
|
2449
|
-
var impl = registeredTypes[rawType];
|
|
2450
|
-
if (undefined === impl) {
|
|
2451
|
-
throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
|
|
2452
|
-
}
|
|
2453
|
-
return impl;
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
var emval_returnValue = (returnType, destructorsRef, handle) => {
|
|
2457
|
-
var destructors = [];
|
|
2458
|
-
var result = returnType['toWireType'](destructors, handle);
|
|
2459
|
-
if (destructors.length) {
|
|
2460
|
-
// void, primitives and any other types w/o destructors don't need to allocate a handle
|
|
2461
|
-
HEAPU32[((destructorsRef)>>2)] = Emval.toHandle(destructors);
|
|
2462
|
-
}
|
|
2463
|
-
return result;
|
|
2464
|
-
};
|
|
2465
|
-
var __emval_as = (handle, returnType, destructorsRef) => {
|
|
2466
|
-
handle = Emval.toValue(handle);
|
|
2467
|
-
returnType = requireRegisteredType(returnType, 'emval::as');
|
|
2468
|
-
return emval_returnValue(returnType, destructorsRef, handle);
|
|
2469
|
-
};
|
|
2470
|
-
|
|
2471
3256
|
var emval_methodCallers = [];
|
|
2472
3257
|
|
|
2473
3258
|
var __emval_call = (caller, handle, destructorsRef, args) => {
|
|
@@ -2512,6 +3297,15 @@ function dbg(...args) {
|
|
|
2512
3297
|
return id;
|
|
2513
3298
|
};
|
|
2514
3299
|
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
var requireRegisteredType = (rawType, humanName) => {
|
|
3303
|
+
var impl = registeredTypes[rawType];
|
|
3304
|
+
if (undefined === impl) {
|
|
3305
|
+
throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
|
|
3306
|
+
}
|
|
3307
|
+
return impl;
|
|
3308
|
+
};
|
|
2515
3309
|
var emval_lookupTypes = (argCount, argTypes) => {
|
|
2516
3310
|
var a = new Array(argCount);
|
|
2517
3311
|
for (var i = 0; i < argCount; ++i) {
|
|
@@ -2524,6 +3318,15 @@ function dbg(...args) {
|
|
|
2524
3318
|
|
|
2525
3319
|
var reflectConstruct = Reflect.construct;
|
|
2526
3320
|
|
|
3321
|
+
var emval_returnValue = (returnType, destructorsRef, handle) => {
|
|
3322
|
+
var destructors = [];
|
|
3323
|
+
var result = returnType['toWireType'](destructors, handle);
|
|
3324
|
+
if (destructors.length) {
|
|
3325
|
+
// void, primitives and any other types w/o destructors don't need to allocate a handle
|
|
3326
|
+
HEAPU32[((destructorsRef)>>2)] = Emval.toHandle(destructors);
|
|
3327
|
+
}
|
|
3328
|
+
return result;
|
|
3329
|
+
};
|
|
2527
3330
|
|
|
2528
3331
|
var __emval_get_method_caller = (argCount, argTypes, kind) => {
|
|
2529
3332
|
var types = emval_lookupTypes(argCount, argTypes);
|
|
@@ -2566,12 +3369,6 @@ function dbg(...args) {
|
|
|
2566
3369
|
return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
|
|
2567
3370
|
};
|
|
2568
3371
|
|
|
2569
|
-
var __emval_get_property = (handle, key) => {
|
|
2570
|
-
handle = Emval.toValue(handle);
|
|
2571
|
-
key = Emval.toValue(key);
|
|
2572
|
-
return Emval.toHandle(handle[key]);
|
|
2573
|
-
};
|
|
2574
|
-
|
|
2575
3372
|
var __emval_new_array = () => Emval.toHandle([]);
|
|
2576
3373
|
|
|
2577
3374
|
|
|
@@ -2757,8 +3554,11 @@ function dbg(...args) {
|
|
|
2757
3554
|
InternalError = Module['InternalError'] = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
|
|
2758
3555
|
embind_init_charCodes();
|
|
2759
3556
|
BindingError = Module['BindingError'] = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }};
|
|
2760
|
-
|
|
3557
|
+
init_ClassHandle();
|
|
3558
|
+
init_embind();;
|
|
3559
|
+
init_RegisteredPointer();
|
|
2761
3560
|
UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
|
|
3561
|
+
init_emval();;
|
|
2762
3562
|
function checkIncomingModuleAPI() {
|
|
2763
3563
|
ignoredModuleProp('fetchSettings');
|
|
2764
3564
|
}
|
|
@@ -2772,6 +3572,12 @@ var wasmImports = {
|
|
|
2772
3572
|
/** @export */
|
|
2773
3573
|
_embind_register_bool: __embind_register_bool,
|
|
2774
3574
|
/** @export */
|
|
3575
|
+
_embind_register_class: __embind_register_class,
|
|
3576
|
+
/** @export */
|
|
3577
|
+
_embind_register_class_constructor: __embind_register_class_constructor,
|
|
3578
|
+
/** @export */
|
|
3579
|
+
_embind_register_class_function: __embind_register_class_function,
|
|
3580
|
+
/** @export */
|
|
2775
3581
|
_embind_register_emval: __embind_register_emval,
|
|
2776
3582
|
/** @export */
|
|
2777
3583
|
_embind_register_float: __embind_register_float,
|
|
@@ -2782,6 +3588,8 @@ var wasmImports = {
|
|
|
2782
3588
|
/** @export */
|
|
2783
3589
|
_embind_register_memory_view: __embind_register_memory_view,
|
|
2784
3590
|
/** @export */
|
|
3591
|
+
_embind_register_optional: __embind_register_optional,
|
|
3592
|
+
/** @export */
|
|
2785
3593
|
_embind_register_std_string: __embind_register_std_string,
|
|
2786
3594
|
/** @export */
|
|
2787
3595
|
_embind_register_std_wstring: __embind_register_std_wstring,
|
|
@@ -2792,8 +3600,6 @@ var wasmImports = {
|
|
|
2792
3600
|
/** @export */
|
|
2793
3601
|
_embind_register_void: __embind_register_void,
|
|
2794
3602
|
/** @export */
|
|
2795
|
-
_emval_as: __emval_as,
|
|
2796
|
-
/** @export */
|
|
2797
3603
|
_emval_call: __emval_call,
|
|
2798
3604
|
/** @export */
|
|
2799
3605
|
_emval_decref: __emval_decref,
|
|
@@ -2802,8 +3608,6 @@ var wasmImports = {
|
|
|
2802
3608
|
/** @export */
|
|
2803
3609
|
_emval_get_method_caller: __emval_get_method_caller,
|
|
2804
3610
|
/** @export */
|
|
2805
|
-
_emval_get_property: __emval_get_property,
|
|
2806
|
-
/** @export */
|
|
2807
3611
|
_emval_new_array: __emval_new_array,
|
|
2808
3612
|
/** @export */
|
|
2809
3613
|
_emval_new_cstring: __emval_new_cstring,
|
|
@@ -3021,38 +3825,10 @@ var missingLibrarySymbols = [
|
|
|
3021
3825
|
'demangle',
|
|
3022
3826
|
'getFunctionArgsName',
|
|
3023
3827
|
'createJsInvokerSignature',
|
|
3024
|
-
'init_embind',
|
|
3025
|
-
'getBasestPointer',
|
|
3026
3828
|
'registerInheritedInstance',
|
|
3027
3829
|
'unregisterInheritedInstance',
|
|
3028
|
-
'getInheritedInstance',
|
|
3029
|
-
'getInheritedInstanceCount',
|
|
3030
|
-
'getLiveInheritedInstances',
|
|
3031
3830
|
'enumReadValueFromPointer',
|
|
3032
|
-
'genericPointerToWireType',
|
|
3033
|
-
'constNoSmartPtrRawPointerToWireType',
|
|
3034
|
-
'nonConstNoSmartPtrRawPointerToWireType',
|
|
3035
|
-
'init_RegisteredPointer',
|
|
3036
|
-
'RegisteredPointer',
|
|
3037
|
-
'RegisteredPointer_fromWireType',
|
|
3038
|
-
'runDestructor',
|
|
3039
|
-
'releaseClassHandle',
|
|
3040
|
-
'detachFinalizer',
|
|
3041
|
-
'attachFinalizer',
|
|
3042
|
-
'makeClassHandle',
|
|
3043
|
-
'init_ClassHandle',
|
|
3044
|
-
'ClassHandle',
|
|
3045
|
-
'throwInstanceAlreadyDeleted',
|
|
3046
|
-
'flushPendingDeletes',
|
|
3047
|
-
'setDelayFunction',
|
|
3048
|
-
'RegisteredClass',
|
|
3049
|
-
'shallowCopyInternalPointer',
|
|
3050
|
-
'downcastPointer',
|
|
3051
|
-
'upcastPointer',
|
|
3052
3831
|
'validateThis',
|
|
3053
|
-
'char_0',
|
|
3054
|
-
'char_9',
|
|
3055
|
-
'makeLegalFunctionName',
|
|
3056
3832
|
];
|
|
3057
3833
|
missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
3058
3834
|
|
|
@@ -3187,6 +3963,7 @@ var unexportedSymbols = [
|
|
|
3187
3963
|
'PureVirtualError',
|
|
3188
3964
|
'GenericWireTypeSize',
|
|
3189
3965
|
'EmValType',
|
|
3966
|
+
'init_embind',
|
|
3190
3967
|
'throwUnboundTypeError',
|
|
3191
3968
|
'ensureOverloadTable',
|
|
3192
3969
|
'exposePublicSymbol',
|
|
@@ -3195,6 +3972,10 @@ var unexportedSymbols = [
|
|
|
3195
3972
|
'createNamedFunction',
|
|
3196
3973
|
'embindRepr',
|
|
3197
3974
|
'registeredInstances',
|
|
3975
|
+
'getBasestPointer',
|
|
3976
|
+
'getInheritedInstance',
|
|
3977
|
+
'getInheritedInstanceCount',
|
|
3978
|
+
'getLiveInheritedInstances',
|
|
3198
3979
|
'registeredPointers',
|
|
3199
3980
|
'registerType',
|
|
3200
3981
|
'integerReadValueFromPointer',
|
|
@@ -3204,10 +3985,33 @@ var unexportedSymbols = [
|
|
|
3204
3985
|
'newFunc',
|
|
3205
3986
|
'craftInvokerFunction',
|
|
3206
3987
|
'embind__requireFunction',
|
|
3988
|
+
'genericPointerToWireType',
|
|
3989
|
+
'constNoSmartPtrRawPointerToWireType',
|
|
3990
|
+
'nonConstNoSmartPtrRawPointerToWireType',
|
|
3991
|
+
'init_RegisteredPointer',
|
|
3992
|
+
'RegisteredPointer',
|
|
3993
|
+
'RegisteredPointer_fromWireType',
|
|
3994
|
+
'runDestructor',
|
|
3995
|
+
'releaseClassHandle',
|
|
3207
3996
|
'finalizationRegistry',
|
|
3208
3997
|
'detachFinalizer_deps',
|
|
3998
|
+
'detachFinalizer',
|
|
3999
|
+
'attachFinalizer',
|
|
4000
|
+
'makeClassHandle',
|
|
4001
|
+
'init_ClassHandle',
|
|
4002
|
+
'ClassHandle',
|
|
4003
|
+
'throwInstanceAlreadyDeleted',
|
|
3209
4004
|
'deletionQueue',
|
|
4005
|
+
'flushPendingDeletes',
|
|
3210
4006
|
'delayFunction',
|
|
4007
|
+
'setDelayFunction',
|
|
4008
|
+
'RegisteredClass',
|
|
4009
|
+
'shallowCopyInternalPointer',
|
|
4010
|
+
'downcastPointer',
|
|
4011
|
+
'upcastPointer',
|
|
4012
|
+
'char_0',
|
|
4013
|
+
'char_9',
|
|
4014
|
+
'makeLegalFunctionName',
|
|
3211
4015
|
'emval_freelist',
|
|
3212
4016
|
'emval_handles',
|
|
3213
4017
|
'emval_symbols',
|