Merge remote-tracking branch 'origin/5.5' into dev
authorLiang Qi <liang.qi@theqtcompany.com>
Wed, 22 Apr 2015 13:04:42 +0000 (15:04 +0200)
committerLiang Qi <liang.qi@theqtcompany.com>
Wed, 22 Apr 2015 13:32:19 +0000 (15:32 +0200)
Conflicts:
src/qml/qml/qqmlbinding.cpp
src/qml/jsruntime/qv4arraybuffer.cpp
src/qml/jsruntime/qv4functionobject.cpp

Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d

22 files changed:
1  2 
src/qml/jsapi/qjsengine.cpp
src/qml/jsapi/qjsvalue.cpp
src/qml/jsruntime/qv4arraybuffer.cpp
src/qml/jsruntime/qv4arraybuffer_p.h
src/qml/jsruntime/qv4context.cpp
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4engine_p.h
src/qml/jsruntime/qv4errorobject.cpp
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4functionobject_p.h
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/jsruntime/qv4value_p.h
src/qml/qml/qqmlbinding.cpp
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmljavascriptexpression.cpp
src/qml/qml/qqmlproperty.cpp
src/qml/qml/qqmltypewrapper.cpp
src/qml/qml/qqmlvaluetypewrapper.cpp
src/qml/qml/qqmlvaluetypewrapper_p.h
src/qml/qml/v8/qqmlbuiltinfunctions.cpp
src/quickwidgets/qquickwidget.cpp

Simple merge
Simple merge
@@@ -95,6 -95,13 +95,13 @@@ Heap::ArrayBuffer::ArrayBuffer(Executio
      memset(data->data(), 0, length + 1);
  }
  
 -    : Heap::Object(e->emptyClass, e->arrayBufferPrototype.asObject())
+ Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, const QByteArray& array)
++    : Heap::Object(e->emptyClass, e->arrayBufferPrototype.as<QV4::Object>())
+     , data(const_cast<QByteArray&>(array).data_ptr())
+ {
+     data->ref.ref();
+ }
  Heap::ArrayBuffer::~ArrayBuffer()
  {
      if (!data->ref.deref())
Simple merge
Simple merge
@@@ -305,9 -305,13 +305,13 @@@ ExecutionEngine::ExecutionEngine(EvalIS
      uint index;
      InternalClass *functionProtoClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable, &index);
      Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
 -    functionPrototype = memoryManager->alloc<FunctionPrototype>(functionProtoClass, objectPrototype.asObject());
 +    functionPrototype = memoryManager->alloc<FunctionPrototype>(functionProtoClass, objectPrototype.as<Object>());
      functionClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
      Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
+     simpleScriptFunctionClass = functionClass->addMember(id_name, Attr_ReadOnly, &index);
+     Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Name);
+     simpleScriptFunctionClass = simpleScriptFunctionClass->addMember(id_length, Attr_ReadOnly, &index);
+     Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Length);
      protoClass = emptyClass->addMember(id_constructor, Attr_NotEnumerable, &index);
      Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor);
  
Simple merge
Simple merge
@@@ -63,8 -63,9 +63,9 @@@ using namespace QV4
  DEFINE_OBJECT_VTABLE(FunctionObject);
  
  Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto)
 -    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
 +    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
      , scope(scope->d())
+     , function(Q_NULLPTR)
  {
      Scope s(scope->engine());
      ScopedFunctionObject f(s, this);
@@@ -72,8 -73,9 +73,9 @@@
  }
  
  Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *function, bool createProto)
 -    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
 +    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
      , scope(scope->d())
+     , function(Q_NULLPTR)
  {
      Scope s(scope->engine());
      ScopedString name(s, function->name());
@@@ -82,8 -84,9 +84,9 @@@
  }
  
  Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString &name, bool createProto)
 -    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
 +    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
      , scope(scope->d())
+     , function(Q_NULLPTR)
  {
      Scope s(scope->engine());
      ScopedFunctionObject f(s, this);
@@@ -92,8 -95,9 +95,9 @@@
  }
  
  Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
 -    : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.asObject())
 +    : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.objectValue())
      , scope(scope)
+     , function(Q_NULLPTR)
  {
      Scope s(scope->engine);
      ScopedFunctionObject f(s, this);
  }
  
  Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name)
 -    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.asObject())
 +    : Heap::Object(scope->d()->engine->functionClass, scope->d()->engine->functionPrototype.objectValue())
      , scope(scope->d())
+     , function(Q_NULLPTR)
  {
      Scope s(scope);
      ScopedFunctionObject f(s, this);
  }
  
  Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
 -    : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.asObject())
 +    : Heap::Object(scope->engine->functionClass, scope->engine->functionPrototype.objectValue())
      , scope(scope)
+     , function(Q_NULLPTR)
  {
      Scope s(scope->engine);
      ScopedFunctionObject f(s, this);
@@@ -446,8 -466,10 +465,10 @@@ ReturnedValue ScriptFunction::call(cons
  DEFINE_OBJECT_VTABLE(SimpleScriptFunction);
  
  Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto)
-     : Heap::FunctionObject(scope, function, createProto)
 -    : Heap::FunctionObject(function->compilationUnit->engine->simpleScriptFunctionClass, function->compilationUnit->engine->functionPrototype.asObject())
++    : Heap::FunctionObject(function->compilationUnit->engine->simpleScriptFunctionClass, function->compilationUnit->engine->functionPrototype.as<QV4::Object>())
  {
+     this->scope = scope->d();
      this->function = function;
      function->compilationUnit->addref();
      Q_ASSERT(function);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -248,9 -259,39 +259,39 @@@ bool QQmlValueTypeWrapper::isEqual(cons
      return (value == d()->toVariant());
  }
  
+ int QQmlValueTypeWrapper::typeId() const
+ {
+     return d()->valueType->typeId;
+ }
+ bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
+ {
+     bool destructGadgetOnExit = false;
+     if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>()) {
+         if (!d()->gadgetPtr) {
+             d()->gadgetPtr = alloca(d()->valueType->metaType.sizeOf());
+             d()->valueType->metaType.construct(d()->gadgetPtr, 0);
+             destructGadgetOnExit = true;
+         }
+         if (!ref->readReferenceValue())
+             return false;
+     }
+     int flags = 0;
+     int status = -1;
+     void *a[] = { d()->gadgetPtr, 0, &status, &flags };
+     QMetaObject::metacall(target, QMetaObject::WriteProperty, propertyIndex, a);
+     if (destructGadgetOnExit) {
+         d()->valueType->metaType.destruct(d()->gadgetPtr);
+         d()->gadgetPtr = 0;
+     }
+     return true;
+ }
  ReturnedValue QQmlValueTypeWrapper::method_toString(CallContext *ctx)
  {
 -    Object *o = ctx->thisObject().asObject();
 +    Object *o = ctx->thisObject().as<Object>();
      if (!o)
          return ctx->engine()->throwTypeError();
      QQmlValueTypeWrapper *w = o->as<QQmlValueTypeWrapper>();
@@@ -84,10 -84,12 +84,12 @@@ public
      static ReturnedValue create(ExecutionEngine *engine, const QVariant &, const QMetaObject *metaObject, int typeId);
  
      QVariant toVariant() const;
-     void toGadget(void *data) const;
+     bool toGadget(void *data) const;
      bool isEqual(const QVariant& value);
+     int typeId() const;
+     bool write(QObject *target, int propertyIndex) const;
  
 -    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
 +    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
      static void put(Managed *m, String *name, const Value &value);
      static bool isEqualTo(Managed *m, Managed *other);
      static PropertyAttributes query(const Managed *, String *name);
Simple merge