Qt 4.8
Classes | Functions
qjsdebuggeragent.cpp File Reference
#include "private/qjsdebuggeragent_p.h"
#include "private/qdeclarativedebughelper_p.h"
#include "private/qjsdebugservice_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qset.h>
#include <QtCore/qurl.h>
#include <QtScript/qscriptcontextinfo.h>
#include <QtScript/qscriptengine.h>
#include <QtScript/qscriptvalueiterator.h>

Go to the source code of this file.

Classes

class  QJSDebuggerAgentPrivate
 

Functions

static QList< JSAgentWatchDataexpandObject (const QScriptValue &object)
 
static QString fileName (const QString &fileUrl)
 
static JSAgentWatchData fromScriptValue (const QString &expression, const QScriptValue &value)
 

Function Documentation

◆ expandObject()

static QList<JSAgentWatchData> expandObject ( const QScriptValue object)
static

Definition at line 172 of file qjsdebuggeragent.cpp.

Referenced by QJSDebuggerAgent::expandObjectById(), and QJSDebuggerAgentPrivate::getLocals().

173 {
175  QScriptValueIterator it(object);
176  while (it.hasNext()) {
177  it.next();
178  if (it.flags() & QScriptValue::SkipInEnumeration)
179  continue;
180  if (/*object.isQObject() &&*/ it.value().isFunction()) {
181  // Cosmetics: skip all functions and slot, there are too many of them,
182  // and it is not useful information in the debugger.
183  continue;
184  }
185  JSAgentWatchData data = fromScriptValue(it.name(), it.value());
186  result.append(data);
187  }
188  if (result.isEmpty()) {
190  data.name = "<no initialized data>";
191  data.hasChildren = false;
192  data.value = " ";
193  data.objectId = 0;
194  result.append(data);
195  }
196  return result;
197 }
#define it(className, varName)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static const char * data(const QByteArray &arr)
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
static JSAgentWatchData fromScriptValue(const QString &expression, const QScriptValue &value)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ fileName()

static QString fileName ( const QString fileUrl)
static

Definition at line 199 of file qjsdebuggeragent.cpp.

Referenced by QFileDialogPrivate::_q_deleteCurrent(), QPrintPreviewDialogPrivate::_q_print(), QFileDialogPrivate::_q_updateOkButton(), QFileDialogPrivate::_q_useNameFilter(), QDir::absoluteFilePath(), QFontDatabasePrivate::addAppFont(), QSvgIconEngine::addFile(), QPixmapIconEngine::addFile(), QDirIteratorPrivate::checkAndPushDirectory(), QGLShader::compileSourceFile(), QScriptDebuggerStackModel::data(), QScriptDebuggerScriptsModel::data(), QFile::decodeName(), QScriptDebuggerBackend::doPendingEvaluate(), QDragManager::drag(), QPdfEnginePrivate::embedFont(), QResourcePrivate::ensureInitialized(), QScriptDebuggerAgent::enterRunToLocationMode(), QScriptDebuggerBackend::evaluate(), QDeclarativeExpressionPrivate::exceptionToError(), QScriptDebuggerCommandExecutor::execute(), QNetworkDiskCache::expire(), fbname(), QNetworkDiskCache::fileMetaData(), QDir::filePath(), QFileSystemEngine::fillMetaData(), QTextBrowserPrivate::findFile(), QFontEngineQPF::fontFile(), QAxServerBase::GetClassID(), QPixmap::handle(), QScriptCompleteScriptsJob::handleResponse(), QFileSystemModelPrivate::index(), QMoviePrivate::infoForFrame(), QImageReaderPrivate::initHandler(), QFontDatabasePrivate::isApplicationFont(), QUrl::isParentOf(), QSystemLibrary::load(), QTextBrowser::loadResource(), QScriptDebuggerConsolePrivate::loadScriptedCommands(), QFSFileEnginePrivate::longFileName(), QFileSystemEngine::nativeAbsoluteFilePath(), QNetworkAccessFileBackend::open(), QFileInfo::operator!=(), QRawFont::operator!=(), QDir::operator!=(), QProcessPrivate::Channel::operator=(), operator>>(), QScriptDebuggerScriptedConsoleCommand::parse(), QDeclarativeScriptParser::parse(), QPlatformFontDatabase::populateFontDatabase(), QJSDebuggerAgentPrivate::positionChange(), QDeclarativeWorkerScriptEnginePrivate::processLoad(), qmlFilesInDirectory(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QPictureIO::QPictureIO(), qt_win_get_save_file_name(), qt_x11ft_convert_pattern(), QUrlInfo::QUrlInfo(), QDeclarativeDebugTrace::rangeLocationImpl(), QPixmapIconEngine::read(), QTestLog::redirectOutput(), QNetworkDiskCachePrivate::removeFile(), QScriptBreakpointsModel::resolveBreakpoint(), QScriptDebuggerScriptsModel::resolveScript(), QScriptDebuggerAgent::resolveScript(), QImage::scaled(), scriptDataFromScriptValue(), QScriptDebuggerAgent::scriptUnload(), QFileDialogPrivate::selectFile_sys(), QScriptDebuggerAgent::setBreakpoint(), QJSDebuggerAgent::setBreakpoints(), QScriptNewBreakpointWidget::setCompleter(), QPictureIO::setFileName(), QDeclarativeGraphics_DerivedObject::setParent_noEvent(), QProcess::setStandardErrorFile(), QProcess::setStandardInputFile(), QProcess::setStandardOutputFile(), QUrlModel::setUrl(), QWidgetPrivate::setWindowFilePath_helper(), QNetworkDiskCachePrivate::storeItem(), QUrl::swap(), QFile::symLinkTarget(), QDir::temp(), JSAgentCoverageData::toByteArray(), QScriptContext::toString(), QFactoryLoader::updateDir(), QFileInfoGatherer::updateFile(), write_xbm_image(), QOutputStrategy::~QOutputStrategy(), and QScriptMessageHandlerInterface::~QScriptMessageHandlerInterface().

200 {
201  int lastDelimiterPos = fileUrl.lastIndexOf(QLatin1Char('/'));
202  return fileUrl.mid(lastDelimiterPos, fileUrl.size() - lastDelimiterPos);
203 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ fromScriptValue()

static JSAgentWatchData fromScriptValue ( const QString expression,
const QScriptValue value 
)
static

Definition at line 115 of file qjsdebuggeragent.cpp.

Referenced by QDeclarativeObjectMethodScriptClass::callMethod(), QJSDebuggerAgent::executeExpression(), expandObject(), QJSDebuggerAgentPrivate::getLocals(), QDeclarativeObjectMethodScriptClass::property(), qScriptRegisterMetaType(), and QJSDebuggerAgent::watches().

117 {
118  static const QString arrayStr = QCoreApplication::translate
119  ("Debugger::JSAgentWatchData", "[Array of length %1]");
120  static const QString undefinedStr = QCoreApplication::translate
121  ("Debugger::JSAgentWatchData", "<undefined>");
122 
124  data.exp = expression.toUtf8();
125  data.name = data.exp;
126  data.hasChildren = false;
127  data.value = value.toString().toUtf8();
128  data.objectId = value.objectId();
129  if (value.isArray()) {
130  data.type = "Array";
131  data.value = arrayStr.arg(value.property(QLatin1String("length")).toString()).toUtf8();
132  data.hasChildren = true;
133  } else if (value.isBool()) {
134  data.type = "Bool";
135  // data.value = value.toBool() ? "true" : "false";
136  } else if (value.isDate()) {
137  data.type = "Date";
138  data.value = value.toDateTime().toString().toUtf8();
139  } else if (value.isError()) {
140  data.type = "Error";
141  } else if (value.isFunction()) {
142  data.type = "Function";
143  } else if (value.isUndefined()) {
144  data.type = undefinedStr.toUtf8();
145  } else if (value.isNumber()) {
146  data.type = "Number";
147  } else if (value.isRegExp()) {
148  data.type = "RegExp";
149  } else if (value.isString()) {
150  data.type = "String";
151  } else if (value.isVariant()) {
152  data.type = "Variant";
153  } else if (value.isQObject()) {
154  const QObject *obj = value.toQObject();
155  data.type = "Object";
156  data.value += '[';
157  data.value += obj->metaObject()->className();
158  data.value += ']';
159  data.hasChildren = true;
160  } else if (value.isObject()) {
161  data.type = "Object";
162  data.hasChildren = true;
163  data.value = "[Object]";
164  } else if (value.isNull()) {
165  data.type = "<null>";
166  } else {
167  data.type = "<unknown>";
168  }
169  return data;
170 }
bool isUndefined() const
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false...
bool isNull() const
Returns true if this QScriptValue is of the primitive type Null; otherwise returns false...
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
bool isBool() const
Returns true if this QScriptValue is of the primitive type Boolean; otherwise returns false...
bool isFunction() const
Returns true if this QScriptValue is a function; otherwise returns false.
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
bool isError() const
Returns true if this QScriptValue is an object of the Error class; otherwise returns false...
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QObject * toQObject() const
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; othe...
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
Definition: qdatetime.cpp:2628
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
qint64 objectId() const
Returns the ID of this object, or -1 if this QScriptValue is not an object.
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
bool isVariant() const
Returns true if this QScriptValue is a variant value; otherwise returns false.
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
bool isRegExp() const
Returns true if this QScriptValue is an object of the RegExp class; otherwise returns false...
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
bool isQObject() const
Returns true if this QScriptValue is a QObject; otherwise returns false.
bool isDate() const
Returns true if this QScriptValue is an object of the Date class; otherwise returns false...
bool isArray() const
Returns true if this QScriptValue is an object of the Array class; otherwise returns false...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
bool isObject() const
Returns true if this QScriptValue is of the Object type; otherwise returns false. ...