diff options
Diffstat (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 5022d7c3bc..4e627e003f 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -97,7 +97,7 @@ struct Scope { engine->jsStackTop = mark; } - Value *alloc(int nValues) const { + QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const { return engine->jsAlloca(nValues); } @@ -189,63 +189,70 @@ struct Scoped { enum ConvertType { Convert }; - inline void setPointer(const Managed *p) { + QML_NEARLY_ALWAYS_INLINE void setPointer(const Managed *p) { ptr->setM(p ? p->m() : 0); } - Scoped(const Scope &scope) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope) { ptr = scope.engine->jsAlloca(1); } - Scoped(const Scope &scope, const Value &v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v) { ptr = scope.engine->jsAlloca(1); setPointer(v.as<T>()); } - Scoped(const Scope &scope, Heap::Base *o) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, Heap::Base *o) { Value v; v = o; ptr = scope.engine->jsAlloca(1); setPointer(v.as<T>()); } - Scoped(const Scope &scope, const ScopedValue &v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ScopedValue &v) { ptr = scope.engine->jsAlloca(1); setPointer(v.ptr->as<T>()); } - Scoped(const Scope &scope, const Value &v, ConvertType) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v, ConvertType) { ptr = scope.engine->jsAlloca(1); ptr->setRawValue(value_convert<T>(scope.engine, v)); } - Scoped(const Scope &scope, const Value *v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value *v) { ptr = scope.engine->jsAlloca(1); setPointer(v ? v->as<T>() : 0); } - Scoped(const Scope &scope, T *t) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, T *t) { ptr = scope.engine->jsAlloca(1); setPointer(t); } - Scoped(const Scope &scope, typename T::Data *t) + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const T *t) + { + ptr = scope.engine->jsAlloca(1); + setPointer(t); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, typename T::Data *t) { ptr = scope.engine->jsAlloca(1); *ptr = t; } - Scoped(const Scope &scope, const ReturnedValue &v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v) { ptr = scope.engine->jsAlloca(1); setPointer(QV4::Value::fromReturnedValue(v).as<T>()); } - Scoped(const Scope &scope, const ReturnedValue &v, ConvertType) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v, ConvertType) { ptr = scope.engine->jsAlloca(1); ptr->setRawValue(value_convert<T>(scope.engine, QV4::Value::fromReturnedValue(v))); @@ -291,11 +298,11 @@ struct Scoped } T *operator->() { - return ptr->cast<T>(); + return getPointer(); } const T *operator->() const { - return ptr->cast<T>(); + return getPointer(); } bool operator!() const { @@ -306,14 +313,19 @@ struct Scoped } T *getPointer() { - return ptr->cast<T>(); + return reinterpret_cast<T *>(ptr); + } + + const T *getPointer() const { + return reinterpret_cast<T *>(ptr); } + Value *getRef() { return ptr; } - ReturnedValue asReturnedValue() const { - return ptr->m() ? ptr->rawValue() : Encode::undefined(); + QML_NEARLY_ALWAYS_INLINE ReturnedValue asReturnedValue() const { + return ptr->rawValue(); } Value *ptr; @@ -358,8 +370,6 @@ struct ScopedProperty ScopedProperty(Scope &scope) { property = reinterpret_cast<Property*>(scope.alloc(sizeof(Property) / sizeof(Value))); - property->value = Encode::undefined(); - property->set = Encode::undefined(); } Property *operator->() { return property; } |