webidl: Refactor isSequence in getJSToNativeConversionInfo

That way it does not depend on the return value for the same type.

This hopefully makes the code more clear, and avoids errors if something
changes in the future (for example, we could want to pass slices as
sequence arguments).
This commit is contained in:
Emilio Cobos Álvarez 2016-01-15 14:17:31 +01:00
parent 8859c617a8
commit 950821989f

View file

@ -700,10 +700,13 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
raise TypeError("Can't handle array arguments yet")
if type.isSequence():
# Use the same type that for return values
declType = getRetvalDeclarationForType(type, descriptorProvider)
innerInfo = getJSToNativeConversionInfo(type.unroll(), descriptorProvider)
declType = CGWrapper(innerInfo.declType, pre="Vec<", post=">")
config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs)
if type.nullable():
declType = CGWrapper(declType, pre="Option<", post=" >")
templateBody = ("match FromJSValConvertible::from_jsval(cx, ${val}, %s) {\n"
" Ok(value) => value,\n"
" Err(()) => { %s },\n"