Add support for undefined default values for 'any'.

This also updates TestBinding to take into account the automatic default
for optional 'any' arguments and dictionary members.
This commit is contained in:
Ms2ger 2014-06-07 17:38:35 +02:00
parent 4786c30bce
commit ef0ccd3e15
2 changed files with 13 additions and 3 deletions

View file

@ -518,7 +518,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
if not isinstance(defaultValue, IDLNullValue):
raise TypeError("Can't handle non-null default value here")
assert type.nullable() or type.isAny() or type.isDictionary()
assert type.nullable() or type.isDictionary()
return nullValue
# A helper function for wrapping up the template body for
@ -752,7 +752,17 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
assert not isEnforceRange and not isClamp
declType = CGGeneric("JSVal")
return handleOptional("${val}", declType, handleDefaultNull("NullValue()"))
if defaultValue is None:
default = None
elif isinstance(defaultValue, IDLNullValue):
default = "NullValue()"
elif isinstance(defaultValue, IDLUndefinedValue):
default = "UndefinedValue()"
else:
raise TypeError("Can't handle non-null, non-undefined default value here")
return handleOptional("${val}", declType, default)
if type.isObject():
raise TypeError("Can't handle object arguments yet")