Bug 812742. Fix sequence codegen to not do AppendElement multiple times by accident. r=peterv

This commit is contained in:
Boris Zbarsky 2012-11-27 15:20:40 -05:00
parent 4200c25df7
commit 6451b2a018
4 changed files with 17 additions and 3 deletions

View File

@ -2202,20 +2202,26 @@ for (uint32_t i = 0; i < length; ++i) {
if (!JS_GetElement(cx, seq, i, &temp)) {
%s
}
%s& slot = *arr.AppendElement();
""" % (CGIndenter(CGGeneric(notSequence)).define(),
exceptionCodeIndented.define(),
elementDeclType.define(),
elementDeclType.define(),
arrayRef,
exceptionCodeIndented.define(),
CGIndenter(exceptionCodeIndented).define()))
CGIndenter(exceptionCodeIndented).define(),
elementDeclType.define()))
templateBody += CGIndenter(CGGeneric(
string.Template(elementTemplate).substitute(
{
"val" : "temp",
"valPtr": "&temp",
"declName" : "(*arr.AppendElement())",
"declName" : "slot",
# We only need holderName here to handle isExternal()
# interfaces, which use an internal holder for the
# conversion even when forceOwningType ends up true.
"holderName": "tempHolder",
# Use the same ${obj} as for the sequence itself
"obj": "${obj}"
}
@ -2533,7 +2539,7 @@ for (uint32_t i = 0; i < length; ++i) {
templateBody += ("}\n"
"MOZ_ASSERT(tmp);\n")
if not isDefinitelyObject:
if not isDefinitelyObject and not forceOwningType:
# Our tmpVal will go out of scope, so we can't rely on it
# for rooting
templateBody += (

View File

@ -310,6 +310,8 @@ public:
void PassOptionalNullableSequence(const Optional<Nullable<Sequence<int32_t> > >&);
void PassOptionalNullableSequenceWithDefaultValue(const Nullable< Sequence<int32_t> >&);
void PassOptionalObjectSequence(const Optional<Sequence<OwningNonNull<TestInterface> > >&);
void PassExternalInterfaceSequence(const Sequence<nsRefPtr<TestExternalInterface> >&);
void PassNullableExternalInterfaceSequence(const Sequence<nsRefPtr<TestExternalInterface> >&);
void ReceiveStringSequence(nsTArray<nsString>&);
void PassStringSequence(const Sequence<nsString>&);

View File

@ -265,6 +265,8 @@ interface TestInterface {
void passOptionalNullableSequence(optional sequence<long>? arg);
void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
void passOptionalObjectSequence(optional sequence<TestInterface> arg);
void passExternalInterfaceSequence(sequence<TestExternalInterface> arg);
void passNullableExternalInterfaceSequence(sequence<TestExternalInterface?> arg);
sequence<DOMString> receiveStringSequence();
void passStringSequence(sequence<DOMString> arg);

View File

@ -186,6 +186,8 @@ interface TestExampleInterface {
void passOptionalNullableSequence(optional sequence<long>? arg);
void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
void passOptionalObjectSequence(optional sequence<TestInterface> arg);
void passExternalInterfaceSequence(sequence<TestExternalInterface> arg);
void passNullableExternalInterfaceSequence(sequence<TestExternalInterface?> arg);
sequence<DOMString> receiveStringSequence();
void passStringSequence(sequence<DOMString> arg);
@ -284,6 +286,7 @@ interface TestExampleInterface {
attribute byte attributeRenamedFrom;
void passDictionary(optional Dict x);
//UNSUPPORTED Dict receiveDictionary();
void passOtherDictionary(optional GrandparentDict x);
void passSequenceOfDictionaries(sequence<Dict> x);
void passDictionaryOrLong(optional Dict x);
@ -291,6 +294,7 @@ interface TestExampleInterface {
void passDictContainingDict(optional DictContainingDict arg);
void passDictContainingSequence(optional DictContainingSequence arg);
//UNSUPPORTED DictContainingSequence receiveDictContainingSequence();
// EnforceRange/Clamp tests
void dontEnforceRangeOrClamp(byte arg);