author | Boris Zbarsky <bzbarsky@mit.edu> |
Mon, 05 Nov 2012 11:58:02 -0500 | |
changeset 112317 | 0b02a816de33c0ddec3f4104a93904df6a8d567a |
parent 112316 | 004a0714ba52dad0c7e0d82fd4b8f1f77d375f76 |
child 112318 | 024d12cc40095f471f94c516055aa281129a6a08 |
push id | 23812 |
push user | emorley@mozilla.com |
push date | Tue, 06 Nov 2012 14:01:34 +0000 |
treeherder | mozilla-central@f4aeed115e54 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | khuey |
bugs | 749866 |
milestone | 19.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2020,18 +2020,21 @@ def getJSToNativeConversionTemplate(type assert not (isEnforceRange and isClamp) # These are mutually exclusive if type.isArray(): raise TypeError("Can't handle array arguments yet") if type.isSequence(): assert not isEnforceRange and not isClamp - if failureCode is not None: - raise TypeError("Can't handle sequences when failureCode is not None") + if failureCode is None: + notSequence = "return ThrowErrorMessage(cx, MSG_NOT_SEQUENCE);" + else: + notSequence = failureCode + nullable = type.nullable(); # Be very careful not to change "type": we need it later if nullable: elementType = type.inner.inner else: elementType = type.inner # We have to be careful with reallocation behavior for arrays. In @@ -2066,34 +2069,35 @@ def getJSToNativeConversionTemplate(type arrayRef = "${declName}" # If we're optional, the const will come from the Optional mutableTypeName = typeName if not isOptional: typeName = CGWrapper(typeName, pre="const ") templateBody = ("""JSObject* seq = &${val}.toObject();\n if (!IsArrayLike(cx, seq)) { - return ThrowErrorMessage(cx, MSG_NOT_SEQUENCE); +%s } uint32_t length; // JS_GetArrayLength actually works on all objects if (!JS_GetArrayLength(cx, seq, &length)) { return false; } Sequence< %s > &arr = const_cast< Sequence< %s >& >(%s); if (!arr.SetCapacity(length)) { JS_ReportOutOfMemory(cx); return false; } for (uint32_t i = 0; i < length; ++i) { jsval temp; if (!JS_GetElement(cx, seq, i, &temp)) { return false; } -""" % (elementDeclType.define(), +""" % (CGIndenter(CGGeneric(notSequence)).define(), + elementDeclType.define(), elementDeclType.define(), arrayRef)) templateBody += CGIndenter(CGGeneric( string.Template(elementTemplate).substitute( { "val" : "temp", "valPtr": "&temp",