aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-02-28 09:57:58 -0700
committerbors-servo <metajack+bors@gmail.com>2015-02-28 09:57:58 -0700
commit1f53d30f858a71206fce01116a3b1e5c199c1648 (patch)
tree613368d01b59d906d4e8cc5baef4574bdc4618e9 /components/script/dom/bindings/codegen
parentb261d27ac5fc5e8a858b344087792f9b1709ee55 (diff)
parentc81f1cc54134a3d542e3da08f00750955c986011 (diff)
downloadservo-1f53d30f858a71206fce01116a3b1e5c199c1648.tar.gz
servo-1f53d30f858a71206fce01116a3b1e5c199c1648.zip
auto merge of #5094 : chmanchester/servo/binarynames, r=jdm
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py39
-rw-r--r--components/script/dom/bindings/codegen/Configuration.py17
-rw-r--r--components/script/dom/bindings/codegen/parser/WebIDL.py6
3 files changed, 42 insertions, 20 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index d5216146aea..6ab32cf1053 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -68,13 +68,6 @@ def stripTrailingWhitespace(text):
return '\n'.join(lines) + tail
def MakeNativeName(name):
- # The gecko counterpart to this file uses the BinaryName machinery
- # for this purpose (#4435 is the servo issue for BinaryName).
- replacements = {
- "__stringifier": "Stringify",
- }
- if name in replacements:
- return replacements[name]
return name[0].upper() + name[1:]
builtinNames = {
@@ -2569,7 +2562,8 @@ class CGSpecializedMethod(CGAbstractExternMethod):
@staticmethod
def makeNativeName(descriptor, method):
- return MakeNativeName(method.identifier.name)
+ name = method.identifier.name
+ return MakeNativeName(descriptor.binaryNameFor(name))
class CGStaticMethod(CGAbstractStaticBindingMethod):
"""
@@ -2635,7 +2629,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
@staticmethod
def makeNativeName(descriptor, attr):
- nativeName = MakeNativeName(attr.identifier.name)
+ name = attr.identifier.name
+ nativeName = MakeNativeName(descriptor.binaryNameFor(name))
infallible = ('infallible' in
descriptor.getExtendedAttributes(attr, getter=True))
if attr.type.nullable() or not infallible:
@@ -2713,7 +2708,8 @@ class CGSpecializedSetter(CGAbstractExternMethod):
@staticmethod
def makeNativeName(descriptor, attr):
- return "Set" + MakeNativeName(attr.identifier.name)
+ name = attr.identifier.name
+ return "Set" + MakeNativeName(descriptor.binaryNameFor(name))
class CGStaticSetter(CGAbstractStaticBindingMethod):
@@ -3569,7 +3565,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
(don't use this directly, use the derived classes below).
"""
def __init__(self, descriptor, operation):
- nativeName = MakeNativeName(operation)
+ nativeName = MakeNativeName(descriptor.binaryNameFor(operation))
operation = descriptor.operations[operation]
assert len(operation.signatures()) == 1
signature = operation.signatures()[0]
@@ -3993,7 +3989,8 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
def getBody(self):
stringifier = self.descriptor.operations['Stringifier']
if stringifier:
- nativeName = MakeNativeName(stringifier.identifier.name)
+ name = self.descriptor.binaryNameFor(stringifier.identifier.name)
+ nativeName = MakeNativeName(name)
signature = stringifier.signatures()[0]
returnType = signature[0]
extendedAttributes = self.descriptor.getExtendedAttributes(stringifier)
@@ -4077,7 +4074,8 @@ class CGClassConstructHook(CGAbstractExternMethod):
let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
let global = global.root();
""")
- nativeName = MakeNativeName(self._ctor.identifier.name)
+ name = self._ctor.identifier.name
+ nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
callGenerator = CGMethodCall(["global.r()"], nativeName, True,
self.descriptor, self._ctor)
return CGList([preamble, callGenerator])
@@ -4848,11 +4846,15 @@ class CGCallback(CGClass):
return self._deps
# We're always fallible
-def callbackGetterName(attr):
- return "Get" + MakeNativeName(attr.identifier.name)
+def callbackGetterName(attr, descriptor):
+ return "Get" + MakeNativeName(
+ descriptor.binaryNameFor(attr.identifier.name))
+
+
+def callbackSetterName(attr, descriptor):
+ return "Set" + MakeNativeName(
+ descriptor.binaryNameFor(attr.identifier.name))
-def callbackSetterName(attr):
- return "Set" + MakeNativeName(attr.identifier.name)
class CGCallbackFunction(CGCallback):
def __init__(self, callback, descriptorProvider):
@@ -5179,7 +5181,8 @@ class CallbackOperation(CallbackOperationBase):
self.ensureASCIIName(method)
jsName = method.identifier.name
CallbackOperationBase.__init__(self, signature,
- jsName, MakeNativeName(jsName),
+ jsName,
+ MakeNativeName(descriptor.binaryNameFor(jsName)),
descriptor, descriptor.interface.isSingleOperationInterface())
class CallbackGetter(CallbackMember):
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py
index 8944070f09c..e6712357d35 100644
--- a/components/script/dom/bindings/codegen/Configuration.py
+++ b/components/script/dom/bindings/codegen/Configuration.py
@@ -251,6 +251,20 @@ class Descriptor(DescriptorProvider):
else:
add('all', [config], attribute)
+ self._binaryNames = desc.get('binaryNames', {})
+ self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
+ self._binaryNames.setdefault('__stringifier', 'Stringify')
+
+ for member in self.interface.members:
+ if not member.isAttr() and not member.isMethod():
+ continue
+ binaryName = member.getExtendedAttribute("BinaryName")
+ if binaryName:
+ assert isinstance(binaryName, list)
+ assert len(binaryName) == 1
+ self._binaryNames.setdefault(member.identifier.name,
+ binaryName[0])
+
# Build the prototype chain.
self.prototypeChain = []
parent = interface
@@ -260,6 +274,9 @@ class Descriptor(DescriptorProvider):
config.maxProtoChainLength = max(config.maxProtoChainLength,
len(self.prototypeChain))
+ def binaryNameFor(self, name):
+ return self._binaryNames.get(name, name)
+
def getExtendedAttributes(self, member, getter=False, setter=False):
def maybeAppendInfallibleToAttrs(attrs, throws):
if throws is None:
diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py
index 370ac7df7c0..7474f56baa2 100644
--- a/components/script/dom/bindings/codegen/parser/WebIDL.py
+++ b/components/script/dom/bindings/codegen/parser/WebIDL.py
@@ -3262,7 +3262,8 @@ class IDLAttribute(IDLInterfaceMember):
identifier == "Frozen" or
identifier == "AvailableIn" or
identifier == "NewObject" or
- identifier == "CheckPermissions"):
+ identifier == "CheckPermissions" or
+ identifier == "BinaryName"):
# Known attributes that we don't need to do anything with here
pass
else:
@@ -3861,7 +3862,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
identifier == "Pref" or
identifier == "Func" or
identifier == "AvailableIn" or
- identifier == "CheckPermissions"):
+ identifier == "CheckPermissions" or
+ identifier == "BinaryName"):
# Known attributes that we don't need to do anything with here
pass
else: