diff options
Diffstat (limited to 'WebCore/bridge/qt')
-rw-r--r-- | WebCore/bridge/qt/qt_class.cpp | 65 | ||||
-rw-r--r-- | WebCore/bridge/qt/qt_instance.cpp | 13 | ||||
-rw-r--r-- | WebCore/bridge/qt/qt_runtime.cpp | 2 | ||||
-rw-r--r-- | WebCore/bridge/qt/qt_runtime.h | 2 |
4 files changed, 44 insertions, 38 deletions
diff --git a/WebCore/bridge/qt/qt_class.cpp b/WebCore/bridge/qt/qt_class.cpp index cfd74d9..2357c23 100644 --- a/WebCore/bridge/qt/qt_class.cpp +++ b/WebCore/bridge/qt/qt_class.cpp @@ -70,7 +70,9 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie { QtInstance* qtinst = static_cast<QtInstance*>(inst); - QByteArray name(identifier.ascii()); + const UString& ustring = identifier.ustring(); + const QByteArray name = QString(reinterpret_cast<const QChar*>(ustring.data()), + ustring.size()).toAscii(); // First see if we have a cache hit JSObject* val = qtinst->m_methods.value(name); @@ -78,7 +80,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie return val; // Nope, create an entry - QByteArray normal = QMetaObject::normalizedSignature(name.constData()); + const QByteArray normal = QMetaObject::normalizedSignature(name.constData()); // See if there is an exact match int index = -1; @@ -92,16 +94,18 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie } // Nope.. try a basename match - int count = m_metaObject->methodCount(); + const int count = m_metaObject->methodCount(); for (index = count - 1; index >= 0; --index) { const QMetaMethod m = m_metaObject->method(index); if (m.access() == QMetaMethod::Private) continue; - QByteArray signature = m.signature(); - signature.truncate(signature.indexOf('(')); + int iter = 0; + const char* signature = m.signature(); + while (signature[iter] && signature[iter] != '(') + ++iter; - if (normal == signature) { + if (normal == QByteArray::fromRawData(signature, iter)) { QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false); qtinst->m_methods.insert(name, val); return val; @@ -126,12 +130,12 @@ Field* QtClass::fieldNamed(const Identifier& identifier, Instance* instance) con QtInstance* qtinst = static_cast<QtInstance*>(instance); QObject* obj = qtinst->getObject(); - UString ustring = identifier.ustring(); - QString objName((const QChar*)ustring.rep()->characters(), ustring.size()); - QByteArray ba = objName.toAscii(); + const UString& ustring = identifier.ustring(); + const QString name(reinterpret_cast<const QChar*>(ustring.data()), ustring.size()); + const QByteArray ascii = name.toAscii(); // First check for a cached field - QtField* f = qtinst->m_fields.value(objName); + QtField* f = qtinst->m_fields.value(name); if (obj) { if (f) { @@ -141,58 +145,60 @@ Field* QtClass::fieldNamed(const Identifier& identifier, Instance* instance) con return f; #ifndef QT_NO_PROPERTIES else if (f->fieldType() == QtField::DynamicProperty) { - if (obj->dynamicPropertyNames().indexOf(ba) >= 0) + if (obj->dynamicPropertyNames().indexOf(ascii) >= 0) return f; else { // Dynamic property that disappeared - qtinst->m_fields.remove(objName); + qtinst->m_fields.remove(name); delete f; } } #endif else { - QList<QObject*> children = obj->children(); - for (int index = 0; index < children.count(); ++index) { + const QList<QObject*>& children = obj->children(); + const int count = children.size(); + for (int index = 0; index < count; ++index) { QObject *child = children.at(index); - if (child->objectName() == objName) + if (child->objectName() == name) return f; } // Didn't find it, delete it from the cache - qtinst->m_fields.remove(objName); + qtinst->m_fields.remove(name); delete f; } } - int index = m_metaObject->indexOfProperty(identifier.ascii()); + int index = m_metaObject->indexOfProperty(ascii); if (index >= 0) { - QMetaProperty prop = m_metaObject->property(index); + const QMetaProperty prop = m_metaObject->property(index); if (prop.isScriptable(obj)) { f = new QtField(prop); - qtinst->m_fields.insert(objName, f); + qtinst->m_fields.insert(name, f); return f; } } #ifndef QT_NO_PROPERTIES // Dynamic properties - index = obj->dynamicPropertyNames().indexOf(ba); + index = obj->dynamicPropertyNames().indexOf(ascii); if (index >= 0) { - f = new QtField(ba); - qtinst->m_fields.insert(objName, f); + f = new QtField(ascii); + qtinst->m_fields.insert(name, f); return f; } #endif // Child objects - QList<QObject*> children = obj->children(); - for (index = 0; index < children.count(); ++index) { + const QList<QObject*>& children = obj->children(); + const int count = children.count(); + for (index = 0; index < count; ++index) { QObject *child = children.at(index); - if (child->objectName() == objName) { + if (child->objectName() == name) { f = new QtField(child); - qtinst->m_fields.insert(objName, f); + qtinst->m_fields.insert(name, f); return f; } } @@ -200,19 +206,18 @@ Field* QtClass::fieldNamed(const Identifier& identifier, Instance* instance) con // Nothing named this return 0; } else { - QByteArray ba(identifier.ascii()); // For compatibility with qtscript, cached methods don't cause // errors until they are accessed, so don't blindly create an error // here. - if (qtinst->m_methods.contains(ba)) + if (qtinst->m_methods.contains(ascii)) return 0; #ifndef QT_NO_PROPERTIES // deleted qobject, but can't throw an error from here (no exec) // create a fake QtField that will throw upon access if (!f) { - f = new QtField(ba); - qtinst->m_fields.insert(objName, f); + f = new QtField(ascii); + qtinst->m_fields.insert(name, f); } #endif return f; diff --git a/WebCore/bridge/qt/qt_instance.cpp b/WebCore/bridge/qt/qt_instance.cpp index f6f368b..97bb34b 100644 --- a/WebCore/bridge/qt/qt_instance.cpp +++ b/WebCore/bridge/qt/qt_instance.cpp @@ -225,12 +225,13 @@ void QtInstance::getPropertyNames(ExecState* exec, PropertyNameArray& array) #ifndef QT_NO_PROPERTIES QList<QByteArray> dynProps = obj->dynamicPropertyNames(); - foreach(QByteArray ba, dynProps) { + foreach(const QByteArray& ba, dynProps) { array.add(Identifier(exec, ba.constData())); } #endif - for (i=0; i < meta->methodCount(); i++) { + const int methodCount = meta->methodCount(); + for (i = 0; i < methodCount; i++) { QMetaMethod method = meta->method(i); if (method.access() != QMetaMethod::Private) { array.add(Identifier(exec, method.signature())); @@ -287,7 +288,7 @@ JSValue QtInstance::stringValue(ExecState* exec) const void * qargs[1]; qargs[0] = ret.data(); - if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, index, qargs) < 0) { + if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, qargs) < 0) { if (ret.isValid() && ret.canConvert(QVariant::String)) { buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii? useDefault = false; @@ -329,7 +330,7 @@ JSValue QtInstance::valueOf(ExecState* exec) const JSValue convertQVariantToValue(ExecState*, PassRefPtr<RootObject> root, const QVariant& variant); QVariant convertValueToQVariant(ExecState*, JSValue, QMetaType::Type hint, int *distance); -const char* QtField::name() const +QByteArray QtField::name() const { if (m_type == MetaProperty) return m_property.name(); @@ -337,9 +338,9 @@ const char* QtField::name() const return m_childObject->objectName().toLatin1(); #ifndef QT_NO_PROPERTIES else if (m_type == DynamicProperty) - return m_dynamicProperty.constData(); + return m_dynamicProperty; #endif - return ""; // deleted child object + return QByteArray(); // deleted child object } JSValue QtField::valueFromInstance(ExecState* exec, const Instance* inst) const diff --git a/WebCore/bridge/qt/qt_runtime.cpp b/WebCore/bridge/qt/qt_runtime.cpp index 1775815..4524d97 100644 --- a/WebCore/bridge/qt/qt_runtime.cpp +++ b/WebCore/bridge/qt/qt_runtime.cpp @@ -1397,7 +1397,7 @@ JSValue QtRuntimeMetaMethod::call(ExecState* exec, JSObject* functionObject, JSV int methodIndex; JSObject* errorObj = 0; if ((methodIndex = findMethodIndex(exec, obj->metaObject(), d->m_signature, d->m_allowPrivate, args, vargs, (void **)qargs, &errorObj)) != -1) { - if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, methodIndex, qargs) >= 0) + if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, methodIndex, qargs) >= 0) return jsUndefined(); if (vargs[0].isValid()) diff --git a/WebCore/bridge/qt/qt_runtime.h b/WebCore/bridge/qt/qt_runtime.h index 0951e5b..5739cb4 100644 --- a/WebCore/bridge/qt/qt_runtime.h +++ b/WebCore/bridge/qt/qt_runtime.h @@ -62,7 +62,7 @@ public: virtual JSValue valueFromInstance(ExecState*, const Instance*) const; virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const; - virtual const char* name() const; + QByteArray name() const; QtFieldType fieldType() const {return m_type;} private: QtFieldType m_type; |