Qt 4.8
|
The QScriptContextInfo class provides additional information about a QScriptContext. More...
#include <qscriptcontextinfo.h>
Public Types | |
enum | FunctionType { ScriptFunction, QtFunction, QtPropertyFunction, NativeFunction } |
This enum specifies the type of function being called. More... | |
Public Functions | |
QT_DEPRECATED int | columnNumber () const |
QString | fileName () const |
Returns the name of the file where the code being executed was defined, if available; otherwise returns an empty string. More... | |
int | functionEndLineNumber () const |
Returns the line number where the definition of the called function ends, or -1 if the line number is not available. More... | |
int | functionMetaIndex () const |
Returns the meta index of the called function, or -1 if the meta index is not available. More... | |
QString | functionName () const |
Returns the name of the called function, or an empty string if the name is not available. More... | |
QStringList | functionParameterNames () const |
Returns the names of the formal parameters of the called function, or an empty QStringList if the parameter names are not available. More... | |
int | functionStartLineNumber () const |
Returns the line number where the definition of the called function starts, or -1 if the line number is not available. More... | |
FunctionType | functionType () const |
Returns the type of the called function. More... | |
bool | isNull () const |
Returns true if this QScriptContextInfo is null, i.e. More... | |
int | lineNumber () const |
Returns the line number corresponding to the statement being executed, or -1 if the line number is not available. More... | |
bool | operator!= (const QScriptContextInfo &other) const |
Returns true if this QScriptContextInfo is not equal to the other info, otherwise returns false. More... | |
QScriptContextInfo & | operator= (const QScriptContextInfo &other) |
Assigns the other info to this QScriptContextInfo, and returns a reference to this QScriptContextInfo. More... | |
bool | operator== (const QScriptContextInfo &other) const |
Returns true if this QScriptContextInfo is equal to the other info, otherwise returns false. More... | |
QScriptContextInfo (const QScriptContext *context) | |
Constructs a new QScriptContextInfo from the given context. More... | |
QScriptContextInfo (const QScriptContextInfo &other) | |
Constructs a new QScriptContextInfo from the other info. More... | |
QScriptContextInfo () | |
Constructs a null QScriptContextInfo. More... | |
qint64 | scriptId () const |
Returns the ID of the script where the code being executed was defined, or -1 if the ID is not available (i.e. More... | |
~QScriptContextInfo () | |
Destroys the QScriptContextInfo. More... | |
Properties | |
QExplicitlySharedDataPointer< QScriptContextInfoPrivate > | d_ptr |
Friends | |
Q_SCRIPT_EXPORT QDataStream & | operator<< (QDataStream &, const QScriptContextInfo &) |
Writes the given info to the specified stream. More... | |
Q_SCRIPT_EXPORT QDataStream & | operator>> (QDataStream &, QScriptContextInfo &) |
Reads a QScriptContextInfo from the specified stream into the given info. More... | |
The QScriptContextInfo class provides additional information about a QScriptContext.
QScriptContextInfo is typically used for debugging purposes. It can provide information about the code being executed, such as the type of the called function, and the original source code location of the current statement.
If the called function is executing Qt Script code, you can obtain the script location with the functions fileName() and lineNumber().
You can obtain the starting line number and ending line number of a Qt Script function definition with functionStartLineNumber() and functionEndLineNumber(), respectively.
For Qt Script functions and Qt methods (e.g. slots), you can call functionParameterNames() to get the names of the formal parameters of the function.
For Qt methods and Qt property accessors, you can obtain the index of the underlying QMetaMethod or QMetaProperty by calling functionMetaIndex().
Definition at line 45 of file qscriptcontextinfo.h.
This enum specifies the type of function being called.
Enumerator | |
---|---|
ScriptFunction | |
QtFunction | |
QtPropertyFunction | |
NativeFunction |
Definition at line 53 of file qscriptcontextinfo.h.
QScriptContextInfo::QScriptContextInfo | ( | const QScriptContext * | context | ) |
Constructs a new QScriptContextInfo from the given context.
The relevant information is extracted from the context at construction time; i.e. if you continue script execution in the context, the new state of the context will not be reflected in a previously created QScriptContextInfo.
Definition at line 240 of file qscriptcontextinfo.cpp.
QScriptContextInfo::QScriptContextInfo | ( | const QScriptContextInfo & | other | ) |
Constructs a new QScriptContextInfo from the other info.
Definition at line 252 of file qscriptcontextinfo.cpp.
QScriptContextInfo::QScriptContextInfo | ( | ) |
Constructs a null QScriptContextInfo.
Definition at line 262 of file qscriptcontextinfo.cpp.
QScriptContextInfo::~QScriptContextInfo | ( | ) |
int QScriptContextInfo::columnNumber | ( | ) | const |
Definition at line 336 of file qscriptcontextinfo.cpp.
Referenced by contextInfoToScriptValue(), and operator<<().
QString QScriptContextInfo::fileName | ( | ) | const |
Returns the name of the file where the code being executed was defined, if available; otherwise returns an empty string.
For Qt Script code, this function returns the fileName argument that was passed to QScriptEngine::evaluate().
Definition at line 308 of file qscriptcontextinfo.cpp.
Referenced by QJSDebuggerAgent::backtrace(), contextInfoToScriptValue(), QScriptDebuggerStackModel::data(), operator<<(), QJSDebuggerAgentPrivate::positionChange(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), and QScriptContext::toString().
int QScriptContextInfo::functionEndLineNumber | ( | ) | const |
Returns the line number where the definition of the called function ends, or -1 if the line number is not available.
The ending line number is only available if the functionType() is ScriptFunction.
Definition at line 402 of file qscriptcontextinfo.cpp.
Referenced by QScriptDebuggerCommandExecutor::execute(), and operator<<().
int QScriptContextInfo::functionMetaIndex | ( | ) | const |
Returns the meta index of the called function, or -1 if the meta index is not available.
The meta index is only available if the functionType() is QtFunction or QtPropertyFunction. For QtFunction, the meta index can be passed to QMetaObject::method() to obtain the corresponding method definition; for QtPropertyFunction, the meta index can be passed to QMetaObject::property() to obtain the corresponding property definition.
Definition at line 437 of file qscriptcontextinfo.cpp.
Referenced by operator<<().
QString QScriptContextInfo::functionName | ( | ) | const |
Returns the name of the called function, or an empty string if the name is not available.
For script functions of type QtPropertyFunction, this function always returns the name of the property; you can use QScriptContext::argumentCount() to differentiate between reads and writes.
Definition at line 355 of file qscriptcontextinfo.cpp.
Referenced by QJSDebuggerAgent::backtrace(), contextInfoToScriptValue(), QScriptDebuggerStackModel::data(), operator<<(), and QScriptContext::toString().
QStringList QScriptContextInfo::functionParameterNames | ( | ) | const |
Returns the names of the formal parameters of the called function, or an empty QStringList if the parameter names are not available.
Definition at line 416 of file qscriptcontextinfo.cpp.
Referenced by operator<<(), and QScriptContext::toString().
int QScriptContextInfo::functionStartLineNumber | ( | ) | const |
Returns the line number where the definition of the called function starts, or -1 if the line number is not available.
The starting line number is only available if the functionType() is ScriptFunction.
Definition at line 385 of file qscriptcontextinfo.cpp.
Referenced by QJSDebuggerAgent::backtrace(), QScriptDebuggerCommandExecutor::execute(), operator<<(), QDeclarativeValueTypeScriptClass::setProperty(), and QDeclarativeObjectScriptClass::setProperty().
QScriptContextInfo::FunctionType QScriptContextInfo::functionType | ( | ) | const |
Returns the type of the called function.
Definition at line 368 of file qscriptcontextinfo.cpp.
Referenced by QJSDebuggerAgent::backtrace(), QScriptDebuggerStackModel::data(), operator<<(), QJSDebuggerAgentPrivate::positionChange(), and QScriptContext::toString().
bool QScriptContextInfo::isNull | ( | ) | const |
Returns true if this QScriptContextInfo is null, i.e.
does not contain any information.
Definition at line 449 of file qscriptcontextinfo.cpp.
int QScriptContextInfo::lineNumber | ( | ) | const |
Returns the line number corresponding to the statement being executed, or -1 if the line number is not available.
The line number is only available if Qt Script code is being executed.
Definition at line 325 of file qscriptcontextinfo.cpp.
Referenced by QJSDebuggerAgent::backtrace(), contextInfoToScriptValue(), QScriptDebuggerStackModel::data(), operator<<(), and QScriptContext::toString().
bool QScriptContextInfo::operator!= | ( | const QScriptContextInfo & | other | ) | const |
Returns true if this QScriptContextInfo is not equal to the other info, otherwise returns false.
Definition at line 483 of file qscriptcontextinfo.cpp.
QScriptContextInfo & QScriptContextInfo::operator= | ( | const QScriptContextInfo & | other | ) |
Assigns the other info to this QScriptContextInfo, and returns a reference to this QScriptContextInfo.
Definition at line 278 of file qscriptcontextinfo.cpp.
bool QScriptContextInfo::operator== | ( | const QScriptContextInfo & | other | ) | const |
Returns true if this QScriptContextInfo is equal to the other info, otherwise returns false.
Definition at line 459 of file qscriptcontextinfo.cpp.
qint64 QScriptContextInfo::scriptId | ( | ) | const |
Returns the ID of the script where the code being executed was defined, or -1 if the ID is not available (i.e.
a native function is being executed).
Definition at line 291 of file qscriptcontextinfo.cpp.
Referenced by contextInfoToScriptValue(), QScriptDebuggerStackModel::data(), and operator<<().
|
friend |
Writes the given info to the specified stream.
Definition at line 499 of file qscriptcontextinfo.cpp.
|
friend |
Reads a QScriptContextInfo from the specified stream into the given info.
Definition at line 528 of file qscriptcontextinfo.cpp.
|
private |
Definition at line 90 of file qscriptcontextinfo.h.
Referenced by operator=(), operator>>(), and QScriptContextInfo().