Bug 1050340 - Handle object and array. r=luke

This commit is contained in:
Bobby Holley 2014-08-18 14:18:39 -07:00
parent f69cb3da4a
commit 5e44b4c25a
3 changed files with 8 additions and 5 deletions

View File

@ -518,9 +518,9 @@ Valueify(const JSClass *c)
* value of objects.
*/
enum ESClassValue {
ESClass_Array, ESClass_Number, ESClass_String, ESClass_Boolean,
ESClass_RegExp, ESClass_ArrayBuffer, ESClass_Date, ESClass_Set,
ESClass_Map
ESClass_Object, ESClass_Array, ESClass_Number, ESClass_String,
ESClass_Boolean, ESClass_RegExp, ESClass_ArrayBuffer, ESClass_Date,
ESClass_Set, ESClass_Map
};
/*

View File

@ -1026,6 +1026,7 @@ ObjectClassIs(HandleObject obj, ESClassValue classValue, JSContext *cx)
return Proxy::objectClassIs(obj, classValue, cx);
switch (classValue) {
case ESClass_Object: return obj->is<JSObject>();
case ESClass_Array: return obj->is<ArrayObject>();
case ESClass_Number: return obj->is<NumberObject>();
case ESClass_String: return obj->is<StringObject>();

View File

@ -930,7 +930,7 @@ JSStructuredCloneWriter::traverseObject(HandleObject obj)
checkStack();
/* Write the header for obj. */
return out.writePair(obj->is<ArrayObject>() ? SCTAG_ARRAY_OBJECT : SCTAG_OBJECT_OBJECT, 0);
return out.writePair(ObjectClassIs(obj, ESClass_Array, context()) ? SCTAG_ARRAY_OBJECT : SCTAG_OBJECT_OBJECT, 0);
}
bool
@ -1042,7 +1042,9 @@ JSStructuredCloneWriter::startWrite(HandleValue v)
return writeTypedArray(obj);
} else if (JS_IsArrayBufferObject(obj) && JS_ArrayBufferHasData(obj)) {
return writeArrayBuffer(obj);
} else if (obj->is<JSObject>() || obj->is<ArrayObject>()) {
} else if (ObjectClassIs(obj, ESClass_Object, context())) {
return traverseObject(obj);
} else if (ObjectClassIs(obj, ESClass_Array, context())) {
return traverseObject(obj);
} else if (ObjectClassIs(obj, ESClass_Boolean, context())) {
RootedValue unboxed(context());