From e74c19da8eb74132aba761f8b8fe0eac47fe2dcd Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 29 Apr 2014 10:49:54 +0200 Subject: Convert RegexpObject to new storage scheme Change-Id: I7dbaa52d3898bbe44b5a865ded6361bcc7ec2acf Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4regexpobject.cpp | 36 ++++++++++++++-------------- src/qml/jsruntime/qv4regexpobject_p.h | 45 +++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index b9e4c37e26..b46c6914d5 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -74,8 +74,8 @@ DEFINE_OBJECT_VTABLE(RegExpObject); RegExpObject::RegExpObject(InternalClass *ic) : Object(ic) { - data.value = RegExp::create(ic->engine, QString(), false, false); - data.global = false; + d()->value = RegExp::create(ic->engine, QString(), false, false); + d()->global = false; Q_ASSERT(internalClass()->vtable == staticVTable()); init(ic->engine); } @@ -83,8 +83,8 @@ RegExpObject::RegExpObject(InternalClass *ic) RegExpObject::RegExpObject(ExecutionEngine *engine, RegExpRef value, bool global) : Object(engine->regExpClass) { - data.value = value; - data.global = global; + d()->value = value; + d()->global = global; init(engine); } @@ -94,8 +94,8 @@ RegExpObject::RegExpObject(ExecutionEngine *engine, RegExpRef value, bool global RegExpObject::RegExpObject(ExecutionEngine *engine, const QRegExp &re) : Object(engine->regExpClass) { - data.value = 0; - data.global = false; + d()->value = 0; + d()->global = false; // Convert the pattern to a ECMAScript pattern. QString pattern = QT_PREPEND_NAMESPACE(qt_regexp_toCanonical)(re.pattern(), re.patternSyntax()); @@ -137,7 +137,7 @@ RegExpObject::RegExpObject(ExecutionEngine *engine, const QRegExp &re) Scope scope(engine); ScopedObject protectThis(scope, this); - data.value = RegExp::create(engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false); + d()->value = RegExp::create(engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false); init(engine); } @@ -238,10 +238,10 @@ RegExpCtor::RegExpCtor(ExecutionContext *scope) void RegExpCtor::clearLastMatch() { - data.lastMatch = Primitive::nullValue(); - data.lastInput = engine()->id_empty; - data.lastMatchStart = 0; - data.lastMatchEnd = 0; + d()->lastMatch = Primitive::nullValue(); + d()->lastInput = engine()->id_empty; + d()->lastMatchStart = 0; + d()->lastMatchEnd = 0; } ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) @@ -393,11 +393,11 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) array->memberData()[Index_ArrayIndex] = Primitive::fromInt32(result); array->memberData()[Index_ArrayInput] = arg.asReturnedValue(); - RegExpCtor::Data *d = ®ExpCtor->data; - d->lastMatch = array; - d->lastInput = arg->stringValue(); - d->lastMatchStart = matchOffsets[0]; - d->lastMatchEnd = matchOffsets[1]; + RegExpCtor::Data *dd = regExpCtor->d(); + dd->lastMatch = array; + dd->lastInput = arg->stringValue(); + dd->lastMatchStart = matchOffsets[0]; + dd->lastMatchEnd = matchOffsets[1]; if (r->global()) r->lastIndexProperty(ctx)->value = Primitive::fromInt32(matchOffsets[1]); @@ -434,8 +434,8 @@ ReturnedValue RegExpPrototype::method_compile(CallContext *ctx) Scoped re(scope, ctx->engine->regExpCtor.asFunctionObject()->construct(callData)); - r->data.value = re->value(); - r->data.global = re->global(); + r->d()->value = re->value(); + r->d()->global = re->global(); return Encode::undefined(); } diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 909628cd72..2948dbda83 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -66,8 +66,18 @@ namespace QV4 { class RegExp; struct RegExpObject: Object { - V4_OBJECT + struct Data : Object::Data { + RegExp* value; + bool global; + }; + struct { + RegExp* value; + bool global; + } __data; + + V4_OBJECT_NEW Q_MANAGED_TYPE(RegExpObject) + // needs to be compatible with the flags in qv4jsir_p.h enum Flags { RegExp_Global = 0x01, @@ -80,14 +90,8 @@ struct RegExpObject: Object { Index_ArrayInput = Index_ArrayIndex + 1 }; - struct Data { - RegExp* value; - bool global; - }; - Data data; - - RegExp* value() const { return data.value; } - bool global() const { return data.global; } + RegExp *value() const { return d()->value; } + bool global() const { return d()->global; } RegExpObject(ExecutionEngine *engine, RegExpRef value, bool global); RegExpObject(ExecutionEngine *engine, const QRegExp &re); @@ -109,21 +113,26 @@ DEFINE_REF(RegExp, Object); struct RegExpCtor: FunctionObject { - V4_OBJECT - RegExpCtor(ExecutionContext *scope); - - struct Data { + struct Data : FunctionObject::Data { Value lastMatch; StringValue lastInput; int lastMatchStart; int lastMatchEnd; }; - Data data; + struct { + Value lastMatch; + StringValue lastInput; + int lastMatchStart; + int lastMatchEnd; + } __data; + + V4_OBJECT_NEW + RegExpCtor(ExecutionContext *scope); - Value lastMatch() { return data.lastMatch; } - StringValue lastInput() { return data.lastInput; } - int lastMatchStart() { return data.lastMatchStart; } - int lastMatchEnd() { return data.lastMatchEnd; } + 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); -- cgit v1.2.3