Qt 4.8
qscriptdebuggercommand.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSCriptTools module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
44 #include "qscriptdebuggervalue_p.h"
45 
46 #include <QtCore/qhash.h>
47 #include <QtCore/qdatastream.h>
48 #include <QtCore/qstringlist.h>
49 
52 
54 
73 {
74 public:
77 
80 };
81 
84 {
85 }
86 
88 {
89 }
90 
96 {
97  d_ptr->type = None;
98 }
99 
106 {
107  d_ptr->type = type;
108 }
109 
116 {
117  *d_ptr = *other.d_ptr;
118 }
119 
124 {
125 }
126 
131 {
132  *d_ptr = *other.d_ptr;
133  return *this;
134 }
135 
140 {
142  return d->type;
143 }
144 
150  const QVariant &defaultValue) const
151 {
153  return d->attributes.value(attribute, defaultValue);
154 }
155 
160  const QVariant &value)
161 {
163  if (!value.isValid())
164  d->attributes.remove(attribute);
165  else
166  d->attributes[attribute] = value;
167 }
168 
170 {
172  return d->attributes;
173 }
174 
182 {
184  return d->attributes.value(FileName).toString();
185 }
186 
188 {
190  d->attributes[FileName] = fileName;
191 }
192 
200 {
202  return d->attributes.value(LineNumber, -1).toInt();
203 }
204 
206 {
208  d->attributes[LineNumber] = lineNumber;
209 }
210 
218 {
220  return d->attributes.value(ScriptID, -1).toLongLong();
221 }
222 
224 {
226  d->attributes[ScriptID] = id;
227 }
228 
230 {
232  return d->attributes.value(Program).toString();
233 }
234 
236 {
238  d->attributes[Program] = program;
239 }
240 
242 {
244  return d->attributes.value(BreakpointID, -1).toInt();
245 }
246 
248 {
250  d->attributes[BreakpointID] = id;
251 }
252 
254 {
256  return qvariant_cast<QScriptBreakpointData>(d->attributes.value(BreakpointData));
257 }
258 
260 {
262  d->attributes[BreakpointData] = QVariant::fromValue(data);
263 }
264 
266 {
268  return qvariant_cast<QScriptDebuggerValue>(d->attributes.value(ScriptValue));
269 }
270 
272 {
274  d->attributes[ScriptValue] = QVariant::fromValue(value);
275 }
276 
278 {
280  return d->attributes.value(ContextIndex, -1).toInt();
281 }
282 
284 {
286  d->attributes[ContextIndex] = index;
287 }
288 
290 {
292  return d->attributes.value(IteratorID, -1).toInt();
293 }
294 
296 {
298  d->attributes[IteratorID] = id;
299 }
300 
302 {
304  return d->attributes.value(Name).toString();
305 }
306 
308 {
310  d->attributes[Name] = name;
311 }
312 
314 {
316  return qvariant_cast<QScriptDebuggerValue>(d->attributes.value(SubordinateScriptValue));
317 }
318 
320 {
322  d->attributes[SubordinateScriptValue] = QVariant::fromValue(value);
323 }
324 
326 {
328  return d->attributes.value(SnapshotID, -1).toInt();
329 }
330 
332 {
334  d->attributes[SnapshotID] = id;
335 }
336 
342 {
344  const QScriptDebuggerCommandPrivate *od = other.d_func();
345  if (d == od)
346  return true;
347  if (!d || !od)
348  return false;
349  return ((d->type == od->type)
350  && (d->attributes == od->attributes));
351 }
352 
358 {
359  return !(*this == other);
360 }
361 
363 {
365  return cmd;
366 }
367 
369 {
371  return cmd;
372 }
373 
375 {
377  cmd.setAttribute(StepCount, count);
378  return cmd;
379 }
380 
382 {
384  cmd.setAttribute(StepCount, count);
385  return cmd;
386 }
387 
389 {
391  return cmd;
392 }
393 
395 {
397  cmd.setFileName(fileName);
398  cmd.setLineNumber(lineNumber);
399  return cmd;
400 }
401 
403 {
405  cmd.setScriptId(scriptId);
406  cmd.setLineNumber(lineNumber);
407  return cmd;
408 }
409 
411 {
413  cmd.setContextIndex(contextIndex);
414  cmd.setScriptValue(value);
415  return cmd;
416 }
417 
419 {
421  return cmd;
422 }
423 
425 {
427  cmd.setBreakpointData(QScriptBreakpointData(fileName, lineNumber));
428  return cmd;
429 }
430 
432 {
434  cmd.setBreakpointData(data);
435  return cmd;
436 }
437 
439 {
441  cmd.setBreakpointId(id);
442  return cmd;
443 }
444 
446 {
448  return cmd;
449 }
450 
452 {
454  return cmd;
455 }
456 
458 {
460  cmd.setBreakpointId(id);
461  return cmd;
462 }
463 
465 {
467  cmd.setBreakpointId(id);
468  cmd.setBreakpointData(data);
469  return cmd;
470 }
471 
473 {
475  return cmd;
476 }
477 
479 {
481  cmd.setScriptId(id);
482  return cmd;
483 }
484 
486 {
488  return cmd;
489 }
490 
492 {
494  return cmd;
495 }
496 
498 {
500  cmd.setFileName(fileName);
501  return cmd;
502 }
503 
505 {
507  return cmd;
508 }
509 
511 {
513  return cmd;
514 }
515 
517 {
519  cmd.setContextIndex(contextIndex);
520  return cmd;
521 }
522 
524 {
526  cmd.setContextIndex(contextIndex);
527  return cmd;
528 }
529 
531 {
533  cmd.setContextIndex(contextIndex);
534  return cmd;
535 }
536 
538 {
540  cmd.setContextIndex(contextIndex);
541  return cmd;
542 }
543 
545 {
547  cmd.setContextIndex(contextIndex);
548  return cmd;
549 }
550 
552 {
554  cmd.setContextIndex(contextIndex);
555  return cmd;
556 }
557 
559 {
561  return cmd;
562 }
563 
565  int contextIndex, int lineNumber, const QStringList &path)
566 {
568  cmd.setContextIndex(contextIndex);
569  cmd.setLineNumber(lineNumber);
570  cmd.setAttribute(UserAttribute, path);
571  return cmd;
572 }
573 
575  int contextIndex, const QStringList &path)
576 {
578  cmd.setContextIndex(contextIndex);
579  cmd.setAttribute(UserAttribute, path);
580  return cmd;
581 }
582 
584 {
586  return cmd;
587 }
588 
590 {
593  cmd.setSnapshotId(id);
594  cmd.setScriptValue(object);
595  return cmd;
596 }
597 
599 {
601  cmd.setSnapshotId(id);
602  return cmd;
603 }
604 
606 {
609  cmd.setScriptValue(object);
610  return cmd;
611 }
612 
614 {
615  Q_UNUSED(count);
617  cmd.setIteratorId(id);
618  return cmd;
619 }
620 
622 {
624  cmd.setIteratorId(id);
625  return cmd;
626 }
627 
629  int contextIndex, const QString &program, const QString &fileName, int lineNumber)
630 {
632  cmd.setContextIndex(contextIndex);
633  cmd.setProgram(program);
634  cmd.setFileName(fileName);
635  cmd.setLineNumber(lineNumber);
636  return cmd;
637 }
638 
640 {
642  cmd.setScriptValue(value);
643  return cmd;
644 }
645 
647  const QScriptDebuggerValue &object, const QString &name,
648  const QScriptDebuggerValue &value)
649 {
651  cmd.setScriptValue(object);
652  cmd.setName(name);
653  cmd.setSubordinateScriptValue(value);
654  return cmd;
655 }
656 
658 {
660  return cmd;
661 }
662 
673 {
674  const QScriptDebuggerCommandPrivate *d = command.d_ptr.data();
675  out << (quint32)d->type;
676  out << (qint32)d->attributes.size();
678  for (it = d->attributes.constBegin(); it != d->attributes.constEnd(); ++it) {
679  out << (quint32)it.key();
680  out << it.value();
681  }
682  return out;
683 }
684 
696 {
698 
699  quint32 type;
700  in >> type;
702 
703  qint32 attribCount;
704  in >> attribCount;
706  for (qint32 i = 0; i < attribCount; ++i) {
707  quint32 key;
708  in >> key;
709  QVariant value;
710  in >> value;
711  attribs[QScriptDebuggerCommand::Attribute(key)] = value;
712  }
713  d->attributes = attribs;
714 
715  return in;
716 }
717 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QScriptDebuggerValue scriptValue() const
static QScriptDebuggerCommand newScriptValueIteratorCommand(const QScriptDebuggerValue &object)
static QScriptDebuggerCommand setBreakpointDataCommand(int id, const QScriptBreakpointData &data)
void setAttribute(Attribute attribute, const QVariant &value)
Sets the value of the given attribute.
static QScriptDebuggerCommand runToLocationCommand(const QString &fileName, int lineNumber)
static QScriptDebuggerCommand getBreakpointsCommand()
void setFileName(const QString &fileName)
static QScriptDebuggerCommand newScriptObjectSnapshotCommand()
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int qint32
Definition: qglobal.h:937
static QScriptDebuggerCommand interruptCommand()
T * data() const
Returns the value of the pointer referenced by this object.
#define it(className, varName)
static QScriptDebuggerCommand evaluateCommand(int contextIndex, const QString &program, const QString &fileName=QString(), int lineNumber=1)
static QScriptDebuggerCommand getContextStateCommand(int contextIndex)
static QScriptDebuggerCommand getPropertyExpressionValue(int contextIndex, int lineNumber, const QStringList &path)
void setScriptValue(const QScriptDebuggerValue &value)
static QScriptDebuggerCommand deleteScriptValueIteratorCommand(int id)
static QScriptDebuggerCommand getActivationObjectCommand(int contextIndex)
int lineNumber() const
Returns the LineNumber attribute of this command converted to an int.
static QScriptDebuggerCommand getScriptDataCommand(qint64 id)
static QScriptDebuggerCommand forceReturnCommand(int contextIndex, const QScriptDebuggerValue &value)
static QScriptDebuggerCommand deleteAllBreakpointsCommand()
static QScriptDebuggerCommand getContextIdCommand(int contextIndex)
static QScriptDebuggerCommand setBreakpointCommand(const QString &fileName, int lineNumber)
bool operator==(const QScriptDebuggerCommand &other) const
Returns true if this QScriptDebuggerCommand is equal to the other command, otherwise returns false...
static QScriptDebuggerCommand stepOverCommand(int count=1)
static QScriptDebuggerCommand getBacktraceCommand()
static QScriptDebuggerCommand scriptsCheckpointCommand()
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QScriptDebuggerCommand getContextInfoCommand(int contextIndex)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
static QScriptDebuggerCommand scriptValueToStringCommand(const QScriptDebuggerValue &value)
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QScriptDebuggerCommand getContextCountCommand()
Type type() const
Returns the type of this command.
static QScriptDebuggerCommand deleteBreakpointCommand(int id)
static QScriptDebuggerCommand resumeCommand()
static QScriptDebuggerCommand getScriptsDeltaCommand()
QString fileName() const
Returns the FileName attribute of this command converted to a string.
static QScriptDebuggerCommand getPropertiesByIteratorCommand(int id, int count)
static QScriptDebuggerCommand getScriptsCommand()
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QScriptDebuggerCommand continueCommand()
QHash< QScriptDebuggerCommand::Attribute, QVariant > attributes
static QScriptDebuggerCommand stepOutCommand()
static QScriptDebuggerCommand deleteScriptObjectSnapshotCommand(int id)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QScriptDebuggerCommand getBreakpointDataCommand(int id)
static const char * data(const QByteArray &arr)
__int64 qint64
Definition: qglobal.h:942
The QScriptBreakpointData class contains data associated with a breakpoint.
friend Q_AUTOTEST_EXPORT QDataStream & operator<<(QDataStream &, const QScriptDebuggerCommand &)
Writes the given command to the specified stream.
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
static QScriptDebuggerCommand clearExceptionsCommand()
void setProgram(const QString &program)
void setSubordinateScriptValue(const QScriptDebuggerValue &value)
void setLineNumber(int lineNumber)
static QScriptDebuggerCommand contextsCheckpoint()
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
#define None
static QScriptDebuggerCommand getScopeChainCommand(int contextIndex)
QScriptDebuggerCommand & operator=(const QScriptDebuggerCommand &other)
Assigns the other value to this QScriptDebuggerCommand.
The QScriptDebuggerCommand class represents a command issued to a QScriptDebuggerFrontend.
static QScriptDebuggerCommand setScriptValuePropertyCommand(const QScriptDebuggerValue &object, const QString &name, const QScriptDebuggerValue &value)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
The QScriptDebuggerValue class represents a script value.
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
QHash< Attribute, QVariant > attributes() const
QScriptDebuggerValue subordinateScriptValue() const
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
int key
static QScriptDebuggerCommand getThisObjectCommand(int contextIndex)
unsigned int quint32
Definition: qglobal.h:938
friend Q_AUTOTEST_EXPORT QDataStream & operator>>(QDataStream &, QScriptDebuggerCommand &)
Reads a QScriptDebuggerCommand from the specified stream into the given command.
static QScriptDebuggerCommand resolveScriptCommand(const QString &fileName)
QScopedPointer< QScriptDebuggerCommandPrivate > d_ptr
QVariant attribute(Attribute attribute, const QVariant &defaultValue=QVariant()) const
Returns the value of the given attribute, or defaultValue if the attribute is not defined...
QScriptDebuggerCommand()
Constructs a QScriptDebuggerCommand of type None.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
quint16 index
bool operator!=(const QScriptDebuggerCommand &other) const
Returns true if this QScriptDebuggerCommand is not equal to the other command, otherwise returns fals...
QScriptDebuggerCommand::Type type
void setName(const QString &name)
static QScriptDebuggerCommand getCompletions(int contextIndex, const QStringList &path)
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
~QScriptDebuggerCommand()
Destroys this QScriptDebuggerCommand.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
qint64 scriptId() const
Returns the ScriptID attribute of this command converted to a qint64.
static QScriptDebuggerCommand stepIntoCommand(int count=1)
QScriptBreakpointData breakpointData() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static QScriptDebuggerCommand scriptObjectSnapshotCaptureCommand(int id, const QScriptDebuggerValue &object)
void setBreakpointData(const QScriptBreakpointData &data)