diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-12 11:13:03 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:13:47 +0200 |
commit | 16f92ad85cf665d863ded5eeaaa7fc3f90820b3f (patch) | |
tree | 74b3477b9d6c023730835f1c478ceb6eaec68a2b /src/qml/jsruntime/qv4objectproto.cpp | |
parent | 7d4e61dd824706984030c58684fa844ff9cde251 (diff) |
Convert builtin methods to return a ReturnedValue
Change-Id: I6b75adbf53a5be0deab023d2eed98ce2a7915551
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4objectproto.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 1192dd5952..0d168ea814 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -135,17 +135,17 @@ void ObjectPrototype::init(ExecutionContext *ctx, const Value &ctor) p->setSetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_set_proto)); } -Value ObjectPrototype::method_getPrototypeOf(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_getPrototypeOf(SimpleCallContext *ctx) { Value o = ctx->argument(0); if (! o.isObject()) ctx->throwTypeError(); Object *p = o.objectValue()->prototype(); - return p ? Value::fromObject(p) : Value::nullValue(); + return p ? Value::fromObject(p).asReturnedValue() : Encode::null(); } -Value ObjectPrototype::method_getOwnPropertyDescriptor(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(SimpleCallContext *ctx) { Value O = ctx->argument(0); if (!O.isObject()) @@ -157,17 +157,17 @@ Value ObjectPrototype::method_getOwnPropertyDescriptor(SimpleCallContext *ctx) return fromPropertyDescriptor(ctx, desc, attrs); } -Value ObjectPrototype::method_getOwnPropertyNames(SimpleCallContext *context) +ReturnedValue ObjectPrototype::method_getOwnPropertyNames(SimpleCallContext *context) { Object *O = context->argumentCount ? context->arguments[0].asObject() : 0; if (!O) context->throwTypeError(); ArrayObject *array = getOwnPropertyNames(context->engine, context->arguments[0]); - return Value::fromObject(array); + return Value::fromObject(array).asReturnedValue(); } -Value ObjectPrototype::method_create(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_create(SimpleCallContext *ctx) { Value O = ctx->argument(0); if (!O.isObject() && !O.isNull()) @@ -182,10 +182,10 @@ Value ObjectPrototype::method_create(SimpleCallContext *ctx) method_defineProperties(ctx); } - return objValue; + return objValue.asReturnedValue(); } -Value ObjectPrototype::method_defineProperty(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_defineProperty(SimpleCallContext *ctx) { Value O = ctx->argument(0); if (!O.isObject()) @@ -201,10 +201,10 @@ Value ObjectPrototype::method_defineProperty(SimpleCallContext *ctx) if (!O.objectValue()->__defineOwnProperty__(ctx, name, pd, attrs)) ctx->throwTypeError(); - return O; + return O.asReturnedValue(); } -Value ObjectPrototype::method_defineProperties(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_defineProperties(SimpleCallContext *ctx) { Value O = ctx->argument(0); if (!O.isObject()) @@ -232,10 +232,10 @@ Value ObjectPrototype::method_defineProperties(SimpleCallContext *ctx) ctx->throwTypeError(); } - return O; + return O.asReturnedValue(); } -Value ObjectPrototype::method_seal(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_seal(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); @@ -251,10 +251,10 @@ Value ObjectPrototype::method_seal(SimpleCallContext *ctx) o->arrayAttributes[i].setConfigurable(false); } - return ctx->argument(0); + return ctx->argument(0).asReturnedValue(); } -Value ObjectPrototype::method_freeze(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_freeze(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); @@ -271,83 +271,83 @@ Value ObjectPrototype::method_freeze(SimpleCallContext *ctx) if (o->arrayAttributes[i].isData()) o->arrayAttributes[i].setWritable(false); } - return ctx->argument(0); + return ctx->argument(0).asReturnedValue(); } -Value ObjectPrototype::method_preventExtensions(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_preventExtensions(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); Object *o = ctx->argument(0).objectValue(); o->extensible = false; - return ctx->argument(0); + return ctx->argument(0).asReturnedValue(); } -Value ObjectPrototype::method_isSealed(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_isSealed(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); Object *o = ctx->argument(0).objectValue(); if (o->extensible) - return Value::fromBoolean(false); + return Encode(false); if (o->internalClass != o->internalClass->sealed()) - return Value::fromBoolean(false); + return Encode(false); if (!o->arrayDataLen) - return Value::fromBoolean(true); + return Encode(true); if (!o->arrayAttributes) - return Value::fromBoolean(false); + return Encode(false); for (uint i = 0; i < o->arrayDataLen; ++i) { if (!o->arrayAttributes[i].isGeneric()) if (o->arrayAttributes[i].isConfigurable()) - return Value::fromBoolean(false); + return Encode(false); } - return Value::fromBoolean(true); + return Encode(true); } -Value ObjectPrototype::method_isFrozen(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_isFrozen(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); Object *o = ctx->argument(0).objectValue(); if (o->extensible) - return Value::fromBoolean(false); + return Encode(false); if (o->internalClass != o->internalClass->frozen()) - return Value::fromBoolean(false); + return Encode(false); if (!o->arrayDataLen) - return Value::fromBoolean(true); + return Encode(true); if (!o->arrayAttributes) - return Value::fromBoolean(false); + return Encode(false); for (uint i = 0; i < o->arrayDataLen; ++i) { if (!o->arrayAttributes[i].isGeneric()) if (o->arrayAttributes[i].isConfigurable() || o->arrayAttributes[i].isWritable()) - return Value::fromBoolean(false); + return Encode(false); } - return Value::fromBoolean(true); + return Encode(true); } -Value ObjectPrototype::method_isExtensible(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_isExtensible(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); Object *o = ctx->argument(0).objectValue(); - return Value::fromBoolean(o->extensible); + return Encode(o->extensible); } -Value ObjectPrototype::method_keys(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_keys(SimpleCallContext *ctx) { if (!ctx->argument(0).isObject()) ctx->throwTypeError(); @@ -364,23 +364,23 @@ Value ObjectPrototype::method_keys(SimpleCallContext *ctx) a->push_back(name); } - return Value::fromObject(a); + return Value::fromObject(a).asReturnedValue(); } -Value ObjectPrototype::method_toString(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_toString(SimpleCallContext *ctx) { if (ctx->thisObject.isUndefined()) { - return Value::fromString(ctx, QStringLiteral("[object Undefined]")); + return Value::fromString(ctx, QStringLiteral("[object Undefined]")).asReturnedValue(); } else if (ctx->thisObject.isNull()) { - return Value::fromString(ctx, QStringLiteral("[object Null]")); + return Value::fromString(ctx, QStringLiteral("[object Null]")).asReturnedValue(); } else { Value obj = Value::fromReturnedValue(__qmljs_to_object(ctx, ValueRef(&ctx->thisObject))); QString className = obj.objectValue()->className(); - return Value::fromString(ctx, QString::fromUtf8("[object %1]").arg(className)); + return Value::fromString(ctx, QString::fromUtf8("[object %1]").arg(className)).asReturnedValue(); } } -Value ObjectPrototype::method_toLocaleString(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_toLocaleString(SimpleCallContext *ctx) { Scope scope(ctx); Object *o = ctx->thisObject.toObject(ctx); @@ -389,51 +389,51 @@ Value ObjectPrototype::method_toLocaleString(SimpleCallContext *ctx) ctx->throwTypeError(); ScopedCallData callData(scope, 0); callData->thisObject = Value::fromObject(o); - return Value::fromReturnedValue(f->call(callData)); + return f->call(callData); } -Value ObjectPrototype::method_valueOf(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_valueOf(SimpleCallContext *ctx) { - return Value::fromObject(ctx->thisObject.toObject(ctx)); + return Value::fromObject(ctx->thisObject.toObject(ctx)).asReturnedValue(); } -Value ObjectPrototype::method_hasOwnProperty(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_hasOwnProperty(SimpleCallContext *ctx) { String *P = ctx->argument(0).toString(ctx); Object *O = ctx->thisObject.toObject(ctx); bool r = O->__getOwnProperty__(P) != 0; if (!r) r = !O->query(P).isEmpty(); - return Value::fromBoolean(r); + return Encode(r); } -Value ObjectPrototype::method_isPrototypeOf(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_isPrototypeOf(SimpleCallContext *ctx) { Value V = ctx->argument(0); if (! V.isObject()) - return Value::fromBoolean(false); + return Encode(false); Object *O = ctx->thisObject.toObject(ctx); Object *proto = V.objectValue()->prototype(); while (proto) { if (O == proto) - return Value::fromBoolean(true); + return Encode(true); proto = proto->prototype(); } - return Value::fromBoolean(false); + return Encode(false); } -Value ObjectPrototype::method_propertyIsEnumerable(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_propertyIsEnumerable(SimpleCallContext *ctx) { String *p = ctx->argument(0).toString(ctx); Object *o = ctx->thisObject.toObject(ctx); PropertyAttributes attrs; o->__getOwnProperty__(p, &attrs); - return Value::fromBoolean(attrs.isEnumerable()); + return Encode(attrs.isEnumerable()); } -Value ObjectPrototype::method_defineGetter(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_defineGetter(SimpleCallContext *ctx) { if (ctx->argumentCount < 2) ctx->throwTypeError(); @@ -446,16 +446,16 @@ Value ObjectPrototype::method_defineGetter(SimpleCallContext *ctx) Object *o = ctx->thisObject.asObject(); if (!o) { if (!ctx->thisObject.isUndefined()) - return Value::undefinedValue(); + return Encode::undefined(); o = ctx->engine->globalObject; } Property pd = Property::fromAccessor(f, 0); o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor); - return Value::undefinedValue(); + return Encode::undefined(); } -Value ObjectPrototype::method_defineSetter(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_defineSetter(SimpleCallContext *ctx) { if (ctx->argumentCount < 2) ctx->throwTypeError(); @@ -468,25 +468,25 @@ Value ObjectPrototype::method_defineSetter(SimpleCallContext *ctx) Object *o = ctx->thisObject.asObject(); if (!o) { if (!ctx->thisObject.isUndefined()) - return Value::undefinedValue(); + return Encode::undefined(); o = ctx->engine->globalObject; } Property pd = Property::fromAccessor(0, f); o->__defineOwnProperty__(ctx, prop, pd, Attr_Accessor); - return Value::undefinedValue(); + return Encode::undefined(); } -Value ObjectPrototype::method_get_proto(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_get_proto(SimpleCallContext *ctx) { Object *o = ctx->thisObject.asObject(); if (!o) ctx->throwTypeError(); - return Value::fromObject(o->prototype()); + return Value::fromObject(o->prototype()).asReturnedValue(); } -Value ObjectPrototype::method_set_proto(SimpleCallContext *ctx) +ReturnedValue ObjectPrototype::method_set_proto(SimpleCallContext *ctx) { Object *o = ctx->thisObject.asObject(); if (!o) @@ -506,7 +506,7 @@ Value ObjectPrototype::method_set_proto(SimpleCallContext *ctx) } if (!ok) ctx->throwTypeError(QStringLiteral("Cyclic __proto__ value")); - return Value::undefinedValue(); + return Encode::undefined(); } void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Property *desc, PropertyAttributes *attrs) @@ -573,10 +573,10 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope } -Value ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, const Property *desc, PropertyAttributes attrs) +ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, const Property *desc, PropertyAttributes attrs) { if (!desc) - return Value::undefinedValue(); + return Encode::undefined(); ExecutionEngine *engine = ctx->engine; // Let obj be the result of creating a new object as if by the expression new Object() where Object is the standard built-in constructor with that name. @@ -599,7 +599,7 @@ Value ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, const Prope pd.value = Value::fromBoolean(attrs.isConfigurable()); o->__defineOwnProperty__(ctx, engine->newString(QStringLiteral("configurable")), pd, Attr_Data); - return Value::fromObject(o); + return Value::fromObject(o).asReturnedValue(); } |