Qt 4.8
Public Functions | Static Public Functions | Protected Functions | List of all members
QScriptDebuggerScriptedConsoleCommand Class Reference

The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script. More...

#include <qscriptdebuggerscriptedconsolecommand_p.h>

Inheritance diagram for QScriptDebuggerScriptedConsoleCommand:
QScriptDebuggerConsoleCommand

Public Functions

QStringList aliases () const
 
QStringList argumentTypes () const
 
QScriptDebuggerConsoleCommandJob * createJob (const QStringList &arguments, QScriptDebuggerConsole *console, QScriptMessageHandlerInterface *messageHandler, QScriptDebuggerCommandSchedulerInterface *commandScheduler)
 
QString group () const
 
QString longDescription () const
 
QString name () const
 
QStringList seeAlso () const
 
QString shortDescription () const
 
QStringList subCommands () const
 
 ~QScriptDebuggerScriptedConsoleCommand ()
 
- Public Functions inherited from QScriptDebuggerConsoleCommand
 QScriptDebuggerConsoleCommand ()
 
virtual ~QScriptDebuggerConsoleCommand ()
 

Static Public Functions

static QScriptDebuggerScriptedConsoleCommand * parse (const QString &program, const QString &fileName, QScriptEngine *engine, QScriptMessageHandlerInterface *messageHandler)
 Parses a command defined by the given program. More...
 

Protected Functions

 QScriptDebuggerScriptedConsoleCommand (const QString &name, const QString &group, const QString &shortDescription, const QString &longDescription, const QStringList &aliases, const QStringList &seeAlso, const QStringList &argumentTypes, const QStringList &subCommands, const QScriptValue &globalObject, const QScriptValue &execFunction, const QScriptValue &responseFunction)
 
- Protected Functions inherited from QScriptDebuggerConsoleCommand
 QScriptDebuggerConsoleCommand (QScriptDebuggerConsoleCommandPrivate &dd)
 

Additional Inherited Members

- Protected Variables inherited from QScriptDebuggerConsoleCommand
QScopedPointer< QScriptDebuggerConsoleCommandPrivate > d_ptr
 

Detailed Description

The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script.

Since
4.5
Warning
This function is not part of the public interface.

Definition at line 64 of file qscriptdebuggerscriptedconsolecommand_p.h.

Constructors and Destructors

◆ QScriptDebuggerScriptedConsoleCommand()

QScriptDebuggerScriptedConsoleCommand::QScriptDebuggerScriptedConsoleCommand ( const QString &  name,
const QString &  group,
const QString &  shortDescription,
const QString &  longDescription,
const QStringList &  aliases,
const QStringList &  seeAlso,
const QStringList &  argumentTypes,
const QStringList &  subCommands,
const QScriptValue &  globalObject,
const QScriptValue &  execFunction,
const QScriptValue &  responseFunction 
)
protected

Definition at line 103 of file qscriptdebuggerscriptedconsolecommand.cpp.

111 {
113  d->name = name;
114  d->group = group;
115  d->shortDescription = shortDescription;
116  d->longDescription = longDescription;
117  d->aliases = aliases;
118  d->seeAlso = seeAlso;
119  d->argumentTypes = argumentTypes;
120  d->subCommands = subCommands;
121  d->globalObject = globalObject;
122  d->execFunction = execFunction;
123  d->responseFunction = responseFunction;
124 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ ~QScriptDebuggerScriptedConsoleCommand()

QScriptDebuggerScriptedConsoleCommand::~QScriptDebuggerScriptedConsoleCommand ( )

Definition at line 126 of file qscriptdebuggerscriptedconsolecommand.cpp.

127 {
128 }

Functions

◆ aliases()

QStringList QScriptDebuggerScriptedConsoleCommand::aliases ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QScriptDebuggerConsoleCommand.

Definition at line 294 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

295 {
297  return d->aliases;
298 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ argumentTypes()

QStringList QScriptDebuggerScriptedConsoleCommand::argumentTypes ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QScriptDebuggerConsoleCommand.

Definition at line 312 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

313 {
315  return d->argumentTypes;
316 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ createJob()

QScriptDebuggerConsoleCommandJob * QScriptDebuggerScriptedConsoleCommand::createJob ( const QStringList &  arguments,
QScriptDebuggerConsole *  console,
QScriptMessageHandlerInterface *  messageHandler,
QScriptDebuggerCommandSchedulerInterface *  commandScheduler 
)
virtual
Warning
This function is not part of the public interface.

Implements QScriptDebuggerConsoleCommand.

Definition at line 330 of file qscriptdebuggerscriptedconsolecommand.cpp.

335 {
338  d, arguments, console, messageHandler, commandScheduler);
339 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ group()

QString QScriptDebuggerScriptedConsoleCommand::group ( ) const
virtual
Warning
This function is not part of the public interface.

Implements QScriptDebuggerConsoleCommand.

Definition at line 267 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

268 {
270  return d->group;
271 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ longDescription()

QString QScriptDebuggerScriptedConsoleCommand::longDescription ( ) const
virtual
Warning
This function is not part of the public interface.

Implements QScriptDebuggerConsoleCommand.

Definition at line 285 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

286 {
288  return d->longDescription;
289 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ name()

QString QScriptDebuggerScriptedConsoleCommand::name ( ) const
virtual
Warning
This function is not part of the public interface.

Implements QScriptDebuggerConsoleCommand.

Definition at line 258 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

259 {
261  return d->name;
262 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ parse()

QScriptDebuggerScriptedConsoleCommand * QScriptDebuggerScriptedConsoleCommand::parse ( const QString &  program,
const QString &  fileName,
QScriptEngine *  engine,
QScriptMessageHandlerInterface *  messageHandler 
)
static

Parses a command defined by the given program.

Returns an object that encapsulates the command, or 0 if parsing failed.

Definition at line 345 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerConsolePrivate::loadScriptedCommands().

348 {
349  // create a custom global object
351  QScriptValue global = engine->newQObject(cppGlobal,
354  {
356  while (it.hasNext()) {
357  it.next();
358  global.setProperty(it.scriptName(), it.value(), it.flags());
359  }
360  }
361  engine->setGlobalObject(global);
362 
363  cppGlobal->setMessageHandler(messageHandler);
364  QScriptValue ret = engine->evaluate(program, fileName);
365  cppGlobal->setMessageHandler(0);
366  if (engine->hasUncaughtException()) {
367  messageHandler->message(QtCriticalMsg, ret.toString(), fileName,
368  engine->uncaughtExceptionLineNumber());
369  return 0;
370  }
371 
372  QScriptValue name = global.property(QLatin1String("name"));
373  if (!name.isString()) {
374  messageHandler->message(QtCriticalMsg, QLatin1String("command definition lacks a name"), fileName);
375  return 0;
376  }
377  QString nameStr = name.toString();
378 
379  QScriptValue group = global.property(QLatin1String("group"));
380  if (!group.isString()) {
381  messageHandler->message(QtCriticalMsg, QString::fromLatin1("definition of command \"%0\" lacks a group name")
382  .arg(nameStr), fileName);
383  return 0;
384  }
385  QString groupStr = group.toString();
386 
387  QScriptValue shortDesc = global.property(QLatin1String("shortDescription"));
388  if (!shortDesc.isString()) {
389  messageHandler->message(QtCriticalMsg, QString::fromLatin1("definition of command \"%0\" lacks shortDescription")
390  .arg(nameStr), fileName);
391  return 0;
392  }
393  QString shortDescStr = shortDesc.toString();
394 
395  QScriptValue longDesc = global.property(QLatin1String("longDescription"));
396  if (!longDesc.isString()) {
397  messageHandler->message(QtCriticalMsg, QString::fromLatin1("definition of command \"%0\" lacks longDescription")
398  .arg(nameStr), fileName);
399  return 0;
400  }
401  QString longDescStr = longDesc.toString();
402 
405 
408 
409  QStringList argTypes;
410  qScriptValueToSequence(global.property(QLatin1String("argumentTypes")), argTypes);
411 
413  qScriptValueToSequence(global.property(QLatin1String("subCommands")), subCommands);
414 
415  QScriptValue execFunction = global.property(QLatin1String("execute"));
416  if (!execFunction.isFunction()) {
417  messageHandler->message(QtCriticalMsg, QString::fromLatin1("definition of command \"%0\" lacks execute() function")
418  .arg(nameStr), fileName);
419  return 0;
420  }
421 
422  QScriptValue responseFunction = global.property(QLatin1String("handleResponse"));
423 
425  nameStr, groupStr,
426  shortDescStr, longDescStr,
427  aliases, seeAlso,
428  argTypes, subCommands,
429  global, execFunction, responseFunction);
430  return result;
431 }
QScriptValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
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...
#define it(className, varName)
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void setGlobalObject(const QScriptValue &object)
Sets this engine&#39;s Global Object to be the given object.
int uncaughtExceptionLineNumber() const
Returns the line number where the last uncaught exception occurred.
QScriptDebuggerScriptedConsoleCommand(const QString &name, const QString &group, const QString &shortDescription, const QString &longDescription, const QStringList &aliases, const QStringList &seeAlso, const QStringList &argumentTypes, const QStringList &subCommands, const QScriptValue &globalObject, const QScriptValue &execFunction, const QScriptValue &responseFunction)
QScriptValue newQObject(QObject *object, ValueOwnership ownership=QtOwnership, const QObjectWrapOptions &options=0)
Creates a QtScript object that wraps the given QObject object, using the given ownership.
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
void setMessageHandler(QScriptMessageHandlerInterface *messageHandler)
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
void qScriptValueToSequence(const QScriptValue &value, Container &cont)
bool hasUncaughtException() const
Returns true if the last script evaluation resulted in an uncaught exception; otherwise returns false...
virtual void message(QtMsgType type, const QString &text, const QString &fileName=QString(), int lineNumber=-1, int columnNumber=-1, const QVariant &data=QVariant())=0
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
static QString fileName(const QString &fileUrl)

◆ seeAlso()

QStringList QScriptDebuggerScriptedConsoleCommand::seeAlso ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QScriptDebuggerConsoleCommand.

Definition at line 303 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

304 {
306  return d->seeAlso;
307 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ shortDescription()

QString QScriptDebuggerScriptedConsoleCommand::shortDescription ( ) const
virtual
Warning
This function is not part of the public interface.

Implements QScriptDebuggerConsoleCommand.

Definition at line 276 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

277 {
279  return d->shortDescription;
280 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

◆ subCommands()

QStringList QScriptDebuggerScriptedConsoleCommand::subCommands ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QScriptDebuggerConsoleCommand.

Definition at line 321 of file qscriptdebuggerscriptedconsolecommand.cpp.

Referenced by QScriptDebuggerScriptedConsoleCommand().

322 {
324  return d->subCommands;
325 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerScriptedConsoleCommand class encapsulates a command defined in a script...

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