diff options
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject_p.h | 14 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 110 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 41 |
4 files changed, 90 insertions, 79 deletions
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 8424fd6935..fd20a628cf 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -338,10 +338,10 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok) DEFINE_OBJECT_VTABLE(EvalFunction); -EvalFunction::Data::Data(ExecutionContext *scope) +Heap::EvalFunction::EvalFunction(QV4::ExecutionContext *scope) : Heap::FunctionObject(scope, scope->d()->engine->id_eval) { - setVTable(staticVTable()); + setVTable(QV4::EvalFunction::staticVTable()); Scope s(scope); ScopedFunctionObject f(s, this); f->defineReadonlyProperty(s.engine->id_length, Primitive::fromInt32(1)); diff --git a/src/qml/jsruntime/qv4globalobject_p.h b/src/qml/jsruntime/qv4globalobject_p.h index b14364b127..176ae37300 100644 --- a/src/qml/jsruntime/qv4globalobject_p.h +++ b/src/qml/jsruntime/qv4globalobject_p.h @@ -40,13 +40,17 @@ QT_BEGIN_NAMESPACE namespace QV4 { +namespace Heap { + +struct EvalFunction : FunctionObject { + EvalFunction(QV4::ExecutionContext *scope); +}; + +} + struct Q_QML_EXPORT EvalFunction : FunctionObject { - struct Data : Heap::FunctionObject { - Data(ExecutionContext *scope); - }; - - V4_OBJECT(FunctionObject) + V4_OBJECT2(EvalFunction, FunctionObject) ReturnedValue evalCall(CallData *callData, bool directCall); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index fa076073d8..efcd557409 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -78,10 +78,10 @@ struct StaticQtMetaObject : public QObject { return &staticQtMetaObject; } }; -QV4::QtObject::Data::Data(ExecutionEngine *v4, QQmlEngine *qmlEngine) +Heap::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine) : Heap::Object(v4) { - setVTable(staticVTable()); + setVTable(QV4::QtObject::staticVTable()); Scope scope(v4); ScopedObject o(scope, this); @@ -100,47 +100,47 @@ QV4::QtObject::Data::Data(ExecutionEngine *v4, QQmlEngine *qmlEngine) o->put((str = v4->newString(QStringLiteral("Synchronous"))).getPointer(), (v = QV4::Primitive::fromInt32(1))); o->defineDefaultProperty(QStringLiteral("include"), QV4Include::method_include); - o->defineDefaultProperty(QStringLiteral("isQtObject"), method_isQtObject); - o->defineDefaultProperty(QStringLiteral("rgba"), method_rgba); - o->defineDefaultProperty(QStringLiteral("hsla"), method_hsla); - o->defineDefaultProperty(QStringLiteral("colorEqual"), method_colorEqual); - o->defineDefaultProperty(QStringLiteral("rect"), method_rect); - o->defineDefaultProperty(QStringLiteral("point"), method_point); - o->defineDefaultProperty(QStringLiteral("size"), method_size); - o->defineDefaultProperty(QStringLiteral("font"), method_font); - - o->defineDefaultProperty(QStringLiteral("vector2d"), method_vector2d); - o->defineDefaultProperty(QStringLiteral("vector3d"), method_vector3d); - o->defineDefaultProperty(QStringLiteral("vector4d"), method_vector4d); - o->defineDefaultProperty(QStringLiteral("quaternion"), method_quaternion); - o->defineDefaultProperty(QStringLiteral("matrix4x4"), method_matrix4x4); - - o->defineDefaultProperty(QStringLiteral("formatDate"), method_formatDate); - o->defineDefaultProperty(QStringLiteral("formatTime"), method_formatTime); - o->defineDefaultProperty(QStringLiteral("formatDateTime"), method_formatDateTime); - - o->defineDefaultProperty(QStringLiteral("openUrlExternally"), method_openUrlExternally); - o->defineDefaultProperty(QStringLiteral("fontFamilies"), method_fontFamilies); - o->defineDefaultProperty(QStringLiteral("md5"), method_md5); - o->defineDefaultProperty(QStringLiteral("btoa"), method_btoa); - o->defineDefaultProperty(QStringLiteral("atob"), method_atob); - o->defineDefaultProperty(QStringLiteral("resolvedUrl"), method_resolvedUrl); - o->defineDefaultProperty(QStringLiteral("locale"), method_locale); - o->defineDefaultProperty(QStringLiteral("binding"), method_binding); + o->defineDefaultProperty(QStringLiteral("isQtObject"), QV4::QtObject::method_isQtObject); + o->defineDefaultProperty(QStringLiteral("rgba"), QV4::QtObject::method_rgba); + o->defineDefaultProperty(QStringLiteral("hsla"), QV4::QtObject::method_hsla); + o->defineDefaultProperty(QStringLiteral("colorEqual"), QV4::QtObject::method_colorEqual); + o->defineDefaultProperty(QStringLiteral("rect"), QV4::QtObject::method_rect); + o->defineDefaultProperty(QStringLiteral("point"), QV4::QtObject::method_point); + o->defineDefaultProperty(QStringLiteral("size"), QV4::QtObject::method_size); + o->defineDefaultProperty(QStringLiteral("font"), QV4::QtObject::method_font); + + o->defineDefaultProperty(QStringLiteral("vector2d"), QV4::QtObject::method_vector2d); + o->defineDefaultProperty(QStringLiteral("vector3d"), QV4::QtObject::method_vector3d); + o->defineDefaultProperty(QStringLiteral("vector4d"), QV4::QtObject::method_vector4d); + o->defineDefaultProperty(QStringLiteral("quaternion"), QV4::QtObject::method_quaternion); + o->defineDefaultProperty(QStringLiteral("matrix4x4"), QV4::QtObject::method_matrix4x4); + + o->defineDefaultProperty(QStringLiteral("formatDate"), QV4::QtObject::method_formatDate); + o->defineDefaultProperty(QStringLiteral("formatTime"), QV4::QtObject::method_formatTime); + o->defineDefaultProperty(QStringLiteral("formatDateTime"), QV4::QtObject::method_formatDateTime); + + o->defineDefaultProperty(QStringLiteral("openUrlExternally"), QV4::QtObject::method_openUrlExternally); + o->defineDefaultProperty(QStringLiteral("fontFamilies"), QV4::QtObject::method_fontFamilies); + o->defineDefaultProperty(QStringLiteral("md5"), QV4::QtObject::method_md5); + o->defineDefaultProperty(QStringLiteral("btoa"), QV4::QtObject::method_btoa); + o->defineDefaultProperty(QStringLiteral("atob"), QV4::QtObject::method_atob); + o->defineDefaultProperty(QStringLiteral("resolvedUrl"), QV4::QtObject::method_resolvedUrl); + o->defineDefaultProperty(QStringLiteral("locale"), QV4::QtObject::method_locale); + o->defineDefaultProperty(QStringLiteral("binding"), QV4::QtObject::method_binding); if (qmlEngine) { - o->defineDefaultProperty(QStringLiteral("lighter"), method_lighter); - o->defineDefaultProperty(QStringLiteral("darker"), method_darker); - o->defineDefaultProperty(QStringLiteral("tint"), method_tint); - o->defineDefaultProperty(QStringLiteral("quit"), method_quit); - o->defineDefaultProperty(QStringLiteral("createQmlObject"), method_createQmlObject); - o->defineDefaultProperty(QStringLiteral("createComponent"), method_createComponent); + o->defineDefaultProperty(QStringLiteral("lighter"), QV4::QtObject::method_lighter); + o->defineDefaultProperty(QStringLiteral("darker"), QV4::QtObject::method_darker); + o->defineDefaultProperty(QStringLiteral("tint"), QV4::QtObject::method_tint); + o->defineDefaultProperty(QStringLiteral("quit"), QV4::QtObject::method_quit); + o->defineDefaultProperty(QStringLiteral("createQmlObject"), QV4::QtObject::method_createQmlObject); + o->defineDefaultProperty(QStringLiteral("createComponent"), QV4::QtObject::method_createComponent); } - o->defineAccessorProperty(QStringLiteral("platform"), method_get_platform, 0); - o->defineAccessorProperty(QStringLiteral("application"), method_get_application, 0); + o->defineAccessorProperty(QStringLiteral("platform"), QV4::QtObject::method_get_platform, 0); + o->defineAccessorProperty(QStringLiteral("application"), QV4::QtObject::method_get_application, 0); #ifndef QT_NO_IM - o->defineAccessorProperty(QStringLiteral("inputMethod"), method_get_inputMethod, 0); + o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, 0); #endif } @@ -1166,11 +1166,11 @@ ReturnedValue QtObject::method_locale(CallContext *ctx) return QQmlLocale::locale(v8engine, code); } -QQmlBindingFunction::Data::Data(QV4::FunctionObject *originalFunction) +Heap::QQmlBindingFunction::QQmlBindingFunction(QV4::FunctionObject *originalFunction) : QV4::Heap::FunctionObject(originalFunction->scope(), originalFunction->name()) , originalFunction(originalFunction) { - setVTable(staticVTable()); + setVTable(QV4::QQmlBindingFunction::staticVTable()); bindingKeyFlag = true; } @@ -1296,26 +1296,26 @@ ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx) #endif -QV4::ConsoleObject::Data::Data(ExecutionEngine *v4) +QV4::Heap::ConsoleObject::ConsoleObject(ExecutionEngine *v4) : Heap::Object(v4) { QV4::Scope scope(v4); QV4::ScopedObject o(scope, this); - o->defineDefaultProperty(QStringLiteral("debug"), method_log); - o->defineDefaultProperty(QStringLiteral("log"), method_log); - o->defineDefaultProperty(QStringLiteral("info"), method_log); - o->defineDefaultProperty(QStringLiteral("warn"), method_warn); - o->defineDefaultProperty(QStringLiteral("error"), method_error); - o->defineDefaultProperty(QStringLiteral("assert"), method_assert); - - o->defineDefaultProperty(QStringLiteral("count"), method_count); - o->defineDefaultProperty(QStringLiteral("profile"), method_profile); - o->defineDefaultProperty(QStringLiteral("profileEnd"), method_profileEnd); - o->defineDefaultProperty(QStringLiteral("time"), method_time); - o->defineDefaultProperty(QStringLiteral("timeEnd"), method_timeEnd); - o->defineDefaultProperty(QStringLiteral("trace"), method_trace); - o->defineDefaultProperty(QStringLiteral("exception"), method_exception); + o->defineDefaultProperty(QStringLiteral("debug"), QV4::ConsoleObject::method_log); + o->defineDefaultProperty(QStringLiteral("log"), QV4::ConsoleObject::method_log); + o->defineDefaultProperty(QStringLiteral("info"), QV4::ConsoleObject::method_log); + o->defineDefaultProperty(QStringLiteral("warn"), QV4::ConsoleObject::method_warn); + o->defineDefaultProperty(QStringLiteral("error"), QV4::ConsoleObject::method_error); + o->defineDefaultProperty(QStringLiteral("assert"), QV4::ConsoleObject::method_assert); + + o->defineDefaultProperty(QStringLiteral("count"), QV4::ConsoleObject::method_count); + o->defineDefaultProperty(QStringLiteral("profile"), QV4::ConsoleObject::method_profile); + o->defineDefaultProperty(QStringLiteral("profileEnd"), QV4::ConsoleObject::method_profileEnd); + o->defineDefaultProperty(QStringLiteral("time"), QV4::ConsoleObject::method_time); + o->defineDefaultProperty(QStringLiteral("timeEnd"), QV4::ConsoleObject::method_timeEnd); + o->defineDefaultProperty(QStringLiteral("trace"), QV4::ConsoleObject::method_trace); + o->defineDefaultProperty(QStringLiteral("exception"), QV4::ConsoleObject::method_exception); } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 696cf04397..8379cbc3a0 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -55,15 +55,30 @@ class QV8Engine; namespace QV4 { +namespace Heap { + +struct QtObject : Object { + QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine); + QObject *platform; + QObject *application; +}; + +struct ConsoleObject : Object { + ConsoleObject(ExecutionEngine *engine); +}; + +struct QQmlBindingFunction : FunctionObject { + QQmlBindingFunction(QV4::FunctionObject *originalFunction); + QV4::FunctionObject *originalFunction; + // Set when the binding is created later + QQmlSourceLocation bindingLocation; +}; + +} + struct QtObject : Object { - struct Data : Heap::Object { - Data(ExecutionEngine *v4, QQmlEngine *qmlEngine); - QObject *platform; - QObject *application; - }; - V4_OBJECT(Object) - + V4_OBJECT2(QtObject, Object) static ReturnedValue method_isQtObject(CallContext *ctx); static ReturnedValue method_rgba(CallContext *ctx); @@ -105,9 +120,7 @@ struct QtObject : Object struct ConsoleObject : Object { - struct Data : Heap::Object { - Data(ExecutionEngine *engine); - }; + typedef Heap::ConsoleObject Data; static ReturnedValue method_error(CallContext *ctx); static ReturnedValue method_log(CallContext *ctx); @@ -143,13 +156,7 @@ struct GlobalExtensions { struct QQmlBindingFunction : public QV4::FunctionObject { - struct Data : Heap::FunctionObject { - Data(QV4::FunctionObject *originalFunction); - QV4::FunctionObject *originalFunction; - // Set when the binding is created later - QQmlSourceLocation bindingLocation; - }; - V4_OBJECT(QV4::FunctionObject) + V4_OBJECT2(QQmlBindingFunction, FunctionObject) void initBindingLocation(); // from caller stack trace |