aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-09-21 13:53:16 +0200
committerMs2ger <Ms2ger@gmail.com>2016-09-21 14:03:33 +0200
commit9a9ca450846457613a96c4364d16d0630320d3d5 (patch)
tree8a67da4919a620bf8a1144cafe5fec29a0d0cc3a /components/script/dom
parent9371889a03f9d181405fa2aa68e7cc57c1640aa0 (diff)
downloadservo-9a9ca450846457613a96c4364d16d0630320d3d5.tar.gz
servo-9a9ca450846457613a96c4364d16d0630320d3d5.zip
Introduce wrapInNativeContainerType.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 5efdf40b60a..654714ec204 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -97,6 +97,15 @@ def innerContainerType(type):
return type.inner.inner if type.nullable() else type.inner
+def wrapInNativeContainerType(type, inner):
+ if type.isSequence():
+ containerType = "Vec"
+ else:
+ raise TypeError("Unexpected container type %s", type)
+
+ return CGWrapper(inner, pre=containerType + "<", post=">")
+
+
builtinNames = {
IDLType.Tags.bool: 'bool',
IDLType.Tags.int8: 'i8',
@@ -728,7 +737,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
descriptorProvider,
isMember=isMember)
- declType = CGWrapper(innerInfo.declType, pre="Vec<", post=">")
+ declType = wrapInNativeContainerType(type, innerInfo.declType)
config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs)
if type.nullable():
@@ -1352,7 +1361,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
return result
if returnType.isSequence():
result = getRetvalDeclarationForType(innerContainerType(returnType), descriptorProvider)
- result = CGWrapper(result, pre="Vec<", post=">")
+ result = wrapInNativeContainerType(returnType, result)
if returnType.nullable():
result = CGWrapper(result, pre="Option<", post=">")
return result
@@ -3998,7 +4007,7 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
elif type.isSequence():
name = type.name
inner = getUnionTypeTemplateVars(innerContainerType(type), descriptorProvider)
- typeName = "Vec<" + inner["typeName"] + ">"
+ typeName = wrapInNativeContainerType(type, CGGeneric(inner["typeName"])).define()
elif type.isByteString():
name = type.name
typeName = "ByteString"