Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync WebIDL.py with gecko #23748

Merged
merged 2 commits into from Jul 12, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Require default dictionary value for optional dicts

  • Loading branch information
saschanaz committed Jul 12, 2019
commit 01151274f1487e630852680ba38ab5a651db44ec

Some generated files are not rendered by default. Learn more.

@@ -17,6 +17,7 @@
from WebIDL import (
BuiltinTypes,
IDLBuiltinType,
IDLDefaultDictionaryValue,
IDLEmptySequenceValue,
IDLInterfaceMember,
IDLNullableType,
@@ -678,13 +679,16 @@ def handleDefault(nullValue):
return None

if isinstance(defaultValue, IDLNullValue):
assert type.nullable() or type.isDictionary()
assert type.nullable()
return nullValue
elif isinstance(defaultValue, IDLDefaultDictionaryValue):
assert type.isDictionary()
return nullValue
elif isinstance(defaultValue, IDLEmptySequenceValue):
assert type.isSequence()
return "Vec::new()"

raise TypeError("Can't handle non-null or non-empty sequence default value here")
raise TypeError("Can't handle non-null, non-empty sequence or non-empty dictionary default value here")

# A helper function for wrapping up the template body for
# possibly-nullable objecty stuff
@@ -747,17 +751,19 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
for memberType in type.unroll().flatMemberTypes
if memberType.isDictionary()
]
if defaultValue and not isinstance(defaultValue, IDLNullValue):
if (defaultValue and
not isinstance(defaultValue, IDLNullValue) and
not isinstance(defaultValue, IDLDefaultDictionaryValue)):
tag = defaultValue.type.tag()
if tag is IDLType.Tags.bool:
default = "%s::Boolean(%s)" % (
union_native_type(type),
"true" if defaultValue.value else "false")
else:
raise("We don't currently support default values that aren't null or boolean")
raise("We don't currently support default values that aren't null, boolean or default dictionary")
elif dictionaries:
if defaultValue:
assert isinstance(defaultValue, IDLNullValue)
assert isinstance(defaultValue, IDLDefaultDictionaryValue)
dictionary, = dictionaries
default = "%s::%s(%s::%s::empty())" % (
union_native_type(type),
@@ -14,7 +14,7 @@ dictionary AnalyserOptions : AudioNodeOptions {
};

[Exposed=Window,
Constructor (BaseAudioContext context, optional AnalyserOptions options)]
Constructor (BaseAudioContext context, optional AnalyserOptions options = {})]
interface AnalyserNode : AudioNode {
void getFloatFrequencyData (Float32Array array);
void getByteFrequencyData (Uint8Array array);
@@ -16,7 +16,7 @@ dictionary AudioBufferSourceOptions {
};

[Exposed=Window,
Constructor (BaseAudioContext context, optional AudioBufferSourceOptions options)]
Constructor (BaseAudioContext context, optional AudioBufferSourceOptions options = {})]
interface AudioBufferSourceNode : AudioScheduledSourceNode {
[Throws] attribute AudioBuffer? buffer;
readonly attribute AudioParam playbackRate;
@@ -23,7 +23,7 @@ dictionary AudioTimestamp {
};

[Exposed=Window,
Constructor(optional AudioContextOptions contextOptions)]
Constructor(optional AudioContextOptions contextOptions = {})]
interface AudioContext : BaseAudioContext {
readonly attribute double baseLatency;
readonly attribute double outputLatency;
@@ -26,7 +26,7 @@ dictionary BiquadFilterOptions : AudioNodeOptions {
};

[Exposed=Window,
Constructor (BaseAudioContext context, optional BiquadFilterOptions options)]
Constructor (BaseAudioContext context, optional BiquadFilterOptions options = {})]
interface BiquadFilterNode : AudioNode {
attribute BiquadFilterType type;
readonly attribute AudioParam frequency;
@@ -5,7 +5,7 @@
// https://w3c.github.io/FileAPI/#blob

[Constructor(optional sequence<BlobPart> blobParts,
optional BlobPropertyBag options),
optional BlobPropertyBag options = {}),
Exposed=(Window,Worker)]
interface Blob {

@@ -34,7 +34,7 @@ interface Bluetooth : EventTarget {
// [SecureContext, SameObject]
// readonly attribute BluetoothDevice? referringDevice;
[SecureContext]
Promise<BluetoothDevice> requestDevice(optional RequestDeviceOptions options);
Promise<BluetoothDevice> requestDevice(optional RequestDeviceOptions options = {});
};

// Bluetooth implements BluetoothDeviceEventHandlers;
@@ -11,6 +11,6 @@ dictionary ChannelMergerOptions : AudioNodeOptions {
};

[Exposed=Window,
Constructor (BaseAudioContext context, optional ChannelMergerOptions options)]
Constructor (BaseAudioContext context, optional ChannelMergerOptions options = {})]
interface ChannelMergerNode : AudioNode {
};
@@ -11,6 +11,6 @@ dictionary ChannelSplitterOptions : AudioNodeOptions {
};

[Exposed=Window,
Constructor (BaseAudioContext context, optional ChannelSplitterOptions options)]
Constructor (BaseAudioContext context, optional ChannelSplitterOptions options = {})]
interface ChannelSplitterNode : AudioNode {
};
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

//https://html.spec.whatwg.org/multipage/#the-closeevent-interfaces
[Constructor(DOMString type, optional CloseEventInit eventInitDict), Exposed=(Window,Worker)]
[Constructor(DOMString type, optional CloseEventInit eventInitDict = {}), Exposed=(Window,Worker)]
interface CloseEvent : Event {
readonly attribute boolean wasClean;
readonly attribute unsigned short code;
@@ -8,7 +8,7 @@
*/

// https://w3c.github.io/uievents/#idl-compositionevent
[Pref="dom.compositionevent.enabled", Constructor(DOMString type, optional CompositionEventInit eventInitDict)]
[Pref="dom.compositionevent.enabled", Constructor(DOMString type, optional CompositionEventInit eventInitDict = {})]
interface CompositionEvent : UIEvent {
readonly attribute DOMString data;
};
@@ -6,7 +6,7 @@
[Pref="dom.customelements.enabled"]
interface CustomElementRegistry {
[Throws, CEReactions]
void define(DOMString name, CustomElementConstructor constructor_, optional ElementDefinitionOptions options);
void define(DOMString name, CustomElementConstructor constructor_, optional ElementDefinitionOptions options = {});

any get(DOMString name);

@@ -13,7 +13,7 @@
* http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0.
*/

[Constructor(DOMString type, optional CustomEventInit eventInitDict),
[Constructor(DOMString type, optional CustomEventInit eventInitDict = {}),
Exposed=(Window,Worker)]
interface CustomEvent : Event {
readonly attribute any detail;
@@ -14,7 +14,7 @@
Exposed=(Window,Worker)]
interface DOMMatrix : DOMMatrixReadOnly {

[NewObject, Throws] static DOMMatrix fromMatrix(optional DOMMatrixInit other);
[NewObject, Throws] static DOMMatrix fromMatrix(optional DOMMatrixInit other = {});
[NewObject, Throws] static DOMMatrix fromFloat32Array(Float32Array array32);
[NewObject, Throws] static DOMMatrix fromFloat64Array(Float64Array array64);

@@ -44,8 +44,8 @@ interface DOMMatrix : DOMMatrixReadOnly {
inherit attribute unrestricted double m44;

// Mutable transform methods
[Throws] DOMMatrix multiplySelf(optional DOMMatrixInit other);
[Throws] DOMMatrix preMultiplySelf(optional DOMMatrixInit other);
[Throws] DOMMatrix multiplySelf(optional DOMMatrixInit other = {});
[Throws] DOMMatrix preMultiplySelf(optional DOMMatrixInit other = {});
DOMMatrix translateSelf(optional unrestricted double tx = 0,
optional unrestricted double ty = 0,
optional unrestricted double tz = 0);
@@ -14,7 +14,7 @@
Exposed=(Window,Worker)]
interface DOMMatrixReadOnly {

[NewObject, Throws] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
[NewObject, Throws] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other = {});
[NewObject, Throws] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
[NewObject, Throws] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64);

@@ -73,12 +73,12 @@ interface DOMMatrixReadOnly {
optional unrestricted double angle = 0);
DOMMatrix skewX(optional unrestricted double sx = 0);
DOMMatrix skewY(optional unrestricted double sy = 0);
[Throws] DOMMatrix multiply(optional DOMMatrixInit other);
[Throws] DOMMatrix multiply(optional DOMMatrixInit other = {});
DOMMatrix flipX();
DOMMatrix flipY();
DOMMatrix inverse();

DOMPoint transformPoint(optional DOMPointInit point);
DOMPoint transformPoint(optional DOMPointInit point = {});
Float32Array toFloat32Array();
Float64Array toFloat64Array();
// stringifier;
@@ -14,7 +14,7 @@
optional unrestricted double z = 0, optional unrestricted double w = 1),
Exposed=(Window,Worker)]
interface DOMPoint : DOMPointReadOnly {
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other = null);
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other = {});

inherit attribute unrestricted double x;
inherit attribute unrestricted double y;
@@ -14,7 +14,7 @@
optional unrestricted double z = 0, optional unrestricted double w = 1),
Exposed=(Window,Worker)]
interface DOMPointReadOnly {
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other = null);
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other = {});

readonly attribute unrestricted double x;
readonly attribute unrestricted double y;
@@ -10,12 +10,12 @@
* related or neighboring rights to this work.
*/

[Constructor(optional DOMPointInit p1, optional DOMPointInit p2,
optional DOMPointInit p3, optional DOMPointInit p4),
[Constructor(optional DOMPointInit p1 = {}, optional DOMPointInit p2 = {},
optional DOMPointInit p3 = {}, optional DOMPointInit p4 = {}),
Exposed=(Window,Worker)]
interface DOMQuad {
[NewObject] static DOMQuad fromRect(optional DOMRectInit other);
[NewObject] static DOMQuad fromQuad(optional DOMQuadInit other);
[NewObject] static DOMQuad fromRect(optional DOMRectInit other = {});
[NewObject] static DOMQuad fromQuad(optional DOMQuadInit other = {});

[SameObject] readonly attribute DOMPoint p1;
[SameObject] readonly attribute DOMPoint p2;
@@ -25,8 +25,8 @@ interface DOMQuad {
};

dictionary DOMQuadInit {
DOMPointInit p1 = null;
DOMPointInit p2 = null;
DOMPointInit p3 = null;
DOMPointInit p4 = null;
DOMPointInit p1 = {};
DOMPointInit p2 = {};
DOMPointInit p3 = {};
DOMPointInit p4 = {};
};
@@ -33,9 +33,9 @@ interface Document : Node {
HTMLCollection getElementsByClassName(DOMString classNames);

[CEReactions, NewObject, Throws]
Element createElement(DOMString localName, optional ElementCreationOptions options);
Element createElement(DOMString localName, optional ElementCreationOptions options = {});
[CEReactions, NewObject, Throws]
Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional ElementCreationOptions options);
Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional ElementCreationOptions options = {});
[NewObject]
DocumentFragment createDocumentFragment();
[NewObject]
@@ -91,12 +91,12 @@ partial interface Element {
[NewObject]
DOMRect getBoundingClientRect();

void scroll(optional ScrollToOptions options);
void scroll(optional ScrollToOptions options = {});
void scroll(unrestricted double x, unrestricted double y);

void scrollTo(optional ScrollToOptions options);
void scrollTo(optional ScrollToOptions options = {});
void scrollTo(unrestricted double x, unrestricted double y);
void scrollBy(optional ScrollToOptions options);
void scrollBy(optional ScrollToOptions options = {});
void scrollBy(unrestricted double x, unrestricted double y);
attribute unrestricted double scrollTop;
attribute unrestricted double scrollLeft;
@@ -4,7 +4,7 @@

// https://html.spec.whatwg.org/multipage/#the-errorevent-interface

[Constructor(DOMString type, optional ErrorEventInit eventInitDict), Exposed=(Window,Worker)]
[Constructor(DOMString type, optional ErrorEventInit eventInitDict = {}), Exposed=(Window,Worker)]
interface ErrorEvent : Event {
readonly attribute DOMString message;
readonly attribute DOMString filename;
@@ -6,7 +6,7 @@
* https://dom.spec.whatwg.org/#event
*/

[Constructor(DOMString type, optional EventInit eventInitDict), Exposed=(Window,Worker)]
[Constructor(DOMString type, optional EventInit eventInitDict = {}), Exposed=(Window,Worker)]
interface Event {
[Pure]
readonly attribute DOMString type;
@@ -6,7 +6,7 @@
* https://html.spec.whatwg.org/multipage/#eventsource
*/

[Constructor(DOMString url, optional EventSourceInit eventSourceInitDict),
[Constructor(DOMString url, optional EventSourceInit eventSourceInitDict = {}),
Exposed=(Window,Worker)]
interface EventSource : EventTarget {
readonly attribute DOMString url;
@@ -10,13 +10,13 @@ interface EventTarget {
void addEventListener(
DOMString type,
EventListener? callback,
optional (AddEventListenerOptions or boolean) options
optional (AddEventListenerOptions or boolean) options = {}
);

void removeEventListener(
DOMString type,
EventListener? callback,
optional (EventListenerOptions or boolean) options
optional (EventListenerOptions or boolean) options = {}
);

[Throws]
@@ -5,7 +5,7 @@
// https://w3c.github.io/ServiceWorker/#extendable-event

[Constructor(DOMString type,
optional ExtendableEventInit eventInitDict),
optional ExtendableEventInit eventInitDict = {}),
Exposed=ServiceWorker,
Pref="dom.serviceworker.enabled"]
interface ExtendableEvent : Event {
@@ -4,7 +4,7 @@

// https://w3c.github.io/ServiceWorker/#extendablemessage-event-section

[Constructor(DOMString type, optional ExtendableMessageEventInit eventInitDict),
[Constructor(DOMString type, optional ExtendableMessageEventInit eventInitDict = {}),
Exposed=ServiceWorker,
Pref="dom.serviceworker.enabled"]
interface ExtendableMessageEvent : ExtendableEvent {
@@ -7,5 +7,5 @@
[Exposed=(Window,Worker)]

partial interface WindowOrWorkerGlobalScope {
[NewObject] Promise<Response> fetch(RequestInfo input, optional RequestInit init);
[NewObject] Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
};
@@ -6,7 +6,7 @@

[Constructor(sequence<BlobPart> fileBits,
DOMString fileName,
optional FilePropertyBag options),
optional FilePropertyBag options = {}),
Exposed=(Window,Worker)]
interface File : Blob {
readonly attribute DOMString name;
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// https://w3c.github.io/uievents/#interface-FocusEvent
[Constructor(DOMString typeArg, optional FocusEventInit focusEventInitDict),
[Constructor(DOMString typeArg, optional FocusEventInit focusEventInitDict = {}),
Exposed=Window]
interface FocusEvent : UIEvent {
readonly attribute EventTarget? relatedTarget;
@@ -4,7 +4,7 @@

// https://html.spec.whatwg.org/multipage/#the-formdataevent-interface
[Exposed=Window,
Constructor(DOMString type, optional FormDataEventInit eventInitDict)]
Constructor(DOMString type, optional FormDataEventInit eventInitDict = {})]
interface FormDataEvent : Event {
readonly attribute FormData formData;
};
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.