Skip to content

Commit a2ba621

Browse files
committed
revert symbol rename
1 parent bb4a763 commit a2ba621

File tree

5 files changed

+1152
-1032
lines changed

5 files changed

+1152
-1032
lines changed

lib/constructs/attribute.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class Attribute {
3232
throw new TypeError("Illegal invocation");
3333
}
3434
`;
35-
let getterBody = `return utils.tryWrapperForImpl(${objName}[implSymbol]["${this.idl.name}"]);`;
36-
let setterBody = `${objName}[implSymbol]["${this.idl.name}"] = V;`;
35+
let getterBody = `return utils.tryWrapperForImpl(${objName}[impl]["${this.idl.name}"]);`;
36+
let setterBody = `${objName}[impl]["${this.idl.name}"] = V;`;
3737
if (conversions[this.idl.idlType.idlType]) {
38-
getterBody = `return ${objName}[implSymbol]["${this.idl.name}"];`;
38+
getterBody = `return ${objName}[impl]["${this.idl.name}"];`;
3939
}
4040

4141
const addMethod = this.static ?

lib/constructs/interface.js

+53-49
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class Interface {
404404
value: function next() {
405405
const internal = this[utils.iterInternalSymbol];
406406
const { target, kind, index } = internal;
407-
const values = Array.from(target[implSymbol]);
407+
const values = Array.from(target[impl]);
408408
const len = values.length;
409409
if (index >= len) {
410410
return { value: undefined, done: true };
@@ -498,9 +498,9 @@ class Interface {
498498
}
499499

500500
generateRequires() {
501-
this.requires.addRaw("implSymbol", "utils.implSymbol");
501+
this.requires.addRaw("impl", "utils.implSymbol");
502+
this.requires.addRaw("ctorRegistry", "utils.ctorRegistrySymbol");
502503
this.requires.addRaw("wrapperSymbol", "utils.wrapperSymbol");
503-
this.requires.addRaw("ctorRegistrySymbol", "utils.ctorRegistrySymbol");
504504
this.requires.addRaw("globalObjectSymbol", "utils.globalObjectSymbol");
505505
this.requires.addRaw("createWrapperSymbol", "utils.createWrapperSymbol");
506506

@@ -537,7 +537,7 @@ class Interface {
537537
exports._mixedIntoPredicates = [];
538538
exports.is = function is(obj) {
539539
if (obj) {
540-
if (utils.hasOwn(obj, implSymbol) && obj[implSymbol] instanceof Impl.implementation) {
540+
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
541541
return true;
542542
}
543543
for (const isMixedInto of exports._mixedIntoPredicates) {
@@ -598,10 +598,10 @@ class Interface {
598598
}
599599
if (unsupportedValue) {
600600
const func = this.indexedGetter.name ? `.${this.indexedGetter.name}` : "[utils.indexedGet]";
601-
const value = indexedValue || `${O}[implSymbol]${func}(${index})`;
601+
const value = indexedValue || `${O}[impl]${func}(${index})`;
602602
return `${value} !== ${unsupportedValue}`;
603603
}
604-
return `${O}[implSymbol][utils.supportsPropertyIndex](${index})`;
604+
return `${O}[impl][utils.supportsPropertyIndex](${index})`;
605605
};
606606

607607
const supportsPropertyName = (O, P, namedValue) => {
@@ -611,10 +611,10 @@ class Interface {
611611
}
612612
if (unsupportedValue) {
613613
const func = this.namedGetter.name ? `.${this.namedGetter.name}` : "[utils.namedGet]";
614-
const value = namedValue || `${O}[implSymbol]${func}(${P})`;
614+
const value = namedValue || `${O}[impl]${func}(${P})`;
615615
return `${value} !== ${unsupportedValue}`;
616616
}
617-
return `${O}[implSymbol][utils.supportsPropertyName](${P})`;
617+
return `${O}[impl][utils.supportsPropertyName](${P})`;
618618
};
619619

620620
// "named property visibility algorithm"
@@ -651,14 +651,14 @@ class Interface {
651651
str += `
652652
const creating = !(${supportsPropertyIndex(O, "index")});
653653
if (creating) {
654-
${O}[implSymbol][utils.indexedSetNew](index, indexedValue);
654+
${O}[impl][utils.indexedSetNew](index, indexedValue);
655655
} else {
656-
${O}[implSymbol][utils.indexedSetExisting](index, indexedValue);
656+
${O}[impl][utils.indexedSetExisting](index, indexedValue);
657657
}
658658
`;
659659
} else {
660660
str += `
661-
${O}[implSymbol].${this.indexedSetter.name}(index, indexedValue);
661+
${O}[impl].${this.indexedSetter.name}(index, indexedValue);
662662
`;
663663
}
664664

@@ -682,14 +682,14 @@ class Interface {
682682
str += `
683683
const creating = !(${supportsPropertyName(O, P)});
684684
if (creating) {
685-
${O}[implSymbol][utils.namedSetNew](${P}, namedValue);
685+
${O}[impl][utils.namedSetNew](${P}, namedValue);
686686
} else {
687-
${O}[implSymbol][utils.namedSetExisting](${P}, namedValue);
687+
${O}[impl][utils.namedSetExisting](${P}, namedValue);
688688
}
689689
`;
690690
} else {
691691
str += `
692-
${O}[implSymbol].${this.namedSetter.name}(${P}, namedValue);
692+
${O}[impl].${this.namedSetter.name}(${P}, namedValue);
693693
`;
694694
}
695695

@@ -752,14 +752,14 @@ class Interface {
752752
`;
753753
if (this.supportsIndexedProperties) {
754754
this.str += `
755-
for (const key of target[implSymbol][utils.supportedPropertyIndices]) {
755+
for (const key of target[impl][utils.supportedPropertyIndices]) {
756756
keys.add(\`\${key}\`);
757757
}
758758
`;
759759
}
760760
if (this.supportsNamedProperties) {
761761
this.str += `
762-
for (const key of target[implSymbol][utils.supportedPropertyNames]) {
762+
for (const key of target[impl][utils.supportedPropertyNames]) {
763763
if (${namedPropertyVisible("key", "target", true)}) {
764764
keys.add(\`\${key}\`);
765765
}
@@ -792,10 +792,10 @@ class Interface {
792792
let preamble = "";
793793
let condition;
794794
if (utils.getExtAttr(this.indexedGetter.extAttrs, "WebIDL2JSValueAsUnsupported")) {
795-
this.str += `const indexedValue = target[implSymbol]${func}(index);`;
795+
this.str += `const indexedValue = target[impl]${func}(index);`;
796796
condition = supportsPropertyIndex("target", "index", "indexedValue");
797797
} else {
798-
preamble = `const indexedValue = target[implSymbol]${func}(index);`;
798+
preamble = `const indexedValue = target[impl]${func}(index);`;
799799
condition = supportsPropertyIndex("target", "index");
800800
}
801801

@@ -820,13 +820,13 @@ class Interface {
820820
const conditions = [];
821821
if (utils.getExtAttr(this.namedGetter.extAttrs, "WebIDL2JSValueAsUnsupported")) {
822822
this.str += `
823-
const namedValue = target[implSymbol]${func}(P);
823+
const namedValue = target[impl]${func}(P);
824824
`;
825825
conditions.push(supportsPropertyName("target", "index", "namedValue"));
826826
conditions.push(namedPropertyVisible("P", "target", true));
827827
} else {
828828
preamble = `
829-
const namedValue = target[implSymbol]${func}(P);
829+
const namedValue = target[impl]${func}(P);
830830
`;
831831
conditions.push(namedPropertyVisible("P", "target", false));
832832
}
@@ -902,10 +902,10 @@ class Interface {
902902
let preamble = "";
903903
let condition;
904904
if (utils.getExtAttr(this.indexedGetter.extAttrs, "WebIDL2JSValueAsUnsupported")) {
905-
this.str += `const indexedValue = target[implSymbol]${func}(index);`;
905+
this.str += `const indexedValue = target[impl]${func}(index);`;
906906
condition = supportsPropertyIndex("target", "index", "indexedValue");
907907
} else {
908-
preamble = `const indexedValue = target[implSymbol]${func}(index);`;
908+
preamble = `const indexedValue = target[impl]${func}(index);`;
909909
condition = supportsPropertyIndex("target", "index");
910910
}
911911

@@ -1071,11 +1071,11 @@ class Interface {
10711071
const func = this.namedDeleter.name ? `.${this.namedDeleter.name}` : "[utils.namedDelete]";
10721072
if (this.namedDeleter.idlType.idlType === "bool") {
10731073
this.str += `
1074-
return target[implSymbol]${func}(P);
1074+
return target[impl]${func}(P);
10751075
`;
10761076
} else {
10771077
this.str += `
1078-
target[implSymbol]${func}(P);
1078+
target[impl]${func}(P);
10791079
return true;
10801080
`;
10811081
}
@@ -1103,51 +1103,55 @@ class Interface {
11031103

11041104
generateIface() {
11051105
this.str += `
1106-
function createWrapper(impl) {
1107-
const globalObject = impl[globalObjectSymbol];
1106+
function createWrapper(implObject) {
1107+
const globalObject = implObject[globalObjectSymbol];
11081108
1109-
if (globalObject[ctorRegistrySymbol] === undefined) {
1109+
if (globalObject[ctorRegistry] === undefined) {
11101110
throw new Error('Internal error: invalid global object');
11111111
}
11121112
1113-
const ctor = globalObject[ctorRegistrySymbol]["${this.name}"];
1113+
const ctor = globalObject[ctorRegistry]["${this.name}"];
11141114
if (ctor === undefined) {
11151115
throw new Error('Internal error: constructor ${this.name} is not installed on the passed global object');
11161116
}
11171117
1118-
let wrapper = Object.create(ctor.prototype);
1119-
exports._internalSetup(wrapper);
1118+
let wrapperObject = Object.create(ctor.prototype);
1119+
exports._internalSetup(wrapperObject);
11201120
`;
11211121

11221122
if (this.isLegacyPlatformObj) {
11231123
this.str += `
1124-
wrapper = new Proxy(wrapper, proxyHandler);
1124+
wrapperObject = new Proxy(wrapperObject, proxyHandler);
11251125
`;
11261126
}
11271127

11281128
this.str += `
1129-
impl[wrapperSymbol] = wrapper;
1130-
wrapper[implSymbol] = impl;
1131-
return wrapper;
1129+
implObject[wrapperSymbol] = wrapperObject;
1130+
wrapperObject[impl] = implObject;
1131+
return wrapperObject;
11321132
};
11331133
exports.create = function create(globalObject, constructorArgs, privateData) {
1134-
const impl = exports.createImpl(globalObject, constructorArgs, privateData);
1135-
return utils.wrapperForImpl(impl);
1134+
const implObject = exports.createImpl(globalObject, constructorArgs, privateData);
1135+
return utils.wrapperForImpl(implObject);
11361136
};
11371137
exports.createImpl = function createImpl(globalObject, constructorArgs = [], privateData = {}) {
1138-
const impl = new Impl.implementation(globalObject, constructorArgs, privateData);
1138+
const implObject = new Impl.implementation(globalObject, constructorArgs, privateData);
11391139
1140-
impl[wrapperSymbol] = null;
1141-
impl[globalObjectSymbol] = globalObject;
1142-
impl[createWrapperSymbol] = createWrapper;
1140+
implObject[wrapperSymbol] = null;
1141+
implObject[globalObjectSymbol] = globalObject;
1142+
implObject[createWrapperSymbol] = createWrapper;
11431143
1144-
return impl;
1144+
return implObject;
11451145
};
1146-
exports.setup = function setup(wrapper, globalObject, constructorArgs = [], privateData = {}) {
1147-
const impl = exports.createImpl(globalObject, constructorArgs, privateData);
1148-
impl[wrapperSymbol] = wrapper;
1149-
wrapper[implSymbol] = impl;
1150-
return wrapper;
1146+
exports.setup = function setup(wrapperObject, globalObject, constructorArgs = [], privateData = {}) {
1147+
const implObject = exports.createImpl(globalObject, constructorArgs, privateData);
1148+
1149+
implObject[wrapperSymbol] = wrapperObject;
1150+
wrapperObject[impl] = implObject;
1151+
1152+
exports._internalSetup(wrapperObject);
1153+
1154+
return wrapperObject;
11511155
};
11521156
exports._internalSetup = function _internalSetup(obj) {
11531157
`;
@@ -1445,10 +1449,10 @@ class Interface {
14451449
this.generateOffInstanceAfterClass();
14461450

14471451
this.str += `
1448-
if (globalObject[ctorRegistrySymbol] === undefined) {
1449-
globalObject[ctorRegistrySymbol] = Object.create(null);
1452+
if (globalObject[ctorRegistry] === undefined) {
1453+
globalObject[ctorRegistry] = Object.create(null);
14501454
}
1451-
globalObject[ctorRegistrySymbol]["${name}"] = ${name};
1455+
globalObject[ctorRegistry]["${name}"] = ${name};
14521456
14531457
Object.defineProperty(globalObject, "${name}", {
14541458
configurable: true,

lib/constructs/operation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Operation {
6767
`;
6868
}
6969

70-
const callOn = this.static ? "Impl.implementation" : "this[implSymbol]";
70+
const callOn = this.static ? "Impl.implementation" : "this[impl]";
7171
// In case of stringifiers, use the named implementation function rather than hardcoded "toString".
7272
// All overloads will have the same name, so pick the first one.
7373
const implFunc = this.idls[0].name || this.name;

lib/reflector.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
module.exports.boolean = {
44
get(objName, attrName) {
5-
return `return this[implSymbol].hasAttributeNS(null, "${attrName}");`;
5+
return `return this[impl].hasAttributeNS(null, "${attrName}");`;
66
},
77
set(objName, attrName) {
88
return `
99
if (V) {
10-
this[implSymbol].setAttributeNS(null, "${attrName}", "");
10+
this[impl].setAttributeNS(null, "${attrName}", "");
1111
} else {
12-
this[implSymbol].removeAttributeNS(null, "${attrName}");
12+
this[impl].removeAttributeNS(null, "${attrName}");
1313
}
1414
`;
1515
}
@@ -18,35 +18,35 @@ module.exports.boolean = {
1818
module.exports.DOMString = {
1919
get(objName, attrName) {
2020
return `
21-
const value = this[implSymbol].getAttributeNS(null, "${attrName}");
21+
const value = this[impl].getAttributeNS(null, "${attrName}");
2222
return value === null ? "" : value;
2323
`;
2424
},
2525
set(objName, attrName) {
26-
return `this[implSymbol].setAttributeNS(null, "${attrName}", V);`;
26+
return `this[impl].setAttributeNS(null, "${attrName}", V);`;
2727
}
2828
};
2929

3030
module.exports.long = {
3131
get(objName, attrName) {
3232
return `
33-
const value = parseInt(this[implSymbol].getAttributeNS(null, "${attrName}"));
33+
const value = parseInt(this[impl].getAttributeNS(null, "${attrName}"));
3434
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
3535
`;
3636
},
3737
set(objName, attrName) {
38-
return `this[implSymbol].setAttributeNS(null, "${attrName}", String(V));`;
38+
return `this[impl].setAttributeNS(null, "${attrName}", String(V));`;
3939
}
4040
};
4141

4242
module.exports["unsigned long"] = {
4343
get(objName, attrName) {
4444
return `
45-
const value = parseInt(this[implSymbol].getAttributeNS(null, "${attrName}"));
45+
const value = parseInt(this[impl].getAttributeNS(null, "${attrName}"));
4646
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
4747
`;
4848
},
4949
set(objName, attrName) {
50-
return `this[implSymbol].setAttributeNS(null, "${attrName}", String(V > 2147483647 ? 0 : V));`;
50+
return `this[impl].setAttributeNS(null, "${attrName}", String(V > 2147483647 ? 0 : V));`;
5151
}
5252
};

0 commit comments

Comments
 (0)