Convert remaining FunctionObject's to new constructor scheme
authorLars Knoll <lars.knoll@digia.com>
Fri, 9 May 2014 10:15:23 +0000 (12:15 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Tue, 22 Jul 2014 11:49:18 +0000 (13:49 +0200)
Change-Id: I440d5b128d0ee28566ebfa82c2505a4bd97bba6b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
23 files changed:
src/qml/jsruntime/qv4argumentsobject_p.h
src/qml/jsruntime/qv4arrayobject.cpp
src/qml/jsruntime/qv4arrayobject_p.h
src/qml/jsruntime/qv4booleanobject.cpp
src/qml/jsruntime/qv4booleanobject_p.h
src/qml/jsruntime/qv4dateobject.cpp
src/qml/jsruntime/qv4dateobject_p.h
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4errorobject.cpp
src/qml/jsruntime/qv4errorobject_p.h
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4functionobject_p.h
src/qml/jsruntime/qv4globalobject.cpp
src/qml/jsruntime/qv4globalobject_p.h
src/qml/jsruntime/qv4numberobject.cpp
src/qml/jsruntime/qv4numberobject_p.h
src/qml/jsruntime/qv4objectproto.cpp
src/qml/jsruntime/qv4objectproto_p.h
src/qml/jsruntime/qv4regexpobject.cpp
src/qml/jsruntime/qv4regexpobject_p.h
src/qml/jsruntime/qv4stringobject.cpp
src/qml/jsruntime/qv4stringobject_p.h
tools/qmljs/main.cpp

index b32e935..3b03008 100644 (file)
@@ -51,6 +51,12 @@ namespace QV4 {
 struct ArgumentsGetterFunction: FunctionObject
 {
     struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope, uint index)
+            : FunctionObject::Data(scope)
+            , index(index)
+        {
+            setVTable(staticVTable());
+        }
         uint index;
     };
     struct {
@@ -60,19 +66,18 @@ struct ArgumentsGetterFunction: FunctionObject
 
     uint index() const { return d()->index; }
 
-    ArgumentsGetterFunction(ExecutionContext *scope, uint index)
-        : FunctionObject(scope)
-    {
-        d()->index = index;
-        setVTable(staticVTable());
-    }
-
     static ReturnedValue call(Managed *that, CallData *d);
 };
 
 struct ArgumentsSetterFunction: FunctionObject
 {
     struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope, uint index)
+            : FunctionObject::Data(scope)
+            , index(index)
+        {
+            setVTable(staticVTable());
+        }
         uint index;
     };
     struct {
@@ -82,13 +87,6 @@ struct ArgumentsSetterFunction: FunctionObject
 
     uint index() const { return d()->index; }
 
-    ArgumentsSetterFunction(ExecutionContext *scope, uint index)
-        : FunctionObject(scope)
-    {
-        d()->index = index;
-        setVTable(staticVTable());
-    }
-
     static ReturnedValue call(Managed *that, CallData *callData);
 };
 
index 1b0a5bf..6fba53a 100644 (file)
@@ -48,8 +48,8 @@ using namespace QV4;
 
 DEFINE_OBJECT_VTABLE(ArrayCtor);
 
-ArrayCtor::ArrayCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("Array"))
+ArrayCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("Array"))
 {
     setVTable(staticVTable());
 }
index 341b7be..97cffb3 100644 (file)
@@ -51,8 +51,11 @@ namespace QV4 {
 
 struct ArrayCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
+
     V4_OBJECT
-    ArrayCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *callData);
index 305f80a..38a0f7f 100644 (file)
@@ -46,8 +46,8 @@ using namespace QV4;
 DEFINE_OBJECT_VTABLE(BooleanCtor);
 DEFINE_OBJECT_VTABLE(BooleanObject);
 
-BooleanCtor::BooleanCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("Boolean"))
+BooleanCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("Boolean"))
 {
     setVTable(staticVTable());
 }
index 3dc4a3d..3ff0569 100644 (file)
@@ -51,8 +51,11 @@ namespace QV4 {
 
 struct BooleanCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
+
     V4_OBJECT
-    BooleanCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *callData);
index b27d08e..e14523d 100644 (file)
@@ -657,8 +657,8 @@ QDateTime DateObject::toQDateTime() const
 
 DEFINE_OBJECT_VTABLE(DateCtor);
 
-DateCtor::DateCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("Date"))
+DateCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("Date"))
 {
     setVTable(staticVTable());
 }
index 85e85e2..3e8bdc3 100644 (file)
@@ -84,8 +84,10 @@ protected:
 
 struct DateCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    DateCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *);
index 1f7d756..863f4b2 100644 (file)
@@ -295,7 +295,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     uint index;
     functionProtoClass = functionProtoClass->addMember(id_prototype, Attr_NotEnumerable, &index);
     Q_ASSERT(index == FunctionObject::Index_Prototype);
-    FunctionPrototype *functionPrototype = new (memoryManager) FunctionPrototype(functionProtoClass);
+    Scoped<FunctionPrototype> functionPrototype(scope, new (this) FunctionPrototype::Data(functionProtoClass));
     functionClass = InternalClass::create(this, FunctionObject::staticVTable(), functionPrototype);
     functionClass = functionClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
     Q_ASSERT(index == FunctionObject::Index_Prototype);
@@ -331,21 +331,21 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
 
     sequencePrototype = new (memoryManager) SequencePrototype(arrayClass);
 
-    objectCtor = new (memoryManager) ObjectCtor(rootContext);
-    stringCtor = new (memoryManager) StringCtor(rootContext);
-    numberCtor = new (memoryManager) NumberCtor(rootContext);
-    booleanCtor = new (memoryManager) BooleanCtor(rootContext);
-    arrayCtor = new (memoryManager) ArrayCtor(rootContext);
+    objectCtor = static_cast<HeapObject *>(new (this) ObjectCtor::Data(rootContext));
+    stringCtor = static_cast<HeapObject *>(new (this) StringCtor::Data(rootContext));
+    numberCtor = static_cast<HeapObject *>(new (this) NumberCtor::Data(rootContext));
+    booleanCtor = static_cast<HeapObject *>(new (this) BooleanCtor::Data(rootContext));
+    arrayCtor = static_cast<HeapObject *>(new (this) ArrayCtor::Data(rootContext));
     functionCtor = static_cast<HeapObject *>(new (this) FunctionCtor::Data(rootContext));
-    dateCtor = new (memoryManager) DateCtor(rootContext);
-    regExpCtor = new (memoryManager) RegExpCtor(rootContext);
-    errorCtor = new (memoryManager) ErrorCtor(rootContext);
-    evalErrorCtor = new (memoryManager) EvalErrorCtor(rootContext);
-    rangeErrorCtor = new (memoryManager) RangeErrorCtor(rootContext);
-    referenceErrorCtor = new (memoryManager) ReferenceErrorCtor(rootContext);
-    syntaxErrorCtor = new (memoryManager) SyntaxErrorCtor(rootContext);
-    typeErrorCtor = new (memoryManager) TypeErrorCtor(rootContext);
-    uRIErrorCtor = new (memoryManager) URIErrorCtor(rootContext);
+    dateCtor = static_cast<HeapObject *>(new (this) DateCtor::Data(rootContext));
+    regExpCtor = static_cast<HeapObject *>(new (this) RegExpCtor::Data(rootContext));
+    errorCtor = static_cast<HeapObject *>(new (this) ErrorCtor::Data(rootContext));
+    evalErrorCtor = static_cast<HeapObject *>(new (this) EvalErrorCtor::Data(rootContext));
+    rangeErrorCtor = static_cast<HeapObject *>(new (this) RangeErrorCtor::Data(rootContext));
+    referenceErrorCtor = static_cast<HeapObject *>(new (this) ReferenceErrorCtor::Data(rootContext));
+    syntaxErrorCtor = static_cast<HeapObject *>(new (this) SyntaxErrorCtor::Data(rootContext));
+    typeErrorCtor = static_cast<HeapObject *>(new (this) TypeErrorCtor::Data(rootContext));
+    uRIErrorCtor = static_cast<HeapObject *>(new (this) URIErrorCtor::Data(rootContext));
 
     objectPrototype->init(this, objectCtor.asObject());
     stringPrototype->init(this, stringCtor.asObject());
@@ -397,7 +397,8 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN()));
     globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY));
 
-    evalFunction = new (memoryManager) EvalFunction(rootContext);
+
+    evalFunction = Scoped<EvalFunction>(scope, new (this) EvalFunction::Data(rootContext));
     globalObject->defineDefaultProperty(QStringLiteral("eval"), (o = evalFunction));
 
     globalObject->defineDefaultProperty(QStringLiteral("parseInt"), GlobalFunctions::method_parseInt, 2);
@@ -807,8 +808,8 @@ void ExecutionEngine::requireArgumentsAccessors(int n)
             delete [] oldAccessors;
         }
         for (int i = oldSize; i < nArgumentsAccessors; ++i) {
-            argumentsAccessors[i].value = Value::fromManaged(new (memoryManager) ArgumentsGetterFunction(rootContext, i));
-            argumentsAccessors[i].set = Value::fromManaged(new (memoryManager) ArgumentsSetterFunction(rootContext, i));
+            argumentsAccessors[i].value = ScopedValue(scope, new (scope.engine) ArgumentsGetterFunction::Data(rootContext, i));
+            argumentsAccessors[i].set = ScopedValue(scope, new (scope.engine) ArgumentsSetterFunction::Data(rootContext, i));
         }
     }
 }
index 666353f..03ad40e 100644 (file)
@@ -253,14 +253,14 @@ DEFINE_OBJECT_VTABLE(SyntaxErrorCtor);
 DEFINE_OBJECT_VTABLE(TypeErrorCtor);
 DEFINE_OBJECT_VTABLE(URIErrorCtor);
 
-ErrorCtor::ErrorCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("Error"))
+ErrorCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("Error"))
 {
     setVTable(staticVTable());
 }
 
-ErrorCtor::ErrorCtor(ExecutionContext *scope, const QString &name)
-    : FunctionObject(scope, name)
+ErrorCtor::Data::Data(ExecutionContext *scope, const QString &name)
+    : FunctionObject::Data(scope, name)
 {
     setVTable(staticVTable());
 }
@@ -277,8 +277,8 @@ ReturnedValue ErrorCtor::call(Managed *that, CallData *callData)
     return static_cast<Object *>(that)->construct(callData);
 }
 
-EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope)
-    : ErrorCtor(scope, QStringLiteral("EvalError"))
+EvalErrorCtor::Data::Data(ExecutionContext *scope)
+    : ErrorCtor::Data(scope, QStringLiteral("EvalError"))
 {
     setVTable(staticVTable());
 }
@@ -290,8 +290,8 @@ ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData)
     return (new (m->engine()->memoryManager) EvalErrorObject(m->engine(), v))->asReturnedValue();
 }
 
-RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope)
-    : ErrorCtor(scope, QStringLiteral("RangeError"))
+RangeErrorCtor::Data::Data(ExecutionContext *scope)
+    : ErrorCtor::Data(scope, QStringLiteral("RangeError"))
 {
     setVTable(staticVTable());
 }
@@ -303,8 +303,8 @@ ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData)
     return (new (m->engine()->memoryManager) RangeErrorObject(scope.engine, v))->asReturnedValue();
 }
 
-ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope)
-    : ErrorCtor(scope, QStringLiteral("ReferenceError"))
+ReferenceErrorCtor::Data::Data(ExecutionContext *scope)
+    : ErrorCtor::Data(scope, QStringLiteral("ReferenceError"))
 {
     setVTable(staticVTable());
 }
@@ -316,8 +316,8 @@ ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData)
     return (new (m->engine()->memoryManager) ReferenceErrorObject(scope.engine, v))->asReturnedValue();
 }
 
-SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope)
-    : ErrorCtor(scope, QStringLiteral("SyntaxError"))
+SyntaxErrorCtor::Data::Data(ExecutionContext *scope)
+    : ErrorCtor::Data(scope, QStringLiteral("SyntaxError"))
 {
     setVTable(staticVTable());
 }
@@ -329,8 +329,8 @@ ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData)
     return (new (m->engine()->memoryManager) SyntaxErrorObject(scope.engine, v))->asReturnedValue();
 }
 
-TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope)
-    : ErrorCtor(scope, QStringLiteral("TypeError"))
+TypeErrorCtor::Data::Data(ExecutionContext *scope)
+    : ErrorCtor::Data(scope, QStringLiteral("TypeError"))
 {
     setVTable(staticVTable());
 }
@@ -342,8 +342,8 @@ ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData)
     return (new (m->engine()->memoryManager) TypeErrorObject(scope.engine, v))->asReturnedValue();
 }
 
-URIErrorCtor::URIErrorCtor(ExecutionContext *scope)
-    : ErrorCtor(scope, QStringLiteral("URIError"))
+URIErrorCtor::Data::Data(ExecutionContext *scope)
+    : ErrorCtor::Data(scope, QStringLiteral("URIError"))
 {
     setVTable(staticVTable());
 }
index 949ac3b..2bfdd49 100644 (file)
@@ -125,9 +125,12 @@ struct URIErrorObject: ErrorObject {
 
 struct ErrorCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+        Data(ExecutionContext *scope, const QString &name);
+    };
+
     V4_OBJECT
-    ErrorCtor(ExecutionContext *scope);
-    ErrorCtor(ExecutionContext *scope, const QString &name);
 
     static ReturnedValue construct(Managed *, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *callData);
@@ -135,49 +138,60 @@ struct ErrorCtor: FunctionObject
 
 struct EvalErrorCtor: ErrorCtor
 {
+    struct Data : ErrorCtor::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
 
-    EvalErrorCtor(ExecutionContext *scope);
-
     static ReturnedValue construct(Managed *m, CallData *callData);
 };
 
 struct RangeErrorCtor: ErrorCtor
 {
+    struct Data : ErrorCtor::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    RangeErrorCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
 };
 
 struct ReferenceErrorCtor: ErrorCtor
 {
+    struct Data : ErrorCtor::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    ReferenceErrorCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
 };
 
 struct SyntaxErrorCtor: ErrorCtor
 {
+    struct Data : ErrorCtor::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    SyntaxErrorCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
 };
 
 struct TypeErrorCtor: ErrorCtor
 {
+    struct Data : ErrorCtor::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    TypeErrorCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
 };
 
 struct URIErrorCtor: ErrorCtor
 {
+    struct Data : ErrorCtor::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    URIErrorCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
 };
index c3b4860..1cbc803 100644 (file)
@@ -112,48 +112,6 @@ FunctionObject::Data::Data(InternalClass *ic)
     memberData[Index_Prototype] = Encode::undefined();
 }
 
-FunctionObject::FunctionObject(ExecutionContext *scope, String *name, bool createProto)
-    : Object(scope->d()->engine->functionClass)
-{
-    d()->scope = scope;
-    d()->function = 0;
-    init(name, createProto);
-}
-
-FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
-    : Object(scope->d()->engine->functionClass)
-{
-    d()->scope = scope;
-    d()->function = 0;
-
-    Scope s(scope);
-    ScopedValue protectThis(s, this);
-    ScopedString n(s, s.engine->newString(name));
-    init(n.getPointer(), createProto);
-}
-
-FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
-    : Object(scope->d()->engine->functionClass)
-{
-    d()->scope = scope;
-    d()->function = 0;
-
-    Scope s(scope);
-    ScopedValue protectThis(s, this);
-    ScopedString n(s, name);
-    init(n.getPointer(), false);
-}
-
-FunctionObject::FunctionObject(InternalClass *ic)
-    : Object(ic)
-{
-    d()->scope = ic->engine->rootContext;
-    d()->function = 0;
-
-    d()->needsActivation = false;
-    d()->strictMode = false;
-    memberData()[Index_Prototype] = Encode::undefined();
-}
 
 FunctionObject::Data::~Data()
 {
@@ -288,8 +246,10 @@ ReturnedValue FunctionCtor::call(Managed *that, CallData *callData)
     return construct(that, callData);
 }
 
-FunctionPrototype::FunctionPrototype(InternalClass *ic)
-    : FunctionObject(ic)
+DEFINE_OBJECT_VTABLE(FunctionPrototype);
+
+FunctionPrototype::Data::Data(InternalClass *ic)
+    : FunctionObject::Data(ic)
 {
 }
 
index 970df44..16377aa 100644 (file)
@@ -134,10 +134,6 @@ struct Q_QML_EXPORT FunctionObject: Object {
     unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 0; }
     unsigned int varCount() { return function() ? function()->compiledFunction->nLocals : 0; }
 
-    FunctionObject(ExecutionContext *scope, String *name, bool createProto = false);
-    FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
-    FunctionObject(ExecutionContext *scope, const ReturnedValue name);
-
     void init(String *name, bool createProto);
 
     ReturnedValue newInstance();
@@ -162,9 +158,6 @@ struct Q_QML_EXPORT FunctionObject: Object {
     bool strictMode() const { return d()->strictMode; }
     bool bindingKeyFlag() const { return d()->bindingKeyFlag; }
 
-protected:
-    FunctionObject(InternalClass *ic);
-
     static void markObjects(Managed *that, ExecutionEngine *e);
 };
 
@@ -187,7 +180,11 @@ struct FunctionCtor: FunctionObject
 
 struct FunctionPrototype: FunctionObject
 {
-    FunctionPrototype(InternalClass *ic);
+    struct Data : FunctionObject::Data {
+        Data(InternalClass *ic);
+    };
+    V4_OBJECT
+
     void init(ExecutionEngine *engine, Object *ctor);
 
     static ReturnedValue method_toString(CallContext *ctx);
index 1be9561..fc4a097 100644 (file)
@@ -346,11 +346,13 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
 
 DEFINE_OBJECT_VTABLE(EvalFunction);
 
-EvalFunction::EvalFunction(ExecutionContext *scope)
-    : FunctionObject(scope, scope->d()->engine->id_eval)
+EvalFunction::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, scope->d()->engine->id_eval)
 {
     setVTable(staticVTable());
-    defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
+    Scope s(scope);
+    ScopedFunctionObject f(s, this);
+    f->defineReadonlyProperty(s.engine->id_length, Primitive::fromInt32(1));
 }
 
 ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall)
index 63823ac..d973adc 100644 (file)
@@ -50,8 +50,11 @@ namespace QV4 {
 
 struct Q_QML_EXPORT EvalFunction : FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
+
     V4_OBJECT
-    EvalFunction(ExecutionContext *scope);
 
     ReturnedValue evalCall(CallData *callData, bool directCall);
 
index 1c8552c..f1bac11 100644 (file)
@@ -51,8 +51,8 @@ using namespace QV4;
 DEFINE_OBJECT_VTABLE(NumberCtor);
 DEFINE_OBJECT_VTABLE(NumberObject);
 
-NumberCtor::NumberCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("Number"))
+NumberCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("Number"))
 {
     setVTable(staticVTable());
 }
index 6a7b54e..0a76159 100644 (file)
@@ -51,8 +51,10 @@ namespace QV4 {
 
 struct NumberCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    NumberCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *that, CallData *callData);
     static ReturnedValue call(Managed *, CallData *callData);
index 5ac90db..6b8a19c 100644 (file)
@@ -74,8 +74,8 @@ using namespace QV4;
 
 DEFINE_OBJECT_VTABLE(ObjectCtor);
 
-ObjectCtor::ObjectCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("Object"))
+ObjectCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("Object"))
 {
     setVTable(staticVTable());
 }
index 3f7c21e..495fe3e 100644 (file)
@@ -51,8 +51,10 @@ namespace QV4 {
 
 struct ObjectCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    ObjectCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *that, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *callData);
index f7135d9..6a592ee 100644 (file)
@@ -237,19 +237,19 @@ uint RegExpObject::flags() const
 
 DEFINE_OBJECT_VTABLE(RegExpCtor);
 
-RegExpCtor::RegExpCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("RegExp"))
+RegExpCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("RegExp"))
 {
     setVTable(staticVTable());
     clearLastMatch();
 }
 
-void RegExpCtor::clearLastMatch()
+void RegExpCtor::Data::clearLastMatch()
 {
-    d()->lastMatch = Primitive::nullValue();
-    d()->lastInput = engine()->id_empty;
-    d()->lastMatchStart = 0;
-    d()->lastMatchEnd = 0;
+    lastMatch = Primitive::nullValue();
+    lastInput = internalClass->engine->id_empty;
+    lastMatchStart = 0;
+    lastMatchEnd = 0;
 }
 
 ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
@@ -379,7 +379,7 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
     const int result = r->value()->match(s, offset, matchOffsets);
 
     Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
-    regExpCtor->clearLastMatch();
+    regExpCtor->d()->clearLastMatch();
 
     if (result == -1) {
         r->lastIndexProperty(ctx)->value = Primitive::fromInt32(0);
index 90ff8ca..238ce8a 100644 (file)
@@ -110,10 +110,12 @@ protected:
 struct RegExpCtor: FunctionObject
 {
     struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
         Value lastMatch;
         StringValue lastInput;
         int lastMatchStart;
         int lastMatchEnd;
+        void clearLastMatch();
     };
     struct {
         Value lastMatch;
@@ -123,13 +125,11 @@ struct RegExpCtor: FunctionObject
     } __data;
 
     V4_OBJECT
-    RegExpCtor(ExecutionContext *scope);
 
     Value lastMatch() { return d()->lastMatch; }
     StringValue lastInput() { return d()->lastInput; }
     int lastMatchStart() { return d()->lastMatchStart; }
     int lastMatchEnd() { return d()->lastMatchEnd; }
-    void clearLastMatch();
 
     static ReturnedValue construct(Managed *m, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *callData);
index 3969de3..c47e1ae 100644 (file)
@@ -173,8 +173,8 @@ void StringObject::markObjects(Managed *that, ExecutionEngine *e)
 
 DEFINE_OBJECT_VTABLE(StringCtor);
 
-StringCtor::StringCtor(ExecutionContext *scope)
-    : FunctionObject(scope, QStringLiteral("String"))
+StringCtor::Data::Data(ExecutionContext *scope)
+    : FunctionObject::Data(scope, QStringLiteral("String"))
 {
     setVTable(staticVTable());
 }
index 5999a4f..6656e29 100644 (file)
@@ -76,8 +76,10 @@ protected:
 
 struct StringCtor: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope);
+    };
     V4_OBJECT
-    StringCtor(ExecutionContext *scope);
 
     static ReturnedValue construct(Managed *m, CallData *callData);
     static ReturnedValue call(Managed *that, CallData *callData);
index f3642cd..3fe3a0d 100644 (file)
@@ -72,10 +72,13 @@ using namespace QV4;
 
 struct Print: FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope)
+            : FunctionObject::Data(scope, QStringLiteral("print")) {
+            setVTable(staticVTable());
+        }
+    };
     V4_OBJECT
-    Print(ExecutionContext *scope): FunctionObject(scope, QStringLiteral("print")) {
-        setVTable(staticVTable());
-    }
 
     static ReturnedValue call(Managed *, CallData *callData)
     {
@@ -94,12 +97,16 @@ DEFINE_OBJECT_VTABLE(Print);
 
 struct GC: public FunctionObject
 {
+    struct Data : FunctionObject::Data {
+        Data(ExecutionContext *scope)
+            : FunctionObject::Data(scope, QStringLiteral("gc"))
+        {
+            setVTable(staticVTable());
+        }
+
+    };
     V4_OBJECT
-    GC(ExecutionContext* scope)
-        : FunctionObject(scope, QStringLiteral("gc"))
-    {
-        setVTable(staticVTable());
-    }
+
     static ReturnedValue call(Managed *m, CallData *)
     {
         m->engine()->memoryManager->runGC();
@@ -190,9 +197,9 @@ int main(int argc, char *argv[])
         QV4::Scope scope(ctx);
 
         QV4::ScopedObject globalObject(scope, vm.globalObject);
-        QV4::ScopedObject print(scope, new (scope.engine->memoryManager) builtins::Print(ctx));
+        QV4::ScopedObject print(scope, new (scope.engine) builtins::Print::Data(ctx));
         globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print);
-        QV4::ScopedObject gc(scope, new (scope.engine->memoryManager) builtins::GC(ctx));
+        QV4::ScopedObject gc(scope, new (scope.engine) builtins::GC::Data(ctx));
         globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
 
         foreach (const QString &fn, args) {