mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
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:
parent
8859c617a8
commit
950821989f
1 changed files with 5 additions and 2 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue