зеркало из https://github.com/mozilla/pjs.git
Bug 683361 - Fix part 6: add and call Proxy::objectClassIs (r=waldo)
--HG-- extra : rebase_source : b387bc288a45fc985df06ce2ca84823cf45803b3
This commit is contained in:
Родитель
8f538d497b
Коммит
7852c745c4
|
@ -13,3 +13,13 @@ assertEq(JSON.stringify({2:'ponies', unicorns:'not real'}, array), "{\"2\":\"pon
|
|||
assertEq(JSON.stringify({42:true, ponies:true, unicorns:'sad'}, [number, string]), "{\"42\":true,\"ponies\":true}");
|
||||
assertEq(JSON.stringify({a:true,b:false}, undefined, number), "{\n \"a\": true,\n \"b\": false\n}");
|
||||
assertEq(JSON.stringify({a:true,b:false}, undefined, string), "{\nponies\"a\": true,\nponies\"b\": false\n}");
|
||||
|
||||
var o = Proxy.create({getPropertyDescriptor:function(name) {}}, Object.prototype);
|
||||
var threw = false;
|
||||
try {
|
||||
print([].concat(o).toString());
|
||||
} catch(e) {
|
||||
assertEq(e instanceof TypeError, true);
|
||||
threw = true;
|
||||
}
|
||||
assertEq(threw, true);
|
||||
|
|
|
@ -1753,7 +1753,7 @@ inline bool
|
|||
ObjectClassIs(JSObject &obj, ESClassValue classValue, JSContext *cx)
|
||||
{
|
||||
if (JS_UNLIKELY(obj.isProxy()))
|
||||
return obj.getProxyHandler()->classPropertyIs(cx, &obj, classValue);
|
||||
return Proxy::objectClassIs(&obj, classValue, cx);
|
||||
|
||||
switch (classValue) {
|
||||
case ESClass_Array: return obj.isArray();
|
||||
|
|
|
@ -314,7 +314,7 @@ ProxyHandler::typeOf(JSContext *cx, JSObject *proxy)
|
|||
}
|
||||
|
||||
bool
|
||||
ProxyHandler::classPropertyIs(JSContext *cx, JSObject *proxy, ESClassValue classValue)
|
||||
ProxyHandler::objectClassIs(JSObject *proxy, ESClassValue classValue, JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(OperationInProgress(cx, proxy));
|
||||
return false;
|
||||
|
@ -874,6 +874,14 @@ Proxy::typeOf(JSContext *cx, JSObject *proxy)
|
|||
return proxy->getProxyHandler()->typeOf(cx, proxy);
|
||||
}
|
||||
|
||||
bool
|
||||
Proxy::objectClassIs(JSObject *proxy, ESClassValue classValue, JSContext *cx)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, JS_NOT_REACHED("cannot reenter"));
|
||||
AutoPendingProxyOperation pending(cx, proxy);
|
||||
return proxy->getProxyHandler()->objectClassIs(proxy, classValue, cx);
|
||||
}
|
||||
|
||||
JSString *
|
||||
Proxy::obj_toString(JSContext *cx, JSObject *proxy)
|
||||
{
|
||||
|
|
|
@ -82,7 +82,7 @@ class JS_FRIEND_API(ProxyHandler) {
|
|||
virtual bool nativeCall(JSContext *cx, JSObject *proxy, Class *clasp, Native native, CallArgs args);
|
||||
virtual bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp);
|
||||
virtual JSType typeOf(JSContext *cx, JSObject *proxy);
|
||||
virtual bool classPropertyIs(JSContext *cx, JSObject *obj, ESClassValue classValue);
|
||||
virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx);
|
||||
virtual JSString *obj_toString(JSContext *cx, JSObject *proxy);
|
||||
virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, uintN indent);
|
||||
virtual bool defaultValue(JSContext *cx, JSObject *obj, JSType hint, Value *vp);
|
||||
|
@ -131,6 +131,7 @@ class Proxy {
|
|||
static bool nativeCall(JSContext *cx, JSObject *proxy, Class *clasp, Native native, CallArgs args);
|
||||
static bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp);
|
||||
static JSType typeOf(JSContext *cx, JSObject *proxy);
|
||||
static bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx);
|
||||
static JSString *obj_toString(JSContext *cx, JSObject *proxy);
|
||||
static JSString *fun_toString(JSContext *cx, JSObject *proxy, uintN indent);
|
||||
static bool defaultValue(JSContext *cx, JSObject *obj, JSType hint, Value *vp);
|
||||
|
|
|
@ -292,7 +292,7 @@ Wrapper::typeOf(JSContext *cx, JSObject *wrapper)
|
|||
}
|
||||
|
||||
bool
|
||||
Wrapper::classPropertyIs(JSContext *cx, JSObject *wrapper, ESClassValue classValue)
|
||||
Wrapper::objectClassIs(JSObject *wrapper, ESClassValue classValue, JSContext *cx)
|
||||
{
|
||||
return ObjectClassIs(*wrappedObject(wrapper), classValue, cx);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class JS_FRIEND_API(Wrapper) : public ProxyHandler
|
|||
virtual bool nativeCall(JSContext *cx, JSObject *wrapper, Class *clasp, Native native, CallArgs args);
|
||||
virtual bool hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp);
|
||||
virtual JSType typeOf(JSContext *cx, JSObject *proxy);
|
||||
virtual bool classPropertyIs(JSContext *cx, JSObject *obj, ESClassValue classValue);
|
||||
virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx);
|
||||
virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper);
|
||||
virtual JSString *fun_toString(JSContext *cx, JSObject *wrapper, uintN indent);
|
||||
virtual bool defaultValue(JSContext *cx, JSObject *wrapper, JSType hint, Value *vp);
|
||||
|
|
Загрузка…
Ссылка в новой задаче