Bug 742153 part 4. Allow strings inside sequences and dictionaries. r=peterv

This commit is contained in:
Boris Zbarsky 2012-06-12 10:22:05 -04:00
Родитель 6c6503abf1
Коммит cf8f8a0d31
3 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -1456,6 +1456,7 @@ for (uint32_t i = 0; i < length; ++i) {
string.Template(elementTemplate).substitute(
{
"val" : "temp",
"valPtr": "&temp",
"declName" : "(*arr.AppendElement())"
}
))).define()
@ -1629,9 +1630,6 @@ for (uint32_t i = 0; i < length; ++i) {
return (template, CGGeneric(declType), holderType, False)
if type.isString():
if isMember:
raise TypeError("Can't handle member strings; need to sort out "
"rooting issues")
# XXXbz Need to figure out string behavior based on extended args? Also, how to
# detect them?
@ -1644,6 +1642,22 @@ for (uint32_t i = 0; i < length; ++i) {
nullBehavior = "eStringify"
undefinedBehavior = "eStringify"
if isMember:
# We have to make a copy, because our jsval may well not
# live as long as our string needs to.
declType = CGGeneric("nsString")
return (
"{\n"
" nsDependentString str;\n"
" if (!ConvertJSValueToString(cx, ${val}, ${valPtr}, %s, %s, str)) {\n"
" return false;\n"
" }\n"
" ${declName} = str;\n"
"}\n" %
(nullBehavior, undefinedBehavior),
declType, None,
isOptional)
if isOptional:
declType = "Optional<nsAString>"
else:

Просмотреть файл

@ -233,6 +233,9 @@ public:
void PassOptionalObjectSequence(const Optional<Sequence<OwningNonNull<TestInterface> > >&,
ErrorResult&);
void ReceiveStringSequence(nsTArray<nsString>&, ErrorResult&);
void PassStringSequence(const Sequence<nsString>&, ErrorResult&);
// Typed array types
void PassArrayBuffer(ArrayBuffer&, ErrorResult&);
void PassNullableArrayBuffer(ArrayBuffer*, ErrorResult&);

Просмотреть файл

@ -163,6 +163,9 @@ interface TestInterface {
void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
void passOptionalObjectSequence(optional sequence<TestInterface> arg);
sequence<DOMString> receiveStringSequence();
void passStringSequence(sequence<DOMString> arg);
// Typed array types
void passArrayBuffer(ArrayBuffer arg);
void passNullableArrayBuffer(ArrayBuffer? arg);
@ -279,6 +282,7 @@ dictionary Dict : ParentDict {
long a;
long b = 8;
long z = 9;
DOMString str;
};
dictionary ParentDict : GrandparentDict {