From fb16ab4badfd86bdfb4a9eccc92d77f7167ae8ab Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 13 Jun 2013 13:45:23 +0200 Subject: [PATCH] Port the QVariant wrapper away from v4classgen Replaced with four new lines of code :) Change-Id: Ie48608d332f8eb0c5ab6615aa62e5865d307c7bd Reviewed-by: Lars Knoll --- src/qml/qml/v4/qv4engine.cpp | 2 +- src/qml/qml/v4/qv4variantobject.cpp | 10 ++++++++-- src/qml/qml/v4/qv4variantobject_p.h | 4 ++-- src/qml/qml/v4/v4.pri | 3 +-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/qml/qml/v4/qv4engine.cpp b/src/qml/qml/v4/qv4engine.cpp index 20a65a8..c0119a7 100644 --- a/src/qml/qml/v4/qv4engine.cpp +++ b/src/qml/qml/v4/qv4engine.cpp @@ -224,7 +224,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) typeErrorPrototype->init(this, typeErrorCtor); uRIErrorPrototype->init(this, uRIErrorCtor); - variantPrototype->initClass(this); + variantPrototype->init(this); sequencePrototype->init(this); // diff --git a/src/qml/qml/v4/qv4variantobject.cpp b/src/qml/qml/v4/qv4variantobject.cpp index 733f289..4841008 100644 --- a/src/qml/qml/v4/qv4variantobject.cpp +++ b/src/qml/qml/v4/qv4variantobject.cpp @@ -138,6 +138,14 @@ VariantPrototype::VariantPrototype(ExecutionEngine *engine) prototype = engine->objectPrototype; } +void VariantPrototype::init(ExecutionEngine *engine) +{ + defineDefaultProperty(engine, QStringLiteral("preserve"), method_preserve, 0); + defineDefaultProperty(engine, QStringLiteral("destroy"), method_destroy, 0); + defineDefaultProperty(engine, QStringLiteral("valueOf"), method_valueOf, 0); + defineDefaultProperty(engine, QStringLiteral("toString"), method_toString, 0); +} + QV4::Value VariantPrototype::method_preserve(SimpleCallContext *ctx) { VariantObject *o = ctx->thisObject.as(); @@ -192,6 +200,4 @@ QV4::Value VariantPrototype::method_valueOf(SimpleCallContext *ctx) return ctx->thisObject; } -#include "qv4variantobject_p_jsclass.cpp" - QT_END_NAMESPACE diff --git a/src/qml/qml/v4/qv4variantobject_p.h b/src/qml/qml/v4/qv4variantobject_p.h index 74aff80..876539a 100644 --- a/src/qml/qml/v4/qv4variantobject_p.h +++ b/src/qml/qml/v4/qv4variantobject_p.h @@ -81,12 +81,12 @@ public: static bool isEqualTo(Managed *m, Managed *other); }; -struct QV4_JS_CLASS(VariantPrototype) : VariantObject +struct VariantPrototype : VariantObject { public: VariantPrototype(ExecutionEngine *engine); - void initClass(ExecutionEngine *engine); + void init(ExecutionEngine *engine); static Value method_preserve(SimpleCallContext *ctx); static Value method_destroy(SimpleCallContext *ctx); diff --git a/src/qml/qml/v4/v4.pri b/src/qml/qml/v4/v4.pri index 942c445..28910f4 100644 --- a/src/qml/qml/v4/v4.pri +++ b/src/qml/qml/v4/v4.pri @@ -110,8 +110,7 @@ HEADERS += \ OTHER_FILES += \ $$PWD/v4classgen -JS_CLASS_SOURCES += $$PWD/qv4dateobject_p.h \ - $$PWD/qv4variantobject_p.h +JS_CLASS_SOURCES += $$PWD/qv4dateobject_p.h js_class_bindings.output = ${QMAKE_FILE_BASE}_jsclass.cpp js_class_bindings.input = JS_CLASS_SOURCES -- 2.7.4