From 3373f67d47a3f0e2a191dec4d7d97cc0a1b02e2d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 12 Jan 2015 13:48:47 +0100 Subject: QV4::String is not an Object Remove all the code related to Object vtable's in here. This code never got called anyway, as it would require casting to an Object to call it (which would of course fail for Strings). Change-Id: Ib62bb1b10999304cb65f6030d805698b9f60700d Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4string.cpp | 110 +--------------------------------------- src/qml/jsruntime/qv4string_p.h | 11 +--- 2 files changed, 2 insertions(+), 119 deletions(-) diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 795a6dfdc4..de5c7ffa24 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -94,24 +94,7 @@ static uint toArrayIndex(const char *ch, const char *end) } -const ObjectVTable String::static_vtbl = -{ - DEFINE_MANAGED_VTABLE_INT(String, 0), - 0, - 0, - get, - getIndexed, - put, - putIndexed, - query, - queryIndexed, - deleteProperty, - deleteIndexedProperty, - 0 /*getLookup*/, - 0 /*setLookup*/, - 0, - 0 /*advanceIterator*/, -}; +DEFINE_MANAGED_VTABLE(String); void String::markObjects(Heap::Base *that, ExecutionEngine *e) { @@ -122,97 +105,6 @@ void String::markObjects(Heap::Base *that, ExecutionEngine *e) } } -ReturnedValue String::get(Managed *m, String *name, bool *hasProperty) -{ - ExecutionEngine *v4 = m->engine(); - Scope scope(v4); - ScopedString that(scope, static_cast(m)); - - if (name->equals(v4->id_length)) { - if (hasProperty) - *hasProperty = true; - return Primitive::fromInt32(that->d()->text->size).asReturnedValue(); - } - PropertyAttributes attrs; - Property *pd = v4->stringPrototype.asObject()->__getPropertyDescriptor__(name, &attrs); - if (!pd || attrs.isGeneric()) { - if (hasProperty) - *hasProperty = false; - return Primitive::undefinedValue().asReturnedValue(); - } - if (hasProperty) - *hasProperty = true; - return v4->stringPrototype.asObject()->getValue(that, pd, attrs); -} - -ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) -{ - ExecutionEngine *engine = m->engine(); - Scope scope(engine); - ScopedString that(scope, static_cast(m)); - - if (index < static_cast(that->d()->text->size)) { - if (hasProperty) - *hasProperty = true; - return Encode(engine->newString(that->toQString().mid(index, 1))); - } - PropertyAttributes attrs; - Property *pd = engine->stringPrototype.asObject()->__getPropertyDescriptor__(index, &attrs); - if (!pd || attrs.isGeneric()) { - if (hasProperty) - *hasProperty = false; - return Primitive::undefinedValue().asReturnedValue(); - } - if (hasProperty) - *hasProperty = true; - return engine->stringPrototype.asObject()->getValue(that, pd, attrs); -} - -void String::put(Managed *m, String *name, const ValueRef value) -{ - Scope scope(m->engine()); - if (scope.hasException()) - return; - ScopedString that(scope, static_cast(m)); - ScopedObject o(scope, that->engine()->newStringObject(that)); - o->put(name, value); -} - -void String::putIndexed(Managed *m, uint index, const ValueRef value) -{ - Scope scope(m->engine()); - if (scope.hasException()) - return; - - ScopedString that(scope, static_cast(m)); - ScopedObject o(scope, that->engine()->newStringObject(that)); - o->putIndexed(index, value); -} - -PropertyAttributes String::query(const Managed *m, String *name) -{ - uint idx = name->asArrayIndex(); - if (idx != UINT_MAX) - return queryIndexed(m, idx); - return Attr_Invalid; -} - -PropertyAttributes String::queryIndexed(const Managed *m, uint index) -{ - const String *that = static_cast(m); - return (index < static_cast(that->d()->text->size)) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid; -} - -bool String::deleteProperty(Managed *, String *) -{ - return false; -} - -bool String::deleteIndexedProperty(Managed *, uint) -{ - return false; -} - bool String::isEqualTo(Managed *t, Managed *o) { if (t == o) diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 3af945fc1d..e70af2462a 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -116,8 +116,7 @@ private: struct Q_QML_PRIVATE_EXPORT String : public Managed { #ifndef V4_BOOTSTRAP - // ### FIXME: Should this be a V4_OBJECT - V4_OBJECT2(String, Managed) + V4_MANAGED(String, Managed) Q_MANAGED_TYPE(String) V4_NEEDS_DESTROY enum { @@ -177,14 +176,6 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { protected: static void markObjects(Heap::Base *that, ExecutionEngine *e); - static ReturnedValue get(Managed *m, String *name, bool *hasProperty); - static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, String *name, const ValueRef value); - static void putIndexed(Managed *m, uint index, const ValueRef value); - static PropertyAttributes query(const Managed *m, String *name); - static PropertyAttributes queryIndexed(const Managed *m, uint index); - static bool deleteProperty(Managed *, String *); - static bool deleteIndexedProperty(Managed *m, uint index); static bool isEqualTo(Managed *that, Managed *o); static uint getLength(const Managed *m); #endif -- cgit v1.2.3