Revert "Ported boolean prototype over to class generator"
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 11:17:20 +0000 (13:17 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 12:14:44 +0000 (14:14 +0200)
This reverts commit b6263687dd876959379022090eb8d43a0dbcdd08.

Conflicts:
src/qml/qml/v4/v4.pri

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

index bee08dc..3395e79 100644 (file)
 
 using namespace QV4;
 
-Value BooleanPrototype::ctor_method_construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
+DEFINE_MANAGED_VTABLE(BooleanCtor);
+
+BooleanCtor::BooleanCtor(ExecutionContext *scope)
+    : FunctionObject(scope, scope->engine->newIdentifier("Boolean"))
+{
+    vtbl = &static_vtbl;
+}
+
+Value BooleanCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
 {
     bool n = argc ? args[0].toBoolean() : false;
     return Value::fromObject(ctx->engine->newBooleanObject(Value::fromBoolean(n)));
 }
 
-Value BooleanPrototype::ctor_method_call(Managed *, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc)
+Value BooleanCtor::call(Managed *, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc)
 {
     bool value = argc ? argv[0].toBoolean() : 0;
     return Value::fromBoolean(value);
 }
 
+void BooleanPrototype::init(ExecutionContext *ctx, const Value &ctor)
+{
+    ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_length, Value::fromInt32(1));
+    ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this));
+    defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor);
+    defineDefaultProperty(ctx, QStringLiteral("toString"), method_toString);
+    defineDefaultProperty(ctx, QStringLiteral("valueOf"), method_valueOf);
+}
+
 Value BooleanPrototype::method_toString(SimpleCallContext *ctx)
 {
     bool result;
@@ -78,5 +95,3 @@ Value BooleanPrototype::method_valueOf(SimpleCallContext *ctx)
 
     return thisObject->value;
 }
-
-#include "qv4booleanobject_p_jsclass.cpp"
index f0baa6e..79f5d4a 100644 (file)
@@ -39,7 +39,7 @@
 **
 ****************************************************************************/
 #ifndef QV4BOOLEANOBJECT_H
-#define QV4BOOLEANOBJECT_H
+#define QBOOLEANOBJECT_H
 
 #include "qv4object_p.h"
 #include "qv4functionobject_p.h"
@@ -49,15 +49,21 @@ QT_BEGIN_NAMESPACE
 
 namespace QV4 {
 
-struct QV4_JS_CLASS(BooleanPrototype): BooleanObject
+struct BooleanCtor: FunctionObject
 {
-    QV4_ANNOTATE(argc 1)
-    BooleanPrototype(ExecutionEngine *engine): BooleanObject(engine, Value::fromBoolean(false)) {}
-    void initClass(ExecutionEngine *engine, const Value &ctor);
-    static Object *newConstructor(ExecutionContext *scope);
+    BooleanCtor(ExecutionContext *scope);
+
+    static Value construct(Managed *, ExecutionContext *context, Value *args, int argc);
+    static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
+
+protected:
+    static const ManagedVTable static_vtbl;
+};
 
-    static Value ctor_method_construct(Managed *, ExecutionContext *context, Value *args, int argc);
-    static Value ctor_method_call(Managed *that, ExecutionContext *, const Value &, Value *, int);
+struct BooleanPrototype: BooleanObject
+{
+    BooleanPrototype(ExecutionEngine *engine): BooleanObject(engine, Value::fromBoolean(false)) {}
+    void init(ExecutionContext *ctx, const Value &ctor);
 
     static Value method_toString(SimpleCallContext *ctx);
     static Value method_valueOf(SimpleCallContext *ctx);
@@ -68,4 +74,4 @@ struct QV4_JS_CLASS(BooleanPrototype): BooleanObject
 
 QT_END_NAMESPACE
 
-#endif // QV4BOOLEANOBJECT_H
+#endif // QV4ECMAOBJECTS_P_H
index 62f7206..91fcdbb 100644 (file)
@@ -179,7 +179,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
     objectCtor = Value::fromObject(new (memoryManager) ObjectCtor(rootContext));
     stringCtor = Value::fromObject(StringPrototype::newConstructor(rootContext));
     numberCtor = Value::fromObject(new (memoryManager) NumberCtor(rootContext));
-    booleanCtor = Value::fromObject(BooleanPrototype::newConstructor(rootContext));
+    booleanCtor = Value::fromObject(new (memoryManager) BooleanCtor(rootContext));
     arrayCtor = Value::fromObject(new (memoryManager) ArrayCtor(rootContext));
     functionCtor = Value::fromObject(new (memoryManager) FunctionCtor(rootContext));
     dateCtor = Value::fromObject(DatePrototype::newConstructor(rootContext));
@@ -211,7 +211,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
     objectPrototype->init(rootContext, objectCtor);
     stringPrototype->initClass(this, stringCtor);
     numberPrototype->init(rootContext, numberCtor);
-    booleanPrototype->initClass(this, booleanCtor);
+    booleanPrototype->init(rootContext, booleanCtor);
     arrayPrototype->init(rootContext, arrayCtor);
     datePrototype->init(rootContext, dateCtor);
     functionPrototype->init(rootContext, functionCtor);
index e5bdc45..670f436 100644 (file)
@@ -112,7 +112,6 @@ OTHER_FILES += \
 
 JS_CLASS_SOURCES += $$PWD/qv4dateobject_p.h \
                     $$PWD/qv4stringobject_p.h \
-                    $$PWD/qv4booleanobject_p.h \
                     $$PWD/qv4variantobject_p.h \
                     $$PWD/qv4sequenceobject_p.h \
                     $$PWD/qv4errorobject_p.h