diff options
author | Chris Manchester <cmanchester@mozilla.com> | 2015-02-25 17:06:29 -0800 |
---|---|---|
committer | Chris Manchester <cmanchester@mozilla.com> | 2015-02-27 18:28:01 -0800 |
commit | c81f1cc54134a3d542e3da08f00750955c986011 (patch) | |
tree | cab716cb4fe202e444183e07d30e93e46ff7c8ca /components/script/dom/bindings/codegen/CodegenRust.py | |
parent | 26567ef2e62597b359c179f8665213002e05da96 (diff) | |
download | servo-c81f1cc54134a3d542e3da08f00750955c986011.tar.gz servo-c81f1cc54134a3d542e3da08f00750955c986011.zip |
Add support for BinaryName attribute to servo's codegen (fixes #4435) r=jdm
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 3ac47486fe0..db45daea970 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): |