mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
Support static and instance members having the same name in IDLs (#36523)
This is needed to implement features like `Response.json` which is a static helper added to the fetch spec which overlaps with the `json` instance method `Response` has from `Body`. Partly based these changes on what Firefox does for this same issue. (https://searchfox.org/mozilla-central/source/dom/bindings/Codegen.py and https://searchfox.org/mozilla-central/source/dom/bindings/Configuration.py specifically keying `binaryNameFor` on name and `isStatic`). Testing: I locally updated the Response.webidl to contain the new static `json` and it compiles. Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This commit is contained in:
parent
f2ee40e40b
commit
a1b9949f75
2 changed files with 35 additions and 21 deletions
|
@ -353,8 +353,8 @@ class Descriptor(DescriptorProvider):
|
|||
add('all', [config], attribute)
|
||||
|
||||
self._binaryNames = desc.get('binaryNames', {})
|
||||
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
||||
self._binaryNames.setdefault('__stringifier', 'Stringifier')
|
||||
self._binaryNames.setdefault(('__legacycaller', False), 'LegacyCall')
|
||||
self._binaryNames.setdefault(('__stringifier', False), 'Stringifier')
|
||||
|
||||
self._internalNames = desc.get('internalNames', {})
|
||||
|
||||
|
@ -365,7 +365,7 @@ class Descriptor(DescriptorProvider):
|
|||
if binaryName:
|
||||
assert isinstance(binaryName, list)
|
||||
assert len(binaryName) == 1
|
||||
self._binaryNames.setdefault(member.identifier.name,
|
||||
self._binaryNames.setdefault((member.identifier.name, member.isStatic()),
|
||||
binaryName[0])
|
||||
self._internalNames.setdefault(member.identifier.name,
|
||||
member.identifier.name.replace('-', '_'))
|
||||
|
@ -391,8 +391,8 @@ class Descriptor(DescriptorProvider):
|
|||
return filename
|
||||
return None
|
||||
|
||||
def binaryNameFor(self, name):
|
||||
return self._binaryNames.get(name, name)
|
||||
def binaryNameFor(self, name, isStatic):
|
||||
return self._binaryNames.get((name, isStatic), name)
|
||||
|
||||
def internalNameFor(self, name):
|
||||
return self._internalNames.get(name, name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue