@@ -66,8 +66,6 @@ class Interface {
66
66
this . ctx = ctx ;
67
67
this . idl = idl ;
68
68
this . name = idl . name ;
69
- this . sharedConstructorName = `Shared${ this . name } ` ;
70
-
71
69
for ( const member of this . idl . members ) {
72
70
member . definingInterface = this . name ;
73
71
}
@@ -1407,15 +1405,15 @@ class Interface {
1407
1405
}
1408
1406
1409
1407
generateInstall ( ) {
1410
- const { idl, name, sharedConstructorName } = this ;
1408
+ const { idl, name } = this ;
1411
1409
1412
1410
this . str += `
1413
1411
install(globalObject) {
1414
1412
` ;
1415
1413
1416
1414
const ctor = this . getConstructor ( ) ;
1417
1415
this . str += `
1418
- const ${ name } = function(${ formatArgs ( ctor . argNames ) } ) {
1416
+ const ctor = function ${ name } (${ formatArgs ( ctor . argNames ) } ) {
1419
1417
${ ctor . body }
1420
1418
};
1421
1419
` ;
@@ -1426,7 +1424,7 @@ class Interface {
1426
1424
] ;
1427
1425
if ( staticPropertyNames . length ) {
1428
1426
this . str += `
1429
- Object.defineProperties(${ name } , {
1427
+ Object.defineProperties(ctor , {
1430
1428
` ;
1431
1429
1432
1430
for ( const staticProperty of staticPropertyNames ) {
@@ -1436,7 +1434,7 @@ class Interface {
1436
1434
propertyKey . replace ( "[" , "" ) . replace ( "]" , "" ) :
1437
1435
`"${ propertyKey } "` ;
1438
1436
1439
- this . str += `${ propertyKey } : Object.getOwnPropertyDescriptor(${ sharedConstructorName } , ${ propertyValue } ),\n` ;
1437
+ this . str += `${ propertyKey } : Object.getOwnPropertyDescriptor(${ name } , ${ propertyValue } ),\n` ;
1440
1438
}
1441
1439
1442
1440
this . str += `
@@ -1464,14 +1462,14 @@ class Interface {
1464
1462
// newly created constructor.
1465
1463
this . str += `
1466
1464
Object.defineProperties(proto, {
1467
- ...Object.getOwnPropertyDescriptors(${ sharedConstructorName } .prototype),
1465
+ ...Object.getOwnPropertyDescriptors(${ name } .prototype),
1468
1466
constructor: {
1469
1467
writable: true,
1470
1468
configurable: true,
1471
- value: ${ name }
1469
+ value: ctor
1472
1470
}
1473
1471
});
1474
- Object.defineProperty(${ name } , "prototype", {
1472
+ Object.defineProperty(ctor , "prototype", {
1475
1473
writable: false,
1476
1474
value: proto
1477
1475
});
@@ -1483,12 +1481,12 @@ class Interface {
1483
1481
if (globalObject[ctorRegistry] === undefined) {
1484
1482
globalObject[ctorRegistry] = {};
1485
1483
}
1486
- globalObject[ctorRegistry]["${ name } "] = ${ name } ;
1484
+ globalObject[ctorRegistry]["${ name } "] = ctor ;
1487
1485
1488
1486
Object.defineProperty(globalObject, "${ name } ", {
1489
1487
configurable: true,
1490
1488
writable: true,
1491
- value: ${ name }
1489
+ value: ctor
1492
1490
});
1493
1491
},
1494
1492
` ;
@@ -1497,7 +1495,7 @@ class Interface {
1497
1495
generate ( ) {
1498
1496
this . generateIterator ( ) ;
1499
1497
1500
- this . str += `class ${ this . sharedConstructorName } {` ;
1498
+ this . str += `class ${ this . name } {` ;
1501
1499
1502
1500
this . generateOffInstanceMethods ( ) ;
1503
1501
0 commit comments