Get rid of asNumberObject
authorLars Knoll <lars.knoll@theqtcompany.com>
Fri, 13 Feb 2015 10:47:25 +0000 (11:47 +0100)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Tue, 21 Apr 2015 13:01:35 +0000 (13:01 +0000)
Change-Id: Ie6355beabce3de65c215514d9dc98294b5980c9d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/jsruntime/qv4jsonobject.cpp
src/qml/jsruntime/qv4managed_p.h
src/qml/jsruntime/qv4numberobject.cpp
src/qml/jsruntime/qv4value_inl_p.h
src/qml/jsruntime/qv4value_p.h

index 8c6bdb7..ef298c5 100644 (file)
@@ -700,7 +700,7 @@ QString Stringify::Str(const QString &key, const Value &v)
 
     o = value->asReturnedValue();
     if (o) {
-        if (NumberObject *n = o->asNumberObject())
+        if (NumberObject *n = o->as<NumberObject>())
             value = Encode(n->value());
         else if (StringObject *so = o->as<StringObject>())
             value = so->d()->value;
@@ -893,7 +893,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx)
             ScopedValue v(scope);
             for (uint i = 0; i < arrayLen; ++i) {
                 v = o->getIndexed(i);
-                if (v->asNumberObject() || v->as<StringObject>() || v->isNumber())
+                if (v->as<NumberObject>() || v->as<StringObject>() || v->isNumber())
                     v = RuntimeHelpers::toString(scope.engine, v);
                 if (v->isString()) {
                     String *s = v->stringValue();
@@ -905,7 +905,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx)
     }
 
     ScopedValue s(scope, ctx->argument(2));
-    if (NumberObject *n = s->asNumberObject())
+    if (NumberObject *n = s->as<NumberObject>())
         s = Encode(n->value());
     else if (StringObject *so = s->as<StringObject>())
         s = so->d()->value;
index 4a6f750..4b455cb 100644 (file)
@@ -154,7 +154,6 @@ public:
     Object *asObject() { return d()->vtable->isObject ? reinterpret_cast<Object *>(this) : 0; }
     FunctionObject *asFunctionObject() { return d()->vtable->isFunctionObject ? reinterpret_cast<FunctionObject *>(this) : 0; }
     BooleanObject *asBooleanObject() { return d()->vtable->type == Type_BooleanObject ? reinterpret_cast<BooleanObject *>(this) : 0; }
-    NumberObject *asNumberObject() { return d()->vtable->type == Type_NumberObject ? reinterpret_cast<NumberObject *>(this) : 0; }
     ArgumentsObject *asArgumentsObject() { return d()->vtable->type == Type_ArgumentsObject ? reinterpret_cast<ArgumentsObject *>(this) : 0; }
 
     bool isListType() const { return d()->vtable->type == Type_QmlSequence; }
index 89ff110..f4d2929 100644 (file)
@@ -97,7 +97,7 @@ inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
 {
     if (ctx->thisObject().isNumber())
         return ctx->thisObject().asReturnedValue();
-    NumberObject *n = ctx->thisObject().asNumberObject();
+    NumberObject *n = ctx->thisObject().as<NumberObject>();
     if (!n)
         return ctx->engine()->throwTypeError();
     return Encode(n->value());
@@ -107,7 +107,7 @@ inline double thisNumber(ExecutionContext *ctx)
 {
     if (ctx->thisObject().isNumber())
         return ctx->thisObject().asDouble();
-    NumberObject *n = ctx->thisObject().asNumberObject();
+    NumberObject *n = ctx->thisObject().as<NumberObject>();
     if (!n)
         return ctx->engine()->throwTypeError();
     return n->value();
index dea510e..3d25d8a 100644 (file)
@@ -248,11 +248,6 @@ inline FunctionObject *Value::asFunctionObject() const
     return isObject() ? managed()->asFunctionObject() : 0;
 }
 
-inline NumberObject *Value::asNumberObject() const
-{
-    return isObject() ? managed()->asNumberObject() : 0;
-}
-
 template<>
 inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v)
 {
index 29781cd..035eaa8 100644 (file)
@@ -308,7 +308,6 @@ struct Q_QML_PRIVATE_EXPORT Value
     inline Managed *asManaged() const;
     inline Object *asObject() const;
     inline FunctionObject *asFunctionObject() const;
-    inline NumberObject *asNumberObject() const;
 
     template <typename T>
     const T *as() const {