arrayCtor = Value::fromObject(new (memoryManager) ArrayCtor(rootContext));
functionCtor = Value::fromObject(new (memoryManager) FunctionCtor(rootContext));
dateCtor = Value::fromObject(DatePrototype::newConstructor(rootContext));
- regExpCtor = Value::fromObject(RegExpPrototype::newConstructor(rootContext));
+ regExpCtor = Value::fromObject(new (memoryManager) RegExpCtor(rootContext));
errorCtor = Value::fromObject(new (memoryManager) ErrorCtor(rootContext));
evalErrorCtor = Value::fromObject(new (memoryManager) EvalErrorCtor(rootContext));
rangeErrorCtor = Value::fromObject(new (memoryManager) RangeErrorCtor(rootContext));
arrayPrototype->init(rootContext, arrayCtor);
datePrototype->init(rootContext, dateCtor);
functionPrototype->init(rootContext, functionCtor);
- regExpPrototype->initClass(this, regExpCtor);
+ regExpPrototype->init(rootContext, regExpCtor);
errorPrototype->init(this, errorCtor);
evalErrorPrototype->init(this, evalErrorCtor);
rangeErrorPrototype->init(this, rangeErrorCtor);
return f;
}
-Value RegExpPrototype::ctor_method_construct(Managed *, ExecutionContext *ctx, Value *argv, int argc)
+DEFINE_MANAGED_VTABLE(RegExpCtor);
+
+RegExpCtor::RegExpCtor(ExecutionContext *scope)
+ : FunctionObject(scope, scope->engine->newIdentifier(QStringLiteral("RegExp")))
+{
+ vtbl = &static_vtbl;
+}
+
+Value RegExpCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc)
{
Value r = argc > 0 ? argv[0] : Value::undefinedValue();
Value f = argc > 1 ? argv[1] : Value::undefinedValue();
return Value::fromObject(o);
}
-Value RegExpPrototype::ctor_method_call(Managed *that, ExecutionContext *ctx, const Value &thisObject, Value *argv, int argc)
+Value RegExpCtor::call(Managed *that, ExecutionContext *ctx, const Value &thisObject, Value *argv, int argc)
{
if (argc > 0 && argv[0].as<RegExpObject>()) {
if (argc == 1 || argv[1].isUndefined())
return argv[0];
}
- return ctor_method_construct(that, ctx, argv, argc);
+ return construct(that, ctx, argv, argc);
+}
+
+void RegExpPrototype::init(ExecutionContext *ctx, const Value &ctor)
+{
+ ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this));
+ ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_length, Value::fromInt32(2));
+ defineDefaultProperty(ctx, QStringLiteral("constructor"), ctor);
+ defineDefaultProperty(ctx, QStringLiteral("exec"), method_exec, 1);
+ defineDefaultProperty(ctx, QStringLiteral("test"), method_test, 1);
+ defineDefaultProperty(ctx, QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(ctx, QStringLiteral("compile"), method_compile, 2);
}
Value RegExpPrototype::method_exec(SimpleCallContext *ctx)
return Value::undefinedValue();
}
-#include "qv4regexpobject_p_jsclass.cpp"
static void markObjects(Managed *that);
};
-struct QV4_JS_CLASS(RegExpPrototype): RegExpObject
+
+struct RegExpCtor: FunctionObject
{
- QV4_ANNOTATE(argc 2)
- RegExpPrototype(ExecutionEngine* engine): RegExpObject(engine, RegExp::create(engine, QString()), false) {}
- void initClass(ExecutionEngine *engine, const Value &ctor);
- static Object *newConstructor(ExecutionContext *scope);
+ RegExpCtor(ExecutionContext *scope);
+
+ static Value construct(Managed *that, 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 *that, ExecutionContext *context, Value *args, int argc);
- static Value ctor_method_call(Managed *that, ExecutionContext *, const Value &, Value *, int);
+struct RegExpPrototype: RegExpObject
+{
+ RegExpPrototype(ExecutionEngine* engine): RegExpObject(engine, RegExp::create(engine, QString()), false) {}
+ void init(ExecutionContext *ctx, const Value &ctor);
- static Value method_exec(SimpleCallContext *ctx) QV4_ARGC(1);
- static Value method_test(SimpleCallContext *ctx) QV4_ARGC(1);
+ static Value method_exec(SimpleCallContext *ctx);
+ static Value method_test(SimpleCallContext *ctx);
static Value method_toString(SimpleCallContext *ctx);
- static Value method_compile(SimpleCallContext *ctx) QV4_ARGC(2);
+ static Value method_compile(SimpleCallContext *ctx);
};
}
JS_CLASS_SOURCES += $$PWD/qv4dateobject_p.h \
$$PWD/qv4stringobject_p.h \
$$PWD/qv4booleanobject_p.h \
- $$PWD/qv4regexpobject_p.h \
$$PWD/qv4variantobject_p.h \
$$PWD/qv4sequenceobject_p.h \
$$PWD/qv4errorobject_p.h