diff --git a/lib/parameters.js b/lib/parameters.js index adfab32f..22c975a1 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -273,32 +273,41 @@ module.exports.generateOverloadConversions = function (ctx, typeOfOp, name, pare } const booleans = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => t.idlType === "boolean")); - if (booleans.length) { - possibilities.push(` - if (typeof curArg === "boolean") { - ${continued(booleans[0], i)} - } - `); - } - const numerics = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => Types.numericTypes.has(t.idlType))); - if (numerics.length) { - possibilities.push(` - if (typeof curArg === "number") { - ${continued(numerics[0], i)} - } - `); - } - const strings = S.filter(o => { return isOrIncludes(ctx, o.typeList[d], t => { return Types.stringTypes.has(t.idlType) || ctx.enumerations.has(t.idlType); }); }); + const any = S.filter(o => isOrIncludes(ctx, o.typeList[d], t => t.idlType === "any")); if (strings.length) { + if (booleans.length) { + possibilities.push(` + if (typeof curArg === "boolean") { + ${continued(booleans[0], i)} + } + `); + } + + if (numerics.length) { + possibilities.push(` + if (typeof curArg === "number") { + ${continued(numerics[0], i)} + } + `); + } + possibilities.push(`{ ${continued(strings[0], i)} }`); } else if (numerics.length) { + if (booleans.length) { + possibilities.push(` + if (typeof curArg === "boolean") { + ${continued(booleans[0], i)} + } + `); + } + possibilities.push(`{ ${continued(numerics[0], i)} }`); } else if (booleans.length) { possibilities.push(`{ ${continued(booleans[0], i)} }`); diff --git a/lib/types.js b/lib/types.js index 3ec2d5f0..03d048ac 100644 --- a/lib/types.js +++ b/lib/types.js @@ -208,7 +208,8 @@ function generateTypeConversion(ctx, name, idlType, argAttrs = [], parentName, e if (union.ArrayBufferViews.size > 0 || union.object) { let condition = `ArrayBuffer.isView(${name})`; // Skip specific type check if all ArrayBufferView member types are allowed. - if (union.ArrayBufferViews.size !== arrayBufferViewTypes.size) { + if (union.ArrayBufferViews.size !== 0 && + union.ArrayBufferViews.size !== arrayBufferViewTypes.size) { const exprs = [...union.ArrayBufferViews].map(a => `${name}.constructor.name === "${a}"`); condition += ` && (${exprs.join(" || ")})`; } @@ -272,25 +273,26 @@ function generateTypeConversion(ctx, name, idlType, argAttrs = [], parentName, e output.push(code); } - if (union.boolean) { - output.push(` - if (typeof ${name} === "boolean") { - ${generateTypeConversion(ctx, name, union.boolean, [], parentName, errPrefix).body} - } - `); - } + { + const { string, numeric, boolean } = union; + if (boolean && (string || numeric)) { + output.push(` + if (typeof ${name} === "boolean") { + ${generateTypeConversion(ctx, name, boolean, [], parentName, errPrefix).body} + } + `); + } - if (union.numeric) { - output.push(` - if (typeof ${name} === "number") { - ${generateTypeConversion(ctx, name, union.numeric, [], parentName, errPrefix).body} - } - `); - } + if (numeric && string) { + output.push(` + if (typeof ${name} === "number") { + ${generateTypeConversion(ctx, name, numeric, [], parentName, errPrefix).body} + } + `); + } - { let code = "{"; - const type = union.string || union.numeric || union.boolean; + const type = string || numeric || boolean; if (type) { const conv = generateTypeConversion(ctx, name, type, [], parentName, errPrefix); code += conv.body; diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 8023678b..cdf200b5 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,147 @@ 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 { + { + 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 { { - 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: + } + } + 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[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + curArg = conversions[\\"object\\"](curArg, { + context: \\"Failed to execute 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); args.push(curArg); } + } else { { - 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 'overloadsObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" }); 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)); + 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,118 +4558,940 @@ exports.install = (globalObject, globalNames) => { const args = []; { let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { + if (typeof curArg === \\"boolean\\") { { let curArg = arguments[0]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + curArg = conversions[\\"boolean\\"](curArg, { + 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[1]; - if (curArg === undefined) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = URL.convert(curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - } - args.push(curArg); - } - } else if (URL.is(curArg)) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { + 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)); + } + + unionObjectOrBoolean(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBoolean' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBoolean(...args)); + } + + unionObjectOrBooleanOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumeric(...args)); + } + + unionObjectOrNumeric(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrNumeric' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumeric(...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 { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumeric(...args)); + } + + unionObjectOrBooleanOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrString(...args)); + } + + unionObjectOrBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrBooleanOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumericOrString(...args)); + } + + unionObjectOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumericOrString(...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 }, + unionObjectOrBoolean: { enumerable: true }, + unionObjectOrBooleanOrNumeric: { enumerable: true }, + unionObjectOrNumeric: { enumerable: true }, + unionBooleanOrNumeric: { enumerable: true }, + unionObjectOrBooleanOrString: { enumerable: true }, + unionObjectOrBooleanOrNumericOrString: { enumerable: true }, + unionObjectOrNumericOrString: { 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); + } + { + let curArg = arguments[1]; + if (curArg === undefined) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = URL.convert(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); + } + } else if (URL.is(curArg)) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { curArg = URL.convert(curArg, { context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" }); @@ -14256,7 +15035,194 @@ const utils = require(\\"./utils.js\\"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; -const interfaceName = \\"MixedIn\\"; +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.\\"); + } + + return esValue[implSymbol].mixedInOp(); + } + + 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.\\"); + } + + return esValue[implSymbol].ifaceMixinOp(); + } + + 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.\\"); + } + + return esValue[implSymbol][\\"mixedInAttr\\"]; + } + + set mixedInAttr(V) { + 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.\\"); + } + + 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(\\"'get ifaceMixinAttr' called on an object that is not a valid instance of MixedIn.\\"); + } + + return esValue[implSymbol][\\"ifaceMixinAttr\\"]; + } + + set ifaceMixinAttr(V) { + 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.\\"); + } + + 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 NoUselessIfElse.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = \\"NoUselessIfElse\\"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; @@ -14268,7 +15234,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 +15242,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 +15294,701 @@ 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 { + { + 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 { + { + 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 { + { + 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.\\" + ); + } + + 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 { + { + 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)); + } + + overloadsObjectOrBooleanOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + 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 '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)); + } + + overloadsObjectOrBooleanOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + 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 '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)); + } + + 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.\\" + ); + } -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 '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)); } - mixedInOp() { + unionObjectOrBoolean(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( + \\"'unionObjectOrBoolean' 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 'unionObjectOrBoolean' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBoolean(...args)); } - ifaceMixinOp() { + unionObjectOrBooleanOrNumeric(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( + \\"'unionObjectOrBooleanOrNumeric' 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 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumeric(...args)); } - get mixedInAttr() { + unionObjectOrNumeric(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( + \\"'unionObjectOrNumeric' 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 'unionObjectOrNumeric' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumeric(...args)); } - set mixedInAttr(V) { + unionBooleanOrNumeric(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( + \\"'unionBooleanOrNumeric' 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 '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 { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionBooleanOrNumeric' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionBooleanOrNumeric(...args)); } - get ifaceMixinAttr() { + unionObjectOrBooleanOrString(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( + \\"'unionObjectOrBooleanOrString' 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 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrString(...args)); } - set ifaceMixinAttr(V) { + unionObjectOrBooleanOrNumericOrString(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( + \\"'unionObjectOrBooleanOrNumericOrString' 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\\" - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"boolean\\") { + curArg = conversions[\\"boolean\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrBooleanOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrBooleanOrNumericOrString(...args)); + } - esValue[implSymbol][\\"ifaceMixinAttr\\"] = V; + unionObjectOrNumericOrString(arg1) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new TypeError( + \\"'unionObjectOrNumericOrString' called on an object that is not a valid instance of NoUselessIfElse.\\" + ); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (utils.isObject(curArg) && curArg[utils.implSymbol]) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + } else if (ArrayBuffer.isView(curArg)) { + } else if (typeof curArg === \\"function\\") { + } else if (utils.isObject(curArg)) { + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'unionObjectOrNumericOrString' on 'NoUselessIfElse': parameter 1\\" + }); + } + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].unionObjectOrNumericOrString(...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 } + + 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 }, + unionObjectOrBoolean: { enumerable: true }, + unionObjectOrBooleanOrNumeric: { enumerable: true }, + unionObjectOrNumeric: { enumerable: true }, + unionBooleanOrNumeric: { enumerable: true }, + unionObjectOrBooleanOrString: { enumerable: true }, + unionObjectOrBooleanOrNumericOrString: { enumerable: true }, + unionObjectOrNumericOrString: { 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..5a278f56 --- /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); +};