diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 8023678b..173d1652 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -4323,95 +4323,16 @@ const Impl = require(\\"../implementations/MixedIn.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; - } - - const NodeFilter = () => { - throw new TypeError(\\"Illegal invocation\\"); - }; - - Object.defineProperties(NodeFilter, { - FILTER_ACCEPT: { value: 1, enumerable: true }, - FILTER_REJECT: { value: 2, enumerable: true }, - FILTER_SKIP: { value: 3, enumerable: true }, - SHOW_ALL: { value: 0xffffffff, enumerable: true }, - SHOW_ELEMENT: { value: 0x1, enumerable: true }, - SHOW_ATTRIBUTE: { value: 0x2, enumerable: true }, - SHOW_TEXT: { value: 0x4, enumerable: true }, - SHOW_CDATA_SECTION: { value: 0x8, enumerable: true }, - SHOW_ENTITY_REFERENCE: { value: 0x10, enumerable: true }, - SHOW_ENTITY: { value: 0x20, enumerable: true }, - SHOW_PROCESSING_INSTRUCTION: { value: 0x40, enumerable: true }, - SHOW_COMMENT: { value: 0x80, enumerable: true }, - SHOW_DOCUMENT: { value: 0x100, enumerable: true }, - SHOW_DOCUMENT_TYPE: { value: 0x200, enumerable: true }, - SHOW_DOCUMENT_FRAGMENT: { value: 0x400, enumerable: true }, - SHOW_NOTATION: { value: 0x800, enumerable: true } - }); - - Object.defineProperty(globalObject, \\"NodeFilter\\", { - configurable: true, - writable: true, - value: NodeFilter - }); -}; -" -`; - -exports[`with processors Overloads.webidl 1`] = ` +exports[`with processors NoUselessIfElse.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); const utils = require(\\"./utils.js\\"); -const URL = require(\\"./URL.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"Overloads\\"; +const interfaceName = \\"NoUselessIfElse\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -4423,7 +4344,7 @@ exports.convert = (value, { context = \\"The provided value\\" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } - throw new TypeError(\`\${context} is not of type 'Overloads'.\`); + throw new TypeError(\`\${context} is not of type 'NoUselessIfElse'.\`); }; function makeWrapper(globalObject) { @@ -4431,9 +4352,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"Overloads\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"NoUselessIfElse\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor Overloads is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor NoUselessIfElse is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -4489,111 +4410,171 @@ exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } - class Overloads { + class NoUselessIfElse { constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + overloadsObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (URL.is(curArg)) { - { - let curArg = arguments[0]; - curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); - args.push(curArg); - } + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); } } } - return exports.setup(Object.create(new.target.prototype), globalObject, args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBoolean(...args)); } - compatible(arg1) { + overloadsObjectOrBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'compatible' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'compatible' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - switch (arguments.length) { - case 1: + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - case 2: + } else if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else if (typeof curArg === \\"number\\") { { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - default: + } else { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumeric(...args)); + } + + overloadsObjectOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else if (typeof curArg === \\"number\\") { { - let curArg = arguments[2]; - if (curArg !== undefined) { - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 3\\" - }); - } else { - curArg = 0; - } + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); args.push(curArg); } + } } - return utils.tryWrapperForImpl(esValue[implSymbol].compatible(...args)); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumeric(...args)); } - incompatible1(arg1) { + overloadsBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'incompatible1' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'incompatible1' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); @@ -4601,99 +4582,703 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { { let curArg = arguments[0]; curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } } else { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } } } - return esValue[implSymbol].incompatible1(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumeric(...args)); } - incompatible2(arg1) { + overloadsObjectOrBooleanOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'incompatible2' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'incompatible2' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - switch (arguments.length) { - case 1: + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - default: + } else if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else { { - let curArg = arguments[1]; + let curArg = arguments[0]; curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 2\\" + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } } - return esValue[implSymbol].incompatible2(...args); + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrString(...args)); } - incompatible3(arg1) { + overloadsObjectOrBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'incompatible3' called on an object that is not a valid instance of Overloads.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': 1 argument required, but only \\" + + \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + arguments.length + \\" present.\\" ); } const args = []; - switch (arguments.length) { - case 1: + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } - break; - case 2: + } else if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumericOrString(...args)); + } + + overloadsObjectOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumericOrString(...args)); + } + + overloadsBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumericOrString(...args)); + } + + unionBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumeric(...args)); + } + + unionBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumericOrString(...args)); + } + } + Object.defineProperties(NoUselessIfElse.prototype, { + overloadsObjectOrBoolean: { enumerable: true }, + overloadsObjectOrBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrNumeric: { enumerable: true }, + overloadsBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrBooleanOrString: { enumerable: true }, + overloadsObjectOrBooleanOrNumericOrString: { enumerable: true }, + overloadsObjectOrNumericOrString: { enumerable: true }, + overloadsBooleanOrNumericOrString: { enumerable: true }, + unionBooleanOrNumeric: { enumerable: true }, + unionBooleanOrNumericOrString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"NoUselessIfElse\\", configurable: true } + }); + if (globalObject[ctorRegistrySymbol] === undefined) { + globalObject[ctorRegistrySymbol] = Object.create(null); + } + globalObject[ctorRegistrySymbol][interfaceName] = NoUselessIfElse; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: NoUselessIfElse + }); +}; + +const Impl = require(\\"../implementations/NoUselessIfElse.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; + } + + const NodeFilter = () => { + throw new TypeError(\\"Illegal invocation\\"); + }; + + Object.defineProperties(NodeFilter, { + FILTER_ACCEPT: { value: 1, enumerable: true }, + FILTER_REJECT: { value: 2, enumerable: true }, + FILTER_SKIP: { value: 3, enumerable: true }, + SHOW_ALL: { value: 0xffffffff, enumerable: true }, + SHOW_ELEMENT: { value: 0x1, enumerable: true }, + SHOW_ATTRIBUTE: { value: 0x2, enumerable: true }, + SHOW_TEXT: { value: 0x4, enumerable: true }, + SHOW_CDATA_SECTION: { value: 0x8, enumerable: true }, + SHOW_ENTITY_REFERENCE: { value: 0x10, enumerable: true }, + SHOW_ENTITY: { value: 0x20, enumerable: true }, + SHOW_PROCESSING_INSTRUCTION: { value: 0x40, enumerable: true }, + SHOW_COMMENT: { value: 0x80, enumerable: true }, + SHOW_DOCUMENT: { value: 0x100, enumerable: true }, + SHOW_DOCUMENT_TYPE: { value: 0x200, enumerable: true }, + SHOW_DOCUMENT_FRAGMENT: { value: 0x400, enumerable: true }, + SHOW_NOTATION: { value: 0x800, enumerable: true } + }); + + Object.defineProperty(globalObject, \\"NodeFilter\\", { + configurable: true, + writable: true, + value: NodeFilter + }); +}; +" +`; + +exports[`with processors Overloads.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const URL = require(\\"./URL.js\\"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"Overloads\\"; + +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 'Overloads'.\`); +}; + +function makeWrapper(globalObject) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"Overloads\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor Overloads is not installed on the passed global object\\"); + } + + return Object.create(ctor.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 => { + const wrapper = makeWrapper(globalObject); + + 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 Overloads { + constructor() { + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (URL.is(curArg)) { + { + let curArg = arguments[0]; + curArg = URL.convert(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + args.push(curArg); + } + } + } + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + compatible(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'compatible' called on an object that is not a valid instance of Overloads.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'compatible' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + case 2: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 3\\" + }); + } else { + curArg = 0; + } + args.push(curArg); + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].compatible(...args)); + } + + incompatible1(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'incompatible1' called on an object that is not a valid instance of Overloads.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible1' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + } + } + return esValue[implSymbol].incompatible1(...args); + } + + incompatible2(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'incompatible2' called on an object that is not a valid instance of Overloads.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible2' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible2' on 'Overloads': parameter 2\\" + }); + args.push(curArg); + } + } + return esValue[implSymbol].incompatible2(...args); + } + + incompatible3(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'incompatible3' called on an object that is not a valid instance of Overloads.\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); + } + break; + case 2: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" }); args.push(curArg); } @@ -14162,92 +14747,279 @@ const proxyHandler = { return true; } - } - let ownDesc; + } + let ownDesc; + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, P, V, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (!ownDesc.writable) { + return false; + } + if (!utils.isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); + let valueDesc; + if (existingDesc !== undefined) { + if (existingDesc.get || existingDesc.set) { + return false; + } + if (!existingDesc.writable) { + return false; + } + valueDesc = { value: V }; + } else { + valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; + } + return Reflect.defineProperty(receiver, P, valueDesc); + }, + + defineProperty(target, P, desc) { + if (typeof P === \\"symbol\\") { + return Reflect.defineProperty(target, P, desc); + } + if (![\\"a\\"].includes(P)) { + if (!utils.hasOwn(target, P)) { + if (desc.get || desc.set) { + return false; + } + + let namedValue = desc.value; + + namedValue = conversions[\\"DOMString\\"](namedValue, { + context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" + }); + + const creating = !target[implSymbol][utils.supportsPropertyName](P); + if (creating) { + target[implSymbol][utils.namedSetNew](P, namedValue); + } else { + target[implSymbol][utils.namedSetExisting](P, namedValue); + } + + return true; + } + } + return Reflect.defineProperty(target, P, desc); + }, + + deleteProperty(target, P) { + if (typeof P === \\"symbol\\") { + return Reflect.deleteProperty(target, P); + } + + if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { + return false; + } + + return Reflect.deleteProperty(target, P); + }, + + preventExtensions() { + return false; + } +}; + +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) { + if (globalObject[ctorRegistrySymbol] === undefined) { + throw new Error(\\"Internal error: invalid global object\\"); + } + + const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; + if (ctor === undefined) { + throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); + } + + return Object.create(ctor.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 => { + const wrapper = makeWrapper(globalObject); + + 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(\\"'mixedInOp' called on an object that is not a valid instance of MixedIn.\\"); + } - if (ownDesc === undefined) { - ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + return esValue[implSymbol].mixedInOp(); } - if (ownDesc === undefined) { - const parent = Reflect.getPrototypeOf(target); - if (parent !== null) { - return Reflect.set(parent, P, V, receiver); + + ifaceMixinOp() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError(\\"'ifaceMixinOp' called on an object that is not a valid instance of MixedIn.\\"); } - ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; - } - if (!ownDesc.writable) { - return false; - } - if (!utils.isObject(receiver)) { - return false; + + return esValue[implSymbol].ifaceMixinOp(); } - const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, P); - let valueDesc; - if (existingDesc !== undefined) { - if (existingDesc.get || existingDesc.set) { - return false; - } - if (!existingDesc.writable) { - return false; + + get mixedInAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new TypeError(\\"'get mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); } - valueDesc = { value: V }; - } else { - valueDesc = { writable: true, enumerable: true, configurable: true, value: V }; - } - return Reflect.defineProperty(receiver, P, valueDesc); - }, - defineProperty(target, P, desc) { - if (typeof P === \\"symbol\\") { - return Reflect.defineProperty(target, P, desc); + return esValue[implSymbol][\\"mixedInAttr\\"]; } - if (![\\"a\\"].includes(P)) { - if (!utils.hasOwn(target, P)) { - if (desc.get || desc.set) { - return false; - } - let namedValue = desc.value; + set mixedInAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - namedValue = conversions[\\"DOMString\\"](namedValue, { - context: \\"Failed to set the '\\" + P + \\"' property on 'LegacyUnforgeableMap': The provided value\\" - }); + if (!exports.is(esValue)) { + throw new TypeError(\\"'set mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + } - const creating = !target[implSymbol][utils.supportsPropertyName](P); - if (creating) { - target[implSymbol][utils.namedSetNew](P, namedValue); - } else { - target[implSymbol][utils.namedSetExisting](P, namedValue); - } + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" + }); - return true; - } + esValue[implSymbol][\\"mixedInAttr\\"] = V; } - return Reflect.defineProperty(target, P, desc); - }, - deleteProperty(target, P) { - if (typeof P === \\"symbol\\") { - return Reflect.deleteProperty(target, P); - } + get ifaceMixinAttr() { + const esValue = this !== null && this !== undefined ? this : globalObject; - if (target[implSymbol][utils.supportsPropertyName](P) && !(P in target)) { - return false; + if (!exports.is(esValue)) { + throw new TypeError(\\"'get ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + return esValue[implSymbol][\\"ifaceMixinAttr\\"]; } - return Reflect.deleteProperty(target, P); - }, + set ifaceMixinAttr(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; - preventExtensions() { - return false; + if (!exports.is(esValue)) { + throw new TypeError(\\"'set ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + 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/LegacyUnforgeableMap.js\\"); +const Impl = require(\\"../implementations/MixedIn.js\\"); " `; -exports[`without processors MixedIn.webidl 1`] = ` +exports[`without processors NoUselessIfElse.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -14256,7 +15028,7 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"MixedIn\\"; +const interfaceName = \\"NoUselessIfElse\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -14268,7 +15040,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 'NoUselessIfElse'.\`); }; function makeWrapper(globalObject) { @@ -14276,9 +15048,9 @@ function makeWrapper(globalObject) { throw new Error(\\"Internal error: invalid global object\\"); } - const ctor = globalObject[ctorRegistrySymbol][\\"MixedIn\\"]; + const ctor = globalObject[ctorRegistrySymbol][\\"NoUselessIfElse\\"]; if (ctor === undefined) { - throw new Error(\\"Internal error: constructor MixedIn is not installed on the passed global object\\"); + throw new Error(\\"Internal error: constructor NoUselessIfElse is not installed on the passed global object\\"); } return Object.create(ctor.prototype); @@ -14328,109 +15100,507 @@ exports.new = globalObject => { return wrapper[implSymbol]; }; -const exposed = new Set([\\"Window\\"]); +const exposed = new Set([\\"Window\\"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + class NoUselessIfElse { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + overloadsObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBoolean(...args)); + } + + overloadsObjectOrBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumeric(...args)); + } + + overloadsObjectOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumeric(...args)); + } + + overloadsBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'overloadsBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } -exports.install = (globalObject, globalNames) => { - if (!globalNames.some(globalName => exposed.has(globalName))) { - return; - } - class MixedIn { - constructor() { - throw new TypeError(\\"Illegal constructor\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumeric(...args)); } - mixedInOp() { + overloadsObjectOrBooleanOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'mixedInOp' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol].mixedInOp(); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrString(...args)); } - ifaceMixinOp() { + overloadsObjectOrBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { - throw new TypeError(\\"'ifaceMixinOp' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'overloadsObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol].ifaceMixinOp(); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrBooleanOrNumericOrString(...args)); } - get mixedInAttr() { + overloadsObjectOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'overloadsObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol][\\"mixedInAttr\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsObjectOrNumericOrString(...args)); } - set mixedInAttr(V) { + overloadsBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set mixedInAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'overloadsBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'mixedInAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"mixedInAttr\\"] = V; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloadsBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + args.push(curArg); + } + } + } + return utils.tryWrapperForImpl(esValue[implSymbol].overloadsBooleanOrNumericOrString(...args)); } - get ifaceMixinAttr() { + unionBooleanOrNumeric(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'get ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumeric(...args)); } - set ifaceMixinAttr(V) { + unionBooleanOrNumericOrString(arg1) { const esValue = this !== null && this !== undefined ? this : globalObject; - if (!exports.is(esValue)) { - throw new TypeError(\\"'set ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + throw new TypeError( + \\"'unionBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); } - V = conversions[\\"DOMString\\"](V, { - context: \\"Failed to set the 'ifaceMixinAttr' property on 'MixedIn': The provided value\\" - }); - - esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumericOrString(...args)); } } - 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(NoUselessIfElse.prototype, { + overloadsObjectOrBoolean: { enumerable: true }, + overloadsObjectOrBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrNumeric: { enumerable: true }, + overloadsBooleanOrNumeric: { enumerable: true }, + overloadsObjectOrBooleanOrString: { enumerable: true }, + overloadsObjectOrBooleanOrNumericOrString: { enumerable: true }, + overloadsObjectOrNumericOrString: { enumerable: true }, + overloadsBooleanOrNumericOrString: { enumerable: true }, + unionBooleanOrNumeric: { enumerable: true }, + unionBooleanOrNumericOrString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"NoUselessIfElse\\", configurable: true } }); if (globalObject[ctorRegistrySymbol] === undefined) { globalObject[ctorRegistrySymbol] = Object.create(null); } - globalObject[ctorRegistrySymbol][interfaceName] = MixedIn; + globalObject[ctorRegistrySymbol][interfaceName] = NoUselessIfElse; Object.defineProperty(globalObject, interfaceName, { configurable: true, writable: true, - value: MixedIn + value: NoUselessIfElse }); }; -const Impl = require(\\"../implementations/MixedIn.js\\"); +const Impl = require(\\"../implementations/NoUselessIfElse.js\\"); " `; diff --git a/test/cases/NoUselessIfElse.webidl b/test/cases/NoUselessIfElse.webidl new file mode 100644 index 00000000..b9d77070 --- /dev/null +++ b/test/cases/NoUselessIfElse.webidl @@ -0,0 +1,46 @@ +[Exposed=Window] +interface NoUselessIfElse { + // # Overloads: + undefined overloadsObjectOrBoolean(object arg1); + undefined overloadsObjectOrBoolean(boolean arg1); + + undefined overloadsObjectOrBooleanOrNumeric(object arg1); + undefined overloadsObjectOrBooleanOrNumeric(boolean arg1); + undefined overloadsObjectOrBooleanOrNumeric(long arg1); + + undefined overloadsObjectOrNumeric(object arg1); + undefined overloadsObjectOrNumeric(long arg1); + + undefined overloadsBooleanOrNumeric(boolean arg1); + undefined overloadsBooleanOrNumeric(long arg1); + + // ## Avoid regressions: + undefined overloadsObjectOrBooleanOrString(object arg1); + undefined overloadsObjectOrBooleanOrString(boolean arg1); + undefined overloadsObjectOrBooleanOrString(DOMString arg1); + + undefined overloadsObjectOrBooleanOrNumericOrString(object arg1); + undefined overloadsObjectOrBooleanOrNumericOrString(boolean arg1); + undefined overloadsObjectOrBooleanOrNumericOrString(long arg1); + undefined overloadsObjectOrBooleanOrNumericOrString(DOMString arg1); + + undefined overloadsObjectOrNumericOrString(object arg1); + undefined overloadsObjectOrNumericOrString(long arg1); + undefined overloadsObjectOrNumericOrString(DOMString arg1); + + undefined overloadsBooleanOrNumericOrString(boolean arg1); + undefined overloadsBooleanOrNumericOrString(long arg1); + undefined overloadsBooleanOrNumericOrString(DOMString arg1); + + // # Unions: + // undefined unionObjectOrBoolean((object or boolean) arg1); + // undefined unionObjectOrBooleanOrNumeric((object or boolean or long) arg1); + // undefined unionObjectOrNumeric((object or long) arg1); + undefined unionBooleanOrNumeric((boolean or long) arg1); + + // ## Avoid regressions: + // undefined unionObjectOrBooleanOrString((object or boolean or DOMString) arg1); + // undefined unionObjectOrBooleanOrNumericOrString((object or boolean or long or DOMString) arg1); + // undefined unionObjectOrNumericOrString((object or long or DOMString) arg1); + undefined unionBooleanOrNumericOrString((boolean or long or DOMString) arg1); +};