Disentangle some includes
authorLars Knoll <lars.knoll@digia.com>
Sat, 25 Jan 2014 20:59:15 +0000 (21:59 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 31 Jan 2014 10:13:48 +0000 (11:13 +0100)
ScopedValue should require less dependencies. Hopefully we can then
move it together with the main class definition at some point (ie.
move ScopedValue int qv4value_p.h; similar for the other types).

Change-Id: Ie7b31715cb718a90dba40845c7ae785a29855062
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4context_p.h
src/qml/jsruntime/qv4object_p.h
src/qml/jsruntime/qv4runtime_p.h
src/qml/jsruntime/qv4scopedvalue_p.h
src/qml/jsruntime/qv4string_p.h
src/qml/jsruntime/qv4value.cpp
src/qml/jsruntime/qv4value_p.h

index b5c9736..5904d0b 100644 (file)
@@ -42,7 +42,7 @@
 #define QMLJS_ENVIRONMENT_H
 
 #include "qv4global_p.h"
-#include "qv4value_p.h"
+#include "qv4scopedvalue_p.h"
 #include "qv4managed_p.h"
 #include "qv4engine_p.h"
 
@@ -181,6 +181,10 @@ struct CallContext : public ExecutionContext
     bool needsOwnArguments() const;
 };
 
+inline ReturnedValue CallContext::argument(int i) {
+    return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
+}
+
 struct GlobalContext : public ExecutionContext
 {
     GlobalContext(ExecutionEngine *engine);
@@ -243,6 +247,15 @@ struct ExecutionContextSaver
     }
 };
 
+inline Scope::Scope(ExecutionContext *ctx)
+    : engine(ctx->engine)
+#ifndef QT_NO_DEBUG
+    , size(0)
+#endif
+{
+    mark = engine->jsStackTop;
+}
+
 /* Function *f, int argc */
 #define requiredMemoryForExecutionContect(f, argc) \
     sizeof(CallContext) + sizeof(Value) * (f->varCount + qMax((uint)argc, f->formalParameterCount)) + sizeof(CallData)
index 1df388d..3a4cb3d 100644 (file)
@@ -417,9 +417,9 @@ inline ArrayObject *value_cast(const Value &v) {
 }
 
 template<>
-inline ReturnedValue value_convert<Object>(ExecutionContext *ctx, const Value &v)
+inline ReturnedValue value_convert<Object>(ExecutionEngine *e, const Value &v)
 {
-    return v.toObject(ctx)->asReturnedValue();
+    return v.toObject(e->currentContext())->asReturnedValue();
 }
 
 }
index a7b21f5..c64d120 100644 (file)
@@ -45,6 +45,7 @@
 #include "qv4value_inl_p.h"
 #include "qv4math_p.h"
 #include "qv4scopedvalue_p.h"
+#include "qv4context_p.h"
 
 #include <QtCore/QString>
 #include <QtCore/qnumeric.h>
index 4338d67..3b1f3d5 100644 (file)
@@ -41,7 +41,7 @@
 #ifndef QV4SCOPEDVALUE_P_H
 #define QV4SCOPEDVALUE_P_H
 
-#include "qv4context_p.h"
+#include "qv4engine_p.h"
 #include "qv4value_p.h"
 
 QT_BEGIN_NAMESPACE
@@ -54,15 +54,7 @@ namespace QV4 {
 struct ScopedValue;
 
 struct Scope {
-    explicit Scope(ExecutionContext *ctx)
-        : engine(ctx->engine)
-#ifndef QT_NO_DEBUG
-        , size(0)
-#endif
-    {
-        mark = engine->jsStackTop;
-    }
-
+    inline explicit Scope(ExecutionContext *ctx);
     explicit Scope(ExecutionEngine *e)
         : engine(e)
 #ifndef QT_NO_DEBUG
@@ -234,7 +226,7 @@ struct Scoped
     Scoped(const Scope &scope, const Value &v, _Convert)
     {
         ptr = scope.engine->jsStackTop++;
-        ptr->val = value_convert<T>(scope.engine->currentContext(), v);
+        ptr->val = value_convert<T>(scope.engine, v);
 #ifndef QT_NO_DEBUG
         ++scope.size;
 #endif
@@ -281,7 +273,7 @@ struct Scoped
     Scoped(const Scope &scope, const ReturnedValue &v, _Convert)
     {
         ptr = scope.engine->jsStackTop++;
-        ptr->val = value_convert<T>(scope.engine->currentContext(), QV4::Value::fromReturnedValue(v));
+        ptr->val = value_convert<T>(scope.engine, QV4::Value::fromReturnedValue(v));
 #ifndef QT_NO_DEBUG
         ++scope.size;
 #endif
@@ -703,10 +695,6 @@ inline WeakValue &WeakValue::operator=(Returned<T> *obj)
     return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue());
 }
 
-inline ReturnedValue CallContext::argument(int i) {
-    return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
-}
-
 
 }
 
index e3d8326..40f4ff8 100644 (file)
@@ -186,9 +186,9 @@ inline String *value_cast(const Value &v) {
 }
 
 template<>
-inline ReturnedValue value_convert<String>(ExecutionContext *ctx, const Value &v)
+inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v)
 {
-    return v.toString(ctx)->asReturnedValue();
+    return v.toString(e)->asReturnedValue();
 }
 
 }
index 30f7e8c..33084e0 100644 (file)
@@ -262,6 +262,11 @@ double Primitive::toInteger(double number)
     return std::signbit(number) ? -v : v;
 }
 
+String *Value::toString(ExecutionEngine *e) const
+{
+    return toString(e->currentContext());
+}
+
 String *Value::toString(ExecutionContext *ctx) const
 {
     if (isString())
index 07757ea..4b5d0de 100644 (file)
@@ -300,6 +300,7 @@ struct Q_QML_EXPORT Value
     double toNumberImpl() const;
     QString toQStringNoThrow() const;
     QString toQString() const;
+    String *toString(ExecutionEngine *e) const;
     String *toString(ExecutionContext *ctx) const;
     Object *toObject(ExecutionContext *ctx) const;
 
@@ -505,7 +506,7 @@ T *value_cast(const Value &v)
 }
 
 template<typename T>
-ReturnedValue value_convert(ExecutionContext *ctx, const Value &v);
+ReturnedValue value_convert(ExecutionEngine *e, const Value &v);