aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r--src/qml/qml/v8/qjsengine.h4
-rw-r--r--src/qml/qml/v8/qjsvalue.h4
-rw-r--r--src/qml/qml/v8/qjsvalueiterator.h4
-rw-r--r--src/qml/qml/v8/qv8bindings_p.h4
-rw-r--r--src/qml/qml/v8/qv8domerrors_p.h4
-rw-r--r--src/qml/qml/v8/qv8engine.cpp17
-rw-r--r--src/qml/qml/v8/qv8engine_p.h14
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp6
-rw-r--r--src/qml/qml/v8/qv8sqlerrors_p.h4
-rw-r--r--src/qml/qml/v8/qv8worker.cpp12
10 files changed, 33 insertions, 40 deletions
diff --git a/src/qml/qml/v8/qjsengine.h b/src/qml/qml/v8/qjsengine.h
index 23ee289d6c..0a575f84e9 100644
--- a/src/qml/qml/v8/qjsengine.h
+++ b/src/qml/qml/v8/qjsengine.h
@@ -49,8 +49,6 @@
#include <QtCore/qobject.h>
#include <QtQml/qjsvalue.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -137,6 +135,4 @@ inline QVariant qjsvalue_cast<QVariant>(const QJSValue &value)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QJSENGINE_H
diff --git a/src/qml/qml/v8/qjsvalue.h b/src/qml/qml/v8/qjsvalue.h
index 0a57e3533e..efd52ce880 100644
--- a/src/qml/qml/v8/qjsvalue.h
+++ b/src/qml/qml/v8/qjsvalue.h
@@ -48,8 +48,6 @@
#include <QtCore/qsharedpointer.h>
#include <QtCore/qshareddata.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -157,6 +155,4 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QJSValue)
-QT_END_HEADER
-
#endif
diff --git a/src/qml/qml/v8/qjsvalueiterator.h b/src/qml/qml/v8/qjsvalueiterator.h
index e9a67738ab..b4f90a44b7 100644
--- a/src/qml/qml/v8/qjsvalueiterator.h
+++ b/src/qml/qml/v8/qjsvalueiterator.h
@@ -46,8 +46,6 @@
#include <QtQml/qjsvalue.h>
#include <QtCore/qscopedpointer.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -77,6 +75,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSCRIPTVALUEITERATOR_H
diff --git a/src/qml/qml/v8/qv8bindings_p.h b/src/qml/qml/v8/qv8bindings_p.h
index f3e62faa3b..98b367ac72 100644
--- a/src/qml/qml/v8/qv8bindings_p.h
+++ b/src/qml/qml/v8/qv8bindings_p.h
@@ -61,8 +61,6 @@
#include <private/qflagpointer_p.h>
#include <private/qqmlbinding_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QQmlCompiledData;
@@ -158,8 +156,6 @@ void QV8Bindings::release()
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QV8BINDINGS_P_H
diff --git a/src/qml/qml/v8/qv8domerrors_p.h b/src/qml/qml/v8/qv8domerrors_p.h
index 0542863c32..8fd1ccb6d6 100644
--- a/src/qml/qml/v8/qv8domerrors_p.h
+++ b/src/qml/qml/v8/qv8domerrors_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
// From DOM-Level-3-Core spec
// http://www.w3.org/TR/DOM-Level-3-Core/core.html
@@ -89,6 +87,4 @@ void qt_add_domexceptions(QV8Engine *engine);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QV8DOMERRORS_P_H
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index 2619c1a484..2f14b62618 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -54,6 +54,7 @@
#include <private/qqmllocale_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qqmlmemoryprofiler_p.h>
+#include <private/qqmlplatform_p.h>
#include "qscript_impl_p.h"
#include "qv8domerrors_p.h"
@@ -125,6 +126,7 @@ QV8Engine::QV8Engine(QJSEngine* qq, ContextOwnership ownership)
, m_ownsV8Context(ownership == CreateNewContext)
, m_xmlHttpRequestData(0)
, m_listModelData(0)
+ , m_platform(0)
, m_application(0)
{
QML_MEMORY_SCOPE_STRING("QV8Engine::QV8Engine");
@@ -629,6 +631,7 @@ void QV8Engine::initializeGlobal(v8::Handle<v8::Object> global)
qt->Set(v8::String::New("binding"), V8FUNCTION(binding, this));
if (m_engine) {
+ qt->SetAccessor(v8::String::New("platform"), getPlatform, 0, v8::External::New(this));
qt->SetAccessor(v8::String::New("application"), getApplication, 0, v8::External::New(this));
#ifndef QT_NO_IM
qt->SetAccessor(v8::String::New("inputMethod"), getInputMethod, 0, v8::External::New(this));
@@ -1446,9 +1449,19 @@ int QV8Engine::consoleCountHelper(const QString &file, quint16 line, quint16 col
return number;
}
+v8::Handle<v8::Value> QV8Engine::getPlatform(v8::Local<v8::String>, const v8::AccessorInfo &info)
+{
+ QV8Engine *engine = reinterpret_cast<QV8Engine*>(v8::External::Cast(*info.Data())->Value());
+ if (!engine->m_platform) {
+ // Only allocate a platform object once
+ engine->m_platform = new QQmlPlatform(engine->m_engine);
+ }
+ return engine->newQObject(engine->m_platform);
+}
+
v8::Handle<v8::Value> QV8Engine::getApplication(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
- QV8Engine *engine = reinterpret_cast<QV8Engine*>(v8::External::Unwrap(info.Data()));
+ QV8Engine *engine = reinterpret_cast<QV8Engine*>(v8::External::Cast(*info.Data())->Value());
if (!engine->m_application) {
// Only allocate an application object once
engine->m_application = QQml_guiProvider()->application(engine->m_engine);
@@ -1459,7 +1472,7 @@ v8::Handle<v8::Value> QV8Engine::getApplication(v8::Local<v8::String>, const v8:
#ifndef QT_NO_IM
v8::Handle<v8::Value> QV8Engine::getInputMethod(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
- QV8Engine *engine = reinterpret_cast<QV8Engine*>(v8::External::Unwrap(info.Data()));
+ QV8Engine *engine = reinterpret_cast<QV8Engine*>(v8::External::Cast(*info.Data())->Value());
return engine->newQObject(QQml_guiProvider()->inputMethod(), CppOwnership);
}
#endif
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 43c978c757..5ae0963178 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE
// a handle, qFatal() is called.
// #define QML_GLOBAL_HANDLE_DEBUGGING
-#define V8ENGINE() ((QV8Engine *)v8::External::Unwrap(args.Data()))
-#define V8FUNCTION(function, engine) v8::FunctionTemplate::New(function, v8::External::Wrap((QV8Engine*)engine))->GetFunction()
+#define V8ENGINE() ((QV8Engine *)v8::External::Cast(*args.Data())->Value())
+#define V8FUNCTION(function, engine) v8::FunctionTemplate::New(function, v8::External::New((QV8Engine*)engine))->GetFunction()
#define V8THROW_ERROR(string) { \
v8::ThrowException(v8::Exception::Error(v8::String::New(string))); \
return v8::Handle<v8::Value>(); \
@@ -112,7 +112,7 @@ QT_BEGIN_NAMESPACE
v8::ThrowException(v8::Exception::TypeError(v8::String::New(string))); \
return v8::Handle<v8::Value>(); \
}
-#define V8ENGINE_ACCESSOR() ((QV8Engine *)v8::External::Unwrap(info.Data()));
+#define V8ENGINE_ACCESSOR() ((QV8Engine *)v8::External::Cast(*info.Data())->Value());
#define V8THROW_ERROR_SETTER(string) { \
v8::ThrowException(v8::Exception::Error(v8::String::New(string))); \
return; \
@@ -427,6 +427,7 @@ public:
void addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle);
void addRelationshipForGC(QObject *object, QObject *other);
+ static v8::Handle<v8::Value> getPlatform(v8::Local<v8::String> property, const v8::AccessorInfo &info);
static v8::Handle<v8::Value> getApplication(v8::Local<v8::String> property, const v8::AccessorInfo &info);
#ifndef QT_NO_IM
static v8::Handle<v8::Value> getInputMethod(v8::Local<v8::String> property, const v8::AccessorInfo &info);
@@ -480,6 +481,7 @@ protected:
QHash<QString, quint32> m_consoleCount;
+ QObject *m_platform;
QObject *m_application;
QVariant toBasicVariant(v8::Handle<v8::Value>);
@@ -627,8 +629,10 @@ v8::Handle<v8::String> QV8Engine::bindingFlagKey() const
// unqualified name in QV8ContextWrapper.
bool QV8Engine::startsWithUpper(v8::Handle<v8::String> string)
{
- uint16_t c = string->GetCharacter(0);
- return (c >= 'A' && c <= 'Z') ||
+ v8::String::Value value(string);
+ Q_ASSERT(*value != NULL);
+ uint16_t c = **value;
+ return (c >= 'A' && c <= 'Z') ||
(c > 127 && QChar::category(c) == QChar::Letter_Uppercase);
}
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index 4539401a3b..0982f177d3 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -277,7 +277,7 @@ static v8::Handle<v8::Value> GenericValueGetter(v8::Local<v8::String>, const v8:
if (QQmlData::wasDeleted(object)) return v8::Undefined();
QQmlPropertyData *property =
- (QQmlPropertyData *)v8::External::Unwrap(info.Data());
+ (QQmlPropertyData *)v8::External::Cast(*info.Data())->Value();
QQmlEngine *engine = resource->engine->engine();
QQmlEnginePrivate *ep = engine?QQmlEnginePrivate::get(engine):0;
@@ -894,7 +894,7 @@ static void FastValueSetter(v8::Local<v8::String>, v8::Local<v8::Value> value,
QObject *object = resource->object;
QQmlPropertyData *property =
- (QQmlPropertyData *)v8::External::Unwrap(info.Data());
+ (QQmlPropertyData *)v8::External::Cast(*info.Data())->Value();
int index = property->coreIndex;
@@ -1029,7 +1029,7 @@ v8::Local<v8::Object> QQmlPropertyCache::newQObject(QObject *object, QV8Engine *
// this type and the property accessor checks if the object is 0 (deleted) before
// dereferencing the pointer.
ft->InstanceTemplate()->SetAccessor(engine->toString(iter.key()), fastgetter, fastsetter,
- v8::External::Wrap(property));
+ v8::External::New(property));
}
}
diff --git a/src/qml/qml/v8/qv8sqlerrors_p.h b/src/qml/qml/v8/qv8sqlerrors_p.h
index b2ffbf9233..8a612d69ab 100644
--- a/src/qml/qml/v8/qv8sqlerrors_p.h
+++ b/src/qml/qml/v8/qv8sqlerrors_p.h
@@ -55,8 +55,6 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#define SQLEXCEPTION_UNKNOWN_ERR 1
#define SQLEXCEPTION_DATABASE_ERR 2
@@ -72,6 +70,4 @@ void qt_add_sqlexceptions(QV8Engine *engine);
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QV8SQLERRORS_P_H
diff --git a/src/qml/qml/v8/qv8worker.cpp b/src/qml/qml/v8/qv8worker.cpp
index bf3379b312..9556e146ef 100644
--- a/src/qml/qml/v8/qv8worker.cpp
+++ b/src/qml/qml/v8/qv8worker.cpp
@@ -41,8 +41,8 @@
#include "qv8worker_p.h"
-#include <private/qquicklistmodel_p.h>
-#include <private/qquicklistmodelworkeragent_p.h>
+#include <private/qqmllistmodel_p.h>
+#include <private/qqmllistmodelworkeragent_p.h>
QT_BEGIN_NAMESPACE
@@ -242,9 +242,9 @@ void QV8Worker::serialize(QByteArray &data, v8::Handle<v8::Value> v, QV8Engine *
} else if (engine->isQObject(v)) {
// XXX TODO: Generalize passing objects between the main thread and worker scripts so
// that others can trivially plug in their elements.
- QQuickListModel *lm = qobject_cast<QQuickListModel *>(engine->toQObject(v));
+ QQmlListModel *lm = qobject_cast<QQmlListModel *>(engine->toQObject(v));
if (lm && lm->agent()) {
- QQuickListModelWorkerAgent *agent = lm->agent();
+ QQmlListModelWorkerAgent *agent = lm->agent();
agent->addref();
push(data, valueheader(WorkerListModel));
push(data, (void *)agent);
@@ -347,10 +347,10 @@ v8::Handle<v8::Value> QV8Worker::deserialize(const char *&data, QV8Engine *engin
case WorkerListModel:
{
void *ptr = popPtr(data);
- QQuickListModelWorkerAgent *agent = (QQuickListModelWorkerAgent *)ptr;
+ QQmlListModelWorkerAgent *agent = (QQmlListModelWorkerAgent *)ptr;
v8::Handle<v8::Value> rv = engine->newQObject(agent);
if (rv->IsObject()) {
- QQuickListModelWorkerAgent::VariantRef ref(agent);
+ QQmlListModelWorkerAgent::VariantRef ref(agent);
QVariant var = qVariantFromValue(ref);
rv->ToObject()->SetHiddenValue(v8::String::New("qml::ref"), engine->fromVariant(var));
}