diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-06-22 14:09:28 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-06-22 15:10:56 +0200 |
commit | 92f9fe59e5a60c99a6852a7c7da32e37eb384898 (patch) | |
tree | 2cd131b1915acc6042b0f3a8a56776766b51d1f6 /src/components/script/dom/bindings/codegen | |
parent | 927ae398170a9ab0e7692901a84100f6e580bb36 (diff) | |
download | servo-92f9fe59e5a60c99a6852a7c7da32e37eb384898.tar.gz servo-92f9fe59e5a60c99a6852a7c7da32e37eb384898.zip |
Introduce static makeNativeName methods to share code with the upcoming static members.
Diffstat (limited to 'src/components/script/dom/bindings/codegen')
-rw-r--r-- | src/components/script/dom/bindings/codegen/CodegenRust.py | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 69bf5c87335..8776b32d4a8 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -2396,12 +2396,17 @@ class CGSpecializedMethod(CGAbstractExternMethod): CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args) def definition_body(self): - name = self.method.identifier.name - return CGWrapper(CGMethodCall([], MakeNativeName(name), self.method.isStatic(), + nativeName = CGSpecializedMethod.makeNativeName(self.descriptor, + self.method) + return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(), self.descriptor, self.method), pre="let this = JS::from_raw(this);\n" "let mut this = this.root();\n") + @staticmethod + def makeNativeName(descriptor, method): + return MakeNativeName(method.identifier.name) + class CGGenericGetter(CGAbstractBindingMethod): """ A class for generating the C++ code for an IDL attribute getter. @@ -2441,18 +2446,25 @@ class CGSpecializedGetter(CGAbstractExternMethod): CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args) def definition_body(self): - name = self.attr.identifier.name - nativeName = MakeNativeName(name) - infallible = ('infallible' in - self.descriptor.getExtendedAttributes(self.attr, - getter=True)) - if self.attr.type.nullable() or not infallible: - nativeName = "Get" + nativeName + nativeName = CGSpecializedGetter.makeNativeName(self.descriptor, + self.attr) + return CGWrapper(CGGetterCall([], self.attr.type, nativeName, self.descriptor, self.attr), pre="let this = JS::from_raw(this);\n" "let mut this = this.root();\n") + @staticmethod + def makeNativeName(descriptor, attr): + nativeName = MakeNativeName(attr.identifier.name) + infallible = ('infallible' in + descriptor.getExtendedAttributes(attr, getter=True)) + if attr.type.nullable() or not infallible: + return "Get" + nativeName + + return nativeName + + class CGGenericSetter(CGAbstractBindingMethod): """ A class for generating the Rust code for an IDL attribute setter. @@ -2497,13 +2509,16 @@ class CGSpecializedSetter(CGAbstractExternMethod): CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args) def definition_body(self): - name = self.attr.identifier.name - return CGWrapper(CGSetterCall([], self.attr.type, - "Set" + MakeNativeName(name), + nativeName = CGSpecializedSetter.makeNativeName(self.descriptor, + self.attr) + return CGWrapper(CGSetterCall([], self.attr.type, nativeName, self.descriptor, self.attr), pre="let this = JS::from_raw(this);\n" "let mut this = this.root();\n") + @staticmethod + def makeNativeName(descriptor, attr): + return "Set" + MakeNativeName(attr.identifier.name) class CGMemberJITInfo(CGThing): """ |