Skip to content

Commit 35e95f5

Browse files
authored
Auto merge of servo#28663 - saschanaz:void-undefined, r=jdm
Convert Web IDL void to undefined <!-- Please describe your changes on the following line: --> Thanks to my tool https://github.com/saschanaz/gecko-webidl 🙌 Build is failing on my current VS2022+Python 3.10 environment, but the IDL tests are passing anyway, so... --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix servo#27660 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2 parents 3391772 + 5b38981 commit 35e95f5

File tree

159 files changed

+1162
-1144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+1162
-1144
lines changed

components/script/dom/bindings/codegen/CodegenRust.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
11881188

11891189
return handleOptional(template, declType, handleDefault(empty))
11901190

1191-
if type.isVoid():
1191+
if type.isUndefined():
11921192
# This one only happens for return values, and its easy: Just
11931193
# ignore the jsval.
11941194
return JSToNativeConversionInfo("", None, None)
@@ -1439,7 +1439,7 @@ def getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs):
14391439

14401440
# Returns a CGThing containing the type of the return value.
14411441
def getRetvalDeclarationForType(returnType, descriptorProvider):
1442-
if returnType is None or returnType.isVoid():
1442+
if returnType is None or returnType.isUndefined():
14431443
# Nothing to declare
14441444
return CGGeneric("()")
14451445
if returnType.isPrimitive() and returnType.tag() in builtinNames:
@@ -4338,7 +4338,7 @@ def define(self):
43384338
result += self.defineJitInfo(setterinfo, setter, "Setter",
43394339
False, False, "AliasEverything",
43404340
False, False, "0",
4341-
[BuiltinTypes[IDLBuiltinType.Types.void]],
4341+
[BuiltinTypes[IDLBuiltinType.Types.undefined]],
43424342
None)
43434343
return result
43444344
if self.member.isMethod():
@@ -4426,7 +4426,7 @@ def getJSReturnTypeTag(t):
44264426
if t.nullable():
44274427
# Sometimes it might return null, sometimes not
44284428
return "JSVAL_TYPE_UNKNOWN"
4429-
if t.isVoid():
4429+
if t.isUndefined():
44304430
# No return, every time
44314431
return "JSVAL_TYPE_UNDEFINED"
44324432
if t.isSequence():
@@ -4500,7 +4500,7 @@ def getSingleReturnType(existingType, t):
45004500

45014501
@staticmethod
45024502
def getJSArgType(t):
4503-
assert not t.isVoid()
4503+
assert not t.isUndefined()
45044504
if t.nullable():
45054505
# Sometimes it might return null, sometimes not
45064506
return "JSJitInfo_ArgType::Null as i32 | %s" % CGMemberJITInfo.getJSArgType(t.inner)
@@ -7336,7 +7336,7 @@ def __init__(self, descriptorProvider, member, name, signature, extendedAttrs,
73367336
# Mark our getters, which are attrs that
73377337
# have a non-void return type, as const.
73387338
const=(not member.isStatic() and member.isAttr()
7339-
and not signature[0].isVoid()),
7339+
and not signature[0].isUndefined()),
73407340
breakAfterSelf=breakAfterSelf,
73417341
unsafe=unsafe,
73427342
visibility=visibility)
@@ -7608,7 +7608,7 @@ def getResultConversion(self):
76087608
convertType = instantiateJSToNativeConversionTemplate(
76097609
template, replacements, declType, "rvalDecl")
76107610

7611-
if self.retvalType is None or self.retvalType.isVoid():
7611+
if self.retvalType is None or self.retvalType.isUndefined():
76127612
retval = "()"
76137613
elif self.retvalType.isAny():
76147614
retval = "rvalDecl.get()"

components/script/dom/bindings/codegen/parser/WebIDL.py

+39-39
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,7 @@ class IDLType(IDLObject):
20932093
'utf8string',
20942094
'jsstring',
20952095
'object',
2096-
'void',
2096+
'undefined',
20972097
# Funny stuff
20982098
'interface',
20992099
'dictionary',
@@ -2168,8 +2168,8 @@ def isUTF8String(self):
21682168
def isJSString(self):
21692169
return False
21702170

2171-
def isVoid(self):
2172-
return self.name == "Void"
2171+
def isUndefined(self):
2172+
return self.name == "Undefined"
21732173

21742174
def isSequence(self):
21752175
return False
@@ -2355,7 +2355,7 @@ def _getDependentObjects(self):
23552355

23562356
class IDLNullableType(IDLParametrizedType):
23572357
def __init__(self, location, innerType):
2358-
assert not innerType.isVoid()
2358+
assert not innerType.isUndefined()
23592359
assert not innerType == BuiltinTypes[IDLBuiltinType.Types.any]
23602360

23612361
IDLParametrizedType.__init__(self, location, None, innerType)
@@ -2414,7 +2414,7 @@ def isUnrestricted(self):
24142414
def isInteger(self):
24152415
return self.inner.isInteger()
24162416

2417-
def isVoid(self):
2417+
def isUndefined(self):
24182418
return False
24192419

24202420
def isSequence(self):
@@ -2517,7 +2517,7 @@ def withExtendedAttributes(self, attrs):
25172517

25182518
class IDLSequenceType(IDLParametrizedType):
25192519
def __init__(self, location, parameterType):
2520-
assert not parameterType.isVoid()
2520+
assert not parameterType.isUndefined()
25212521

25222522
IDLParametrizedType.__init__(self, location, parameterType.name, parameterType)
25232523
# Need to set self.name up front if our inner type is already complete,
@@ -2561,7 +2561,7 @@ def isUTF8String(self):
25612561
def isJSString(self):
25622562
return False
25632563

2564-
def isVoid(self):
2564+
def isUndefined(self):
25652565
return False
25662566

25672567
def isSequence(self):
@@ -2602,7 +2602,7 @@ class IDLRecordType(IDLParametrizedType):
26022602
def __init__(self, location, keyType, valueType):
26032603
assert keyType.isString()
26042604
assert keyType.isComplete()
2605-
assert not valueType.isVoid()
2605+
assert not valueType.isUndefined()
26062606

26072607
IDLParametrizedType.__init__(self, location, valueType.name, valueType)
26082608
self.keyType = keyType
@@ -2673,7 +2673,7 @@ def __hash__(self):
26732673
def prettyName(self):
26742674
return "(" + " or ".join(m.prettyName() for m in self.memberTypes) + ")"
26752675

2676-
def isVoid(self):
2676+
def isUndefined(self):
26772677
return False
26782678

26792679
def isUnion(self):
@@ -2836,8 +2836,8 @@ def isUTF8String(self):
28362836
def isJSString(self):
28372837
return self.inner.isJSString()
28382838

2839-
def isVoid(self):
2840-
return self.inner.isVoid()
2839+
def isUndefined(self):
2840+
return self.inner.isUndefined()
28412841

28422842
def isJSONType(self):
28432843
return self.inner.isJSONType()
@@ -2972,7 +2972,7 @@ def isUTF8String(self):
29722972
def isJSString(self):
29732973
return False
29742974

2975-
def isVoid(self):
2975+
def isUndefined(self):
29762976
return False
29772977

29782978
def isSequence(self):
@@ -3178,7 +3178,7 @@ class IDLBuiltinType(IDLType):
31783178
'utf8string',
31793179
'jsstring',
31803180
'object',
3181-
'void',
3181+
'undefined',
31823182
# Funny stuff
31833183
'ArrayBuffer',
31843184
'ArrayBufferView',
@@ -3215,7 +3215,7 @@ class IDLBuiltinType(IDLType):
32153215
Types.utf8string: IDLType.Tags.utf8string,
32163216
Types.jsstring: IDLType.Tags.jsstring,
32173217
Types.object: IDLType.Tags.object,
3218-
Types.void: IDLType.Tags.void,
3218+
Types.undefined: IDLType.Tags.undefined,
32193219
Types.ArrayBuffer: IDLType.Tags.interface,
32203220
Types.ArrayBufferView: IDLType.Tags.interface,
32213221
Types.Int8Array: IDLType.Tags.interface,
@@ -3251,7 +3251,7 @@ class IDLBuiltinType(IDLType):
32513251
Types.utf8string: "USVString", # That's what it is in spec terms
32523252
Types.jsstring: "USVString", # Again, that's what it is in spec terms
32533253
Types.object: "object",
3254-
Types.void: "void",
3254+
Types.undefined: "undefined",
32553255
Types.ArrayBuffer: "ArrayBuffer",
32563256
Types.ArrayBufferView: "ArrayBufferView",
32573257
Types.Int8Array: "Int8Array",
@@ -3456,8 +3456,8 @@ def isDistinguishableFrom(self, other):
34563456
return False
34573457
if self.isObject():
34583458
return other.isPrimitive() or other.isString() or other.isEnum()
3459-
if self.isVoid():
3460-
return not other.isVoid()
3459+
if self.isUndefined():
3460+
return not other.isUndefined()
34613461
# Not much else we could be!
34623462
assert self.isSpiderMonkeyInterface()
34633463
# Like interfaces, but we know we're not a callback
@@ -3591,9 +3591,9 @@ def withExtendedAttributes(self, attrs):
35913591
IDLBuiltinType.Types.object:
35923592
IDLBuiltinType(BuiltinLocation("<builtin type>"), "Object",
35933593
IDLBuiltinType.Types.object),
3594-
IDLBuiltinType.Types.void:
3595-
IDLBuiltinType(BuiltinLocation("<builtin type>"), "Void",
3596-
IDLBuiltinType.Types.void),
3594+
IDLBuiltinType.Types.undefined:
3595+
IDLBuiltinType(BuiltinLocation("<builtin type>"), "Undefined",
3596+
IDLBuiltinType.Types.undefined),
35973597
IDLBuiltinType.Types.ArrayBuffer:
35983598
IDLBuiltinType(BuiltinLocation("<builtin type>"), "ArrayBuffer",
35993599
IDLBuiltinType.Types.ArrayBuffer),
@@ -4196,9 +4196,9 @@ def expand(self, members, isJSImplemented):
41964196
self.addMethod("values", members, False, self.iteratorType,
41974197
affectsNothing=True, newObject=True)
41984198

4199-
# void forEach(callback(valueType, keyType), optional any thisArg)
4199+
# undefined forEach(callback(valueType, keyType), optional any thisArg)
42004200
self.addMethod("forEach", members, False,
4201-
BuiltinTypes[IDLBuiltinType.Types.void],
4201+
BuiltinTypes[IDLBuiltinType.Types.undefined],
42024202
self.getForEachArguments())
42034203

42044204
def isValueIterator(self):
@@ -4256,8 +4256,8 @@ def expand(self, members, isJSImplemented):
42564256
self.addMethod("values", members, False, BuiltinTypes[IDLBuiltinType.Types.object],
42574257
affectsNothing=True, isIteratorAlias=self.isSetlike())
42584258

4259-
# void forEach(callback(valueType, keyType), thisVal)
4260-
self.addMethod("forEach", members, False, BuiltinTypes[IDLBuiltinType.Types.void],
4259+
# undefined forEach(callback(valueType, keyType), thisVal)
4260+
self.addMethod("forEach", members, False, BuiltinTypes[IDLBuiltinType.Types.undefined],
42614261
self.getForEachArguments())
42624262

42634263
def getKeyArg():
@@ -4270,8 +4270,8 @@ def getKeyArg():
42704270
[getKeyArg()], isPure=True)
42714271

42724272
if not self.readonly:
4273-
# void clear()
4274-
self.addMethod("clear", members, True, BuiltinTypes[IDLBuiltinType.Types.void],
4273+
# undefined clear()
4274+
self.addMethod("clear", members, True, BuiltinTypes[IDLBuiltinType.Types.undefined],
42754275
[])
42764276
# boolean delete(keyType key)
42774277
self.addMethod("delete", members, True,
@@ -4280,8 +4280,8 @@ def getKeyArg():
42804280
# Always generate underscored functions (e.g. __add, __clear) for js
42814281
# implemented interfaces as convenience functions.
42824282
if isJSImplemented:
4283-
# void clear()
4284-
self.addMethod("clear", members, True, BuiltinTypes[IDLBuiltinType.Types.void],
4283+
# undefined clear()
4284+
self.addMethod("clear", members, True, BuiltinTypes[IDLBuiltinType.Types.undefined],
42854285
[], chromeOnly=True)
42864286
# boolean delete(keyType key)
42874287
self.addMethod("delete", members, True,
@@ -5119,7 +5119,7 @@ def assertSignatureConstraints(self):
51195119
assert (arguments[0].type == BuiltinTypes[IDLBuiltinType.Types.domstring] or
51205120
arguments[0].type == BuiltinTypes[IDLBuiltinType.Types.unsigned_long])
51215121
assert not arguments[0].optional and not arguments[0].variadic
5122-
assert not self._getter or not overload.returnType.isVoid()
5122+
assert not self._getter or not overload.returnType.isUndefined()
51235123

51245124
if self._setter:
51255125
assert len(self._overloads) == 1
@@ -5480,8 +5480,8 @@ def handleExtendedAttribute(self, attr):
54805480
# This is called before we've done overload resolution
54815481
overloads = self._overloads
54825482
assert len(overloads) == 1
5483-
if not overloads[0].returnType.isVoid():
5484-
raise WebIDLError("[LenientFloat] used on a non-void method",
5483+
if not overloads[0].returnType.isUndefined():
5484+
raise WebIDLError("[LenientFloat] used on a non-undefined returning method",
54855485
[attr.location, self.location])
54865486
if not overloads[0].includesRestrictedFloatArgument():
54875487
raise WebIDLError("[LenientFloat] used on an operation with no "
@@ -5837,7 +5837,7 @@ def t_OTHER(self, t):
58375837
"record": "RECORD",
58385838
"short": "SHORT",
58395839
"unsigned": "UNSIGNED",
5840-
"void": "VOID",
5840+
"undefined": "UNDEFINED",
58415841
":": "COLON",
58425842
";": "SEMICOLON",
58435843
"{": "LBRACE",
@@ -6722,8 +6722,8 @@ def p_Operation(self, p):
67226722
"optional" if arguments[0].optional else "variadic"),
67236723
[arguments[0].location])
67246724
if getter:
6725-
if returnType.isVoid():
6726-
raise WebIDLError("getter cannot have void return type",
6725+
if returnType.isUndefined():
6726+
raise WebIDLError("getter cannot have undefined return type",
67276727
[self.getLocation(p, 2)])
67286728
if setter:
67296729
if len(arguments) != 2:
@@ -7103,7 +7103,7 @@ def p_Other(self, p):
71037103
| SYMBOL
71047104
| TRUE
71057105
| UNSIGNED
7106-
| VOID
7106+
| UNDEFINED
71077107
| ArgumentNameKeyword
71087108
"""
71097109
pass
@@ -7145,7 +7145,7 @@ def p_SingleTypeAnyType(self, p):
71457145
"""
71467146
p[0] = BuiltinTypes[IDLBuiltinType.Types.any]
71477147

7148-
# Note: Promise<void> is allowed, so we want to parametrize on ReturnType,
7148+
# Note: Promise<undefined> is allowed, so we want to parametrize on ReturnType,
71497149
# not Type. Promise types can't be null, hence no "Null" in there.
71507150
def p_SingleTypePromiseType(self, p):
71517151
"""
@@ -7413,11 +7413,11 @@ def p_ReturnTypeType(self, p):
74137413
"""
74147414
p[0] = p[1]
74157415

7416-
def p_ReturnTypeVoid(self, p):
7416+
def p_ReturnTypeUndefined(self, p):
74177417
"""
7418-
ReturnType : VOID
7418+
ReturnType : UNDEFINED
74197419
"""
7420-
p[0] = BuiltinTypes[IDLBuiltinType.Types.void]
7420+
p[0] = BuiltinTypes[IDLBuiltinType.Types.undefined]
74217421

74227422
def p_ScopedName(self, p):
74237423
"""

components/script/dom/bindings/codegen/parser/tests/test_argument_identifier_conflicts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def WebIDLTest(parser, harness):
33
try:
44
parser.parse("""
55
interface ArgumentIdentifierConflict {
6-
void foo(boolean arg1, boolean arg1);
6+
undefined foo(boolean arg1, boolean arg1);
77
};
88
""")
99

components/script/dom/bindings/codegen/parser/tests/test_argument_keywords.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def WebIDLTest(parser, harness):
22
parser.parse("""
33
interface Foo {
4-
void foo(object constructor);
4+
undefined foo(object constructor);
55
};
66
""")
77

components/script/dom/bindings/codegen/parser/tests/test_argument_novoid.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ def WebIDLTest(parser, harness):
22
threw = False
33
try:
44
parser.parse("""
5-
interface VoidArgument1 {
6-
void foo(void arg2);
5+
interface UndefinedArgument1 {
6+
undefined foo(undefined arg2);
77
};
88
""")
99

0 commit comments

Comments
 (0)