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;
return thisObject->value;
}
-
-#include "qv4booleanobject_p_jsclass.cpp"
**
****************************************************************************/
#ifndef QV4BOOLEANOBJECT_H
-#define QV4BOOLEANOBJECT_H
+#define QBOOLEANOBJECT_H
#include "qv4object_p.h"
#include "qv4functionobject_p.h"
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);
QT_END_NAMESPACE
-#endif // QV4BOOLEANOBJECT_H
+#endif // QV4ECMAOBJECTS_P_H
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));
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);
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