From 950821989f57933a1b83623e1a2aea3dccd6c52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 15 Jan 2016 14:17:31 +0100 Subject: [PATCH] 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). --- components/script/dom/bindings/codegen/CodegenRust.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 643c396febc..84d80124df9 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -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"