Port the QVariant wrapper away from v4classgen
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 11:45:23 +0000 (13:45 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 12:16:43 +0000 (14:16 +0200)
Replaced with four new lines of code :)

Change-Id: Ie48608d332f8eb0c5ab6615aa62e5865d307c7bd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4engine.cpp
src/qml/qml/v4/qv4variantobject.cpp
src/qml/qml/v4/qv4variantobject_p.h
src/qml/qml/v4/v4.pri

index 20a65a8..c0119a7 100644 (file)
@@ -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);
 
     //
index 733f289..4841008 100644 (file)
@@ -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<QV4::VariantObject>();
@@ -192,6 +200,4 @@ QV4::Value VariantPrototype::method_valueOf(SimpleCallContext *ctx)
     return ctx->thisObject;
 }
 
-#include "qv4variantobject_p_jsclass.cpp"
-
 QT_END_NAMESPACE
index 74aff80..876539a 100644 (file)
@@ -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);
index 942c445..28910f4 100644 (file)
@@ -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