Qt 4.8
Public Functions | Public Variables | List of all members
QScriptDebuggerConsolePrivate Class Reference

Public Functions

QScriptDebuggerConsoleCommandJobcreateJob (const QString &command, QScriptMessageHandlerInterface *messageHandler, QScriptDebuggerCommandSchedulerInterface *commandScheduler)
 Creates a job that will execute the given debugger command. More...
 
void loadScriptedCommands (const QString &scriptsPath, QScriptMessageHandlerInterface *messageHandler)
 Loads command definitions from scripts located in the given scriptsPath. More...
 
 QScriptDebuggerConsolePrivate (QScriptDebuggerConsole *)
 
 ~QScriptDebuggerConsolePrivate ()
 

Public Variables

QScriptEnginecommandEngine
 
QStringList commandHistory
 
QScriptDebuggerConsoleCommandManagercommandManager
 
QString commandPrefix
 
int currentFrameIndex
 
int currentLineNumber
 
qint64 currentScriptId
 
int evaluateAction
 
QString input
 
QScriptDebuggerConsoleq_ptr
 
qint64 sessionId
 

Detailed Description

Definition at line 268 of file qscriptdebuggerconsole.cpp.

Constructors and Destructors

◆ QScriptDebuggerConsolePrivate()

QScriptDebuggerConsolePrivate::QScriptDebuggerConsolePrivate ( QScriptDebuggerConsole parent)

Definition at line 296 of file qscriptdebuggerconsole.cpp.

297  : q_ptr(parent)
298 {
299  sessionId = 0;
300  currentFrameIndex = 0;
301  currentScriptId = -1;
302  currentLineNumber = -1;
303  evaluateAction = 0;
306 
308  qScriptRegisterMetaType<QScriptBreakpointData>(commandEngine, breakpointDataToScriptValue, breakpointDataFromScriptValue);
309  qScriptRegisterMetaType<QScriptBreakpointMap>(commandEngine, breakpointMapToScriptValue, breakpointMapFromScriptValue);
310  qScriptRegisterMetaType<QScriptScriptData>(commandEngine, scriptDataToScriptValue, scriptDataFromScriptValue);
311  qScriptRegisterMetaType<QScriptScriptMap>(commandEngine, scriptMapToScriptValue, scriptMapFromScriptValue);
312  qScriptRegisterMetaType<QScriptContextInfo>(commandEngine, contextInfoToScriptValue, contextInfoFromScriptValue);
313  qScriptRegisterMetaType<QScriptDebuggerValueProperty>(commandEngine, debuggerScriptValuePropertyToScriptValue, debuggerScriptValuePropertyFromScriptValue);
314  qScriptRegisterSequenceMetaType<QScriptDebuggerValuePropertyList>(commandEngine);
315  qScriptRegisterMetaType<QScriptDebuggerResponse>(commandEngine, debuggerResponseToScriptValue, debuggerResponseFromScriptValue);
316  qScriptRegisterMetaType<QScriptDebuggerConsoleCommand*>(commandEngine, consoleCommandToScriptValue, consoleCommandFromScriptValue);
317  qScriptRegisterSequenceMetaType<QScriptDebuggerConsoleCommandList>(commandEngine);
318  qScriptRegisterMetaType<QScriptDebuggerConsoleCommandGroupData>(commandEngine, consoleCommandGroupDataToScriptValue, consoleCommandGroupDataFromScriptValue);
319  qScriptRegisterMetaType<QScriptDebuggerConsoleCommandGroupMap>(commandEngine, consoleCommandGroupMapToScriptValue, consoleCommandGroupMapFromScriptValue);
320 // ### can't do this, if it's an object ID the conversion will be incorrect since
321 // ### the object ID refers to an object in a different engine!
322 // qScriptRegisterMetaType(commandEngine, debuggerScriptValueToScriptValue, debuggerScriptValueFromScriptValue);
323 }
QScriptDebuggerConsoleCommandManager * commandManager
static void debuggerScriptValuePropertyFromScriptValue(const QScriptValue &in, QScriptDebuggerValueProperty &out)
static QScriptValue scriptDataToScriptValue(QScriptEngine *eng, const QScriptScriptData &in)
static QScriptValue debuggerScriptValuePropertyToScriptValue(QScriptEngine *eng, const QScriptDebuggerValueProperty &in)
static void breakpointMapFromScriptValue(const QScriptValue &, QScriptBreakpointMap &)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QScriptValue debuggerResponseToScriptValue(QScriptEngine *eng, const QScriptDebuggerResponse &in)
static QScriptValue breakpointMapToScriptValue(QScriptEngine *eng, const QScriptBreakpointMap &in)
static QScriptValue consoleCommandGroupDataToScriptValue(QScriptEngine *eng, const QScriptDebuggerConsoleCommandGroupData &in)
The QScriptEngine class provides an environment for evaluating Qt Script code.
static void scriptDataFromScriptValue(const QScriptValue &in, QScriptScriptData &out)
static QScriptValue breakpointDataToScriptValue(QScriptEngine *eng, const QScriptBreakpointData &in)
static QScriptValue consoleCommandGroupMapToScriptValue(QScriptEngine *eng, const QScriptDebuggerConsoleCommandGroupMap &in)
static QScriptValue contextInfoToScriptValue(QScriptEngine *eng, const QScriptContextInfo &in)
static void breakpointDataFromScriptValue(const QScriptValue &in, QScriptBreakpointData &out)
static void consoleCommandGroupMapFromScriptValue(const QScriptValue &, QScriptDebuggerConsoleCommandGroupMap &)
static QScriptValue consoleCommandToScriptValue(QScriptEngine *eng, QScriptDebuggerConsoleCommand *const &in)
static void scriptMapFromScriptValue(const QScriptValue &, QScriptScriptMap &)
static QScriptValue scriptMapToScriptValue(QScriptEngine *eng, const QScriptScriptMap &in)
static void consoleCommandGroupDataFromScriptValue(const QScriptValue &, QScriptDebuggerConsoleCommandGroupData &)
static void consoleCommandFromScriptValue(const QScriptValue &, QScriptDebuggerConsoleCommand *&)
static void contextInfoFromScriptValue(const QScriptValue &, QScriptContextInfo &)
static void debuggerResponseFromScriptValue(const QScriptValue &, QScriptDebuggerResponse &)

◆ ~QScriptDebuggerConsolePrivate()

QScriptDebuggerConsolePrivate::~QScriptDebuggerConsolePrivate ( )

Definition at line 325 of file qscriptdebuggerconsole.cpp.

326 {
327  delete commandManager;
328  delete commandEngine;
329 }
QScriptDebuggerConsoleCommandManager * commandManager

Functions

◆ createJob()

QScriptDebuggerConsoleCommandJob * QScriptDebuggerConsolePrivate::createJob ( const QString command,
QScriptMessageHandlerInterface messageHandler,
QScriptDebuggerCommandSchedulerInterface commandScheduler 
)

Creates a job that will execute the given debugger command.

Returns the new job, or 0 if the command is undefined.

Definition at line 363 of file qscriptdebuggerconsole.cpp.

366 {
367  QString name;
368  int i = command.indexOf(QLatin1Char(' '));
369  if (i == -1) {
370  name = command;
371  i = name.size();
372  } else {
373  name = command.left(i);
374  }
375  if (name.isEmpty())
376  return 0;
378  if (!cmd) {
379  // try to auto-complete
380  QStringList completions = commandManager->completions(name);
381  if (!completions.isEmpty()) {
382  if (completions.size() > 1) {
383  QString msg;
384  msg.append(QString::fromLatin1("Ambiguous command \"%0\": ")
385  .arg(name));
386  for (int j = 0; j < completions.size(); ++j) {
387  if (j > 0)
388  msg.append(QLatin1String(", "));
389  msg.append(completions.at(j));
390  }
391  msg.append(QLatin1Char('.'));
392  messageHandler->message(QtWarningMsg, msg);
393  return 0;
394  }
395  cmd = commandManager->findCommand(completions.at(0));
396  Q_ASSERT(cmd != 0);
397  }
398  if (!cmd) {
399  messageHandler->message(
400  QtWarningMsg,
401  QString::fromLatin1("Undefined command \"%0\". Try \"help\".")
402  .arg(name));
403  return 0;
404  }
405  }
406  QStringList args;
407  QString tmp = command.mid(i+1);
408  if (cmd->argumentTypes().contains(QString::fromLatin1("script"))) {
409  if (!tmp.isEmpty())
410  args.append(tmp);
411  } else {
412  args = tmp.split(QLatin1Char(' '), QString::SkipEmptyParts);
413  }
414  return cmd->createJob(args, q_func(), messageHandler, commandScheduler);
415 }
QScriptDebuggerConsoleCommandManager * commandManager
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QStringList completions(const QString &prefix) const
Returns the possible completions for the given prefix.
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
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QScriptDebuggerConsoleCommand * findCommand(const QString &name) const
Returns the command with the given name if one exists, otherwise returns 0.
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
QString & append(QChar c)
Definition: qstring.cpp:1777
The QScriptDebuggerConsoleCommand class is the base class of console commands.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
virtual QScriptDebuggerConsoleCommandJob * createJob(const QStringList &arguments, QScriptDebuggerConsole *console, QScriptMessageHandlerInterface *messageHandler, QScriptDebuggerCommandSchedulerInterface *scheduler)=0
Creates a job that will execute this command with the given arguments.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
virtual void message(QtMsgType type, const QString &text, const QString &fileName=QString(), int lineNumber=-1, int columnNumber=-1, const QVariant &data=QVariant())=0
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ loadScriptedCommands()

void QScriptDebuggerConsolePrivate::loadScriptedCommands ( const QString scriptsPath,
QScriptMessageHandlerInterface messageHandler 
)

Loads command definitions from scripts located in the given scriptsPath.

Definition at line 334 of file qscriptdebuggerconsole.cpp.

337 {
338  QDir dir(scriptsPath);
339  QFileInfoList entries = dir.entryInfoList(QStringList()
340  << QLatin1String("*.qs"));
341  for (int i = 0; i < entries.size(); ++i) {
342  const QFileInfo &fi = entries.at(i);
343  QString fileName = fi.fileName();
344  QFile file(scriptsPath + QLatin1Char('/') + fileName);
345  if (!file.open(QIODevice::ReadOnly))
346  continue;
347  QTextStream stream(&file);
348  QString program = stream.readAll();
351  program, fileName, commandEngine, messageHandler);
352  if (!command)
353  continue;
354  commandManager->addCommand(command);
355  }
356 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QScriptDebuggerConsoleCommandManager * commandManager
void addCommand(QScriptDebuggerConsoleCommand *command)
Adds the given command.
static QScriptDebuggerScriptedConsoleCommand * parse(const QString &program, const QString &fileName, QScriptEngine *engine, QScriptMessageHandlerInterface *messageHandler)
Parses a command defined by the given program.
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static FILE * stream
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const MacSpecialKey entries[NumEntries]
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:73
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
static QString fileName(const QString &fileUrl)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Properties

◆ commandEngine

QScriptEngine* QScriptDebuggerConsolePrivate::commandEngine

◆ commandHistory

QStringList QScriptDebuggerConsolePrivate::commandHistory

Definition at line 286 of file qscriptdebuggerconsole.cpp.

◆ commandManager

QScriptDebuggerConsoleCommandManager* QScriptDebuggerConsolePrivate::commandManager

◆ commandPrefix

QString QScriptDebuggerConsolePrivate::commandPrefix

Definition at line 284 of file qscriptdebuggerconsole.cpp.

Referenced by QScriptDebuggerConsolePrivate().

◆ currentFrameIndex

int QScriptDebuggerConsolePrivate::currentFrameIndex

Definition at line 287 of file qscriptdebuggerconsole.cpp.

Referenced by QScriptDebuggerConsolePrivate().

◆ currentLineNumber

int QScriptDebuggerConsolePrivate::currentLineNumber

Definition at line 289 of file qscriptdebuggerconsole.cpp.

Referenced by QScriptDebuggerConsolePrivate().

◆ currentScriptId

qint64 QScriptDebuggerConsolePrivate::currentScriptId

Definition at line 288 of file qscriptdebuggerconsole.cpp.

Referenced by QScriptDebuggerConsolePrivate().

◆ evaluateAction

int QScriptDebuggerConsolePrivate::evaluateAction

Definition at line 290 of file qscriptdebuggerconsole.cpp.

Referenced by QScriptDebuggerConsolePrivate().

◆ input

QString QScriptDebuggerConsolePrivate::input

Definition at line 285 of file qscriptdebuggerconsole.cpp.

◆ q_ptr

QScriptDebuggerConsole* QScriptDebuggerConsolePrivate::q_ptr

Definition at line 293 of file qscriptdebuggerconsole.cpp.

◆ sessionId

qint64 QScriptDebuggerConsolePrivate::sessionId

Definition at line 291 of file qscriptdebuggerconsole.cpp.

Referenced by QScriptDebuggerConsolePrivate().


The documentation for this class was generated from the following file: