aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-05-25 13:45:25 +1000
committerCharles Yin <charles.yin@nokia.com>2011-05-25 13:53:31 +1000
commitd5f12d1348fa882577d24b47958b03ab9d037b8a (patch)
treef12557613c0aa2db7133b4a2d1b5479b79c1a6fe /src
parentc741910ef6857e355c0715b872902df87fd4443f (diff)
Revert "uses the cached argument info"
This reverts commit 68d18d77ebac49c2b863c425969c70c5426864cd.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp25
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index f4ca9fe758..edc1755a72 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -672,7 +672,7 @@ struct MetaCallArgument {
inline void *dataPtr();
inline void initAsType(int type, QDeclarativeEngine *);
- inline void fromScriptValue(int type, QDeclarativeEngine *, const QScriptValue &);
+ void fromScriptValue(int type, QDeclarativeEngine *, const QScriptValue &);
inline QScriptDeclarativeClass::Value toValue(QDeclarativeEngine *);
private:
@@ -908,9 +908,24 @@ QDeclarativeObjectMethodScriptClass::callPrecise(QObject *object, const QDeclara
QScriptContext *ctxt)
{
if (data.flags & QDeclarativePropertyCache::Data::HasArguments) {
- if (data.paramTypes.size() > ctxt->argumentCount())
- return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments")));
- return callMethod(object, data.coreIndex, data.propType, data.paramTypes.size(), data.paramTypes.data(), ctxt);
+
+ QMetaMethod m = object->metaObject()->method(data.coreIndex);
+ QList<QByteArray> argTypeNames = m.parameterTypes();
+ QVarLengthArray<int, 9> argTypes(argTypeNames.count());
+
+ // ### Cache
+ for (int ii = 0; ii < argTypeNames.count(); ++ii) {
+ argTypes[ii] = QMetaType::type(argTypeNames.at(ii));
+ if (argTypes[ii] == QVariant::Invalid)
+ argTypes[ii] = enumType(object->metaObject(), QString::fromLatin1(argTypeNames.at(ii)));
+ if (argTypes[ii] == QVariant::Invalid)
+ return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii)))));
+ }
+
+ if (argTypes.count() > ctxt->argumentCount())
+ return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments")));
+
+ return callMethod(object, data.coreIndex, data.propType, argTypes.count(), argTypes.data(), ctxt);
} else {
@@ -921,7 +936,7 @@ QDeclarativeObjectMethodScriptClass::callPrecise(QObject *object, const QDeclara
QDeclarativeObjectMethodScriptClass::Value
QDeclarativeObjectMethodScriptClass::callMethod(QObject *object, int index,
- int returnType, int argCount, const int *argTypes,
+ int returnType, int argCount, int *argTypes,
QScriptContext *ctxt)
{
if (argCount > 0) {
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
index 24fcbda106..850a94f364 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -85,7 +85,7 @@ private:
Value callPrecise(QObject *, const QDeclarativePropertyCache::Data &, QScriptContext *);
Value callOverloaded(MethodData *, QScriptContext *);
- Value callMethod(QObject *, int index, int returnType, int argCount, const int *argTypes, QScriptContext *ctxt);
+ Value callMethod(QObject *, int index, int returnType, int argCount, int *argTypes, QScriptContext *ctxt);
int matchScore(const QScriptValue &, int, const QByteArray &);
QDeclarativePropertyCache::Data *relatedMethod(QObject *, QDeclarativePropertyCache::Data *current,