From bca28cb0d0dd922ee5d54e5d64d31b97ae5d0266 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 25 Jan 2014 21:59:15 +0100 Subject: [PATCH] Disentangle some includes 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 --- src/qml/jsruntime/qv4context_p.h | 15 ++++++++++++++- src/qml/jsruntime/qv4object_p.h | 4 ++-- src/qml/jsruntime/qv4runtime_p.h | 1 + src/qml/jsruntime/qv4scopedvalue_p.h | 20 ++++---------------- src/qml/jsruntime/qv4string_p.h | 4 ++-- src/qml/jsruntime/qv4value.cpp | 5 +++++ src/qml/jsruntime/qv4value_p.h | 3 ++- 7 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index b5c9736..5904d0b 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -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) diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 1df388d..3a4cb3d 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -417,9 +417,9 @@ inline ArrayObject *value_cast(const Value &v) { } template<> -inline ReturnedValue value_convert(ExecutionContext *ctx, const Value &v) +inline ReturnedValue value_convert(ExecutionEngine *e, const Value &v) { - return v.toObject(ctx)->asReturnedValue(); + return v.toObject(e->currentContext())->asReturnedValue(); } } diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index a7b21f5..c64d120 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -45,6 +45,7 @@ #include "qv4value_inl_p.h" #include "qv4math_p.h" #include "qv4scopedvalue_p.h" +#include "qv4context_p.h" #include #include diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 4338d67..3b1f3d5 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -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(scope.engine->currentContext(), v); + ptr->val = value_convert(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(scope.engine->currentContext(), QV4::Value::fromReturnedValue(v)); + ptr->val = value_convert(scope.engine, QV4::Value::fromReturnedValue(v)); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -703,10 +695,6 @@ inline WeakValue &WeakValue::operator=(Returned *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(); -} - } diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index e3d8326..40f4ff8 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -186,9 +186,9 @@ inline String *value_cast(const Value &v) { } template<> -inline ReturnedValue value_convert(ExecutionContext *ctx, const Value &v) +inline ReturnedValue value_convert(ExecutionEngine *e, const Value &v) { - return v.toString(ctx)->asReturnedValue(); + return v.toString(e)->asReturnedValue(); } } diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index 30f7e8c..33084e0 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -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()) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 07757ea..4b5d0de 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -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 -ReturnedValue value_convert(ExecutionContext *ctx, const Value &v); +ReturnedValue value_convert(ExecutionEngine *e, const Value &v); -- 2.7.4