diff --git a/README.md b/README.md index 7b8c05ea..5e04dafd 100644 --- a/README.md +++ b/README.md @@ -409,21 +409,13 @@ However, it is not required! The wrapper classes will have a correct inheritance ### The `[LegacyFactoryFunction]` extended attribute -For interfaces which have the `[LegacyFactoryFunction]` extended attribute, the implementation class file must contain the `legacyFactoryFunction` export, with the signature `(globalObject, legacyFactoryFunctionArgs, legacyFactoryFunctionName)`, which is used for: +For interfaces which have the `[LegacyFactoryFunction]` extended attribute, the implementation class file must contain the `legacyFactoryFunction` export, with the signature `(globalObject, ...legacyFactoryFunctionArgs)`, which is used for: - Setting up initial state that will always be used, such as caches or default values - Keep a reference to the relevant `globalObject` for later consumption. - Processing constructor arguments `legacyFactoryFunctionArgs` passed to the legacy factory function constructor, if the legacy factory function takes arguments. -- Switching on the `legacyFactoryFunctionName`, if the interface defines multiple legacy factory functions, eg.: - ```webidl - [LegacyFactoryFunction=OverloadedLegacyFactoryFunction(DOMString arg1), - LegacyFactoryFunction=OverloadedLegacyFactoryFunction(long arg1, long arg2), - LegacyFactoryFunction=SimpleLegacyFactoryFunction(optional DOMString src)] - interface SomeInterface {}; - ``` - -The `legacyFactoryFunction` export is called with a `this` value of a new uninitialized implementation instance, which may be ignored by returning a different object, similarly to how constructors with overridden return types are implemented. +The `legacyFactoryFunction` export is called with a `this` value of a new uninitialized implementation instance, which may be ignored by returning a different object, similarly to how constructors with overridden return values are implemented. ### The init export diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 4a511d9c..7591795a 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -33,65 +33,6 @@ const defaultClassMethodDescriptor = { writable: true }; -class LegacyFactoryFunction { - constructor(ctx, I, idl) { - this.ctx = ctx; - this.interface = I; - this.idls = [idl]; - this.name = idl.rhs.value; - } - - generate() { - const requires = new utils.RequiresMap(this.ctx); - - let str = ""; - - if (!this.name) { - throw new Error(`Internal error: this legacy factory function does not have a name (in interface ${this.interface.name})`); - } - - const overloads = Overloads.getEffectiveOverloads("legacy factory function", this.name, 0, this.interface); - let minOp = overloads[0]; - for (let i = 1; i < overloads.length; ++i) { - if (overloads[i].nameList.length < minOp.nameList.length) { - minOp = overloads[i]; - } - } - - const argNames = minOp.nameList; - - const conversions = Parameters.generateOverloadConversions( - this.ctx, "legacy factory function", this.name, this.interface, `Failed to construct '${this.name}': `); - requires.merge(conversions.requires); - - const setupArgs = [ - "globalObject", - conversions.hasArgs ? "args" : "[]", - `"${this.name}"` - ]; - - str += ` - if (new.target === undefined) { - throw new TypeError("Class constructor ${this.name} cannot be invoked without 'new'"); - } - - ${conversions.body} - `; - - // This implements the WebIDL legacy factory function behavior, as well as support for overridding - // the return type, which is used by HTML's element legacy factory functions: - str += ` - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, ${formatArgs(setupArgs)}); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); - `; - - this.interface.addLegacyFactoryFunction(this.name, argNames, str); - - return { requires }; - } -} - class Interface { constructor(ctx, idl, opts) { this.ctx = ctx; @@ -113,7 +54,7 @@ class Interface { this.attributes = new Map(); this.staticAttributes = new Map(); this.constants = new Map(); - this.legacyFactoryFunctions = new Map(); + this.legacyFactoryFunctions = []; this.indexedGetter = null; this.indexedSetter = null; @@ -130,7 +71,6 @@ class Interface { this._outputStaticMethods = new Map(); this._outputProperties = new Map(); this._outputStaticProperties = new Map(); - this._outputLegacyFactoryFunctions = new Map(); const global = utils.getExtAttr(this.idl.extAttrs, "Global"); this.isGlobal = Boolean(global); @@ -242,10 +182,6 @@ class Interface { this._outputStaticMethods.set(propName, { type, args, body, descriptor }); } - addLegacyFactoryFunction(name, args, body) { - this._outputLegacyFactoryFunctions.set(name, { args, body }); - } - // whence is either "instance" or "prototype" addProperty(whence, propName, str, { configurable = true, @@ -460,19 +396,25 @@ class Interface { } } + let legacyFactoryFunctionName; for (const attr of this.idl.extAttrs) { if (attr.name === "LegacyFactoryFunction") { - if (attr.rhs.type !== "identifier" || !attr.arguments) { + if (!attr.rhs || attr.rhs.type !== "identifier" || !attr.arguments) { throw new Error(`[LegacyFactoryFunction] must take a named argument list`); } const name = attr.rhs.value; - - if (!this.legacyFactoryFunctions.has(name)) { - this.legacyFactoryFunctions.set(name, new LegacyFactoryFunction(this.ctx, this, attr)); - } else { - this.legacyFactoryFunctions.get(name).idls.push(attr); + if (legacyFactoryFunctionName === undefined) { + legacyFactoryFunctionName = name; + } else if (legacyFactoryFunctionName !== name) { + // This is currently valid, but not used anywhere, and there are plans to disallow it: + // https://github.com/jsdom/webidl2js/pull/213#issuecomment-621277733 + throw new Error( + `Multiple [LegacyFactoryFunction] definitions with different names are not supported on ${this.name}` + ); } + + this.legacyFactoryFunctions.push(attr); } } } @@ -1403,11 +1345,6 @@ class Interface { const data = member.generate(); this.requires.merge(data.requires); } - - for (const legacyFactoryFunction of this.legacyFactoryFunctions.values()) { - const data = legacyFactoryFunction.generate(); - this.requires.merge(data.requires); - } } generateOffInstanceMethods() { @@ -1572,29 +1509,63 @@ class Interface { } } - generateLegacyFactoryFunctions() { - for (const [name, { args, body }] of this._outputLegacyFactoryFunctions) { - this.str += ` - { - function ${name}(${formatArgs(args)}) { - ${body} - } + generateLegacyFactoryFunction() { + const { legacyFactoryFunctions } = this; + if (legacyFactoryFunctions.length === 0) { + return; + } - Object.defineProperty(${name}, "prototype", { - configurable: false, - enumerable: false, - writable: false, - value: ${this.name}.prototype - }) + const name = legacyFactoryFunctions[0].rhs.value; - Object.defineProperty(globalObject, "${name}", { - configurable: true, - writable: true, - value: ${name} - }); - } - `; + if (!name) { + throw new Error(`Internal error: The legacy factory function does not have a name (in interface ${this.name})`); + } + + const overloads = Overloads.getEffectiveOverloads("legacy factory function", name, 0, this); + let minOp = overloads[0]; + for (let i = 1; i < overloads.length; ++i) { + if (overloads[i].nameList.length < minOp.nameList.length) { + minOp = overloads[i]; + } } + + const args = minOp.nameList; + const conversions = Parameters.generateOverloadConversions( + this.ctx, "legacy factory function", name, this, `Failed to construct '${name}': `); + this.requires.merge(conversions.requires); + + const argsSpread = conversions.hasArgs ? "...args" : ""; + + this.str += ` + function ${name}(${formatArgs(args)}) { + if (new.target === undefined) { + throw new TypeError("Class constructor ${name} cannot be invoked without 'new'"); + } + + ${conversions.body} + `; + + // This implements the WebIDL legacy factory function behavior, as well as support for overridding + // the return type, which is used by HTML's element legacy factory functions: + this.str += ` + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ${argsSpread}); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + } + + Object.defineProperty(${name}, "prototype", { + configurable: false, + enumerable: false, + writable: false, + value: ${this.name}.prototype + }) + + Object.defineProperty(globalObject, "${name}", { + configurable: true, + writable: true, + value: ${name} + }); + `; } generateInstall() { @@ -1662,7 +1633,7 @@ class Interface { } } - this.generateLegacyFactoryFunctions(); + this.generateLegacyFactoryFunction(); this.str += ` }; diff --git a/lib/overloads.js b/lib/overloads.js index e64d8840..03d00221 100644 --- a/lib/overloads.js +++ b/lib/overloads.js @@ -12,7 +12,7 @@ function getOperations(type, A, I) { return I.constructorOperations; } case "legacy factory function": - return I.legacyFactoryFunctions.get(A).idls; + return I.legacyFactoryFunctions; } throw new RangeError(`${type}s are not yet supported`); } diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index ca29466a..234dcc5a 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -2210,39 +2210,37 @@ exports.install = (globalObject, globalNames) => { value: HTMLAudioElement }); - { - function Audio() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); - } + function Audio() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); + } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); - } - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"Audio\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - Object.defineProperty(Audio, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: HTMLAudioElement.prototype - }); - - Object.defineProperty(globalObject, \\"Audio\\", { - configurable: true, - writable: true, - value: Audio - }); + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); } + + Object.defineProperty(Audio, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLAudioElement.prototype + }); + + Object.defineProperty(globalObject, \\"Audio\\", { + configurable: true, + writable: true, + value: Audio + }); }; const Impl = require(\\"../implementations/HTMLAudioElement.js\\"); @@ -2484,46 +2482,44 @@ exports.install = (globalObject, globalNames) => { value: HTMLImageElement }); - { - function Image() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); - } + function Image() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); + } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 1\\" }); - } - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 1\\" }); } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); - } - args.push(curArg); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"Image\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - Object.defineProperty(Image, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: HTMLImageElement.prototype - }); - - Object.defineProperty(globalObject, \\"Image\\", { - configurable: true, - writable: true, - value: Image - }); + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); } + + Object.defineProperty(Image, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLImageElement.prototype + }); + + Object.defineProperty(globalObject, \\"Image\\", { + configurable: true, + writable: true, + value: Image + }); }; const Impl = require(\\"../implementations/HTMLImageElement.js\\"); @@ -2645,73 +2641,71 @@ exports.install = (globalObject, globalNames) => { value: HTMLOptionElement }); - { - function Option() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor Option cannot be invoked without 'new'\\"); - } + function Option() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Option cannot be invoked without 'new'\\"); + } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 1\\" }); - } else { - curArg = \\"\\"; - } - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 1\\" }); + } else { + curArg = \\"\\"; } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 2\\" }); - } - args.push(curArg); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 2\\" }); } - { - let curArg = arguments[2]; - if (curArg !== undefined) { - curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 3\\" }); - } else { - curArg = false; - } - args.push(curArg); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 3\\" }); + } else { + curArg = false; } - { - let curArg = arguments[3]; - if (curArg !== undefined) { - curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 4\\" }); - } else { - curArg = false; - } - args.push(curArg); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 4\\" }); + } else { + curArg = false; } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"Option\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - Object.defineProperty(Option, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: HTMLOptionElement.prototype - }); - - Object.defineProperty(globalObject, \\"Option\\", { - configurable: true, - writable: true, - value: Option - }); + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); } + + Object.defineProperty(Option, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLOptionElement.prototype + }); + + Object.defineProperty(globalObject, \\"Option\\", { + configurable: true, + writable: true, + value: Option + }); }; const Impl = require(\\"../implementations/HTMLOptionElement.js\\"); " `; -exports[`with processors LegacyFactoryFunction.webidl 1`] = ` +exports[`with processors LegacyLenientAttributes.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -2720,7 +2714,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyFactoryFunction\\"; +const interfaceName = \\"LegacyLenientAttributes\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -2732,7 +2726,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyFactoryFunction'.\`); + throw new TypeError(\`\${context} is not of type 'LegacyLenientAttributes'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -2746,9 +2740,11 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(prototype)) { - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyFactoryFunction\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyLenientAttributes\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyFactoryFunction is not installed on the passed global object\\"); + throw new Error( + \\"Internal error: constructor LegacyLenientAttributes is not installed on the passed global object\\" + ); } ({ prototype } = ctor); } @@ -2806,132 +2802,121 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyFactoryFunction { + class LegacyLenientAttributes { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - } - Object.defineProperties(LegacyFactoryFunction.prototype, { - [Symbol.toStringTag]: { value: \\"LegacyFactoryFunction\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyFactoryFunction; - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: LegacyFactoryFunction - }); + get lenientSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; - { - function OverloadedLegacyFactoryFunction(arg1) { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor OverloadedLegacyFactoryFunction cannot be invoked without 'new'\\"); + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to construct 'OverloadedLegacyFactoryFunction': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return esValue[implSymbol][\\"lenientSetter\\"]; + } + + set lenientSetter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" - }); - args.push(curArg); - } - break; - default: - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 2\\" - }); - args.push(curArg); - } + } + + get lenientThisSetter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; } - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call( - thisArgument, - globalObject, - args, - \\"OverloadedLegacyFactoryFunction\\" - ); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + return esValue[implSymbol][\\"lenientThisSetter\\"]; } - Object.defineProperty(OverloadedLegacyFactoryFunction, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: LegacyFactoryFunction.prototype - }); + set lenientThisSetter(V) {} - Object.defineProperty(globalObject, \\"OverloadedLegacyFactoryFunction\\", { - configurable: true, - writable: true, - value: OverloadedLegacyFactoryFunction - }); - } + get lenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; - { - function SimpleLegacyFactoryFunction() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor SimpleLegacyFactoryFunction cannot be invoked without 'new'\\"); + if (!exports.is(esValue)) { + return; } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to construct 'SimpleLegacyFactoryFunction': parameter 1\\" - }); - } - args.push(curArg); + return esValue[implSymbol][\\"lenientThis\\"]; + } + + set lenientThis(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'lenientThis' property on 'LegacyLenientAttributes': The provided value\\" + }); + + esValue[implSymbol][\\"lenientThis\\"] = V; + } + + get readonlyLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; } - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"SimpleLegacyFactoryFunction\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + return esValue[implSymbol][\\"readonlyLenientThis\\"]; } - Object.defineProperty(SimpleLegacyFactoryFunction, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: LegacyFactoryFunction.prototype - }); + get replaceableLenientThis() { + const esValue = this !== null && this !== undefined ? this : globalObject; - Object.defineProperty(globalObject, \\"SimpleLegacyFactoryFunction\\", { - configurable: true, - writable: true, - value: SimpleLegacyFactoryFunction - }); + if (!exports.is(esValue)) { + return; + } + + return esValue[implSymbol][\\"replaceableLenientThis\\"]; + } + + set replaceableLenientThis(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + Object.defineProperty(esValue, \\"replaceableLenientThis\\", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + } + } + Object.defineProperties(LegacyLenientAttributes.prototype, { + lenientSetter: { enumerable: true }, + lenientThisSetter: { enumerable: true }, + lenientThis: { enumerable: true }, + readonlyLenientThis: { enumerable: true }, + replaceableLenientThis: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"LegacyLenientAttributes\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); } + globalObject[ctorRegistrySymbol][interfaceName] = LegacyLenientAttributes; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: LegacyLenientAttributes + }); }; -const Impl = require(\\"../implementations/LegacyFactoryFunction.js\\"); +const Impl = require(\\"../implementations/LegacyLenientAttributes.js\\"); " `; -exports[`with processors LegacyLenientAttributes.webidl 1`] = ` +exports[`with processors LegacyUnforgeable.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -2940,7 +2925,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyLenientAttributes\\"; +const interfaceName = \\"LegacyUnforgeable\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -2952,7 +2937,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyLenientAttributes'.\`); + throw new TypeError(\`\${context} is not of type 'LegacyUnforgeable'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -2966,218 +2951,7 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(prototype)) { - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyLenientAttributes\\"]; - if (ctor === undefined) { - throw new Error( - \\"Internal error: constructor LegacyLenientAttributes is not installed on the passed global object\\" - ); - } - ({ prototype } = ctor); - } - - return Object.create(prototype); -} - -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; - -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; - -exports._internalSetup = (wrapper, globalObject) => {}; - -exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { - privateData.wrapper = wrapper; - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); - - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper; -}; - -exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: Object.create(Impl.implementation.prototype), - configurable: true - }); - - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper[implSymbol]; -}; - -const exposed = new Set([\\"Window\\"]); - -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class LegacyLenientAttributes { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - - get lenientSetter() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"lenientSetter\\"]; - } - - set lenientSetter(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - } - - get lenientThisSetter() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } - - return esValue[implSymbol][\\"lenientThisSetter\\"]; - } - - set lenientThisSetter(V) {} - - get lenientThis() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } - - return esValue[implSymbol][\\"lenientThis\\"]; - } - - set lenientThis(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } - - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'lenientThis' property on 'LegacyLenientAttributes': The provided value\\" - }); - - esValue[implSymbol][\\"lenientThis\\"] = V; - } - - get readonlyLenientThis() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } - - return esValue[implSymbol][\\"readonlyLenientThis\\"]; - } - - get replaceableLenientThis() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - return; - } - - return esValue[implSymbol][\\"replaceableLenientThis\\"]; - } - - set replaceableLenientThis(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - Object.defineProperty(esValue, \\"replaceableLenientThis\\", { - configurable: true, - enumerable: true, - value: V, - writable: true - }); - } - } - Object.defineProperties(LegacyLenientAttributes.prototype, { - lenientSetter: { enumerable: true }, - lenientThisSetter: { enumerable: true }, - lenientThis: { enumerable: true }, - readonlyLenientThis: { enumerable: true }, - replaceableLenientThis: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"LegacyLenientAttributes\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyLenientAttributes; - - Object.defineProperty(globalObject, interfaceName, { - configurable: true, - writable: true, - value: LegacyLenientAttributes - }); -}; - -const Impl = require(\\"../implementations/LegacyLenientAttributes.js\\"); -" -`; - -exports[`with processors LegacyUnforgeable.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"LegacyUnforgeable\\"; - -exports.is = value => { - return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = value => { - return utils.isObject(value) && value instanceof Impl.implementation; -}; -exports.convert = (value, { context = \\"The provided value\\" } = {}) => { - if (exports.is(value)) { - return utils.implForWrapper(value); - } - throw new TypeError(\`\${context} is not of type 'LegacyUnforgeable'.\`); -}; - -function makeWrapper(globalObject, newTarget) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } - - let prototype; - if (newTarget !== undefined) { - ({ prototype } = newTarget); - } - - if (!utils.isObject(prototype)) { - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"LegacyUnforgeable\\"]; if (ctor === undefined) { throw new Error(\\"Internal error: constructor LegacyUnforgeable is not installed on the passed global object\\"); } @@ -3869,48 +3643,192 @@ const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`with processors NodeFilter.webidl 1`] = ` +exports[`with processors NoArgLegacyFactoryFunctionInterface.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { - if (!utils.isObject(value)) { - throw new TypeError(\`\${context} is not an object.\`); - } - - function callTheUserObjectsOperation(node) { - let thisArg = utils.tryWrapperForImpl(this); - let O = value; - let X = O; - - if (typeof O !== \\"function\\") { - X = O[\\"acceptNode\\"]; - if (typeof X !== \\"function\\") { - throw new TypeError(\`\${context} does not correctly implement NodeFilter.\`); - } - thisArg = O; - } - - node = utils.tryWrapperForImpl(node); - - let callResult = Reflect.apply(X, thisArg, [node]); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; - callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); +const interfaceName = \\"NoArgLegacyFactoryFunctionInterface\\"; - return callResult; +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); } - - callTheUserObjectsOperation[utils.wrapperSymbol] = value; - callTheUserObjectsOperation.objectReference = value; - - return callTheUserObjectsOperation; + throw new TypeError(\`\${context} is not of type 'NoArgLegacyFactoryFunctionInterface'.\`); }; -const exposed = new Set([\\"Window\\"]); +function makeWrapper(globalObject, newTarget) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } -exports.install = (globalObject, globalNames) => { + let prototype; + if (newTarget !== undefined) { + ({ prototype } = newTarget); + } + + if (!utils.isObject(prototype)) { + const ctor = globalObject[ctorRegistrySymbol][\\"NoArgLegacyFactoryFunctionInterface\\"]; + if (ctor === undefined) { + throw new Error( + \\"Internal error: constructor NoArgLegacyFactoryFunctionInterface is not installed on the passed global object\\" + ); + } + ({ prototype } = ctor); + } + + return Object.create(prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class NoArgLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(NoArgLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"NoArgLegacyFactoryFunctionInterface\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = NoArgLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunctionInterface + }); + + function NoArgLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor NoArgLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + } + + Object.defineProperty(NoArgLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: NoArgLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"NoArgLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/NoArgLegacyFactoryFunctionInterface.js\\"); +" +`; + +exports[`with processors NodeFilter.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +exports.convert = function convert(value, { context = \\"The provided value\\" } = {}) { + if (!utils.isObject(value)) { + throw new TypeError(\`\${context} is not an object.\`); + } + + function callTheUserObjectsOperation(node) { + let thisArg = utils.tryWrapperForImpl(this); + let O = value; + let X = O; + + if (typeof O !== \\"function\\") { + X = O[\\"acceptNode\\"]; + if (typeof X !== \\"function\\") { + throw new TypeError(\`\${context} does not correctly implement NodeFilter.\`); + } + thisArg = O; + } + + node = utils.tryWrapperForImpl(node); + + let callResult = Reflect.apply(X, thisArg, [node]); + + callResult = conversions[\\"unsigned short\\"](callResult, { context: context }); + + return callResult; + } + + callTheUserObjectsOperation[utils.wrapperSymbol] = value; + callTheUserObjectsOperation.objectReference = value; + + return callTheUserObjectsOperation; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } @@ -3947,6 +3865,182 @@ exports.install = (globalObject, globalNames) => { " `; +exports[`with processors OverloadedLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"OverloadedLegacyFactoryFunctionInterface\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'OverloadedLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + let prototype; + if (newTarget !== undefined) { + ({ prototype } = newTarget); + } + + if (!utils.isObject(prototype)) { + const ctor = globalObject[ctorRegistrySymbol][\\"OverloadedLegacyFactoryFunctionInterface\\"]; + if (ctor === undefined) { + throw new Error( + \\"Internal error: constructor OverloadedLegacyFactoryFunctionInterface is not installed on the passed global object\\" + ); + } + ({ prototype } = ctor); + } + + return Object.create(prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class OverloadedLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(OverloadedLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"OverloadedLegacyFactoryFunctionInterface\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = OverloadedLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunctionInterface + }); + + function OverloadedLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor OverloadedLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const args = []; + switch (arguments.length) { + case 0: + break; + case 1: + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + } + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 2\\" + }); + args.push(curArg); + } + } + + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + } + + Object.defineProperty(OverloadedLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: OverloadedLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"OverloadedLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/OverloadedLegacyFactoryFunctionInterface.js\\"); +" +`; + exports[`with processors Overloads.webidl 1`] = ` "\\"use strict\\"; @@ -12010,39 +12104,37 @@ exports.install = (globalObject, globalNames) => { value: HTMLAudioElement }); - { - function Audio() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); - } + function Audio() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Audio cannot be invoked without 'new'\\"); + } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); - } - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Audio': parameter 1\\" }); } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"Audio\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - Object.defineProperty(Audio, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: HTMLAudioElement.prototype - }); - - Object.defineProperty(globalObject, \\"Audio\\", { - configurable: true, - writable: true, - value: Audio - }); + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); } + + Object.defineProperty(Audio, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLAudioElement.prototype + }); + + Object.defineProperty(globalObject, \\"Audio\\", { + configurable: true, + writable: true, + value: Audio + }); }; const Impl = require(\\"../implementations/HTMLAudioElement.js\\"); @@ -12282,233 +12374,51 @@ exports.install = (globalObject, globalNames) => { value: HTMLImageElement }); - { - function Image() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); - } + function Image() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Image cannot be invoked without 'new'\\"); + } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 1\\" }); - } - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 1\\" }); } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); - } - args.push(curArg); - } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"Image\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - - Object.defineProperty(Image, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: HTMLImageElement.prototype - }); - - Object.defineProperty(globalObject, \\"Image\\", { - configurable: true, - writable: true, - value: Image - }); - } -}; - -const Impl = require(\\"../implementations/HTMLImageElement.js\\"); -" -`; - -exports[`without processors HTMLOptionElement.webidl 1`] = ` -"\\"use strict\\"; - -const conversions = require(\\"webidl-conversions\\"); -const utils = require(\\"./utils.js\\"); - -const implSymbol = utils.implSymbol; -const ctorRegistrySymbol = utils.ctorRegistrySymbol; - -const interfaceName = \\"HTMLOptionElement\\"; - -exports.is = value => { - return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; -}; -exports.isImpl = value => { - return utils.isObject(value) && value instanceof Impl.implementation; -}; -exports.convert = (value, { context = \\"The provided value\\" } = {}) => { - if (exports.is(value)) { - return utils.implForWrapper(value); - } - throw new TypeError(\`\${context} is not of type 'HTMLOptionElement'.\`); -}; - -function makeWrapper(globalObject, newTarget) { - if (globalObject[ctorRegistrySymbol] === undefined) { - throw new Error(\\"Internal error: invalid global object\\"); - } - - let prototype; - if (newTarget !== undefined) { - ({ prototype } = newTarget); - } - - if (!utils.isObject(prototype)) { - const ctor = globalObject[ctorRegistrySymbol][\\"HTMLOptionElement\\"]; - if (ctor === undefined) { - throw new Error(\\"Internal error: constructor HTMLOptionElement is not installed on the passed global object\\"); + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to construct 'Image': parameter 2\\" }); + } + args.push(curArg); } - ({ prototype } = ctor); - } - - return Object.create(prototype); -} - -exports.create = (globalObject, constructorArgs, privateData) => { - const wrapper = makeWrapper(globalObject); - return exports.setup(wrapper, globalObject, constructorArgs, privateData); -}; - -exports.createImpl = (globalObject, constructorArgs, privateData) => { - const wrapper = exports.create(globalObject, constructorArgs, privateData); - return utils.implForWrapper(wrapper); -}; - -exports._internalSetup = (wrapper, globalObject) => {}; - -exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { - privateData.wrapper = wrapper; - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: new Impl.implementation(globalObject, constructorArgs, privateData), - configurable: true - }); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); } - return wrapper; -}; -exports.new = (globalObject, newTarget) => { - const wrapper = makeWrapper(globalObject, newTarget); - - exports._internalSetup(wrapper, globalObject); - Object.defineProperty(wrapper, implSymbol, { - value: Object.create(Impl.implementation.prototype), - configurable: true + Object.defineProperty(Image, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLImageElement.prototype }); - wrapper[implSymbol][utils.wrapperSymbol] = wrapper; - if (Impl.init) { - Impl.init(wrapper[implSymbol]); - } - return wrapper[implSymbol]; -}; - -const exposed = new Set([\\"Window\\"]); - -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class HTMLOptionElement { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); - } - } - Object.defineProperties(HTMLOptionElement.prototype, { - [Symbol.toStringTag]: { value: \\"HTMLOptionElement\\", configurable: true } - }); - if (globalObject[ctorRegistrySymbol] === undefined) { - globalObject[ctorRegistrySymbol] = Object.create(null); - } - globalObject[ctorRegistrySymbol][interfaceName] = HTMLOptionElement; - - Object.defineProperty(globalObject, interfaceName, { + Object.defineProperty(globalObject, \\"Image\\", { configurable: true, writable: true, - value: HTMLOptionElement + value: Image }); - - { - function Option() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor Option cannot be invoked without 'new'\\"); - } - - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 1\\" }); - } else { - curArg = \\"\\"; - } - args.push(curArg); - } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 2\\" }); - } - args.push(curArg); - } - { - let curArg = arguments[2]; - if (curArg !== undefined) { - curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 3\\" }); - } else { - curArg = false; - } - args.push(curArg); - } - { - let curArg = arguments[3]; - if (curArg !== undefined) { - curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 4\\" }); - } else { - curArg = false; - } - args.push(curArg); - } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"Option\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); - } - - Object.defineProperty(Option, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: HTMLOptionElement.prototype - }); - - Object.defineProperty(globalObject, \\"Option\\", { - configurable: true, - writable: true, - value: Option - }); - } }; -const Impl = require(\\"../implementations/HTMLOptionElement.js\\"); +const Impl = require(\\"../implementations/HTMLImageElement.js\\"); " `; -exports[`without processors LegacyFactoryFunction.webidl 1`] = ` +exports[`without processors HTMLOptionElement.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -12517,7 +12427,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"LegacyFactoryFunction\\"; +const interfaceName = \\"HTMLOptionElement\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -12529,7 +12439,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'LegacyFactoryFunction'.\`); + throw new TypeError(\`\${context} is not of type 'HTMLOptionElement'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -12543,9 +12453,9 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(prototype)) { - const ctor = globalObject[ctorRegistrySymbol][\\"LegacyFactoryFunction\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"HTMLOptionElement\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor LegacyFactoryFunction is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor HTMLOptionElement is not installed on the passed global object\\"); } ({ prototype } = ctor); } @@ -12603,128 +12513,86 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class LegacyFactoryFunction { + class HTMLOptionElement { constructor() { throw new TypeError(\\"Illegal constructor\\"); } } - Object.defineProperties(LegacyFactoryFunction.prototype, { - [Symbol.toStringTag]: { value: \\"LegacyFactoryFunction\\", configurable: true } + Object.defineProperties(HTMLOptionElement.prototype, { + [Symbol.toStringTag]: { value: \\"HTMLOptionElement\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = LegacyFactoryFunction; + globalObject[ctorRegistrySymbol][interfaceName] = HTMLOptionElement; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: LegacyFactoryFunction + value: HTMLOptionElement }); - { - function OverloadedLegacyFactoryFunction(arg1) { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor OverloadedLegacyFactoryFunction cannot be invoked without 'new'\\"); - } + function Option() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor Option cannot be invoked without 'new'\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to construct 'OverloadedLegacyFactoryFunction': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 1\\" }); + } else { + curArg = \\"\\"; } - const args = []; - switch (arguments.length) { - case 1: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" - }); - args.push(curArg); - } - break; - default: - { - let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 2\\" - }); - args.push(curArg); - } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Option': parameter 2\\" }); } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call( - thisArgument, - globalObject, - args, - \\"OverloadedLegacyFactoryFunction\\" - ); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - - Object.defineProperty(OverloadedLegacyFactoryFunction, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: LegacyFactoryFunction.prototype - }); - - Object.defineProperty(globalObject, \\"OverloadedLegacyFactoryFunction\\", { - configurable: true, - writable: true, - value: OverloadedLegacyFactoryFunction - }); - } - - { - function SimpleLegacyFactoryFunction() { - if (new.target === undefined) { - throw new TypeError(\\"Class constructor SimpleLegacyFactoryFunction cannot be invoked without 'new'\\"); + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 3\\" }); + } else { + curArg = false; } - - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to construct 'SimpleLegacyFactoryFunction': parameter 1\\" - }); - } - args.push(curArg); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + curArg = conversions[\\"boolean\\"](curArg, { context: \\"Failed to construct 'Option': parameter 4\\" }); + } else { + curArg = false; } - - const thisArgument = exports.new(globalObject, new.target); - const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, args, \\"SimpleLegacyFactoryFunction\\"); - return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + args.push(curArg); } - Object.defineProperty(SimpleLegacyFactoryFunction, \\"prototype\\", { - configurable: false, - enumerable: false, - writable: false, - value: LegacyFactoryFunction.prototype - }); - - Object.defineProperty(globalObject, \\"SimpleLegacyFactoryFunction\\", { - configurable: true, - writable: true, - value: SimpleLegacyFactoryFunction - }); + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); } + + Object.defineProperty(Option, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: HTMLOptionElement.prototype + }); + + Object.defineProperty(globalObject, \\"Option\\", { + configurable: true, + writable: true, + value: Option + }); }; -const Impl = require(\\"../implementations/LegacyFactoryFunction.js\\"); +const Impl = require(\\"../implementations/HTMLOptionElement.js\\"); " `; @@ -13467,11 +13335,206 @@ const proxyHandler = { } }; -const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); +const Impl = require(\\"../implementations/LegacyUnforgeableMap.js\\"); +" +`; + +exports[`without processors MixedIn.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"MixedIn\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + let prototype; + if (newTarget !== undefined) { + ({ prototype } = newTarget); + } + + if (!utils.isObject(prototype)) { + const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); + } + ({ prototype } = ctor); + } + + return Object.create(prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class MixedIn { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + mixedInOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol].mixedInOp(); + } + + ifaceMixinOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol].ifaceMixinOp(); + } + + get mixedInAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"mixedInAttr\\"]; + } + + set mixedInAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" + }); + + esValue[implSymbol][\\"mixedInAttr\\"] = V; + } + + get ifaceMixinAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + } + + set ifaceMixinAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" + }); + + esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + } + } + Object.defineProperties(MixedIn.prototype, { + mixedInOp: { enumerable: true }, + ifaceMixinOp: { enumerable: true }, + mixedInAttr: { enumerable: true }, + ifaceMixinAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"MixedIn\\", configurable: true }, + mixedInConst: { value: 43, enumerable: true }, + ifaceMixinConst: { value: 42, enumerable: true } + }); + Object.defineProperties(MixedIn, { + mixedInConst: { value: 43, enumerable: true }, + ifaceMixinConst: { value: 42, enumerable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: MixedIn + }); +}; + +const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`without processors MixedIn.webidl 1`] = ` +exports[`without processors NoArgLegacyFactoryFunctionInterface.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -13480,7 +13543,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"MixedIn\\"; +const interfaceName = \\"NoArgLegacyFactoryFunctionInterface\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -13492,7 +13555,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'MixedIn'.\`); + throw new TypeError(\`\${context} is not of type 'NoArgLegacyFactoryFunctionInterface'.\`); }; function makeWrapper(globalObject, newTarget) { @@ -13506,9 +13569,11 @@ function makeWrapper(globalObject, newTarget) { } if (!utils.isObject(prototype)) { - const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"NoArgLegacyFactoryFunctionInterface\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); + throw new Error( + \\"Internal error: constructor NoArgLegacyFactoryFunctionInterface is not installed on the passed global object\\" + ); } ({ prototype } = ctor); } @@ -13566,103 +13631,50 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class MixedIn { + class NoArgLegacyFactoryFunctionInterface { constructor() { throw new TypeError(\\"Illegal constructor\\"); } - - mixedInOp() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol].mixedInOp(); - } - - ifaceMixinOp() { - const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol].ifaceMixinOp(); - } - - get mixedInAttr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"mixedInAttr\\"]; - } - - set mixedInAttr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"mixedInAttr\\"] = V; - } - - get ifaceMixinAttr() { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return esValue[implSymbol][\\"ifaceMixinAttr\\"]; - } - - set ifaceMixinAttr(V) { - const esValue = this !== null && this !== undefined ? this : globalObject; - - if (!exports.is(esValue)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; - } } - Object.defineProperties(MixedIn.prototype, { - mixedInOp: { enumerable: true }, - ifaceMixinOp: { enumerable: true }, - mixedInAttr: { enumerable: true }, - ifaceMixinAttr: { enumerable: true }, - [Symbol.toStringTag]: { value: \\"MixedIn\\", configurable: true }, - mixedInConst: { value: 43, enumerable: true }, - ifaceMixinConst: { value: 42, enumerable: true } - }); - Object.defineProperties(MixedIn, { - mixedInConst: { value: 43, enumerable: true }, - ifaceMixinConst: { value: 42, enumerable: true } + Object.defineProperties(NoArgLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"NoArgLegacyFactoryFunctionInterface\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; + globalObject[ctorRegistrySymbol][interfaceName] = NoArgLegacyFactoryFunctionInterface; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: MixedIn + value: NoArgLegacyFactoryFunctionInterface + }); + + function NoArgLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor NoArgLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + } + + Object.defineProperty(NoArgLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: NoArgLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"NoArgLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: NoArgLegacyFactoryFunction }); }; -const Impl = require(\\"../implementations/MixedIn.js\\"); +const Impl = require(\\"../implementations/NoArgLegacyFactoryFunctionInterface.js\\"); " `; @@ -13744,6 +13756,182 @@ exports.install = (globalObject, globalNames) => { " `; +exports[`without processors OverloadedLegacyFactoryFunctionInterface.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"OverloadedLegacyFactoryFunctionInterface\\"; + +exports.is = value => { + return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; +}; +exports.isImpl = value => { + return utils.isObject(value) && value instanceof Impl.implementation; +}; +exports.convert = (value, { context = \\"The provided value\\" } = {}) => { + if (exports.is(value)) { + return utils.implForWrapper(value); + } + throw new TypeError(\`\${context} is not of type 'OverloadedLegacyFactoryFunctionInterface'.\`); +}; + +function makeWrapper(globalObject, newTarget) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + let prototype; + if (newTarget !== undefined) { + ({ prototype } = newTarget); + } + + if (!utils.isObject(prototype)) { + const ctor = globalObject[ctorRegistrySymbol][\\"OverloadedLegacyFactoryFunctionInterface\\"]; + if (ctor === undefined) { + throw new Error( + \\"Internal error: constructor OverloadedLegacyFactoryFunctionInterface is not installed on the passed global object\\" + ); + } + ({ prototype } = ctor); + } + + return Object.create(prototype); +} + +exports.create = (globalObject, constructorArgs, privateData) => { + const wrapper = makeWrapper(globalObject); + return exports.setup(wrapper, globalObject, constructorArgs, privateData); +}; + +exports.createImpl = (globalObject, constructorArgs, privateData) => { + const wrapper = exports.create(globalObject, constructorArgs, privateData); + return utils.implForWrapper(wrapper); +}; + +exports._internalSetup = (wrapper, globalObject) => {}; + +exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { + privateData.wrapper = wrapper; + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: new Impl.implementation(globalObject, constructorArgs, privateData), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + const wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class OverloadedLegacyFactoryFunctionInterface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + } + Object.defineProperties(OverloadedLegacyFactoryFunctionInterface.prototype, { + [Symbol.toStringTag]: { value: \\"OverloadedLegacyFactoryFunctionInterface\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = OverloadedLegacyFactoryFunctionInterface; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunctionInterface + }); + + function OverloadedLegacyFactoryFunction() { + if (new.target === undefined) { + throw new TypeError(\\"Class constructor OverloadedLegacyFactoryFunction cannot be invoked without 'new'\\"); + } + + const args = []; + switch (arguments.length) { + case 0: + break; + case 1: + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + } + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to construct 'OverloadedLegacyFactoryFunction': parameter 2\\" + }); + args.push(curArg); + } + } + + const thisArgument = exports.new(globalObject, new.target); + const result = Impl.legacyFactoryFunction.call(thisArgument, globalObject, ...args); + return utils.tryWrapperForImpl(utils.isObject(result) ? result : thisArgument); + } + + Object.defineProperty(OverloadedLegacyFactoryFunction, \\"prototype\\", { + configurable: false, + enumerable: false, + writable: false, + value: OverloadedLegacyFactoryFunctionInterface.prototype + }); + + Object.defineProperty(globalObject, \\"OverloadedLegacyFactoryFunction\\", { + configurable: true, + writable: true, + value: OverloadedLegacyFactoryFunction + }); +}; + +const Impl = require(\\"../implementations/OverloadedLegacyFactoryFunctionInterface.js\\"); +" +`; + exports[`without processors Overloads.webidl 1`] = ` "\\"use strict\\"; diff --git a/test/cases/LegacyFactoryFunction.webidl b/test/cases/LegacyFactoryFunction.webidl deleted file mode 100644 index 4569f3e1..00000000 --- a/test/cases/LegacyFactoryFunction.webidl +++ /dev/null @@ -1,5 +0,0 @@ -[Exposed=Window, - LegacyFactoryFunction=OverloadedLegacyFactoryFunction(DOMString arg1), - LegacyFactoryFunction=OverloadedLegacyFactoryFunction(long arg1, long arg2), - LegacyFactoryFunction=SimpleLegacyFactoryFunction(optional DOMString src)] -interface LegacyFactoryFunction {}; diff --git a/test/cases/NoArgLegacyFactoryFunctionInterface.webidl b/test/cases/NoArgLegacyFactoryFunctionInterface.webidl new file mode 100644 index 00000000..d326d105 --- /dev/null +++ b/test/cases/NoArgLegacyFactoryFunctionInterface.webidl @@ -0,0 +1,3 @@ +[Exposed=Window, + LegacyFactoryFunction=NoArgLegacyFactoryFunction()] +interface NoArgLegacyFactoryFunctionInterface {}; diff --git a/test/cases/OverloadedLegacyFactoryFunctionInterface.webidl b/test/cases/OverloadedLegacyFactoryFunctionInterface.webidl new file mode 100644 index 00000000..8a9ac26a --- /dev/null +++ b/test/cases/OverloadedLegacyFactoryFunctionInterface.webidl @@ -0,0 +1,4 @@ +[Exposed=Window, + LegacyFactoryFunction=OverloadedLegacyFactoryFunction(optional DOMString src), + LegacyFactoryFunction=OverloadedLegacyFactoryFunction(long arg1, long arg2)] +interface OverloadedLegacyFactoryFunctionInterface {};