зеркало из https://github.com/mozilla/gecko-dev.git
Bug 714697 - rm lingering remains of JSCLASS_CONSTRUCT_PROTOTYPE (r=waldo)
--HG-- extra : rebase_source : d39774d9d5ae206ea24a0dda45ad308593db1e9d
This commit is contained in:
Родитель
65cc085d05
Коммит
497001495f
|
@ -3425,28 +3425,46 @@ JS_DeepFreezeObject(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_ConstructObject(JSContext *cx, JSClass *jsclasp, JSObject *proto, JSObject *parent)
|
||||
JS_ConstructObject(JSContext *cx, JSClass *jsclasp, JSObject *parent)
|
||||
{
|
||||
AssertNoGC(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto, parent);
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &ObjectClass; /* default class is Object */
|
||||
return js_ConstructObject(cx, clasp, proto, parent, 0, NULL);
|
||||
return JS_ConstructObjectWithArguments(cx, jsclasp, parent, 0, NULL);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_ConstructObjectWithArguments(JSContext *cx, JSClass *jsclasp, JSObject *proto,
|
||||
JSObject *parent, uintN argc, jsval *argv)
|
||||
JS_ConstructObjectWithArguments(JSContext *cx, JSClass *jsclasp, JSObject *parent,
|
||||
uintN argc, jsval *argv)
|
||||
{
|
||||
AssertNoGC(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, proto, parent, JSValueArray(argv, argc));
|
||||
assertSameCompartment(cx, parent, JSValueArray(argv, argc));
|
||||
|
||||
AutoArrayRooter argtvr(cx, argc, argv);
|
||||
|
||||
Class *clasp = Valueify(jsclasp);
|
||||
if (!clasp)
|
||||
clasp = &ObjectClass; /* default class is Object */
|
||||
return js_ConstructObject(cx, clasp, proto, parent, argc, argv);
|
||||
|
||||
JSProtoKey protoKey = GetClassProtoKey(clasp);
|
||||
|
||||
/* Protect constructor in case a crazy getter for .prototype uproots it. */
|
||||
AutoValueRooter tvr(cx);
|
||||
if (!js_FindClassObject(cx, parent, protoKey, tvr.addr(), clasp))
|
||||
return NULL;
|
||||
|
||||
Value rval;
|
||||
if (!InvokeConstructor(cx, tvr.value(), argc, argv, &rval))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* If the instance's class differs from what was requested, throw a type
|
||||
* error.
|
||||
*/
|
||||
if (!rval.isObject() || rval.toObject().getClass() != clasp) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_WRONG_CONSTRUCTOR, clasp->name);
|
||||
return NULL;
|
||||
}
|
||||
return &rval.toObject();
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
|
|
@ -336,16 +336,6 @@ class Value
|
|||
data = MAGIC_TO_JSVAL_IMPL(why);
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE
|
||||
void setMagicWithObjectOrNullPayload(JSObject *obj) {
|
||||
data = MAGIC_OBJ_TO_JSVAL_IMPL(obj);
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE
|
||||
JSObject *getMagicObjectOrNullPayload() const {
|
||||
return MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(data);
|
||||
}
|
||||
|
||||
JS_ALWAYS_INLINE
|
||||
bool setNumber(uint32_t ui) {
|
||||
if (ui > JSVAL_INT_MAX) {
|
||||
|
@ -472,8 +462,13 @@ class Value
|
|||
return JSVAL_IS_MAGIC_IMPL(data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Although the Value class comment says 'magic' is a singleton type, it is
|
||||
* technically possible to use the payload. This should be avoided to
|
||||
* preserve the ability for the strong assertions in isMagic().
|
||||
*/
|
||||
JS_ALWAYS_INLINE
|
||||
bool isMagicCheck(JSWhyMagic why) const {
|
||||
bool isParticularMagic(JSWhyMagic why) const {
|
||||
return isMagic() && data.s.payload.why == why;
|
||||
}
|
||||
|
||||
|
@ -3404,12 +3399,11 @@ extern JS_PUBLIC_API(JSBool)
|
|||
JS_FreezeObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,
|
||||
JSObject *parent);
|
||||
JS_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *parent);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_ConstructObjectWithArguments(JSContext *cx, JSClass *clasp, JSObject *proto,
|
||||
JSObject *parent, uintN argc, jsval *argv);
|
||||
JS_ConstructObjectWithArguments(JSContext *cx, JSClass *clasp, JSObject *parent,
|
||||
uintN argc, jsval *argv);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv);
|
||||
|
|
|
@ -126,7 +126,7 @@ struct JSFunction : public JSObject
|
|||
bool optimizedClosure() const { return kind() > JSFUN_INTERPRETED; }
|
||||
bool isInterpreted() const { return kind() >= JSFUN_INTERPRETED; }
|
||||
bool isNative() const { return !isInterpreted(); }
|
||||
bool isConstructor() const { return flags & JSFUN_CONSTRUCTOR; }
|
||||
bool isNativeConstructor() const { return flags & JSFUN_CONSTRUCTOR; }
|
||||
bool isHeavyweight() const { return JSFUN_HEAVYWEIGHT_TEST(flags); }
|
||||
bool isNullClosure() const { return kind() == JSFUN_NULL_CLOSURE; }
|
||||
bool isFlatClosure() const { return kind() == JSFUN_FLAT_CLOSURE; }
|
||||
|
|
|
@ -299,24 +299,6 @@ IsConstructing(CallReceiver call)
|
|||
return IsConstructing(call.base());
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE bool
|
||||
IsConstructing_PossiblyWithGivenThisObject(const Value *vp, JSObject **ctorThis)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
JSObject *callee = &JS_CALLEE(cx, vp).toObject();
|
||||
if (callee->isFunction()) {
|
||||
JSFunction *fun = callee->toFunction();
|
||||
JS_ASSERT((fun->flags & JSFUN_CONSTRUCTOR) != 0);
|
||||
} else {
|
||||
JS_ASSERT(callee->getClass()->construct != NULL);
|
||||
}
|
||||
#endif
|
||||
bool isCtor = vp[1].isMagic();
|
||||
if (isCtor)
|
||||
*ctorThis = vp[1].getMagicObjectOrNullPayload();
|
||||
return isCtor;
|
||||
}
|
||||
|
||||
inline const char *
|
||||
GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
|
||||
{
|
||||
|
|
|
@ -1685,7 +1685,7 @@ types::MarkArgumentsCreated(JSContext *cx, JSScript *script)
|
|||
*/
|
||||
Value *sp = fp->base() + analysis->getCode(iter.pc()).stackDepth;
|
||||
for (Value *vp = fp->slots(); vp < sp; vp++) {
|
||||
if (vp->isMagicCheck(JS_LAZY_ARGUMENTS)) {
|
||||
if (vp->isParticularMagic(JS_LAZY_ARGUMENTS)) {
|
||||
if (!js_GetArgsValue(cx, fp, vp))
|
||||
vp->setNull();
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ js::InvokeKernel(JSContext *cx, CallArgs args, MaybeConstruct construct)
|
|||
|
||||
/* Invoke native functions. */
|
||||
JSFunction *fun = callee.toFunction();
|
||||
JS_ASSERT_IF(construct, !fun->isConstructor());
|
||||
JS_ASSERT_IF(construct, !fun->isNativeConstructor());
|
||||
if (fun->isNative())
|
||||
return CallJSNative(cx, fun->u.n.native, args);
|
||||
|
||||
|
@ -577,6 +577,45 @@ js::Invoke(JSContext *cx, const Value &thisv, const Value &fval, uintN argc, Val
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::InvokeConstructorKernel(JSContext *cx, const CallArgs &argsRef)
|
||||
{
|
||||
JS_ASSERT(!FunctionClass.construct);
|
||||
CallArgs args = argsRef;
|
||||
|
||||
args.thisv().setMagic(JS_IS_CONSTRUCTING);
|
||||
|
||||
if (args.calleev().isObject()) {
|
||||
JSObject *callee = &args.callee();
|
||||
Class *clasp = callee->getClass();
|
||||
if (clasp == &FunctionClass) {
|
||||
JSFunction *fun = callee->toFunction();
|
||||
|
||||
if (fun->isNativeConstructor()) {
|
||||
Probes::calloutBegin(cx, fun);
|
||||
bool ok = CallJSNativeConstructor(cx, fun->u.n.native, args);
|
||||
Probes::calloutEnd(cx, fun);
|
||||
return ok;
|
||||
}
|
||||
|
||||
if (!fun->isInterpretedConstructor())
|
||||
goto error;
|
||||
|
||||
if (!InvokeKernel(cx, args, CONSTRUCT))
|
||||
return false;
|
||||
|
||||
JS_ASSERT(args.rval().isObject());
|
||||
return true;
|
||||
}
|
||||
if (clasp->construct)
|
||||
return CallJSNativeConstructor(cx, clasp->construct, args);
|
||||
}
|
||||
|
||||
error:
|
||||
js_ReportIsNotFunction(cx, &args.calleev(), JSV2F_CONSTRUCT);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
js::InvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, Value *rval)
|
||||
{
|
||||
|
@ -956,85 +995,6 @@ js::TypeOfValue(JSContext *cx, const Value &vref)
|
|||
return JSTYPE_BOOLEAN;
|
||||
}
|
||||
|
||||
bool
|
||||
js::InvokeConstructorKernel(JSContext *cx, const CallArgs &argsRef)
|
||||
{
|
||||
JS_ASSERT(!FunctionClass.construct);
|
||||
CallArgs args = argsRef;
|
||||
|
||||
/*
|
||||
* Callers are not required to initialize 'this' when constructing, but
|
||||
* make sure the value is initialized in case we are about to call a native
|
||||
* or if something (e.g. type inference) tries to inspect the frame before
|
||||
* its 'this' value is constructed.
|
||||
*/
|
||||
args.thisv().setMagicWithObjectOrNullPayload(NULL);
|
||||
|
||||
if (args.calleev().isObject()) {
|
||||
JSObject *callee = &args.callee();
|
||||
Class *clasp = callee->getClass();
|
||||
if (clasp == &FunctionClass) {
|
||||
JSFunction *fun = callee->toFunction();
|
||||
|
||||
if (fun->isConstructor()) {
|
||||
Probes::calloutBegin(cx, fun);
|
||||
bool ok = CallJSNativeConstructor(cx, fun->u.n.native, args);
|
||||
Probes::calloutEnd(cx, fun);
|
||||
return ok;
|
||||
}
|
||||
|
||||
if (!fun->isInterpretedConstructor())
|
||||
goto error;
|
||||
|
||||
if (!InvokeKernel(cx, args, CONSTRUCT))
|
||||
return false;
|
||||
|
||||
JS_ASSERT(args.rval().isObject());
|
||||
return true;
|
||||
}
|
||||
if (clasp->construct)
|
||||
return CallJSNativeConstructor(cx, clasp->construct, args);
|
||||
}
|
||||
|
||||
error:
|
||||
js_ReportIsNotFunction(cx, &args.calleev(), JSV2F_CONSTRUCT);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
js::InvokeConstructorWithGivenThis(JSContext *cx, JSObject *thisobj, const Value &fval,
|
||||
uintN argc, Value *argv, Value *rval)
|
||||
{
|
||||
InvokeArgsGuard args;
|
||||
if (!cx->stack.pushInvokeArgs(cx, argc, &args))
|
||||
return JS_FALSE;
|
||||
|
||||
args.calleev() = fval;
|
||||
/* Initialize args.thisv on all paths below. */
|
||||
memcpy(args.array(), argv, argc * sizeof(Value));
|
||||
|
||||
/* Handle the fast-constructor cases before calling the general case. */
|
||||
JSObject &callee = fval.toObject();
|
||||
Class *clasp = callee.getClass();
|
||||
JSFunction *fun;
|
||||
bool ok;
|
||||
if (clasp == &FunctionClass && (fun = callee.toFunction())->isConstructor()) {
|
||||
args.thisv().setMagicWithObjectOrNullPayload(thisobj);
|
||||
Probes::calloutBegin(cx, fun);
|
||||
ok = CallJSNativeConstructor(cx, fun->u.n.native, args);
|
||||
Probes::calloutEnd(cx, fun);
|
||||
} else if (clasp->construct) {
|
||||
args.thisv().setMagicWithObjectOrNullPayload(thisobj);
|
||||
ok = CallJSNativeConstructor(cx, clasp->construct, args);
|
||||
} else {
|
||||
args.thisv().setObjectOrNull(thisobj);
|
||||
ok = Invoke(cx, args, CONSTRUCT);
|
||||
}
|
||||
|
||||
*rval = args.rval();
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
js::ValueToId(JSContext *cx, const Value &v, jsid *idp)
|
||||
{
|
||||
|
|
|
@ -197,14 +197,6 @@ InvokeConstructor(JSContext *cx, InvokeArgsGuard &args)
|
|||
extern bool
|
||||
InvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv, Value *rval);
|
||||
|
||||
/*
|
||||
* InvokeConstructorWithGivenThis directly calls the constructor with the given
|
||||
* 'this'; the caller must choose the semantically correct 'this'.
|
||||
*/
|
||||
extern bool
|
||||
InvokeConstructorWithGivenThis(JSContext *cx, JSObject *thisobj, const Value &fval,
|
||||
uintN argc, Value *argv, Value *rval);
|
||||
|
||||
/*
|
||||
* Executes a script with the given scopeChain/this. The 'type' indicates
|
||||
* whether this is eval code or global code. To support debugging, the
|
||||
|
|
|
@ -4517,66 +4517,6 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
|
|||
return true;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
js_ConstructObject(JSContext *cx, Class *clasp, JSObject *proto, JSObject *parent,
|
||||
uintN argc, Value *argv)
|
||||
{
|
||||
AutoArrayRooter argtvr(cx, argc, argv);
|
||||
|
||||
JSProtoKey protoKey = GetClassProtoKey(clasp);
|
||||
|
||||
/* Protect constructor in case a crazy getter for .prototype uproots it. */
|
||||
AutoValueRooter tvr(cx);
|
||||
if (!js_FindClassObject(cx, parent, protoKey, tvr.addr(), clasp))
|
||||
return NULL;
|
||||
|
||||
const Value &cval = tvr.value();
|
||||
if (tvr.value().isPrimitive()) {
|
||||
js_ReportIsNotFunction(cx, tvr.addr(), JSV2F_CONSTRUCT | JSV2F_SEARCH_STACK);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* If proto is NULL, set it to Constructor.prototype, just like JSOP_NEW
|
||||
* does, likewise for the new object's parent.
|
||||
*/
|
||||
JSObject *ctor = &cval.toObject();
|
||||
if (!parent)
|
||||
parent = ctor->getParent();
|
||||
if (!proto) {
|
||||
Value rval;
|
||||
if (!ctor->getProperty(cx, cx->runtime->atomState.classPrototypeAtom, &rval))
|
||||
return NULL;
|
||||
if (rval.isObjectOrNull())
|
||||
proto = rval.toObjectOrNull();
|
||||
}
|
||||
|
||||
JSObject *obj = NewObjectWithClassProto(cx, clasp, proto, parent);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
MarkTypeObjectUnknownProperties(cx, obj->type());
|
||||
|
||||
Value rval;
|
||||
if (!InvokeConstructorWithGivenThis(cx, obj, cval, argc, argv, &rval))
|
||||
return NULL;
|
||||
|
||||
if (rval.isPrimitive())
|
||||
return obj;
|
||||
|
||||
/*
|
||||
* If the instance's class differs from what was requested, throw a type
|
||||
* error.
|
||||
*/
|
||||
obj = &rval.toObject();
|
||||
if (obj->getClass() != clasp) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_WRONG_CONSTRUCTOR, clasp->name);
|
||||
return NULL;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
bool
|
||||
JSObject::allocSlot(JSContext *cx, uint32_t *slotp)
|
||||
{
|
||||
|
|
|
@ -1672,10 +1672,6 @@ extern JSBool
|
|||
js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey key,
|
||||
js::Value *vp, js::Class *clasp = NULL);
|
||||
|
||||
extern JSObject *
|
||||
js_ConstructObject(JSContext *cx, js::Class *clasp, JSObject *proto,
|
||||
JSObject *parent, uintN argc, js::Value *argv);
|
||||
|
||||
// Specialized call for constructing |this| with a known function callee,
|
||||
// and a known prototype.
|
||||
extern JSObject *
|
||||
|
|
|
@ -286,6 +286,7 @@ typedef enum JSWhyMagic
|
|||
JS_ARG_POISON, /* used in debug builds to catch tracing errors */
|
||||
JS_SERIALIZE_NO_NODE, /* an empty subnode in the AST serializer */
|
||||
JS_LAZY_ARGUMENTS, /* lazy arguments value on the stack */
|
||||
JS_IS_CONSTRUCTING, /* magic value passed to natives to indicate construction */
|
||||
JS_GENERIC_MAGIC /* for local use */
|
||||
} JSWhyMagic;
|
||||
|
||||
|
@ -495,13 +496,6 @@ JSVAL_IS_MAGIC_IMPL(jsval_layout l)
|
|||
return l.s.tag == JSVAL_TAG_MAGIC;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSObject *
|
||||
MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(jsval_layout l)
|
||||
{
|
||||
JS_ASSERT(JSVAL_IS_MAGIC_IMPL(l));
|
||||
return l.s.payload.obj;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_OBJECT_IMPL(jsval_layout l)
|
||||
{
|
||||
|
@ -606,15 +600,6 @@ MAGIC_TO_JSVAL_IMPL(JSWhyMagic why)
|
|||
return l;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsval_layout
|
||||
MAGIC_OBJ_TO_JSVAL_IMPL(JSObject *obj)
|
||||
{
|
||||
jsval_layout l;
|
||||
l.s.tag = JSVAL_TAG_MAGIC;
|
||||
l.s.payload.obj = obj;
|
||||
return l;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs)
|
||||
{
|
||||
|
@ -753,15 +738,6 @@ JSVAL_IS_MAGIC_IMPL(jsval_layout l)
|
|||
return (l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_MAGIC;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSObject *
|
||||
MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(jsval_layout l)
|
||||
{
|
||||
uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK;
|
||||
JS_ASSERT(JSVAL_IS_MAGIC_IMPL(l));
|
||||
JS_ASSERT((ptrBits >> JSVAL_TAG_SHIFT) == 0);
|
||||
return (JSObject *)ptrBits;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l)
|
||||
{
|
||||
|
@ -871,14 +847,6 @@ MAGIC_TO_JSVAL_IMPL(JSWhyMagic why)
|
|||
return l;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE jsval_layout
|
||||
MAGIC_OBJ_TO_JSVAL_IMPL(JSObject *obj)
|
||||
{
|
||||
jsval_layout l;
|
||||
l.asBits = ((uint64_t)obj) | JSVAL_SHIFTED_TAG_MAGIC;
|
||||
return l;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs)
|
||||
{
|
||||
|
|
|
@ -547,7 +547,7 @@ js_ConstructXMLQNameObject(JSContext *cx, const Value &nsval, const Value &lnval
|
|||
argv[0] = nsval;
|
||||
}
|
||||
argv[1] = lnval;
|
||||
return js_ConstructObject(cx, &QNameClass, NULL, NULL, 2, argv);
|
||||
return JS_ConstructObjectWithArguments(cx, Jsvalify(&QNameClass), NULL, 2, argv);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -603,8 +603,7 @@ js_IsXMLName(JSContext *cx, jsval v)
|
|||
* if argc is 1 and argv[0] is JSVAL_VOID.
|
||||
*/
|
||||
static JSBool
|
||||
NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
NamespaceHelper(JSContext *cx, intN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
jsval urival, prefixval;
|
||||
JSObject *uriobj;
|
||||
|
@ -628,19 +627,17 @@ NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv,
|
|||
}
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
/* Namespace called as function. */
|
||||
if (argc == 1 && isNamespace) {
|
||||
/* Namespace called with one Namespace argument is identity. */
|
||||
*rval = urival;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
obj = NewBuiltinClassInstanceXML(cx, &NamespaceClass);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
/* Namespace called as function. */
|
||||
if (argc == 1 && isNamespace) {
|
||||
/* Namespace called with one Namespace argument is identity. */
|
||||
*rval = urival;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSObject *obj = NewBuiltinClassInstanceXML(cx, &NamespaceClass);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
/* Per ECMA-357, 13.2.5, these properties must be "own". */
|
||||
if (!JS_DefineProperties(cx, obj, namespace_props))
|
||||
return JS_FALSE;
|
||||
|
@ -713,9 +710,7 @@ NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv,
|
|||
static JSBool
|
||||
Namespace(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JSObject *thisobj = NULL;
|
||||
(void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj);
|
||||
return NamespaceHelper(cx, thisobj, argc, vp + 2, vp);
|
||||
return NamespaceHelper(cx, argc, vp + 2, vp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -723,7 +718,7 @@ Namespace(JSContext *cx, uintN argc, Value *vp)
|
|||
* if argc is 1 and argv[0] is JSVAL_VOID.
|
||||
*/
|
||||
static JSBool
|
||||
QNameHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv, jsval *rval)
|
||||
QNameHelper(JSContext *cx, intN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
jsval nameval, nsval;
|
||||
JSBool isQName, isNamespace;
|
||||
|
@ -742,19 +737,17 @@ QNameHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv, jsval *rval)
|
|||
JSVAL_TO_OBJECT(nameval)->getClass() == &QNameClass;
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
/* QName called as function. */
|
||||
if (argc == 1 && isQName) {
|
||||
/* QName called with one QName argument is identity. */
|
||||
*rval = nameval;
|
||||
return JS_TRUE;
|
||||
}
|
||||
/* QName called as function. */
|
||||
if (argc == 1 && isQName) {
|
||||
/* QName called with one QName argument is identity. */
|
||||
*rval = nameval;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/* Create and return a new QName object exactly as if constructed. */
|
||||
obj = NewBuiltinClassInstanceXML(cx, &QNameClass);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
}
|
||||
JSObject *obj = NewBuiltinClassInstanceXML(cx, &QNameClass);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
|
||||
if (isQName) {
|
||||
|
@ -841,9 +834,7 @@ out:
|
|||
static JSBool
|
||||
QName(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JSObject *thisobj = NULL;
|
||||
(void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj);
|
||||
return QNameHelper(cx, thisobj, argc, vp + 2, vp);
|
||||
return QNameHelper(cx, argc, vp + 2, vp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2291,7 +2282,7 @@ GetNamespace(JSContext *cx, JSObject *qn, const JSXMLArray<JSObject> *inScopeNSe
|
|||
if (!match) {
|
||||
argv[0] = prefix ? STRING_TO_JSVAL(prefix) : JSVAL_VOID;
|
||||
argv[1] = STRING_TO_JSVAL(uri);
|
||||
ns = js_ConstructObject(cx, &NamespaceClass, NULL, NULL, 2, argv);
|
||||
ns = JS_ConstructObjectWithArguments(cx, Jsvalify(&NamespaceClass), NULL, 2, argv);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
match = ns;
|
||||
|
@ -2970,7 +2961,7 @@ ToXMLName(JSContext *cx, jsval v, jsid *funidp)
|
|||
|
||||
construct:
|
||||
v = STRING_TO_JSVAL(name);
|
||||
obj = js_ConstructObject(cx, &QNameClass, NULL, NULL, 1, &v);
|
||||
obj = JS_ConstructObjectWithArguments(cx, Jsvalify(&QNameClass), NULL, 1, &v);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
|
@ -5493,7 +5484,7 @@ xml_addNamespace(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!xml)
|
||||
return JS_FALSE;
|
||||
|
||||
if (!NamespaceHelper(cx, NULL, argc == 0 ? -1 : 1, vp + 2, vp))
|
||||
if (!NamespaceHelper(cx, argc == 0 ? -1 : 1, vp + 2, vp))
|
||||
return JS_FALSE;
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
||||
|
||||
|
@ -6592,7 +6583,7 @@ xml_removeNamespace(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!xml)
|
||||
return JS_FALSE;
|
||||
|
||||
if (!NamespaceHelper(cx, NULL, argc == 0 ? -1 : 1, vp + 2, vp))
|
||||
if (!NamespaceHelper(cx, argc == 0 ? -1 : 1, vp + 2, vp))
|
||||
return JS_FALSE;
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
||||
ns = JSVAL_TO_OBJECT(*vp);
|
||||
|
@ -6653,7 +6644,7 @@ xml_replace(JSContext *cx, uintN argc, jsval *vp)
|
|||
* Call function QName per spec, not ToXMLName, to avoid attribute
|
||||
* names.
|
||||
*/
|
||||
if (!QNameHelper(cx, NULL, argc == 0 ? -1 : 1, vp + 2, vp))
|
||||
if (!QNameHelper(cx, argc == 0 ? -1 : 1, vp + 2, vp))
|
||||
return JS_FALSE;
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
||||
nameqn = JSVAL_TO_OBJECT(*vp);
|
||||
|
@ -6754,7 +6745,7 @@ xml_setName(JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
}
|
||||
|
||||
nameqn = js_ConstructObject(cx, &QNameClass, NULL, NULL, 1, &name);
|
||||
nameqn = JS_ConstructObjectWithArguments(cx, Jsvalify(&QNameClass), NULL, 1, &name);
|
||||
if (!nameqn)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -6859,11 +6850,8 @@ xml_setNamespace(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!JSXML_HAS_NAME(xml))
|
||||
return JS_TRUE;
|
||||
|
||||
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
|
||||
if (!xml)
|
||||
return JS_FALSE;
|
||||
|
||||
ns = js_ConstructObject(cx, &NamespaceClass, NULL, obj, argc == 0 ? 0 : 1, vp + 2);
|
||||
ns = JS_ConstructObjectWithArguments(cx, Jsvalify(&NamespaceClass), NULL,
|
||||
argc == 0 ? 0 : 1, vp + 2);
|
||||
if (!ns)
|
||||
return JS_FALSE;
|
||||
vp[0] = OBJECT_TO_JSVAL(ns);
|
||||
|
@ -6871,7 +6859,7 @@ xml_setNamespace(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
qnargv[0] = OBJECT_TO_JSVAL(ns);
|
||||
qnargv[1] = OBJECT_TO_JSVAL(xml->name);
|
||||
qn = js_ConstructObject(cx, &QNameClass, NULL, NULL, 2, qnargv);
|
||||
qn = JS_ConstructObjectWithArguments(cx, Jsvalify(&QNameClass), NULL, 2, qnargv);
|
||||
if (!qn)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -7607,7 +7595,7 @@ js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
|
|||
obj = tmp;
|
||||
}
|
||||
|
||||
ns = js_ConstructObject(cx, &NamespaceClass, NULL, obj, 0, NULL);
|
||||
ns = JS_ConstructObjectWithArguments(cx, Jsvalify(&NamespaceClass), NULL, 0, NULL);
|
||||
if (!ns)
|
||||
return JS_FALSE;
|
||||
v = OBJECT_TO_JSVAL(ns);
|
||||
|
@ -7625,7 +7613,7 @@ js_SetDefaultXMLNamespace(JSContext *cx, const Value &v)
|
|||
Value argv[2];
|
||||
argv[0].setString(cx->runtime->emptyString);
|
||||
argv[1] = v;
|
||||
JSObject *ns = js_ConstructObject(cx, &NamespaceClass, NULL, NULL, 2, argv);
|
||||
JSObject *ns = JS_ConstructObjectWithArguments(cx, Jsvalify(&NamespaceClass), NULL, 2, argv);
|
||||
if (!ns)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -7744,7 +7732,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
|
|||
nameobj = &nameval.toObject();
|
||||
if (nameobj->getClass() == &AnyNameClass) {
|
||||
v = STRING_TO_JSVAL(cx->runtime->atomState.starAtom);
|
||||
nameobj = js_ConstructObject(cx, &QNameClass, NULL, NULL, 1, &v);
|
||||
nameobj = JS_ConstructObjectWithArguments(cx, Jsvalify(&QNameClass), NULL, 1, &v);
|
||||
if (!nameobj)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
|
|
|
@ -818,11 +818,11 @@ class CallCompiler : public BaseCompiler
|
|||
if (!IsFunctionObject(args.calleev(), &fun))
|
||||
return false;
|
||||
|
||||
if ((!callingNew && !fun->isNative()) || (callingNew && !fun->isConstructor()))
|
||||
if ((!callingNew && !fun->isNative()) || (callingNew && !fun->isNativeConstructor()))
|
||||
return false;
|
||||
|
||||
if (callingNew)
|
||||
args.thisv().setMagicWithObjectOrNullPayload(NULL);
|
||||
args.thisv().setMagic(JS_IS_CONSTRUCTING);
|
||||
|
||||
RecompilationMonitor monitor(cx);
|
||||
|
||||
|
@ -917,11 +917,8 @@ class CallCompiler : public BaseCompiler
|
|||
}
|
||||
|
||||
/* Mark vp[1] as magic for |new|. */
|
||||
if (callingNew) {
|
||||
Value v;
|
||||
v.setMagicWithObjectOrNullPayload(NULL);
|
||||
masm.storeValue(v, Address(vpReg, sizeof(Value)));
|
||||
}
|
||||
if (callingNew)
|
||||
masm.storeValue(MagicValue(JS_IS_CONSTRUCTING), Address(vpReg, sizeof(Value)));
|
||||
|
||||
masm.restoreStackBase();
|
||||
masm.setupABICall(Registers::NormalCall, 3);
|
||||
|
|
Загрузка…
Ссылка в новой задаче