diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-09-21 15:14:48 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-09-21 16:13:42 +0200 |
commit | b40966981ca80603c7ffed2c690ced2abaa8498a (patch) | |
tree | 3cc2bf834a8076935a813333947ae0fe6b417de0 /components/script/dom/bindings/codegen/CodegenRust.py | |
parent | e7748216dfb315a286491d2635f6f20ac6842ff8 (diff) | |
download | servo-b40966981ca80603c7ffed2c690ced2abaa8498a.tar.gz servo-b40966981ca80603c7ffed2c690ced2abaa8498a.zip |
Share code to compute the type of a union.
This does not change the generated code.
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index e16a8664e82..3b02e2a0700 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -422,6 +422,12 @@ def typeIsSequenceOrHasSequenceMember(type): def typeNeedsRooting(type, descriptorProvider): return type.isGeckoInterface() and descriptorProvider.getDescriptor(type.name).needsRooting + +def union_native_type(t): + name = t.unroll().name + return '%s::%s' % (name, name) + + def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, isDefinitelyObject=False, isMember=False, @@ -576,7 +582,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, raise TypeError("Can't handle sequence arguments yet") if type.isUnion(): - declType = CGGeneric(type.name + "::" + type.name) + declType = CGGeneric(union_native_type(type)) if type.nullable(): declType = CGWrapper(declType, pre="Option<", post=" >") @@ -1075,7 +1081,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider): result = CGWrapper(result, pre="Option<", post=">") return result if returnType.isUnion(): - result = CGGeneric('%s::%s' % (returnType.unroll().name, returnType.unroll().name)) + result = CGGeneric(union_native_type(returnType)) if returnType.nullable(): result = CGWrapper(result, pre="Option<", post=">") return result @@ -4751,9 +4757,7 @@ class CGNativeMember(ClassMethod): return decl.define(), True, True if type.isUnion(): - if type.nullable(): - type = type.inner - return str(type) + "::" + str(type), False, True + return union_native_type(type), False, True if type.isGeckoInterface() and not type.isCallbackInterface(): iface = type.unroll().inner |