mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-03 04:52:54 +00:00
Bug 1050340 - Handle object and array. r=luke
This commit is contained in:
parent
f69cb3da4a
commit
5e44b4c25a
@ -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
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -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>();
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user