diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-10 11:25:44 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-10 11:25:44 (GMT) |
commit | ed7acc2ba2d11afd4fb0a8afae3d3e1567283571 (patch) | |
tree | 98fbd870d812d1a81da68d1a648530b624792e9e /src | |
parent | fab932713af6dfa7aad06ddfde774d25f5222472 (diff) | |
download | Qt-ed7acc2ba2d11afd4fb0a8afae3d3e1567283571.zip Qt-ed7acc2ba2d11afd4fb0a8afae3d3e1567283571.tar.gz Qt-ed7acc2ba2d11afd4fb0a8afae3d3e1567283571.tar.bz2 |
implement QScriptContextInfo::parameterNames() for Qt methods
It doesn't work for overloaded methods yet (unless you just
happened to call the overload that's defined last in the source
file).
In the old back-end we stored the actual overload that was being
called in the QScriptContextPrivate. Since QScriptContext is a
JSC::ExecState now, we either have to add the information to
JSC::ExecState, or add some mapping scheme so we can go
determine the meta-index for a particular (ExecState, QtFunction)
pair.
Also in this commit: Marked expected failures, so the autotests
will run to completion.
Diffstat (limited to 'src')
-rw-r--r-- | src/script/api/qscriptcontextinfo.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp index eb9daf0..2e2d346 100644 --- a/src/script/api/qscriptcontextinfo.cpp +++ b/src/script/api/qscriptcontextinfo.cpp @@ -44,6 +44,7 @@ #include "qscriptcontext_p.h" #include "../bridge/qscriptqobject_p.h" #include <QtCore/qdatastream.h> +#include <QtCore/qmetaobject.h> #include "CodeBlock.h" #include "JSFunction.h" @@ -175,7 +176,15 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte // lineNumber = codeBlock->expressionRangeForBytecodeOffset(...); } else if (callee && callee->isObject(&QScript::QtFunction::info)) { functionType = QScriptContextInfo::QtFunction; + // ### the slot can be overloaded -- need to get the particular overload from the context functionMetaIndex = static_cast<QScript::QtFunction*>(callee)->initialIndex(); + const QMetaObject *meta = static_cast<QScript::QtFunction*>(callee)->metaObject(); + if (meta != 0) { + QMetaMethod method = meta->method(functionMetaIndex); + QList<QByteArray> formals = method.parameterNames(); + for (int i = 0; i < formals.count(); ++i) + parameterNames.append(QLatin1String(formals.at(i))); + } } else if (callee && callee->isObject(&QScript::QtPropertyFunction::info)) { functionType = QScriptContextInfo::QtPropertyFunction; |