зеркало из https://github.com/mozilla/gecko-dev.git
Bug 695756 - Implement js::BooleanObject. r=nnethercote.
This commit is contained in:
Родитель
d213388e95
Коммит
c3b75b03ac
|
@ -54,6 +54,7 @@
|
|||
#include "jsobj.h"
|
||||
#include "jsstr.h"
|
||||
|
||||
#include "vm/BooleanObject-inl.h"
|
||||
#include "vm/GlobalObject.h"
|
||||
|
||||
#include "jsinferinlines.h"
|
||||
|
@ -134,17 +135,15 @@ static JSFunctionSpec boolean_methods[] = {
|
|||
static JSBool
|
||||
Boolean(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
Value *argv = vp + 2;
|
||||
bool b = argc != 0 ? js_ValueToBoolean(argv[0]) : false;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
bool b = args.length() != 0 ? js_ValueToBoolean(args[0]) : false;
|
||||
|
||||
if (IsConstructing(vp)) {
|
||||
JSObject *obj = NewBuiltinClassInstance(cx, &BooleanClass);
|
||||
if (!obj)
|
||||
return false;
|
||||
obj->setPrimitiveThis(BooleanValue(b));
|
||||
vp->setObject(*obj);
|
||||
JSObject *obj = BooleanObject::create(cx, b);
|
||||
args.rval().setObject(*obj);
|
||||
} else {
|
||||
vp->setBoolean(b);
|
||||
args.rval().setBoolean(b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -205,14 +204,14 @@ BooleanGetPrimitiveValueSlow(JSContext *cx, JSObject &obj, Value *vp)
|
|||
* its [[Class]] is "Boolean". Boolean.prototype.valueOf is specified to
|
||||
* return the [[PrimitiveValue]] internal property, so call that instead.
|
||||
*/
|
||||
InvokeArgsGuard args;
|
||||
if (!cx->stack.pushInvokeArgs(cx, 0, &args))
|
||||
InvokeArgsGuard ag;
|
||||
if (!cx->stack.pushInvokeArgs(cx, 0, &ag))
|
||||
return false;
|
||||
args.calleev().setUndefined();
|
||||
args.thisv().setObject(obj);
|
||||
if (!GetProxyHandler(&obj)->nativeCall(cx, &obj, &BooleanClass, bool_valueOf, args))
|
||||
ag.calleev().setUndefined();
|
||||
ag.thisv().setObject(obj);
|
||||
if (!GetProxyHandler(&obj)->nativeCall(cx, &obj, &BooleanClass, bool_valueOf, ag))
|
||||
return false;
|
||||
*vp = args.rval();
|
||||
*vp = ag.rval();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
#include "jsscriptinlines.h"
|
||||
#include "jsobjinlines.h"
|
||||
|
||||
#include "vm/BooleanObject-inl.h"
|
||||
#include "vm/NumberObject-inl.h"
|
||||
#include "vm/StringObject-inl.h"
|
||||
|
||||
|
@ -6783,12 +6784,7 @@ PrimitiveToObject(JSContext *cx, const Value &v)
|
|||
return NumberObject::create(cx, v.toNumber());
|
||||
|
||||
JS_ASSERT(v.isBoolean());
|
||||
JSObject *obj = NewBuiltinClassInstance(cx, &BooleanClass);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
obj->setPrimitiveThis(v);
|
||||
return obj;
|
||||
return BooleanObject::create(cx, v.toBoolean());
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
|
|
@ -348,6 +348,7 @@ extern Class WithClass;
|
|||
extern Class XMLFilterClass;
|
||||
|
||||
class ArgumentsObject;
|
||||
class BooleanObject;
|
||||
class GlobalObject;
|
||||
class NormalArgumentsObject;
|
||||
class NumberObject;
|
||||
|
@ -1024,6 +1025,7 @@ struct JSObject : js::gc::Cell {
|
|||
}
|
||||
|
||||
public:
|
||||
inline js::BooleanObject *asBoolean();
|
||||
inline js::NumberObject *asNumber();
|
||||
inline js::StringObject *asString();
|
||||
inline js::RegExpObject *asRegExp();
|
||||
|
|
Загрузка…
Ссылка в новой задаче