mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Introduce wrapInNativeContainerType.
This commit is contained in:
parent
9371889a03
commit
9a9ca45084
1 changed files with 12 additions and 3 deletions
|
@ -97,6 +97,15 @@ def innerContainerType(type):
|
||||||
return type.inner.inner if type.nullable() else type.inner
|
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 = {
|
builtinNames = {
|
||||||
IDLType.Tags.bool: 'bool',
|
IDLType.Tags.bool: 'bool',
|
||||||
IDLType.Tags.int8: 'i8',
|
IDLType.Tags.int8: 'i8',
|
||||||
|
@ -728,7 +737,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
|
innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
|
||||||
descriptorProvider,
|
descriptorProvider,
|
||||||
isMember=isMember)
|
isMember=isMember)
|
||||||
declType = CGWrapper(innerInfo.declType, pre="Vec<", post=">")
|
declType = wrapInNativeContainerType(type, innerInfo.declType)
|
||||||
config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs)
|
config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs)
|
||||||
|
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
|
@ -1352,7 +1361,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
|
||||||
return result
|
return result
|
||||||
if returnType.isSequence():
|
if returnType.isSequence():
|
||||||
result = getRetvalDeclarationForType(innerContainerType(returnType), descriptorProvider)
|
result = getRetvalDeclarationForType(innerContainerType(returnType), descriptorProvider)
|
||||||
result = CGWrapper(result, pre="Vec<", post=">")
|
result = wrapInNativeContainerType(returnType, result)
|
||||||
if returnType.nullable():
|
if returnType.nullable():
|
||||||
result = CGWrapper(result, pre="Option<", post=">")
|
result = CGWrapper(result, pre="Option<", post=">")
|
||||||
return result
|
return result
|
||||||
|
@ -3998,7 +4007,7 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
|
||||||
elif type.isSequence():
|
elif type.isSequence():
|
||||||
name = type.name
|
name = type.name
|
||||||
inner = getUnionTypeTemplateVars(innerContainerType(type), descriptorProvider)
|
inner = getUnionTypeTemplateVars(innerContainerType(type), descriptorProvider)
|
||||||
typeName = "Vec<" + inner["typeName"] + ">"
|
typeName = wrapInNativeContainerType(type, CGGeneric(inner["typeName"])).define()
|
||||||
elif type.isByteString():
|
elif type.isByteString():
|
||||||
name = type.name
|
name = type.name
|
||||||
typeName = "ByteString"
|
typeName = "ByteString"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue