diff --git a/README.md b/README.md index 3bd63632..d4c24973 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ As a very minimal example, the Web IDL file ```webidl interface SomeInterface { unsigned long long add(unsigned long x, unsigned long y); -} +}; ``` combined with the JavaScript implementation class file ```js -exports.implementation = class { +exports.implementation = class SomeInterfaceImpl { add(x, y) { return x + y; } @@ -30,38 +30,38 @@ const impl = require("./utils.js").implSymbol; const Impl = require("./SomeInterface-impl.js").implementation; -function SomeInterface() { - throw new TypeError("Illegal constructor"); -} - -SomeInterface.prototype.add = function add(x, y) { - if (!exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - if (arguments.length < 2) { - throw new TypeError( - "Failed to execute 'add' on 'SomeInterface': 2 arguments required, but only " + - arguments.length + - " present." - ); +class SomeInterface { + constructor() { + throw new TypeError("Illegal constructor"); } - const args = []; - args[0] = conversions["unsigned long"](arguments[0], { - context: "Failed to execute 'add' on 'SomeInterface': parameter 1" - }); - args[1] = conversions["unsigned long"](arguments[1], { - context: "Failed to execute 'add' on 'SomeInterface': parameter 2" - }); - - this[impl].add(...args); -}; + add(x, y) { + if (!exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + if (arguments.length < 2) { + throw new TypeError( + "Failed to execute 'add' on 'SomeInterface': 2 arguments required, but only " + + arguments.length + + " present." + ); + } + + const args = []; + args[0] = conversions["unsigned long"](arguments[0], { + context: "Failed to execute 'add' on 'SomeInterface': parameter 1" + }); + args[1] = conversions["unsigned long"](arguments[1], { + context: "Failed to execute 'add' on 'SomeInterface': parameter 2" + }); + + return this[impl].add(...args); + } +} -Object.defineProperty(SomeInterface.prototype, Symbol.toStringTag, { - value: "SomeInterface", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(SomeInterface.prototype, { + add: { enumerable: true }, + [Symbol.toStringTag]: { value: "SomeInterface", configurable: true } }); exports.interface = SomeInterface; @@ -82,6 +82,7 @@ The above is a simplification of the actual generated code, but should give you - Brand-checking on operation invocation - Argument-length checking for non-optional arguments - Argument conversion according to the rules specified in Web IDL for given argument types + - Enumerability of operations - @@toStringTag semantics to make `Object.prototype.toString.call()` behave correctly - After performing Web IDL-related processing, webidl2js delegates to the implementation class for the non-boilerplate parts of `add()`. This allows you to focus on writing the interesting parts of the implementation without worrying about types, brand-checking, parameter-processing, etc. - webidl2js attempts to generate informative error messages using what it knows. diff --git a/lib/constructs/attribute.js b/lib/constructs/attribute.js index 54c1c9d0..8cc3f8ef 100644 --- a/lib/constructs/attribute.js +++ b/lib/constructs/attribute.js @@ -15,18 +15,17 @@ class Attribute { } generate() { - let str = ""; const requires = new utils.RequiresMap(this.ctx); const configurable = !utils.getExtAttr(this.idl.extAttrs, "Unforgeable"); const shouldReflect = utils.getExtAttr(this.idl.extAttrs, "Reflect"); const sameObject = utils.getExtAttr(this.idl.extAttrs, "SameObject"); + const onInstance = utils.isOnInstance(this.idl, this.interface.idl); + let objName = `this`; - let definedOn = this.interface.name + (this.static ? "" : ".prototype"); - if (utils.isOnInstance(this.idl, this.interface.idl)) { // we're in a setup method + if (onInstance) { // we're in a setup method objName = `obj`; - definedOn = `obj`; } let brandCheck = ` if (!this || !module.exports.is(this)) { @@ -39,6 +38,10 @@ class Attribute { getterBody = `return ${objName}[impl]["${this.idl.name}"];`; } + const addMethod = this.static ? + this.interface.addStaticMethod.bind(this.interface) : + this.interface.addMethod.bind(this.interface, onInstance ? "instance" : "prototype"); + if (this.static) { brandCheck = ""; getterBody = `return Impl.implementation["${this.idl.name}"];`; @@ -60,13 +63,11 @@ class Attribute { getterBody = `return utils.getSameObject(this, "${this.idl.name}", () => { ${getterBody} });`; } - str += ` - Object.defineProperty(${definedOn}, "${this.idl.name}", { - get() { - ${brandCheck} - ${getterBody} - }, - `; + addMethod(this.idl.name, [], ` + ${brandCheck} + ${getterBody} + `, "get", { configurable }); + if (!this.idl.readonly) { let idlConversion; if (typeof this.idl.idlType.idlType === "string" && !this.idl.idlType.nullable && @@ -85,70 +86,39 @@ class Attribute { requires.merge(conv.requires); idlConversion = conv.body; } - str += ` - set(V) { - ${brandCheck} - ${idlConversion} - ${setterBody} - }, - `; + + addMethod(this.idl.name, ["V"], ` + ${brandCheck} + ${idlConversion} + ${setterBody} + `, "set", { configurable }); } else if (utils.getExtAttr(this.idl.extAttrs, "PutForwards")) { - str += ` - set(V) { - ${brandCheck} - this.${this.idl.name}.${utils.getExtAttr(this.idl.extAttrs, "PutForwards").rhs.value} = V; - }, - `; + addMethod(this.idl.name, ["V"], ` + ${brandCheck} + this.${this.idl.name}.${utils.getExtAttr(this.idl.extAttrs, "PutForwards").rhs.value} = V; + `, "set", { configurable }); } else if (utils.getExtAttr(this.idl.extAttrs, "Replaceable")) { - str += ` - set(V) { - ${brandCheck} - Object.defineProperty(this, "${this.idl.name}", { - configurable: true, - enumerable: true, - value: V, - writable: true - }); - }, - `; + addMethod(this.idl.name, ["V"], ` + ${brandCheck} + Object.defineProperty(this, "${this.idl.name}", { + configurable: true, + enumerable: true, + value: V, + writable: true + }); + `, "set", { configurable }); } - str += ` - enumerable: true, - configurable: ${JSON.stringify(configurable)} - }); - `; - if (this.idl.stringifier) { - const functionExpression = ` - function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - ${getterBody}; + if (!this.static && this.idl.stringifier) { + addMethod("toString", [], ` + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); } - `; - - if (utils.getExtAttr(this.idl.extAttrs, "Unforgeable")) { - str += ` - Object.defineProperty(${definedOn}, "toString", { - writable: false, - enumerable: true, - configurable: false, - value: ${functionExpression} - }); - `; - } else { - str += ` - ${definedOn}.toString = ${functionExpression}; - `; - } - str += "\n"; + ${getterBody}; + `, "regular", { configurable, writable: configurable }); } - return { - requires, - body: str - }; + return { requires }; } } diff --git a/lib/constructs/constant.js b/lib/constructs/constant.js index 8d977fab..df696229 100644 --- a/lib/constructs/constant.js +++ b/lib/constructs/constant.js @@ -12,20 +12,15 @@ class Constant { } generate() { - const body = ` - Object.defineProperty(${this.interface.name}, "${this.idl.name}", { - value: ${utils.getDefault(this.idl.value)}, - enumerable: true - }); - Object.defineProperty(${this.interface.name}.prototype, "${this.idl.name}", { - value: ${utils.getDefault(this.idl.value)}, - enumerable: true - }); - `; - return { - requires: new utils.RequiresMap(this.ctx), - body - }; + this.interface.addStaticProperty(this.idl.name, utils.getDefault(this.idl.value), { + configurable: false, + writable: false + }); + this.interface.addProperty(this.interface.defaultWhence, this.idl.name, utils.getDefault(this.idl.value), { + configurable: false, + writable: false + }); + return { requires: new utils.RequiresMap(this.ctx) }; } } diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 6dec8890..81cb4411 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -17,6 +17,50 @@ function isIndexed(idl) { return idl.arguments[0].idlType.idlType === "unsigned long"; } +function formatArgs(args) { + return args.map(name => name + (keywords.has(name) ? "_" : "")).join(", "); +} + +const defaultDefinePropertyDescriptor = { + configurable: false, + enumerable: false, + writable: false +}; + +const defaultObjectLiteralDescriptor = { + configurable: true, + enumerable: true, + writable: true +}; + +const defaultClassMethodDescriptor = { + configurable: true, + enumerable: false, + writable: true +}; + +// type can be "accessor" or "regular" +function getPropertyDescriptorModifier(currentDesc, targetDesc, type, value = undefined) { + const changes = []; + if (value !== undefined) { + changes.push(`value: ${value}`); + } + if (currentDesc.configurable !== targetDesc.configurable) { + changes.push(`configurable: ${targetDesc.configurable}`); + } + if (currentDesc.enumerable !== targetDesc.enumerable) { + changes.push(`enumerable: ${targetDesc.enumerable}`); + } + if (type !== "accessor" && currentDesc.writable !== targetDesc.writable) { + changes.push(`writable: ${targetDesc.writable}`); + } + + if (changes.length === 0) { + return undefined; + } + return `{ ${changes.join(", ")} }`; +} + class Interface { constructor(ctx, idl, opts) { this.ctx = ctx; @@ -47,6 +91,93 @@ class Interface { this.iterable = null; this._analyzed = false; + + this._outputMethods = new Map(); + this._outputStaticMethods = new Map(); + this._outputProperties = new Map(); + this._outputStaticProperties = new Map(); + } + + // whence is either "instance" or "prototype" + // type is either "regular", "get", or "set" + addMethod(whence, propName, args, body, type = "regular", { + configurable = true, + enumerable = typeof propName === "string", + writable = type === "regular" ? true : undefined + } = {}) { + if (whence !== "instance" && whence !== "prototype") { + throw new Error(`Internal error: Invalid whence ${whence}`); + } + if (type !== "regular") { + const existing = this._outputMethods.get(propName); + if (existing !== undefined) { + if (type === "get") { + existing.body[0] = body; + } else { + existing.args = args; + existing.body[1] = body; + } + return; + } + + const pair = new Array(2); + pair[type === "get" ? 0 : 1] = body; + body = pair; + type = "accessor"; + } + + const descriptor = { configurable, enumerable, writable }; + this._outputMethods.set(propName, { whence, type, args, body, descriptor }); + } + + // type is either "regular", "get", or "set" + addStaticMethod(propName, args, body, type = "regular", { + configurable = true, + enumerable = typeof propName === "string", + writable = type === "regular" ? true : undefined + } = {}) { + if (type !== "regular") { + const existing = this._outputStaticMethods.get(propName); + if (existing !== undefined) { + if (type === "get") { + existing.body[0] = body; + } else { + existing.args = args; + existing.body[1] = body; + } + return; + } + + const pair = new Array(2); + pair[type === "get" ? 0 : 1] = body; + body = pair; + type = "accessor"; + } + + const descriptor = { configurable, enumerable, writable }; + this._outputStaticMethods.set(propName, { type, args, body, descriptor }); + } + + // whence is either "instance" or "prototype" + addProperty(whence, propName, str, { + configurable = true, + enumerable = typeof propName === "string", + writable = true + } = {}) { + if (whence !== "instance" && whence !== "prototype") { + throw new Error(`Internal error: Invalid whence ${whence}`); + } + const descriptor = { configurable, enumerable, writable }; + this._outputProperties.set(propName, { whence, body: str, descriptor }); + } + + addStaticProperty(propName, str, { + configurable = true, + enumerable = typeof propName === "string", + writable = true + } = {}) { + const descriptor = { configurable, enumerable, writable }; + this._outputStaticProperties.set(propName, { body: str, descriptor }); } _analyzeMembers() { @@ -293,8 +424,6 @@ class Interface { }, [Symbol.toStringTag]: { value: "${this.name} Iterator", - writable: false, - enumerable: false, configurable: true } }); @@ -302,65 +431,6 @@ class Interface { } } - generateConstructor() { - const overloads = Overloads.getEffectiveOverloads("constructor", this.name, 0, this); - - if (overloads.length !== 0) { - let minConstructor = overloads[0]; - for (let i = 1; i < overloads.length; ++i) { - if (overloads[i].nameList.length < minConstructor.nameList.length) { - minConstructor = overloads[i]; - } - } - - const conversions = Parameters.generateOverloadConversions( - this.ctx, "constructor", this.name, this, `Failed to construct '${this.name}': `); - this.requires.merge(conversions.requires); - - const argNames = minConstructor.nameList.map(name => (keywords.has(name) ? "_" : "") + name); - this.str += ` - function ${this.name}(${argNames.join(", ")}) { - if (new.target === undefined) { - throw new TypeError("Failed to construct '${this.name}'. Please use the 'new' operator; this constructor " + - "cannot be called as a function."); - } - `; - this.str += conversions.body + "\n"; - - const passArgs = conversions.hasArgs ? ", args" : ""; - this.str += ` - iface.setup(this${passArgs}); - } - `; - } else { - this.str += ` - function ${this.name}() { - throw new TypeError("Illegal constructor"); - } - `; - } - - if (this.idl.inheritance) { - this.str += ` - Object.setPrototypeOf(${this.name}.prototype, ${this.idl.inheritance}.interface.prototype); - Object.setPrototypeOf(${this.name}, ${this.idl.inheritance}.interface); - `; - } else if (utils.getExtAttr(this.idl.extAttrs, "LegacyArrayClass")) { - this.str += ` - Object.setPrototypeOf(${this.name}.prototype, Array.prototype); - `; - } - - this.str += ` - Object.defineProperty(${this.name}, "prototype", { - value: ${this.name}.prototype, - writable: false, - enumerable: false, - configurable: false - }); - `; - } - // https://heycam.github.io/webidl/#dfn-consequential-interfaces * consequentialInterfaces(seen = new Set([this.name]), root = this.name) { for (const mixin of this.mixins) { @@ -485,8 +555,6 @@ class Interface { const iterator = Object.create(IteratorPrototype); Object.defineProperty(iterator, utils.iterInternalSymbol, { value: { target, kind, index: 0 }, - writable: false, - enumerable: false, configurable: true }); return iterator; @@ -999,8 +1067,6 @@ class Interface { }, `; - // TODO: Implement [[Call]] / legacycallers. - // [[PreventExtensions]] this.str += ` preventExtensions() { @@ -1060,20 +1126,7 @@ class Interface { `; } - for (const member of this.operations.values()) { - if (member.isOnInstance()) { - const data = member.generate(); - this.requires.merge(data.requires); - this.str += data.body; - } - } - for (const member of this.attributes.values()) { - if (utils.isOnInstance(member.idl, this.idl)) { - const data = member.generate(); - this.requires.merge(data.requires); - this.str += data.body; - } - } + this.generateOnInstance(); this.str += ` }, @@ -1097,8 +1150,6 @@ class Interface { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); `; @@ -1121,122 +1172,254 @@ class Interface { `; } - generateOperations() { + addConstructor() { + const overloads = Overloads.getEffectiveOverloads("constructor", this.name, 0, this); + + let body; + let argNames = []; + + if (overloads.length !== 0) { + let minConstructor = overloads[0]; + for (let i = 1; i < overloads.length; ++i) { + if (overloads[i].nameList.length < minConstructor.nameList.length) { + minConstructor = overloads[i]; + } + } + argNames = minConstructor.nameList; + + const conversions = Parameters.generateOverloadConversions( + this.ctx, "constructor", this.name, this, `Failed to construct '${this.name}': `); + this.requires.merge(conversions.requires); + + const passArgs = conversions.hasArgs ? ", args" : ""; + body = ` + ${conversions.body} + return iface.setup(Object.create(${this.name}.prototype)${passArgs}); + `; + } else { + body = ` + throw new TypeError("Illegal constructor"); + `; + } + + this.addMethod("prototype", "constructor", argNames, body, "regular", { enumerable: false }); + } + + get defaultWhence() { + return utils.isGlobal(this.idl) ? "instance" : "prototype"; + } + + addIteratorMethod() { // TODO maplike setlike // Don't bother checking "length" attribute as interfaces that support indexed properties must implement one. // "Has value iterator" implies "supports indexed properties". - if (this.supportsIndexedProperties || this.iterable && this.iterable.isPair) { - let expr; + if (this.supportsIndexedProperties) { + this.addProperty(this.defaultWhence, Symbol.iterator, "Array.prototype[Symbol.iterator]"); + } + } - if (this.supportsIndexedProperties) { - expr = "Array.prototype[Symbol.iterator]"; + addAllMethodsProperties() { + this.addConstructor(); + + this.addProperty("prototype", Symbol.toStringTag, JSON.stringify(this.name), { + writable: false + }); + + const unscopables = Object.create(null); + for (const member of this.idl.members) { + if (utils.getExtAttr(member.extAttrs, "Unscopable")) { + unscopables[member.name] = true; + } + } + if (Object.keys(unscopables).length > 0) { + this.addProperty("prototype", Symbol.unscopables, JSON.stringify(unscopables), { + writable: false + }); + } + + for (const member of [...this.operations.values(), ...this.staticOperations.values()]) { + const data = member.generate(); + this.requires.merge(data.requires); + } + this.addIteratorMethod(); + if (this.iterable) { + const data = this.iterable.generate(); + this.requires.merge(data.requires); + } + + for (const member of [...this.attributes.values(), ...this.staticAttributes.values(), ...this.constants.values()]) { + const data = member.generate(); + this.requires.merge(data.requires); + } + } + + generateOffInstanceMethods() { + const addOne = (name, args, body) => { + this.str += ` + ${name}(${formatArgs(args)}) {${body}} + `; + }; + + for (const [name, { whence, type, args, body }] of this._outputMethods) { + if (whence !== "prototype") { + continue; + } + + const propName = utils.stringifyPropertyName(name); + if (type === "regular") { + addOne(propName, args, body); } else { - expr = ` - function entries() { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - return module.exports.createDefaultIterator(this, "key+value"); - } - `; + if (body[0] !== undefined) { + addOne(`get ${propName}`, [], body[0]); + } + if (body[1] !== undefined) { + addOne(`set ${propName}`, args, body[1]); + } } + } + for (const [name, { type, args, body }] of this._outputStaticMethods) { + const propName = utils.stringifyPropertyName(name); + if (type === "regular") { + addOne(`static ${propName}`, args, body); + } else { + if (body[0] !== undefined) { + addOne(`static get ${propName}`, [], body[0]); + } + if (body[1] !== undefined) { + addOne(`static set ${propName}`, args, body[0]); + } + } + } + } + + generateOffInstanceAfterClass() { + // Inheritance is taken care of by "extends" clause in class declaration. + if (utils.getExtAttr(this.idl.extAttrs, "LegacyArrayClass")) { + if (this.idl.inheritance) { + throw new Error(`Interface ${this.name} has [LegacyArrayClass] but inherits from ${this.idl.inheritance}`); + } this.str += ` - Object.defineProperty(${this.name}.prototype, Symbol.iterator, { - writable: true, - enumerable: false, - configurable: true, - value: ${expr} - }); + Object.setPrototypeOf(${this.name}.prototype, Array.prototype); `; } - if (this.iterable) { - let expr; + const protoProps = new Map(); + const classProps = new Map(); - if (this.iterable.isValue) { - expr = "Array.prototype.forEach"; - } else { - expr = ` - function forEach(callback) { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - if (arguments.length < 1) { - throw new TypeError("Failed to execute 'forEach' on '${this.name}': 1 argument required, " + - "but only 0 present."); - } - if (typeof callback !== "function") { - throw new TypeError("Failed to execute 'forEach' on '${this.name}': The callback provided " + - "as parameter 1 is not a function."); - } - const thisArg = arguments[1]; - let pairs = Array.from(this[impl]); - let i = 0; - while (i < pairs.length) { - const [key, value] = pairs[i].map(utils.tryWrapperForImpl); - callback.call(thisArg, value, key, this); - pairs = Array.from(this[impl]); - i++; - } - } - `; + for (const [name, { whence, type, descriptor }] of this._outputMethods) { + if (whence !== "prototype") { + continue; } - this.str += `${this.name}.prototype.forEach = ${expr};`; + const descriptorModifier = getPropertyDescriptorModifier(defaultClassMethodDescriptor, descriptor, type); + if (descriptorModifier === undefined) { + continue; + } + protoProps.set(utils.stringifyPropertyName(name), descriptorModifier); } - for (const member of [...this.operations.values(), ...this.staticOperations.values()]) { - if (!member.isOnInstance()) { - const data = member.generate(); - this.requires.merge(data.requires); - this.str += data.body; + for (const [name, { type, descriptor }] of this._outputStaticMethods) { + const descriptorModifier = getPropertyDescriptorModifier(defaultClassMethodDescriptor, descriptor, type); + if (descriptorModifier === undefined) { + continue; } + classProps.set(utils.stringifyPropertyName(name), descriptorModifier); } - if (this.iterable) { - const data = this.iterable.generate(); - this.requires.merge(data.requires); - this.str += data.body; + + for (const [name, { whence, body, descriptor }] of this._outputProperties) { + if (whence !== "prototype") { + continue; + } + + const descriptorModifier = + getPropertyDescriptorModifier(defaultDefinePropertyDescriptor, descriptor, "regular", body); + protoProps.set(utils.stringifyPropertyName(name), descriptorModifier); + } + + for (const [name, { body, descriptor }] of this._outputStaticProperties) { + const descriptorModifier = + getPropertyDescriptorModifier(defaultDefinePropertyDescriptor, descriptor, "regular", body); + classProps.set(utils.stringifyPropertyName(name), descriptorModifier); + } + + if (protoProps.size > 0) { + const props = [...protoProps].map(([name, body]) => `${name}: ${body}`); + this.str += `Object.defineProperties(${this.name}.prototype, { ${props.join(", ")} });`; + } + + if (classProps.size > 0) { + const props = [...classProps].map(([name, body]) => `${name}: ${body}`); + this.str += `Object.defineProperties(${this.name}, { ${props.join(", ")} });`; } } - generateAttributes() { - for (const member of [...this.attributes.values(), ...this.staticAttributes.values(), ...this.constants.values()]) { - if (member instanceof Attribute && utils.isOnInstance(member.idl, this.idl)) { + generateOnInstance() { + const methods = []; + const props = new Map(); + + function addOne(name, args, body) { + methods.push(` + ${name}(${formatArgs(args)}) {${body}} + `); + } + + for (const [name, { whence, type, args, body, descriptor }] of this._outputMethods) { + if (whence !== "instance") { continue; } - const data = member.generate(); - this.requires.merge(data.requires); - this.str += data.body; + + const propName = utils.stringifyPropertyName(name); + if (type === "regular") { + addOne(propName, args, body); + } else { + if (body[0] !== undefined) { + addOne(`get ${propName}`, [], body[0]); + } + if (body[1] !== undefined) { + addOne(`set ${propName}`, args, body[1]); + } + } + + const descriptorModifier = getPropertyDescriptorModifier(defaultObjectLiteralDescriptor, descriptor, type); + if (descriptorModifier === undefined) { + continue; + } + props.set(utils.stringifyPropertyName(name), descriptorModifier); } - } - generateSymbols() { - const unscopables = Object.create(null); - for (const member of this.idl.members) { - if (utils.getExtAttr(member.extAttrs, "Unscopable")) { - unscopables[member.name] = true; + for (const [name, { whence, body, descriptor }] of this._outputProperties) { + if (whence !== "instance") { + continue; } + + const propName = utils.stringifyPropertyName(name); + methods.push(`${propName}: ${body}`); + + const descriptorModifier = getPropertyDescriptorModifier(defaultObjectLiteralDescriptor, descriptor, "regular"); + if (descriptorModifier === undefined) { + continue; + } + props.set(propName, descriptorModifier); } - if (Object.keys(unscopables).length) { + const propStrs = [...props].map(([name, body]) => `${name}: ${body}`); + if (methods.length > 0) { this.str += ` - Object.defineProperty(${this.name}.prototype, Symbol.unscopables, { - value: ${JSON.stringify(unscopables, null, " ")}, - writable: false, - enumerable: false, - configurable: true - }); + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ ${methods.join(", ")} }) + ); + `; + } + if (propStrs.length > 0) { + this.str += ` + Object.defineProperties( + obj, + { ${propStrs.join(", ")} } + ); `; } - this.str += ` - Object.defineProperty(${this.name}.prototype, Symbol.toStringTag, { - value: "${this.name}", - writable: false, - enumerable: false, - configurable: true - }); - `; } generate() { @@ -1249,12 +1432,14 @@ class Interface { `; } - this.generateConstructor(); + const ext = this.idl.inheritance ? ` extends ${this.idl.inheritance}.interface` : ""; + this.str += `class ${this.name}${ext} {`; + + this.generateOffInstanceMethods(); - this.generateOperations(); - this.generateAttributes(); + this.str += "}"; - this.generateSymbols(); + this.generateOffInstanceAfterClass(); this.str += ` const iface = { @@ -1290,6 +1475,7 @@ class Interface { this._analyzed = true; this._analyzeMembers(); } + this.addAllMethodsProperties(); this.generate(); return this.str; } diff --git a/lib/constructs/iterable.js b/lib/constructs/iterable.js index c69b7f82..7ae29e41 100644 --- a/lib/constructs/iterable.js +++ b/lib/constructs/iterable.js @@ -1,6 +1,5 @@ "use strict"; -const keywords = require("../keywords"); const utils = require("../utils"); class Iterable { @@ -19,47 +18,54 @@ class Iterable { return this.idl.idlType.length === 2; } - generateFunction(key, kind, keyExpr, fnName) { - if (fnName === undefined) { - if (typeof key === "symbol") { - fnName = ""; - } else { - fnName = keywords.has(key) ? "_" : key; + generateFunction(key, kind) { + this.interface.addMethod(this.interface.defaultWhence, key, [], ` + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); } - } - - const propExpr = typeof key === "symbol" ? `[${keyExpr}]` : `.${key}`; - - return ` - ${this.interface.name}.prototype${propExpr} = function ${fnName}() { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - return module.exports.createDefaultIterator(this, "${kind}"); - }; - `; + return module.exports.createDefaultIterator(this, "${kind}"); + `); } generate() { - let str = ""; - + const whence = this.interface.defaultWhence; if (this.isPair) { - str += ` - ${this.interface.name}.prototype.entries = ${this.interface.name}.prototype[Symbol.iterator]; - ${this.generateFunction("keys", "key")} - ${this.generateFunction("values", "value")} - `; + this.generateFunction("keys", "key"); + this.generateFunction("values", "value"); + this.generateFunction("entries", "key+value"); + this.interface.addProperty(whence, Symbol.iterator, `${this.interface.name}.prototype.entries`); + this.interface.addMethod(whence, "forEach", ["callback"], ` + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + if (arguments.length < 1) { + throw new TypeError("Failed to execute 'forEach' on '${this.name}': 1 argument required, " + + "but only 0 present."); + } + if (typeof callback !== "function") { + throw new TypeError("Failed to execute 'forEach' on '${this.name}': The callback provided " + + "as parameter 1 is not a function."); + } + const thisArg = arguments[1]; + let pairs = Array.from(this[impl]); + let i = 0; + while (i < pairs.length) { + const [key, value] = pairs[i].map(utils.tryWrapperForImpl); + callback.call(thisArg, value, key, this); + pairs = Array.from(this[impl]); + i++; + } + `); } else { - str += ` - ${this.interface.name}.prototype.entries = Array.prototype.entries; - ${this.interface.name}.prototype.keys = Array.prototype.keys; - ${this.interface.name}.prototype.values = Array.prototype[Symbol.iterator]; - `; + this.interface.addProperty(whence, "keys", "Array.prototype.keys"); + this.interface.addProperty(whence, "values", "Array.prototype[Symbol.iterator]"); + this.interface.addProperty(whence, "entries", "Array.prototype.entries"); + this.interface.addProperty(whence, "forEach", "Array.prototype.forEach"); + // @@iterator is added in Interface class. } return { - requires: new utils.RequiresMap(this.ctx), - body: str + requires: new utils.RequiresMap(this.ctx) }; } } diff --git a/lib/constructs/operation.js b/lib/constructs/operation.js index 2d0794e5..3a4d0e39 100644 --- a/lib/constructs/operation.js +++ b/lib/constructs/operation.js @@ -5,7 +5,6 @@ const conversions = require("webidl-conversions"); const utils = require("../utils"); const Overloads = require("../overloads"); const Parameters = require("../parameters"); -const keywords = require("../keywords"); class Operation { constructor(ctx, I, idl) { @@ -48,10 +47,7 @@ class Operation { throw new Error(`Internal error: this operation does not have a name (in interface ${this.interface.name})`); } - let targetObj = this.interface.name + (this.static ? "" : ".prototype"); - if (this.isOnInstance()) { - targetObj = "obj"; - } + const onInstance = this.isOnInstance(); const type = this.static ? "static operation" : "regular operation"; const overloads = Overloads.getEffectiveOverloads(type, this.name, 0, this.interface); @@ -62,12 +58,8 @@ class Operation { } } - const fnName = (keywords.has(this.name) ? "_" : "") + this.name; - const argNames = minOp.nameList.map(name => (keywords.has(name) ? "_" : "") + name); + const argNames = minOp.nameList; - str += ` - ${targetObj}.${this.name} = function ${fnName}(${argNames.join(", ")}) { - `; if (!this.static) { str += ` if (!this || !module.exports.is(this)) { @@ -89,20 +81,29 @@ class Operation { if (overloads.every(overload => conversions[overload.operation.idlType.idlType])) { str += ` - return ${callOn}.${implFunc}(${argsSpread}); - }; + return ${callOn}.${implFunc}(${argsSpread}); `; } else { str += ` - return utils.tryWrapperForImpl(${callOn}.${implFunc}(${argsSpread})); - }; + return utils.tryWrapperForImpl(${callOn}.${implFunc}(${argsSpread})); `; } - return { - requires, - body: str - }; + if (this.static) { + this.interface.addStaticMethod(this.name, argNames, str); + } else { + const forgeable = !utils.getExtAttr(this.idls[0].extAttrs, "Unforgeable"); + this.interface.addMethod( + onInstance ? "instance" : "prototype", + this.name, + argNames, + str, + "regular", + { configurable: forgeable, writable: forgeable } + ); + } + + return { requires }; } } diff --git a/lib/utils.js b/lib/utils.js index e285f77f..ba0fd425 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -29,14 +29,30 @@ function getExtAttr(attrs, name) { } function isGlobal(idl) { - return Boolean(getExtAttr(idl.extAttrs, "Global")) || - Boolean(getExtAttr(idl.extAttrs, "PrimaryGlobal")); + return Boolean(getExtAttr(idl.extAttrs, "Global")); } function isOnInstance(memberIDL, interfaceIDL) { return !memberIDL.static && (getExtAttr(memberIDL.extAttrs, "Unforgeable") || isGlobal(interfaceIDL)); } +function stringifyPropertyName(propName) { + if (typeof propName === "symbol") { + const desc = String(propName).replace(/^Symbol\((.*)\)$/, "$1"); + if (!desc.startsWith("Symbol.")) { + throw new Error(`Internal error: Unsupported property name ${String(propName)}`); + } + return `[${desc}]`; + } + + // All Web IDL identifiers are valid JavaScript PropertyNames, other than those with '-'. + const isJSIdentifier = !propName.includes("-"); + if (isJSIdentifier) { + return propName; + } + return JSON.stringify(propName); +} + class RequiresMap extends Map { constructor(ctx) { super(); @@ -78,5 +94,6 @@ module.exports = { getExtAttr, isGlobal, isOnInstance, + stringifyPropertyName, RequiresMap }; diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 39793cca..2d956941 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -89,46 +89,37 @@ const utils = require(\\"./utils.js\\"); const convertDictionary = require(\\"./Dictionary.js\\").convert; const impl = utils.implSymbol; -function DictionaryConvert() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(DictionaryConvert, \\"prototype\\", { - value: DictionaryConvert.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -DictionaryConvert.prototype.op = function op() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class DictionaryConvert { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 1\\" - }); + + op() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); } - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = convertDictionary(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 1\\" + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = convertDictionary(curArg, { context: \\"Failed to execute 'op' on 'DictionaryConvert': parameter 2\\" }); + args.push(curArg); + } + return this[impl].op(...args); } - return this[impl].op(...args); -}; - -Object.defineProperty(DictionaryConvert.prototype, Symbol.toStringTag, { - value: \\"DictionaryConvert\\", - writable: false, - enumerable: false, - configurable: true +} +Object.defineProperties(DictionaryConvert.prototype, { + op: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"DictionaryConvert\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -188,8 +179,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -220,46 +209,39 @@ const convertRequestDestination = require(\\"./RequestDestination.js\\").convert const RequestDestination = require(\\"./RequestDestination.js\\"); const impl = utils.implSymbol; -function Enum() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(Enum, \\"prototype\\", { - value: Enum.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Enum.prototype.op = function op(destination) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class Enum { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'op' on 'Enum': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = convertRequestDestination(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); - args.push(curArg); + op(destination) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'op' on 'Enum': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = convertRequestDestination(curArg, { context: \\"Failed to execute 'op' on 'Enum': parameter 1\\" }); + args.push(curArg); + } + return this[impl].op(...args); } - return this[impl].op(...args); -}; -Object.defineProperty(Enum.prototype, \\"attr\\", { - get() { + get attr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return utils.tryWrapperForImpl(this[impl][\\"attr\\"]); - }, + } - set(V) { + set attr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -270,19 +252,13 @@ Object.defineProperty(Enum.prototype, \\"attr\\", { } this[impl][\\"attr\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(Enum.prototype, Symbol.toStringTag, { - value: \\"Enum\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(Enum.prototype, { + op: { enumerable: true }, + attr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Enum\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -342,8 +318,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -374,35 +348,28 @@ const impl = utils.implSymbol; module.exports = { createInterface: function(defaultPrivateData = {}) { - function Factory() { - throw new TypeError(\\"Illegal constructor\\"); - } + class Factory { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } - Object.defineProperty(Factory, \\"prototype\\", { - value: Factory.prototype, - writable: false, - enumerable: false, - configurable: false - }); + method() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - Factory.prototype.method = function method() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].method(); } - return this[impl].method(); - }; - - Object.defineProperty(Factory.prototype, \\"attribute\\", { - get() { + get attribute() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"attribute\\"]; - }, + } - set(V) { + set attribute(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -412,28 +379,15 @@ module.exports = { }); this[impl][\\"attribute\\"] = V; - }, - - enumerable: true, - configurable: true - }); - - Object.defineProperty(Factory, \\"constant\\", { - value: 42, - enumerable: true - }); - Object.defineProperty(Factory.prototype, \\"constant\\", { - value: 42, - enumerable: true - }); - - Object.defineProperty(Factory.prototype, Symbol.toStringTag, { - value: \\"Factory\\", - writable: false, - enumerable: false, - configurable: true + } + } + Object.defineProperties(Factory.prototype, { + method: { enumerable: true }, + attribute: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Factory\\", configurable: true }, + constant: { value: 42, enumerable: true } }); - + Object.defineProperties(Factory, { constant: { value: 42, enumerable: true } }); const iface = { create(constructorArgs, privateData) { let obj = Object.create(Factory.prototype); @@ -460,8 +414,6 @@ module.exports = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -523,7 +475,7 @@ const Impl = require(\\"../implementations/Factory.js\\"); " `; -exports[`LegacyArrayClass.webidl 1`] = ` +exports[`Global.webidl 1`] = ` "\\"use strict\\"; const conversions = require(\\"webidl-conversions\\"); @@ -531,39 +483,202 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function LegacyArrayClass() { - throw new TypeError(\\"Illegal constructor\\"); +class Global { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } } +Object.defineProperties(Global.prototype, { [Symbol.toStringTag]: { value: \\"Global\\", configurable: true } }); +const iface = { + // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` + // method into this array. It allows objects that directly implements *those* interfaces to be recognized as + // implementing this mixin interface. + _mixedIntoPredicates: [], + is(obj) { + if (obj) { + if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) { + return true; + } + for (const isMixedInto of module.exports._mixedIntoPredicates) { + if (isMixedInto(obj)) { + return true; + } + } + } + return false; + }, + isImpl(obj) { + if (obj) { + if (obj instanceof Impl.implementation) { + return true; + } -Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); + const wrapper = utils.wrapperForImpl(obj); + for (const isMixedInto of module.exports._mixedIntoPredicates) { + if (isMixedInto(wrapper)) { + return true; + } + } + } + return false; + }, + convert(obj, { context = \\"The provided value\\" } = {}) { + if (module.exports.is(obj)) { + return utils.implForWrapper(obj); + } + throw new TypeError(\`\${context} is not of type 'Global'.\`); + }, -Object.defineProperty(LegacyArrayClass, \\"prototype\\", { - value: LegacyArrayClass.prototype, - writable: false, - enumerable: false, - configurable: false -}); + create(constructorArgs, privateData) { + let obj = Object.create(Global.prototype); + obj = this.setup(obj, constructorArgs, privateData); + return obj; + }, + createImpl(constructorArgs, privateData) { + let obj = Object.create(Global.prototype); + obj = this.setup(obj, constructorArgs, privateData); + return utils.implForWrapper(obj); + }, + _internalSetup(obj) { + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + op() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return this[impl].op(); + }, + unforgeableOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return this[impl].unforgeableOp(); + }, + get attr() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return obj[impl][\\"attr\\"]; + }, + set attr(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'attr' property on 'Global': The provided value\\" + }); -Object.defineProperty(LegacyArrayClass.prototype, \\"length\\", { - get() { + obj[impl][\\"attr\\"] = V; + }, + get unforgeableAttr() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return obj[impl][\\"unforgeableAttr\\"]; + }, + set unforgeableAttr(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"DOMString\\"](V, { + context: \\"Failed to set the 'unforgeableAttr' property on 'Global': The provided value\\" + }); + + obj[impl][\\"unforgeableAttr\\"] = V; + }, + get length() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return obj[impl][\\"length\\"]; + }, + set length(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + V = conversions[\\"unsigned long\\"](V, { + context: \\"Failed to set the 'length' property on 'Global': The provided value\\" + }); + + obj[impl][\\"length\\"] = V; + }, + [Symbol.iterator]: Array.prototype[Symbol.iterator], + keys: Array.prototype.keys, + values: Array.prototype[Symbol.iterator], + entries: Array.prototype.entries, + forEach: Array.prototype.forEach + }) + ); + + Object.defineProperties(obj, { + unforgeableOp: { configurable: false, writable: false }, + unforgeableAttr: { configurable: false }, + [Symbol.iterator]: { enumerable: false } + }); + }, + setup(obj, constructorArgs, privateData) { + if (!privateData) privateData = {}; + + privateData.wrapper = obj; + + this._internalSetup(obj); + Object.defineProperty(obj, impl, { + value: new Impl.implementation(constructorArgs, privateData), + configurable: true + }); + + obj[impl][utils.wrapperSymbol] = obj; + if (Impl.init) { + Impl.init(obj[impl], privateData); + } + return obj; + }, + interface: Global, + expose: { + Window: { Global } + } +}; // iface +module.exports = iface; + +const Impl = require(\\"../implementations/Global.js\\"); +" +`; + +exports[`LegacyArrayClass.webidl 1`] = ` +"\\"use strict\\"; + +const conversions = require(\\"webidl-conversions\\"); +const utils = require(\\"./utils.js\\"); + +const impl = utils.implSymbol; + +class LegacyArrayClass { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } + + get length() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"length\\"]; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(LegacyArrayClass.prototype, Symbol.toStringTag, { - value: \\"LegacyArrayClass\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.setPrototypeOf(LegacyArrayClass.prototype, Array.prototype); +Object.defineProperties(LegacyArrayClass.prototype, { + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"LegacyArrayClass\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -623,8 +738,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -656,67 +769,60 @@ const Mixin = require(\\"./Mixin.js\\"); const MixinMixin = require(\\"./MixinMixin.js\\"); const MixinInherited = require(\\"./MixinInherited.js\\"); -function MixedIn() { - throw new TypeError(\\"Illegal constructor\\"); -} +class MixedIn { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(MixedIn, \\"prototype\\", { - value: MixedIn.prototype, - writable: false, - enumerable: false, - configurable: false -}); + mixedInOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixedIn.prototype.mixedInOp = function mixedInOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixedInOp(); } - return this[impl].mixedInOp(); -}; + mixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixedIn.prototype.mixinOp = function mixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinOp(); } - return this[impl].mixinOp(); -}; + mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixedIn.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinMixinOp(); } - return this[impl].mixinMixinOp(); -}; + mixinInheritedOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixedIn.prototype.mixinInheritedOp = function mixinInheritedOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinInheritedOp(); } - return this[impl].mixinInheritedOp(); -}; + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixedIn.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinInheritedOp(); } - return this[impl].mixinInheritedOp(); -}; - -Object.defineProperty(MixedIn.prototype, \\"mixedInAttr\\", { - get() { + get mixedInAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixedInAttr\\"]; - }, + } - set(V) { + set mixedInAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -726,22 +832,17 @@ Object.defineProperty(MixedIn.prototype, \\"mixedInAttr\\", { }); this[impl][\\"mixedInAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(MixedIn.prototype, \\"mixinAttr\\", { - get() { + get mixinAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinAttr\\"]; - }, + } - set(V) { + set mixinAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -751,22 +852,17 @@ Object.defineProperty(MixedIn.prototype, \\"mixinAttr\\", { }); this[impl][\\"mixinAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(MixedIn.prototype, \\"mixinMixinAttr\\", { - get() { + get mixinMixinAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinMixinAttr\\"]; - }, + } - set(V) { + set mixinMixinAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -776,22 +872,17 @@ Object.defineProperty(MixedIn.prototype, \\"mixinMixinAttr\\", { }); this[impl][\\"mixinMixinAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(MixedIn.prototype, \\"mixinInheritedAttr\\", { - get() { + get mixinInheritedAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinInheritedAttr\\"]; - }, + } - set(V) { + set mixinInheritedAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -801,55 +892,30 @@ Object.defineProperty(MixedIn.prototype, \\"mixinInheritedAttr\\", { }); this[impl][\\"mixinInheritedAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(MixedIn, \\"mixedInConst\\", { - value: 43, - enumerable: true -}); -Object.defineProperty(MixedIn.prototype, \\"mixedInConst\\", { - value: 43, - enumerable: true -}); - -Object.defineProperty(MixedIn, \\"mixinConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(MixedIn.prototype, \\"mixinConst\\", { - value: 42, - enumerable: true -}); - -Object.defineProperty(MixedIn, \\"mixinMixinConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(MixedIn.prototype, \\"mixinMixinConst\\", { - value: 42, - enumerable: true -}); - -Object.defineProperty(MixedIn, \\"mixinInheritedConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(MixedIn.prototype, \\"mixinInheritedConst\\", { - value: 42, - enumerable: true + } +} +Object.defineProperties(MixedIn.prototype, { + mixedInOp: { enumerable: true }, + mixinOp: { enumerable: true }, + mixinMixinOp: { enumerable: true }, + mixinInheritedOp: { enumerable: true }, + toString: { enumerable: true }, + mixedInAttr: { enumerable: true }, + mixinAttr: { enumerable: true }, + mixinMixinAttr: { enumerable: true }, + mixinInheritedAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"MixedIn\\", configurable: true }, + mixedInConst: { value: 43, enumerable: true }, + mixinConst: { value: 42, enumerable: true }, + mixinMixinConst: { value: 42, enumerable: true }, + mixinInheritedConst: { value: 42, enumerable: true } }); - -Object.defineProperty(MixedIn.prototype, Symbol.toStringTag, { - value: \\"MixedIn\\", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(MixedIn, { + mixedInConst: { value: 43, enumerable: true }, + mixinConst: { value: 42, enumerable: true }, + mixinMixinConst: { value: 42, enumerable: true }, + mixinInheritedConst: { value: 42, enumerable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -909,8 +975,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -947,46 +1011,36 @@ const impl = utils.implSymbol; const MixinInherited = require(\\"./MixinInherited.js\\"); const MixinMixin = require(\\"./MixinMixin.js\\"); -function Mixin() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.setPrototypeOf(Mixin.prototype, MixinInherited.interface.prototype); -Object.setPrototypeOf(Mixin, MixinInherited.interface); +class Mixin extends MixinInherited.interface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(Mixin, \\"prototype\\", { - value: Mixin.prototype, - writable: false, - enumerable: false, - configurable: false -}); + mixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Mixin.prototype.mixinOp = function mixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinOp(); } - return this[impl].mixinOp(); -}; + mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Mixin.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinMixinOp(); } - return this[impl].mixinMixinOp(); -}; - -Object.defineProperty(Mixin.prototype, \\"mixinAttr\\", { - get() { + get mixinAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinAttr\\"]; - }, + } - set(V) { + set mixinAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -996,22 +1050,17 @@ Object.defineProperty(Mixin.prototype, \\"mixinAttr\\", { }); this[impl][\\"mixinAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Mixin.prototype, \\"mixinMixinAttr\\", { - get() { + get mixinMixinAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinMixinAttr\\"]; - }, + } - set(V) { + set mixinMixinAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -1021,37 +1070,21 @@ Object.defineProperty(Mixin.prototype, \\"mixinMixinAttr\\", { }); this[impl][\\"mixinMixinAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(Mixin, \\"mixinConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(Mixin.prototype, \\"mixinConst\\", { - value: 42, - enumerable: true -}); - -Object.defineProperty(Mixin, \\"mixinMixinConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(Mixin.prototype, \\"mixinMixinConst\\", { - value: 42, - enumerable: true + } +} +Object.defineProperties(Mixin.prototype, { + mixinOp: { enumerable: true }, + mixinMixinOp: { enumerable: true }, + mixinAttr: { enumerable: true }, + mixinMixinAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Mixin\\", configurable: true }, + mixinConst: { value: 42, enumerable: true }, + mixinMixinConst: { value: 42, enumerable: true } }); - -Object.defineProperty(Mixin.prototype, Symbol.toStringTag, { - value: \\"Mixin\\", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(Mixin, { + mixinConst: { value: 42, enumerable: true }, + mixinMixinConst: { value: 42, enumerable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -1113,8 +1146,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -1143,43 +1174,36 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function MixinInherited() { - throw new TypeError(\\"Illegal constructor\\"); -} +class MixinInherited { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(MixinInherited, \\"prototype\\", { - value: MixinInherited.prototype, - writable: false, - enumerable: false, - configurable: false -}); + mixinInheritedOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixinInherited.prototype.mixinInheritedOp = function mixinInheritedOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinInheritedOp(); } - return this[impl].mixinInheritedOp(); -}; + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixinInherited.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinInheritedOp(); } - return this[impl].mixinInheritedOp(); -}; - -Object.defineProperty(MixinInherited.prototype, \\"mixinInheritedAttr\\", { - get() { + get mixinInheritedAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinInheritedAttr\\"]; - }, + } - set(V) { + set mixinInheritedAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -1189,28 +1213,16 @@ Object.defineProperty(MixinInherited.prototype, \\"mixinInheritedAttr\\", { }); this[impl][\\"mixinInheritedAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(MixinInherited, \\"mixinInheritedConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(MixinInherited.prototype, \\"mixinInheritedConst\\", { - value: 42, - enumerable: true -}); - -Object.defineProperty(MixinInherited.prototype, Symbol.toStringTag, { - value: \\"MixinInherited\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(MixinInherited.prototype, { + mixinInheritedOp: { enumerable: true }, + toString: { enumerable: true }, + mixinInheritedAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"MixinInherited\\", configurable: true }, + mixinInheritedConst: { value: 42, enumerable: true } }); - +Object.defineProperties(MixinInherited, { mixinInheritedConst: { value: 42, enumerable: true } }); const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -1270,8 +1282,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -1298,35 +1308,28 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function MixinMixin() { - throw new TypeError(\\"Illegal constructor\\"); -} +class MixinMixin { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(MixinMixin, \\"prototype\\", { - value: MixinMixin.prototype, - writable: false, - enumerable: false, - configurable: false -}); + mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -MixinMixin.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].mixinMixinOp(); } - return this[impl].mixinMixinOp(); -}; - -Object.defineProperty(MixinMixin.prototype, \\"mixinMixinAttr\\", { - get() { + get mixinMixinAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinMixinAttr\\"]; - }, + } - set(V) { + set mixinMixinAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -1336,28 +1339,15 @@ Object.defineProperty(MixinMixin.prototype, \\"mixinMixinAttr\\", { }); this[impl][\\"mixinMixinAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(MixinMixin, \\"mixinMixinConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(MixinMixin.prototype, \\"mixinMixinConst\\", { - value: 42, - enumerable: true -}); - -Object.defineProperty(MixinMixin.prototype, Symbol.toStringTag, { - value: \\"MixinMixin\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(MixinMixin.prototype, { + mixinMixinOp: { enumerable: true }, + mixinMixinAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"MixinMixin\\", configurable: true }, + mixinMixinConst: { value: 42, enumerable: true } }); - +Object.defineProperties(MixinMixin, { mixinMixinConst: { value: 42, enumerable: true } }); const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -1417,8 +1407,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -1447,330 +1435,321 @@ const isURL = require(\\"./URL.js\\").is; const convertURL = require(\\"./URL.js\\").convert; const impl = utils.implSymbol; -function Overloads() { - if (new.target === undefined) { - throw new TypeError( - \\"Failed to construct 'Overloads'. Please use the 'new' operator; this constructor \\" + - \\"cannot be called as a function.\\" - ); +class Overloads { + constructor() { + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (isURL(curArg)) { + { + let curArg = arguments[0]; + curArg = convertURL(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 iface.setup(Object.create(Overloads.prototype), args); } - const args = []; - switch (arguments.length) { - case 0: - break; - default: { - let curArg = arguments[0]; - if (isURL(curArg)) { + + compatible(arg1) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + 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 = convertURL(curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'compatible' on 'Overloads': parameter 1\\" + }); args.push(curArg); } - } else { + break; + case 2: { let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to construct 'Overloads': parameter 1\\" }); + 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(this[impl].compatible(...args)); } - iface.setup(this, args); -} - -Object.defineProperty(Overloads, \\"prototype\\", { - value: Overloads.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Overloads.prototype.compatible = function compatible(arg1) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + incompatible1(arg1) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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) { + 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 'compatible' on 'Overloads': parameter 3\\" + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" }); - } else { - curArg = 0; + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible1' on 'Overloads': parameter 1\\" + }); + args.push(curArg); } - args.push(curArg); - } - } - return utils.tryWrapperForImpl(this[impl].compatible(...args)); -}; - -Overloads.prototype.incompatible1 = function incompatible1(arg1) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - 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 this[impl].incompatible1(...args); } - return this[impl].incompatible1(...args); -}; -Overloads.prototype.incompatible2 = function incompatible2(arg1) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + incompatible2(arg1) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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); - } + 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 this[impl].incompatible2(...args); } - return this[impl].incompatible2(...args); -}; -Overloads.prototype.incompatible3 = function incompatible3(arg1) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + incompatible3(arg1) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - 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 = convertURL(curArg, { context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" }); + 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 = convertURL(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); } - args.push(curArg); - } - } else if (isURL(curArg)) { - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = convertURL(curArg, { context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" }); + } else if (isURL(curArg)) { + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = convertURL(curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + } + args.push(curArg); } - args.push(curArg); - } - } else if ( - curArg instanceof ArrayBuffer || - (typeof SharedArrayBuffer !== \\"undefined\\" && curArg instanceof SharedArrayBuffer) - ) { - { - let curArg = arguments[1]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); + } else if ( + curArg instanceof ArrayBuffer || + (typeof SharedArrayBuffer !== \\"undefined\\" && curArg instanceof SharedArrayBuffer) + ) { + { + let curArg = arguments[1]; + if (curArg instanceof ArrayBuffer) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); } - args.push(curArg); - } - } else if (ArrayBuffer.isView(curArg)) { - { - let curArg = arguments[1]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" - ); + } else if (ArrayBuffer.isView(curArg)) { + { + let curArg = arguments[1]; + if (curArg instanceof ArrayBuffer) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } else { + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); } - args.push(curArg); - } - } else { - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - args.push(curArg); } } - } - break; - case 3: - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': only \\" + arguments.length + \\" arguments present.\\" - ); - break; - default: - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"long\\"](curArg, { - context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" - }); - args.push(curArg); - } - { - let curArg = arguments[2]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" - ); + break; + case 3: + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': only \\" + arguments.length + \\" arguments present.\\" + ); + break; + default: + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 1\\" + }); + args.push(curArg); } - args.push(curArg); - } - { - let curArg = arguments[3]; - if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { - throw new TypeError( - \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" - ); + { + let curArg = arguments[1]; + curArg = conversions[\\"long\\"](curArg, { + context: \\"Failed to execute 'incompatible3' on 'Overloads': parameter 2\\" + }); + args.push(curArg); } - args.push(curArg); - } + { + let curArg = arguments[2]; + if (curArg instanceof ArrayBuffer) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 3\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg instanceof ArrayBuffer) { + } else if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'incompatible3' on 'Overloads': parameter 4\\" + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + } + return this[impl].incompatible3(...args); } - return this[impl].incompatible3(...args); -}; - -Object.defineProperty(Overloads.prototype, Symbol.toStringTag, { - value: \\"Overloads\\", - writable: false, - enumerable: false, - configurable: true +} +Object.defineProperties(Overloads.prototype, { + compatible: { enumerable: true }, + incompatible1: { enumerable: true }, + incompatible2: { enumerable: true }, + incompatible3: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Overloads\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -1830,8 +1809,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -1860,72 +1837,64 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function PromiseTypes() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(PromiseTypes, \\"prototype\\", { - value: PromiseTypes.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -PromiseTypes.prototype.voidPromiseConsumer = function voidPromiseConsumer(p) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class PromiseTypes { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'voidPromiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = Promise.resolve(curArg).then(value => {}, reason => reason); - args.push(curArg); - } - return this[impl].voidPromiseConsumer(...args); -}; + voidPromiseConsumer(p) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -PromiseTypes.prototype.promiseConsumer = function promiseConsumer(p) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'voidPromiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Promise.resolve(curArg).then(value => {}, reason => reason); + args.push(curArg); + } + return this[impl].voidPromiseConsumer(...args); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = Promise.resolve(curArg).then(value => { - value = conversions[\\"double\\"](value, { - context: \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': parameter 1\\" + \\" promise value\\" - }); + promiseConsumer(p) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return value; - }, reason => reason); - args.push(curArg); - } - return this[impl].promiseConsumer(...args); -}; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Promise.resolve(curArg).then(value => { + value = conversions[\\"double\\"](value, { + context: \\"Failed to execute 'promiseConsumer' on 'PromiseTypes': parameter 1\\" + \\" promise value\\" + }); -Object.defineProperty(PromiseTypes.prototype, Symbol.toStringTag, { - value: \\"PromiseTypes\\", - writable: false, - enumerable: false, - configurable: true + return value; + }, reason => reason); + args.push(curArg); + } + return this[impl].promiseConsumer(...args); + } +} +Object.defineProperties(PromiseTypes.prototype, { + voidPromiseConsumer: { enumerable: true }, + promiseConsumer: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"PromiseTypes\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -1985,8 +1954,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -2015,27 +1982,20 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function Reflect() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(Reflect, \\"prototype\\", { - value: Reflect.prototype, - writable: false, - enumerable: false, - configurable: false -}); +class Reflect { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(Reflect.prototype, \\"ReflectedBoolean\\", { - get() { + get ReflectedBoolean() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this.hasAttribute(\\"ReflectedBoolean\\"); - }, + } - set(V) { + set ReflectedBoolean(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2049,23 +2009,18 @@ Object.defineProperty(Reflect.prototype, \\"ReflectedBoolean\\", { } else { this.removeAttribute(\\"ReflectedBoolean\\"); } - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Reflect.prototype, \\"ReflectedDOMString\\", { - get() { + get ReflectedDOMString() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } const value = this.getAttribute(\\"ReflectedDOMString\\"); return value === null ? \\"\\" : value; - }, + } - set(V) { + set ReflectedDOMString(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2075,23 +2030,18 @@ Object.defineProperty(Reflect.prototype, \\"ReflectedDOMString\\", { }); this.setAttribute(\\"ReflectedDOMString\\", V); - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Reflect.prototype, \\"ReflectedLong\\", { - get() { + get ReflectedLong() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } const value = parseInt(this.getAttribute(\\"ReflectedLong\\")); return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value; - }, + } - set(V) { + set ReflectedLong(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2101,23 +2051,18 @@ Object.defineProperty(Reflect.prototype, \\"ReflectedLong\\", { }); this.setAttribute(\\"ReflectedLong\\", String(V)); - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Reflect.prototype, \\"ReflectedUnsignedLong\\", { - get() { + get ReflectedUnsignedLong() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } const value = parseInt(this.getAttribute(\\"ReflectedUnsignedLong\\")); return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value; - }, + } - set(V) { + set ReflectedUnsignedLong(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2127,23 +2072,18 @@ Object.defineProperty(Reflect.prototype, \\"ReflectedUnsignedLong\\", { }); this.setAttribute(\\"ReflectedUnsignedLong\\", String(V > 2147483647 ? 0 : V)); - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Reflect.prototype, \\"ReflectionTest\\", { - get() { + get ReflectionTest() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } const value = this.getAttribute(\\"reflection\\"); return value === null ? \\"\\" : value; - }, + } - set(V) { + set ReflectionTest(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2153,23 +2093,18 @@ Object.defineProperty(Reflect.prototype, \\"ReflectionTest\\", { }); this.setAttribute(\\"reflection\\", V); - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Reflect.prototype, \\"withUnderscore\\", { - get() { + get withUnderscore() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } const value = this.getAttribute(\\"with-underscore\\"); return value === null ? \\"\\" : value; - }, + } - set(V) { + set withUnderscore(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2179,19 +2114,17 @@ Object.defineProperty(Reflect.prototype, \\"withUnderscore\\", { }); this.setAttribute(\\"with-underscore\\", V); - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(Reflect.prototype, Symbol.toStringTag, { - value: \\"Reflect\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(Reflect.prototype, { + ReflectedBoolean: { enumerable: true }, + ReflectedDOMString: { enumerable: true }, + ReflectedLong: { enumerable: true }, + ReflectedUnsignedLong: { enumerable: true }, + ReflectionTest: { enumerable: true }, + withUnderscore: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Reflect\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -2251,8 +2184,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -2316,224 +2247,212 @@ const utils = require(\\"./utils.js\\"); const convertURL = require(\\"./URL.js\\").convert; const impl = utils.implSymbol; -function SeqAndRec() { - if (new.target === undefined) { - throw new TypeError( - \\"Failed to construct 'SeqAndRec'. Please use the 'new' operator; this constructor \\" + - \\"cannot be called as a function.\\" - ); +class SeqAndRec { + constructor() { + return iface.setup(Object.create(SeqAndRec.prototype)); } - iface.setup(this); -} - -Object.defineProperty(SeqAndRec, \\"prototype\\", { - value: SeqAndRec.prototype, - writable: false, - enumerable: false, - configurable: false -}); + recordConsumer(rec) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -SeqAndRec.prototype.recordConsumer = function recordConsumer(rec) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'recordConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError(\\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + let typedValue = curArg[key]; - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'recordConsumer' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError(\\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - let typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" - }); + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" + }); - typedValue = conversions[\\"double\\"](typedValue, { - context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" - }); + typedValue = conversions[\\"double\\"](typedValue, { + context: \\"Failed to execute 'recordConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" + }); - result[typedKey] = typedValue; + result[typedKey] = typedValue; + } } + curArg = result; } - curArg = result; + args.push(curArg); } - args.push(curArg); + return this[impl].recordConsumer(...args); } - return this[impl].recordConsumer(...args); -}; -SeqAndRec.prototype.recordConsumer2 = function recordConsumer2(rec) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + recordConsumer2(rec) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { - throw new TypeError(\\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - let typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError(\\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an object.\\"); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + let typedValue = curArg[key]; - typedValue = convertURL(typedValue, { - context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" - }); + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s key\\" + }); + + typedValue = convertURL(typedValue, { + context: \\"Failed to execute 'recordConsumer2' on 'SeqAndRec': parameter 1\\" + \\"'s value\\" + }); - result[typedKey] = typedValue; + result[typedKey] = typedValue; + } } + curArg = result; } - curArg = result; + args.push(curArg); } - args.push(curArg); + return this[impl].recordConsumer2(...args); } - return this[impl].recordConsumer2(...args); -}; -SeqAndRec.prototype.sequenceConsumer = function sequenceConsumer(seq) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + sequenceConsumer(seq) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"USVString\\"](nextItem, { - context: \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" - }); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"USVString\\"](nextItem, { + context: \\"Failed to execute 'sequenceConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" + }); - V.push(nextItem); + V.push(nextItem); + } + curArg = V; } - curArg = V; + args.push(curArg); } - args.push(curArg); - } - return this[impl].sequenceConsumer(...args); -}; - -SeqAndRec.prototype.sequenceConsumer2 = function sequenceConsumer2(seq) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + return this[impl].sequenceConsumer(...args); } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + + sequenceConsumer2(seq) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = utils.tryImplForWrapper(nextItem); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'sequenceConsumer2' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); - V.push(nextItem); + V.push(nextItem); + } + curArg = V; } - curArg = V; + args.push(curArg); } - args.push(curArg); + return this[impl].sequenceConsumer2(...args); } - return this[impl].sequenceConsumer2(...args); -}; -SeqAndRec.prototype.frozenArrayConsumer = function frozenArrayConsumer(arr) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + frozenArrayConsumer(arr) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"double\\"](nextItem, { - context: \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" - }); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"double\\"](nextItem, { + context: \\"Failed to execute 'frozenArrayConsumer' on 'SeqAndRec': parameter 1\\" + \\"'s element\\" + }); - V.push(nextItem); + V.push(nextItem); + } + curArg = V; } - curArg = V; + curArg = Object.freeze(curArg); + args.push(curArg); } - curArg = Object.freeze(curArg); - args.push(curArg); + return this[impl].frozenArrayConsumer(...args); } - return this[impl].frozenArrayConsumer(...args); -}; - -Object.defineProperty(SeqAndRec.prototype, Symbol.toStringTag, { - value: \\"SeqAndRec\\", - writable: false, - enumerable: false, - configurable: true +} +Object.defineProperties(SeqAndRec.prototype, { + recordConsumer: { enumerable: true }, + recordConsumer2: { enumerable: true }, + sequenceConsumer: { enumerable: true }, + sequenceConsumer2: { enumerable: true }, + frozenArrayConsumer: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"SeqAndRec\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -2593,8 +2512,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -2623,39 +2540,28 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function Static() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(Static, \\"prototype\\", { - value: Static.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Static.prototype.def = function def() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class Static { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - return this[impl].def(); -}; + def() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Static.def = function def() { - return Impl.implementation.def(); -}; + return this[impl].def(); + } -Object.defineProperty(Static.prototype, \\"abc\\", { - get() { + get abc() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"abc\\"]; - }, + } - set(V) { + set abc(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -2663,34 +2569,26 @@ Object.defineProperty(Static.prototype, \\"abc\\", { V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'abc' property on 'Static': The provided value\\" }); this[impl][\\"abc\\"] = V; - }, + } - enumerable: true, - configurable: true -}); + static def() { + return Impl.implementation.def(); + } -Object.defineProperty(Static, \\"abc\\", { - get() { + static get abc() { return Impl.implementation[\\"abc\\"]; - }, - - set(V) { - V = conversions[\\"DOMString\\"](V, { context: \\"Failed to set the 'abc' property on 'Static': The provided value\\" }); - - Impl.implementation[\\"abc\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(Static.prototype, Symbol.toStringTag, { - value: \\"Static\\", - writable: false, - enumerable: false, - configurable: true + static set abc(V) { + return Impl.implementation[\\"abc\\"]; + } +} +Object.defineProperties(Static.prototype, { + def: { enumerable: true }, + abc: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Static\\", configurable: true } }); - +Object.defineProperties(Static, { def: { enumerable: true }, abc: { enumerable: true } }); const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -2750,8 +2648,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -2780,126 +2676,119 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function Storage() { - throw new TypeError(\\"Illegal constructor\\"); -} +class Storage { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(Storage, \\"prototype\\", { - value: Storage.prototype, - writable: false, - enumerable: false, - configurable: false -}); + key(index) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.key = function key(index) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'key' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'key' on 'Storage': parameter 1\\" }); + args.push(curArg); + } + return this[impl].key(...args); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'key' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'key' on 'Storage': parameter 1\\" }); - args.push(curArg); - } - return this[impl].key(...args); -}; + getItem(key) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.getItem = function getItem(key) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'getItem' on 'Storage': parameter 1\\" }); + args.push(curArg); + } + return this[impl].getItem(...args); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'getItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'getItem' on 'Storage': parameter 1\\" }); - args.push(curArg); - } - return this[impl].getItem(...args); -}; + setItem(key, value) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.setItem = function setItem(key, value) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'setItem' on 'Storage': 2 arguments required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 1\\" }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 2\\" }); + args.push(curArg); + } + return this[impl].setItem(...args); } - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'setItem' on 'Storage': 2 arguments required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 1\\" }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'setItem' on 'Storage': parameter 2\\" }); - args.push(curArg); - } - return this[impl].setItem(...args); -}; + removeItem(key) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.removeItem = function removeItem(key) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'removeItem' on 'Storage': parameter 1\\" + }); + args.push(curArg); + } + return this[impl].removeItem(...args); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'removeItem' on 'Storage': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'removeItem' on 'Storage': parameter 1\\" }); - args.push(curArg); - } - return this[impl].removeItem(...args); -}; + clear() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Storage.prototype.clear = function clear() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].clear(); } - return this[impl].clear(); -}; - -Object.defineProperty(Storage.prototype, \\"length\\", { - get() { + get length() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"length\\"]; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(Storage.prototype, Symbol.toStringTag, { - value: \\"Storage\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(Storage.prototype, { + key: { enumerable: true }, + getItem: { enumerable: true }, + setItem: { enumerable: true }, + removeItem: { enumerable: true }, + clear: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Storage\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -2959,8 +2848,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -3153,44 +3040,31 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function StringifierAttribute() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(StringifierAttribute, \\"prototype\\", { - value: StringifierAttribute.prototype, - writable: false, - enumerable: false, - configurable: false -}); +class StringifierAttribute { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(StringifierAttribute.prototype, \\"attr\\", { - get() { + get attr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"attr\\"]; - }, - - enumerable: true, - configurable: true -}); - -StringifierAttribute.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); } - return this[impl][\\"attr\\"]; -}; -Object.defineProperty(StringifierAttribute.prototype, Symbol.toStringTag, { - value: \\"StringifierAttribute\\", - writable: false, - enumerable: false, - configurable: true + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl][\\"attr\\"]; + } +} +Object.defineProperties(StringifierAttribute.prototype, { + attr: { enumerable: true }, + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierAttribute\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -3250,8 +3124,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -3280,32 +3152,23 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function StringifierDefaultOperation() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(StringifierDefaultOperation, \\"prototype\\", { - value: StringifierDefaultOperation.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -StringifierDefaultOperation.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class StringifierDefaultOperation { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - return this[impl].toString(); -}; + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Object.defineProperty(StringifierDefaultOperation.prototype, Symbol.toStringTag, { - value: \\"StringifierDefaultOperation\\", - writable: false, - enumerable: false, - configurable: true + return this[impl].toString(); + } +} +Object.defineProperties(StringifierDefaultOperation.prototype, { + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierDefaultOperation\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -3365,8 +3228,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -3395,40 +3256,32 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function StringifierNamedOperation() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(StringifierNamedOperation, \\"prototype\\", { - value: StringifierNamedOperation.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -StringifierNamedOperation.prototype.operation = function operation() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class StringifierNamedOperation { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - return this[impl].operation(); -}; + operation() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -StringifierNamedOperation.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].operation(); } - return this[impl].operation(); -}; + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Object.defineProperty(StringifierNamedOperation.prototype, Symbol.toStringTag, { - value: \\"StringifierNamedOperation\\", - writable: false, - enumerable: false, - configurable: true + return this[impl].operation(); + } +} +Object.defineProperties(StringifierNamedOperation.prototype, { + operation: { enumerable: true }, + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierNamedOperation\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -3488,8 +3341,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -3518,32 +3369,23 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function StringifierOperation() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(StringifierOperation, \\"prototype\\", { - value: StringifierOperation.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -StringifierOperation.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class StringifierOperation { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - return this[impl].toString(); -}; + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Object.defineProperty(StringifierOperation.prototype, Symbol.toStringTag, { - value: \\"StringifierOperation\\", - writable: false, - enumerable: false, - configurable: true + return this[impl].toString(); + } +} +Object.defineProperties(StringifierOperation.prototype, { + toString: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"StringifierOperation\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -3603,8 +3445,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -3636,220 +3476,166 @@ const isURL = require(\\"./URL.js\\").is; const convertURL = require(\\"./URL.js\\").convert; const impl = utils.implSymbol; -function TypedefsAndUnions() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(TypedefsAndUnions, \\"prototype\\", { - value: TypedefsAndUnions.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -TypedefsAndUnions.prototype.numOrStrConsumer = function numOrStrConsumer(a) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class TypedefsAndUnions { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true - }); - } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\" - }); + numOrStrConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); } - args.push(curArg); - } - return this[impl].numOrStrConsumer(...args); -}; - -TypedefsAndUnions.prototype.numOrEnumConsumer = function numOrEnumConsumer(a) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; if (typeof curArg === \\"number\\") { curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true }); } else { - curArg = convertRequestDestination(curArg, { - context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrConsumer' on 'TypedefsAndUnions': parameter 1\\" }); } + args.push(curArg); } - args.push(curArg); + return this[impl].numOrStrConsumer(...args); } - return this[impl].numOrEnumConsumer(...args); -}; -TypedefsAndUnions.prototype.numOrStrOrNullConsumer = function numOrStrOrNullConsumer(a) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + numOrEnumConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true, - enforceRange: true - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - enforceRange: true - }); + if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + }); + } else { + curArg = convertRequestDestination(curArg, { + context: \\"Failed to execute 'numOrEnumConsumer' on 'TypedefsAndUnions': parameter 1\\" + }); + } } + args.push(curArg); } - args.push(curArg); + return this[impl].numOrEnumConsumer(...args); } - return this[impl].numOrStrOrNullConsumer(...args); -}; -TypedefsAndUnions.prototype.numOrStrOrURLOrNullConsumer = function numOrStrOrURLOrNullConsumer(a) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + numOrStrOrNullConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (isURL(curArg)) { - curArg = utils.implForWrapper(curArg); - } else if (typeof curArg === \\"number\\") { - curArg = conversions[\\"double\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - clamp: true, - enforceRange: true - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; } else { - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", - enforceRange: true - }); + if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true, + enforceRange: true + }); + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + enforceRange: true + }); + } } + args.push(curArg); } - args.push(curArg); + return this[impl].numOrStrOrNullConsumer(...args); } - return this[impl].numOrStrOrURLOrNullConsumer(...args); -}; -TypedefsAndUnions.prototype.urlMapInnerConsumer = function urlMapInnerConsumer(a) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + numOrStrOrURLOrNullConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" + \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - let typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (isURL(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (typeof curArg === \\"number\\") { + curArg = conversions[\\"double\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + clamp: true, + enforceRange: true }); - - typedValue = convertURL(typedValue, { - context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" + } else { + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'numOrStrOrURLOrNullConsumer' on 'TypedefsAndUnions': parameter 1\\", + enforceRange: true }); - - result[typedKey] = typedValue; } } - curArg = result; + args.push(curArg); } - args.push(curArg); + return this[impl].numOrStrOrURLOrNullConsumer(...args); } - return this[impl].urlMapInnerConsumer(...args); -}; -TypedefsAndUnions.prototype.urlMapConsumer = function urlMapConsumer(a) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + urlMapInnerConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; if (!utils.isObject(curArg)) { throw new TypeError( - \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" + \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" ); } else { const result = Object.create(null); @@ -3860,11 +3646,11 @@ TypedefsAndUnions.prototype.urlMapConsumer = function urlMapConsumer(a) { let typedValue = curArg[key]; typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" + context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" }); typedValue = convertURL(typedValue, { - context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" + context: \\"Failed to execute 'urlMapInnerConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" }); result[typedKey] = typedValue; @@ -3872,67 +3658,32 @@ TypedefsAndUnions.prototype.urlMapConsumer = function urlMapConsumer(a) { } curArg = result; } + args.push(curArg); } - args.push(curArg); + return this[impl].urlMapInnerConsumer(...args); } - return this[impl].urlMapConsumer(...args); -}; -TypedefsAndUnions.prototype.bufferSourceOrURLConsumer = function bufferSourceOrURLConsumer(b) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + urlMapConsumer(a) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (isURL(curArg)) { - curArg = utils.implForWrapper(curArg); - } else if (curArg instanceof ArrayBuffer) { - } else if (ArrayBuffer.isView(curArg)) { - } else { + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" + \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } - args.push(curArg); - } - return this[impl].bufferSourceOrURLConsumer(...args); -}; - -TypedefsAndUnions.prototype.arrayBufferViewOrURLMapConsumer = function arrayBufferViewOrURLMapConsumer(b) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg === null || curArg === undefined) { - curArg = null; - } else { - if (ArrayBuffer.isView(curArg)) { - } else if (utils.isObject(curArg)) { + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { if (!utils.isObject(curArg)) { throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\" is not an object.\\" + \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not an object.\\" ); } else { const result = Object.create(null); @@ -3943,17 +3694,11 @@ TypedefsAndUnions.prototype.arrayBufferViewOrURLMapConsumer = function arrayBuff let typedValue = curArg[key]; typedKey = conversions[\\"USVString\\"](typedKey, { - context: - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\"'s key\\" + context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s key\\" }); typedValue = convertURL(typedValue, { - context: - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" record\\" + - \\"'s value\\" + context: \\"Failed to execute 'urlMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\"'s value\\" }); result[typedKey] = typedValue; @@ -3961,55 +3706,143 @@ TypedefsAndUnions.prototype.arrayBufferViewOrURLMapConsumer = function arrayBuff } curArg = result; } + } + args.push(curArg); + } + return this[impl].urlMapConsumer(...args); + } + + bufferSourceOrURLConsumer(b) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (isURL(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (curArg instanceof ArrayBuffer) { + } else if (ArrayBuffer.isView(curArg)) { } else { throw new TypeError( - \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\"Failed to execute 'bufferSourceOrURLConsumer' on 'TypedefsAndUnions': parameter 1\\" + \\" is not of any supported type.\\" ); } + args.push(curArg); } - args.push(curArg); + return this[impl].bufferSourceOrURLConsumer(...args); } - return this[impl].arrayBufferViewOrURLMapConsumer(...args); -}; -TypedefsAndUnions.prototype.arrayBufferViewDupConsumer = function arrayBufferViewDupConsumer(b) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + arrayBufferViewOrURLMapConsumer(b) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (ArrayBuffer.isView(curArg)) { + } else if (utils.isObject(curArg)) { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + let typedValue = curArg[key]; + + typedKey = conversions[\\"USVString\\"](typedKey, { + context: + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\"'s key\\" + }); + + typedValue = convertURL(typedValue, { + context: + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" record\\" + + \\"'s value\\" + }); + + result[typedKey] = typedValue; + } + } + curArg = result; + } + } else { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewOrURLMapConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" is not of any supported type.\\" + ); + } + } + args.push(curArg); + } + return this[impl].arrayBufferViewOrURLMapConsumer(...args); } - const args = []; - { - let curArg = arguments[0]; - if (ArrayBuffer.isView(curArg)) { - } else { + + arrayBufferViewDupConsumer(b) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': parameter 1\\" + - \\" is not of any supported type.\\" + \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); } - args.push(curArg); + const args = []; + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + } else { + throw new TypeError( + \\"Failed to execute 'arrayBufferViewDupConsumer' on 'TypedefsAndUnions': parameter 1\\" + + \\" is not of any supported type.\\" + ); + } + args.push(curArg); + } + return this[impl].arrayBufferViewDupConsumer(...args); } - return this[impl].arrayBufferViewDupConsumer(...args); -}; -Object.defineProperty(TypedefsAndUnions.prototype, \\"buf\\", { - get() { + get buf() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return utils.tryWrapperForImpl(this[impl][\\"buf\\"]); - }, + } - set(V) { + set buf(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4022,22 +3855,17 @@ Object.defineProperty(TypedefsAndUnions.prototype, \\"buf\\", { ); } this[impl][\\"buf\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(TypedefsAndUnions.prototype, \\"time\\", { - get() { + get time() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"time\\"]; - }, + } - set(V) { + set time(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4047,19 +3875,22 @@ Object.defineProperty(TypedefsAndUnions.prototype, \\"time\\", { }); this[impl][\\"time\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(TypedefsAndUnions.prototype, Symbol.toStringTag, { - value: \\"TypedefsAndUnions\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(TypedefsAndUnions.prototype, { + numOrStrConsumer: { enumerable: true }, + numOrEnumConsumer: { enumerable: true }, + numOrStrOrNullConsumer: { enumerable: true }, + numOrStrOrURLOrNullConsumer: { enumerable: true }, + urlMapInnerConsumer: { enumerable: true }, + urlMapConsumer: { enumerable: true }, + bufferSourceOrURLConsumer: { enumerable: true }, + arrayBufferViewOrURLMapConsumer: { enumerable: true }, + arrayBufferViewDupConsumer: { enumerable: true }, + buf: { enumerable: true }, + time: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"TypedefsAndUnions\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -4119,8 +3950,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -4149,58 +3978,44 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function URL(url) { - if (new.target === undefined) { - throw new TypeError( - \\"Failed to construct 'URL'. Please use the 'new' operator; this constructor \\" + \\"cannot be called as a function.\\" - ); - } - - if (arguments.length < 1) { - throw new TypeError(\\"Failed to construct 'URL': 1 argument required, but only \\" + arguments.length + \\" present.\\"); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 1\\" }); - args.push(curArg); - } - { - let curArg = arguments[1]; - if (curArg !== undefined) { - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 2\\" }); +class URL { + constructor(url) { + if (arguments.length < 1) { + throw new TypeError(\\"Failed to construct 'URL': 1 argument required, but only \\" + arguments.length + \\" present.\\"); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 1\\" }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URL': parameter 2\\" }); + } + args.push(curArg); } - args.push(curArg); + return iface.setup(Object.create(URL.prototype), args); } - iface.setup(this, args); -} - -Object.defineProperty(URL, \\"prototype\\", { - value: URL.prototype, - writable: false, - enumerable: false, - configurable: false -}); + toJSON() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URL.prototype.toJSON = function toJSON() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].toJSON(); } - return this[impl].toJSON(); -}; - -Object.defineProperty(URL.prototype, \\"href\\", { - get() { + get href() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"href\\"]; - }, + } - set(V) { + set href(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4208,42 +4023,32 @@ Object.defineProperty(URL.prototype, \\"href\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'href' property on 'URL': The provided value\\" }); this[impl][\\"href\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -URL.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return this[impl][\\"href\\"]; } - return this[impl][\\"href\\"]; -}; -Object.defineProperty(URL.prototype, \\"origin\\", { - get() { + get origin() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"origin\\"]; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"protocol\\", { - get() { + get protocol() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"protocol\\"]; - }, + } - set(V) { + set protocol(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4251,22 +4056,17 @@ Object.defineProperty(URL.prototype, \\"protocol\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'protocol' property on 'URL': The provided value\\" }); this[impl][\\"protocol\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"username\\", { - get() { + get username() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"username\\"]; - }, + } - set(V) { + set username(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4274,22 +4074,17 @@ Object.defineProperty(URL.prototype, \\"username\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'username' property on 'URL': The provided value\\" }); this[impl][\\"username\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"password\\", { - get() { + get password() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"password\\"]; - }, + } - set(V) { + set password(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4297,22 +4092,17 @@ Object.defineProperty(URL.prototype, \\"password\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'password' property on 'URL': The provided value\\" }); this[impl][\\"password\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"host\\", { - get() { + get host() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"host\\"]; - }, + } - set(V) { + set host(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4320,22 +4110,17 @@ Object.defineProperty(URL.prototype, \\"host\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'host' property on 'URL': The provided value\\" }); this[impl][\\"host\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"hostname\\", { - get() { + get hostname() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"hostname\\"]; - }, + } - set(V) { + set hostname(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4343,22 +4128,17 @@ Object.defineProperty(URL.prototype, \\"hostname\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'hostname' property on 'URL': The provided value\\" }); this[impl][\\"hostname\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"port\\", { - get() { + get port() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"port\\"]; - }, + } - set(V) { + set port(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4366,22 +4146,17 @@ Object.defineProperty(URL.prototype, \\"port\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'port' property on 'URL': The provided value\\" }); this[impl][\\"port\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"pathname\\", { - get() { + get pathname() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"pathname\\"]; - }, + } - set(V) { + set pathname(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4389,22 +4164,17 @@ Object.defineProperty(URL.prototype, \\"pathname\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'pathname' property on 'URL': The provided value\\" }); this[impl][\\"pathname\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"search\\", { - get() { + get search() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"search\\"]; - }, + } - set(V) { + set search(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4412,14 +4182,9 @@ Object.defineProperty(URL.prototype, \\"search\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'search' property on 'URL': The provided value\\" }); this[impl][\\"search\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"searchParams\\", { - get() { + get searchParams() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4427,22 +4192,17 @@ Object.defineProperty(URL.prototype, \\"searchParams\\", { return utils.getSameObject(this, \\"searchParams\\", () => { return utils.tryWrapperForImpl(this[impl][\\"searchParams\\"]); }); - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(URL.prototype, \\"hash\\", { - get() { + get hash() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"hash\\"]; - }, + } - set(V) { + set hash(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -4450,19 +4210,25 @@ Object.defineProperty(URL.prototype, \\"hash\\", { V = conversions[\\"USVString\\"](V, { context: \\"Failed to set the 'hash' property on 'URL': The provided value\\" }); this[impl][\\"hash\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(URL.prototype, Symbol.toStringTag, { - value: \\"URL\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(URL.prototype, { + toJSON: { enumerable: true }, + href: { enumerable: true }, + toString: { enumerable: true }, + origin: { enumerable: true }, + protocol: { enumerable: true }, + username: { enumerable: true }, + password: { enumerable: true }, + host: { enumerable: true }, + hostname: { enumerable: true }, + port: { enumerable: true }, + pathname: { enumerable: true }, + search: { enumerable: true }, + searchParams: { enumerable: true }, + hash: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URL\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -4522,8 +4288,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -4553,67 +4317,48 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function URLList() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(URLList, \\"prototype\\", { - value: URLList.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(URLList.prototype, Symbol.iterator, { - writable: true, - enumerable: false, - configurable: true, - value: Array.prototype[Symbol.iterator] -}); -URLList.prototype.forEach = Array.prototype.forEach; -URLList.prototype.item = function item(index) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class URLList { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" }); - args.push(curArg); - } - return utils.tryWrapperForImpl(this[impl].item(...args)); -}; + item(index) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URLList.prototype.entries = Array.prototype.entries; -URLList.prototype.keys = Array.prototype.keys; -URLList.prototype.values = Array.prototype[Symbol.iterator]; + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'item' on 'URLList': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { context: \\"Failed to execute 'item' on 'URLList': parameter 1\\" }); + args.push(curArg); + } + return utils.tryWrapperForImpl(this[impl].item(...args)); + } -Object.defineProperty(URLList.prototype, \\"length\\", { - get() { + get length() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"length\\"]; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(URLList.prototype, Symbol.toStringTag, { - value: \\"URLList\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(URLList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLList\\", configurable: true }, + [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true }, + keys: { value: Array.prototype.keys, configurable: true, enumerable: true, writable: true }, + values: { value: Array.prototype[Symbol.iterator], configurable: true, enumerable: true, writable: true }, + entries: { value: Array.prototype.entries, configurable: true, enumerable: true, writable: true }, + forEach: { value: Array.prototype.forEach, configurable: true, enumerable: true, writable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -4673,8 +4418,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -4898,312 +4641,310 @@ const IteratorPrototype = Object.create(utils.IteratorPrototype, { }, [Symbol.toStringTag]: { value: \\"URLSearchParams Iterator\\", - writable: false, - enumerable: false, configurable: true } }); - -function URLSearchParams() { - if (new.target === undefined) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams'. Please use the 'new' operator; this constructor \\" + - \\"cannot be called as a function.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (curArg !== undefined) { - if (utils.isObject(curArg)) { - if (curArg[Symbol.iterator] !== undefined) { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - if (!utils.isObject(nextItem)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + - \\" sequence\\" + - \\"'s element\\" + - \\" is not an iterable object.\\" - ); - } else { - const V = []; - const tmp = nextItem; - for (let nextItem of tmp) { - nextItem = conversions[\\"USVString\\"](nextItem, { - context: - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\"'s element\\" + \\"'s element\\" - }); - - V.push(nextItem); +class URLSearchParams { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + if (utils.isObject(curArg)) { + if (curArg[Symbol.iterator] !== undefined) { + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + if (!utils.isObject(nextItem)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + + \\" sequence\\" + + \\"'s element\\" + + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = nextItem; + for (let nextItem of tmp) { + nextItem = conversions[\\"USVString\\"](nextItem, { + context: + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" sequence\\" + \\"'s element\\" + \\"'s element\\" + }); + + V.push(nextItem); + } + nextItem = V; } - nextItem = V; - } - V.push(nextItem); + V.push(nextItem); + } + curArg = V; } - curArg = V; - } - } else { - if (!utils.isObject(curArg)) { - throw new TypeError( - \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\" is not an object.\\" - ); } else { - const result = Object.create(null); - for (const key of Reflect.ownKeys(curArg)) { - const desc = Object.getOwnPropertyDescriptor(curArg, key); - if (desc && desc.enumerable) { - let typedKey = key; - let typedValue = curArg[key]; - - typedKey = conversions[\\"USVString\\"](typedKey, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s key\\" - }); + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\" is not an object.\\" + ); + } else { + const result = Object.create(null); + for (const key of Reflect.ownKeys(curArg)) { + const desc = Object.getOwnPropertyDescriptor(curArg, key); + if (desc && desc.enumerable) { + let typedKey = key; + let typedValue = curArg[key]; + + typedKey = conversions[\\"USVString\\"](typedKey, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s key\\" + }); - typedValue = conversions[\\"USVString\\"](typedValue, { - context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s value\\" - }); + typedValue = conversions[\\"USVString\\"](typedValue, { + context: \\"Failed to construct 'URLSearchParams': parameter 1\\" + \\" record\\" + \\"'s value\\" + }); - result[typedKey] = typedValue; + result[typedKey] = typedValue; + } } + curArg = result; } - curArg = result; } + } else { + curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URLSearchParams': parameter 1\\" }); } } else { - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to construct 'URLSearchParams': parameter 1\\" }); + curArg = \\"\\"; } - } else { - curArg = \\"\\"; + args.push(curArg); } - args.push(curArg); + return iface.setup(Object.create(URLSearchParams.prototype), args); } - iface.setup(this, args); -} - -Object.defineProperty(URLSearchParams, \\"prototype\\", { - value: URLSearchParams.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(URLSearchParams.prototype, Symbol.iterator, { - writable: true, - enumerable: false, - configurable: true, - value: function entries() { + append(name, value) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } - return module.exports.createDefaultIterator(this, \\"key+value\\"); - } -}); -URLSearchParams.prototype.forEach = function forEach(callback) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'forEach' on 'URLSearchParams': 1 argument required, \\" + \\"but only 0 present.\\" - ); - } - if (typeof callback !== \\"function\\") { - throw new TypeError( - \\"Failed to execute 'forEach' on 'URLSearchParams': The callback provided \\" + \\"as parameter 1 is not a function.\\" - ); - } - const thisArg = arguments[1]; - let pairs = Array.from(this[impl]); - let i = 0; - while (i < pairs.length) { - const [key, value] = pairs[i].map(utils.tryWrapperForImpl); - callback.call(thisArg, value, key, this); - pairs = Array.from(this[impl]); - i++; - } -}; -URLSearchParams.prototype.append = function append(name, value) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 2\\" - }); - args.push(curArg); + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'append' on 'URLSearchParams': parameter 2\\" + }); + args.push(curArg); + } + return this[impl].append(...args); } - return this[impl].append(...args); -}; -URLSearchParams.prototype.delete = function _delete(name) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + delete(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'delete' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return this[impl].delete(...args); } - return this[impl].delete(...args); -}; -URLSearchParams.prototype.get = function get(name) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + get(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" }); - args.push(curArg); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'get' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return this[impl].get(...args); } - return this[impl].get(...args); -}; -URLSearchParams.prototype.getAll = function getAll(name) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + getAll(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" - }); - args.push(curArg); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'getAll' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(this[impl].getAll(...args)); } - return utils.tryWrapperForImpl(this[impl].getAll(...args)); -}; -URLSearchParams.prototype.has = function has(name) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + has(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to execute 'has' on 'URLSearchParams': parameter 1\\" }); - args.push(curArg); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'has' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + return this[impl].has(...args); } - return this[impl].has(...args); -}; -URLSearchParams.prototype.set = function set(name, value) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + set(name, value) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 2) { - throw new TypeError( - \\"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 1\\" }); - args.push(curArg); - } - { - let curArg = arguments[1]; - curArg = conversions[\\"USVString\\"](curArg, { context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 2\\" }); - args.push(curArg); + if (arguments.length < 2) { + throw new TypeError( + \\"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 1\\" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'set' on 'URLSearchParams': parameter 2\\" + }); + args.push(curArg); + } + return this[impl].set(...args); } - return this[impl].set(...args); -}; -URLSearchParams.prototype.sort = function sort() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + sort() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + return this[impl].sort(); } - return this[impl].sort(); -}; + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URLSearchParams.prototype.toString = function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].toString(); } - return this[impl].toString(); -}; - -URLSearchParams.prototype.entries = URLSearchParams.prototype[Symbol.iterator]; + keys() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return module.exports.createDefaultIterator(this, \\"key\\"); + } -URLSearchParams.prototype.keys = function keys() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + values() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return module.exports.createDefaultIterator(this, \\"value\\"); } - return module.exports.createDefaultIterator(this, \\"key\\"); -}; -URLSearchParams.prototype.values = function values() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + entries() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return module.exports.createDefaultIterator(this, \\"key+value\\"); } - return module.exports.createDefaultIterator(this, \\"value\\"); -}; -Object.defineProperty(URLSearchParams.prototype, Symbol.toStringTag, { - value: \\"URLSearchParams\\", - writable: false, - enumerable: false, - configurable: true + forEach(callback) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + if (arguments.length < 1) { + throw new TypeError(\\"Failed to execute 'forEach' on 'iterable': 1 argument required, \\" + \\"but only 0 present.\\"); + } + if (typeof callback !== \\"function\\") { + throw new TypeError( + \\"Failed to execute 'forEach' on 'iterable': The callback provided \\" + \\"as parameter 1 is not a function.\\" + ); + } + const thisArg = arguments[1]; + let pairs = Array.from(this[impl]); + let i = 0; + while (i < pairs.length) { + const [key, value] = pairs[i].map(utils.tryWrapperForImpl); + callback.call(thisArg, value, key, this); + pairs = Array.from(this[impl]); + i++; + } + } +} +Object.defineProperties(URLSearchParams.prototype, { + append: { enumerable: true }, + delete: { enumerable: true }, + get: { enumerable: true }, + getAll: { enumerable: true }, + has: { enumerable: true }, + set: { enumerable: true }, + sort: { enumerable: true }, + toString: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true }, + forEach: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLSearchParams\\", configurable: true }, + [Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -5248,8 +4989,6 @@ const iface = { const iterator = Object.create(IteratorPrototype); Object.defineProperty(iterator, utils.iterInternalSymbol, { value: { target, kind, index: 0 }, - writable: false, - enumerable: false, configurable: true }); return iterator; @@ -5274,8 +5013,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -5305,90 +5042,72 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function URLSearchParamsCollection() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(URLSearchParamsCollection, \\"prototype\\", { - value: URLSearchParamsCollection.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(URLSearchParamsCollection.prototype, Symbol.iterator, { - writable: true, - enumerable: false, - configurable: true, - value: Array.prototype[Symbol.iterator] -}); - -URLSearchParamsCollection.prototype.item = function item(index) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class URLSearchParamsCollection { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" - }); - args.push(curArg); - } - return utils.tryWrapperForImpl(this[impl].item(...args)); -}; + item(index) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -URLSearchParamsCollection.prototype.namedItem = function namedItem(name) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'item' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'item' on 'URLSearchParamsCollection': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(this[impl].item(...args)); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': parameter 1\\" - }); - args.push(curArg); + namedItem(name) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'namedItem' on 'URLSearchParamsCollection': parameter 1\\" + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(this[impl].namedItem(...args)); } - return utils.tryWrapperForImpl(this[impl].namedItem(...args)); -}; -Object.defineProperty(URLSearchParamsCollection.prototype, \\"length\\", { - get() { + get length() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"length\\"]; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(URLSearchParamsCollection.prototype, Symbol.toStringTag, { - value: \\"URLSearchParamsCollection\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(URLSearchParamsCollection.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection\\", configurable: true }, + [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -5448,8 +5167,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -5666,34 +5383,15 @@ const convertURL = require(\\"./URL.js\\").convert; const impl = utils.implSymbol; const URLSearchParamsCollection = require(\\"./URLSearchParamsCollection.js\\"); -function URLSearchParamsCollection2() { - throw new TypeError(\\"Illegal constructor\\"); +class URLSearchParamsCollection2 extends URLSearchParamsCollection.interface { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } } - -Object.setPrototypeOf(URLSearchParamsCollection2.prototype, URLSearchParamsCollection.interface.prototype); -Object.setPrototypeOf(URLSearchParamsCollection2, URLSearchParamsCollection.interface); - -Object.defineProperty(URLSearchParamsCollection2, \\"prototype\\", { - value: URLSearchParamsCollection2.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(URLSearchParamsCollection2.prototype, Symbol.iterator, { - writable: true, - enumerable: false, - configurable: true, - value: Array.prototype[Symbol.iterator] -}); - -Object.defineProperty(URLSearchParamsCollection2.prototype, Symbol.toStringTag, { - value: \\"URLSearchParamsCollection2\\", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(URLSearchParamsCollection2.prototype, { + [Symbol.toStringTag]: { value: \\"URLSearchParamsCollection2\\", configurable: true }, + [Symbol.iterator]: { value: Array.prototype[Symbol.iterator], configurable: true, writable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -5755,8 +5453,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -6001,90 +5697,64 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; const MixinMixin = require(\\"./MixinMixin.js\\"); -function UnderscoredProperties() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(UnderscoredProperties, \\"prototype\\", { - value: UnderscoredProperties.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -UnderscoredProperties.prototype.operation = function operation(sequence) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class UnderscoredProperties { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - if (!utils.isObject(curArg)) { + operation(sequence) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + + if (arguments.length < 1) { throw new TypeError( - \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" + \\"Failed to execute 'operation' on 'UnderscoredProperties': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" ); - } else { - const V = []; - const tmp = curArg; - for (let nextItem of tmp) { - nextItem = conversions[\\"DOMString\\"](nextItem, { - context: \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\"'s element\\" - }); + } + const args = []; + { + let curArg = arguments[0]; + if (!utils.isObject(curArg)) { + throw new TypeError( + \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\" is not an iterable object.\\" + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions[\\"DOMString\\"](nextItem, { + context: \\"Failed to execute 'operation' on 'UnderscoredProperties': parameter 1\\" + \\"'s element\\" + }); - V.push(nextItem); + V.push(nextItem); + } + curArg = V; } - curArg = V; + args.push(curArg); } - args.push(curArg); - } - return this[impl].operation(...args); -}; - -UnderscoredProperties.prototype.mixinMixinOp = function mixinMixinOp() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + return this[impl].operation(...args); } - return this[impl].mixinMixinOp(); -}; + mixinMixinOp() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -UnderscoredProperties.static = function _static(_void) { - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + - arguments.length + - \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" - }); - args.push(curArg); + return this[impl].mixinMixinOp(); } - return Impl.implementation.static(...args); -}; -Object.defineProperty(UnderscoredProperties.prototype, \\"attribute\\", { - get() { + get attribute() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"attribute\\"]; - }, + } - set(V) { + set attribute(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -6094,22 +5764,17 @@ Object.defineProperty(UnderscoredProperties.prototype, \\"attribute\\", { }); this[impl][\\"attribute\\"] = V; - }, - - enumerable: true, - configurable: true -}); + } -Object.defineProperty(UnderscoredProperties.prototype, \\"mixinMixinAttr\\", { - get() { + get mixinMixinAttr() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"mixinMixinAttr\\"]; - }, + } - set(V) { + set mixinMixinAttr(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -6119,37 +5784,41 @@ Object.defineProperty(UnderscoredProperties.prototype, \\"mixinMixinAttr\\", { }); this[impl][\\"mixinMixinAttr\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(UnderscoredProperties, \\"const\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(UnderscoredProperties.prototype, \\"const\\", { - value: 42, - enumerable: true -}); + } -Object.defineProperty(UnderscoredProperties, \\"mixinMixinConst\\", { - value: 42, - enumerable: true -}); -Object.defineProperty(UnderscoredProperties.prototype, \\"mixinMixinConst\\", { - value: 42, - enumerable: true + static static(void_) { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'static' on 'UnderscoredProperties': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'static' on 'UnderscoredProperties': parameter 1\\" + }); + args.push(curArg); + } + return Impl.implementation.static(...args); + } +} +Object.defineProperties(UnderscoredProperties.prototype, { + operation: { enumerable: true }, + mixinMixinOp: { enumerable: true }, + attribute: { enumerable: true }, + mixinMixinAttr: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"UnderscoredProperties\\", configurable: true }, + const: { value: 42, enumerable: true }, + mixinMixinConst: { value: 42, enumerable: true } }); - -Object.defineProperty(UnderscoredProperties.prototype, Symbol.toStringTag, { - value: \\"UnderscoredProperties\\", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(UnderscoredProperties, { + static: { enumerable: true }, + const: { value: 42, enumerable: true }, + mixinMixinConst: { value: 42, enumerable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -6209,8 +5878,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -6241,24 +5908,12 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function Unforgeable() { - throw new TypeError(\\"Illegal constructor\\"); +class Unforgeable { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } } - -Object.defineProperty(Unforgeable, \\"prototype\\", { - value: Unforgeable.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(Unforgeable.prototype, Symbol.toStringTag, { - value: \\"Unforgeable\\", - writable: false, - enumerable: false, - configurable: true -}); - +Object.defineProperties(Unforgeable.prototype, { [Symbol.toStringTag]: { value: \\"Unforgeable\\", configurable: true } }); const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -6310,100 +5965,89 @@ const iface = { return utils.implForWrapper(obj); }, _internalSetup(obj) { - obj.assign = function assign(url) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'assign' on 'Unforgeable': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"USVString\\"](curArg, { - context: \\"Failed to execute 'assign' on 'Unforgeable': parameter 1\\" - }); - args.push(curArg); - } - return this[impl].assign(...args); - }; - - Object.defineProperty(obj, \\"href\\", { - get() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - return obj[impl][\\"href\\"]; - }, - - set(V) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'href' property on 'Unforgeable': The provided value\\" - }); - - obj[impl][\\"href\\"] = V; - }, + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + assign(url) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - enumerable: true, - configurable: false - }); + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'assign' on 'Unforgeable': 1 argument required, but only \\" + + arguments.length + + \\" present.\\" + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions[\\"USVString\\"](curArg, { + context: \\"Failed to execute 'assign' on 'Unforgeable': parameter 1\\" + }); + args.push(curArg); + } + return this[impl].assign(...args); + }, + get href() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - Object.defineProperty(obj, \\"toString\\", { - writable: false, - enumerable: true, - configurable: false, - value: function toString() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - return obj[impl][\\"href\\"]; - } - }); + return obj[impl][\\"href\\"]; + }, + set href(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - Object.defineProperty(obj, \\"origin\\", { - get() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'href' property on 'Unforgeable': The provided value\\" + }); - return obj[impl][\\"origin\\"]; - }, + obj[impl][\\"href\\"] = V; + }, + toString() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + return obj[impl][\\"href\\"]; + }, + get origin() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - enumerable: true, - configurable: false - }); + return obj[impl][\\"origin\\"]; + }, + get protocol() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - Object.defineProperty(obj, \\"protocol\\", { - get() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + return obj[impl][\\"protocol\\"]; + }, + set protocol(V) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return obj[impl][\\"protocol\\"]; - }, + V = conversions[\\"USVString\\"](V, { + context: \\"Failed to set the 'protocol' property on 'Unforgeable': The provided value\\" + }); - set(V) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + obj[impl][\\"protocol\\"] = V; } + }) + ); - V = conversions[\\"USVString\\"](V, { - context: \\"Failed to set the 'protocol' property on 'Unforgeable': The provided value\\" - }); - - obj[impl][\\"protocol\\"] = V; - }, - - enumerable: true, - configurable: false + Object.defineProperties(obj, { + assign: { configurable: false, writable: false }, + href: { configurable: false }, + toString: { configurable: false, writable: false }, + origin: { configurable: false }, + protocol: { configurable: false } }); }, setup(obj, constructorArgs, privateData) { @@ -6414,8 +6058,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -6444,24 +6086,14 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function UnforgeableMap() { - throw new TypeError(\\"Illegal constructor\\"); +class UnforgeableMap { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } } - -Object.defineProperty(UnforgeableMap, \\"prototype\\", { - value: UnforgeableMap.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(UnforgeableMap.prototype, Symbol.toStringTag, { - value: \\"UnforgeableMap\\", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(UnforgeableMap.prototype, { + [Symbol.toStringTag]: { value: \\"UnforgeableMap\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -6513,18 +6145,20 @@ const iface = { return utils.implForWrapper(obj); }, _internalSetup(obj) { - Object.defineProperty(obj, \\"a\\", { - get() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + Object.defineProperties( + obj, + Object.getOwnPropertyDescriptors({ + get a() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - return obj[impl][\\"a\\"]; - }, + return obj[impl][\\"a\\"]; + } + }) + ); - enumerable: true, - configurable: false - }); + Object.defineProperties(obj, { a: { configurable: false } }); }, setup(obj, constructorArgs, privateData) { if (!privateData) privateData = {}; @@ -6534,8 +6168,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -6739,27 +6371,20 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function Unscopable() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(Unscopable, \\"prototype\\", { - value: Unscopable.prototype, - writable: false, - enumerable: false, - configurable: false -}); +class Unscopable { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); + } -Object.defineProperty(Unscopable.prototype, \\"unscopableTest\\", { - get() { + get unscopableTest() { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } return this[impl][\\"unscopableTest\\"]; - }, + } - set(V) { + set unscopableTest(V) { if (!this || !module.exports.is(this)) { throw new TypeError(\\"Illegal invocation\\"); } @@ -6769,28 +6394,13 @@ Object.defineProperty(Unscopable.prototype, \\"unscopableTest\\", { }); this[impl][\\"unscopableTest\\"] = V; - }, - - enumerable: true, - configurable: true -}); - -Object.defineProperty(Unscopable.prototype, Symbol.unscopables, { - value: { - unscopableTest: true - }, - writable: false, - enumerable: false, - configurable: true -}); - -Object.defineProperty(Unscopable.prototype, Symbol.toStringTag, { - value: \\"Unscopable\\", - writable: false, - enumerable: false, - configurable: true + } +} +Object.defineProperties(Unscopable.prototype, { + unscopableTest: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Unscopable\\", configurable: true }, + [Symbol.unscopables]: { value: { unscopableTest: true }, configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -6850,8 +6460,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -6881,102 +6489,117 @@ const utils = require(\\"./utils.js\\"); const convertURL = require(\\"./URL.js\\").convert; const impl = utils.implSymbol; -function Variadic() { - throw new TypeError(\\"Illegal constructor\\"); -} - -Object.defineProperty(Variadic, \\"prototype\\", { - value: Variadic.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Variadic.prototype.simple1 = function simple1() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); +class Variadic { + constructor() { + throw new TypeError(\\"Illegal constructor\\"); } - const args = []; - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'simple1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - return this[impl].simple1(...args); -}; -Variadic.prototype.simple2 = function simple2(first) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); + simple1() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + const args = []; + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'simple1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + return this[impl].simple1(...args); } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'simple2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter 1\\" }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = convertURL(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); - args.push(curArg); - } - return this[impl].simple2(...args); -}; + simple2(first) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } -Variadic.prototype.overloaded1 = function overloaded1() { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } - const args = []; - switch (arguments.length) { - case 0: - break; - default: { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'simple2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + { let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - for (let i = 0; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); + curArg = conversions[\\"DOMString\\"](curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter 1\\" }); + args.push(curArg); + } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = convertURL(curArg, { context: \\"Failed to execute 'simple2' on 'Variadic': parameter \\" + (i + 1) }); + args.push(curArg); + } + return this[impl].simple2(...args); + } + + overloaded1() { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } + const args = []; + switch (arguments.length) { + case 0: + break; + default: { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } + } else { + for (let i = 0; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded1' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } } } } + return this[impl].overloaded1(...args); } - return this[impl].overloaded1(...args); -}; -Variadic.prototype.overloaded2 = function overloaded2(first) { - if (!this || !module.exports.is(this)) { - throw new TypeError(\\"Illegal invocation\\"); - } + overloaded2(first) { + if (!this || !module.exports.is(this)) { + throw new TypeError(\\"Illegal invocation\\"); + } - if (arguments.length < 1) { - throw new TypeError( - \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" - ); - } - const args = []; - switch (arguments.length) { - case 1: - { + if (arguments.length < 1) { + throw new TypeError( + \\"Failed to execute 'overloaded2' on 'Variadic': 1 argument required, but only \\" + arguments.length + \\" present.\\" + ); + } + const args = []; + switch (arguments.length) { + case 1: + { + let curArg = arguments[0]; + if (typeof curArg === \\"number\\") { + { + let curArg = arguments[0]; + curArg = conversions[\\"unsigned long\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" + }); + args.push(curArg); + } + } + } + break; + default: { let curArg = arguments[0]; if (typeof curArg === \\"number\\") { { @@ -6986,6 +6609,13 @@ Variadic.prototype.overloaded2 = function overloaded2(first) { }); args.push(curArg); } + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } } else { { let curArg = arguments[0]; @@ -6994,54 +6624,26 @@ Variadic.prototype.overloaded2 = function overloaded2(first) { }); args.push(curArg); } - } - } - break; - default: { - let curArg = arguments[0]; - if (typeof curArg === \\"number\\") { - { - let curArg = arguments[0]; - curArg = conversions[\\"unsigned long\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); - } - } else { - { - let curArg = arguments[0]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter 1\\" - }); - args.push(curArg); - } - for (let i = 1; i < arguments.length; i++) { - let curArg = arguments[i]; - curArg = conversions[\\"DOMString\\"](curArg, { - context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) - }); - args.push(curArg); + for (let i = 1; i < arguments.length; i++) { + let curArg = arguments[i]; + curArg = conversions[\\"DOMString\\"](curArg, { + context: \\"Failed to execute 'overloaded2' on 'Variadic': parameter \\" + (i + 1) + }); + args.push(curArg); + } } } } + return this[impl].overloaded2(...args); } - return this[impl].overloaded2(...args); -}; - -Object.defineProperty(Variadic.prototype, Symbol.toStringTag, { - value: \\"Variadic\\", - writable: false, - enumerable: false, - configurable: true +} +Object.defineProperties(Variadic.prototype, { + simple1: { enumerable: true }, + simple2: { enumerable: true }, + overloaded1: { enumerable: true }, + overloaded2: { enumerable: true }, + [Symbol.toStringTag]: { value: \\"Variadic\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -7101,8 +6703,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); @@ -7131,31 +6731,14 @@ const utils = require(\\"./utils.js\\"); const impl = utils.implSymbol; -function ZeroArgConstructor() { - if (new.target === undefined) { - throw new TypeError( - \\"Failed to construct 'ZeroArgConstructor'. Please use the 'new' operator; this constructor \\" + - \\"cannot be called as a function.\\" - ); +class ZeroArgConstructor { + constructor() { + return iface.setup(Object.create(ZeroArgConstructor.prototype)); } - - iface.setup(this); } - -Object.defineProperty(ZeroArgConstructor, \\"prototype\\", { - value: ZeroArgConstructor.prototype, - writable: false, - enumerable: false, - configurable: false -}); - -Object.defineProperty(ZeroArgConstructor.prototype, Symbol.toStringTag, { - value: \\"ZeroArgConstructor\\", - writable: false, - enumerable: false, - configurable: true +Object.defineProperties(ZeroArgConstructor.prototype, { + [Symbol.toStringTag]: { value: \\"ZeroArgConstructor\\", configurable: true } }); - const iface = { // When an interface-module that implements this interface as a mixin is loaded, it will append its own \`.is()\` // method into this array. It allows objects that directly implements *those* interfaces to be recognized as @@ -7215,8 +6798,6 @@ const iface = { this._internalSetup(obj); Object.defineProperty(obj, impl, { value: new Impl.implementation(constructorArgs, privateData), - writable: false, - enumerable: false, configurable: true }); diff --git a/test/cases/Global.webidl b/test/cases/Global.webidl new file mode 100644 index 00000000..1d945e32 --- /dev/null +++ b/test/cases/Global.webidl @@ -0,0 +1,11 @@ +[Global=Global] +interface Global { + void op(); + [Unforgeable] void unforgeableOp(); + attribute DOMString attr; + [Unforgeable] attribute DOMString unforgeableAttr; + + getter DOMString (unsigned long index); + attribute unsigned long length; + iterable; +};