author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtSCriptTools module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qscriptdebuggercommand_p.h" |
|
43 |
#include "qscriptbreakpointdata_p.h" |
|
44 |
#include "qscriptdebuggervalue_p.h" |
|
45 |
||
46 |
#include <QtCore/qhash.h> |
|
47 |
#include <QtCore/qdatastream.h> |
|
48 |
#include <QtCore/qstringlist.h> |
|
49 |
||
50 |
Q_DECLARE_METATYPE(QScriptBreakpointData) |
|
51 |
Q_DECLARE_METATYPE(QScriptDebuggerValue) |
|
52 |
||
53 |
QT_BEGIN_NAMESPACE |
|
54 |
||
55 |
/*! |
|
56 |
\since 4.5 |
|
57 |
\class QScriptDebuggerCommand |
|
58 |
\internal |
|
59 |
||
60 |
\brief The QScriptDebuggerCommand class represents a command issued to a QScriptDebuggerFrontend. |
|
61 |
||
62 |
A debugger command is described by a command type and zero or more |
|
63 |
attributes. Such commands are generated internally by the |
|
64 |
QScriptDebuggerFrontend class (through the scheduleXXX commands). A |
|
65 |
command is typically passed on to a QScriptDebuggerCommandExecutor |
|
66 |
that applies the command to a QScriptDebuggerBackend. |
|
67 |
*/ |
|
68 |
||
69 |
class QScriptDebuggerCommandPrivate |
|
70 |
{ |
|
71 |
public: |
|
72 |
QScriptDebuggerCommandPrivate(); |
|
73 |
~QScriptDebuggerCommandPrivate(); |
|
74 |
||
75 |
QScriptDebuggerCommand::Type type; |
|
76 |
QHash<QScriptDebuggerCommand::Attribute, QVariant> attributes; |
|
77 |
}; |
|
78 |
||
79 |
QScriptDebuggerCommandPrivate::QScriptDebuggerCommandPrivate() |
|
80 |
: type(QScriptDebuggerCommand::None) |
|
81 |
{ |
|
82 |
} |
|
83 |
||
84 |
QScriptDebuggerCommandPrivate::~QScriptDebuggerCommandPrivate() |
|
85 |
{ |
|
86 |
} |
|
87 |
||
88 |
/*! |
|
89 |
Constructs a QScriptDebuggerCommand of type None. |
|
90 |
*/ |
|
91 |
QScriptDebuggerCommand::QScriptDebuggerCommand() |
|
92 |
: d_ptr(new QScriptDebuggerCommandPrivate) |
|
93 |
{ |
|
94 |
d_ptr->type = None; |
|
95 |
} |
|
96 |
||
97 |
/*! |
|
98 |
Constructs a QScriptDebuggerCommand of the given \a type, with no |
|
99 |
attributes defined. |
|
100 |
*/ |
|
101 |
QScriptDebuggerCommand::QScriptDebuggerCommand(Type type) |
|
102 |
: d_ptr(new QScriptDebuggerCommandPrivate) |
|
103 |
{ |
|
104 |
d_ptr->type = type; |
|
105 |
} |
|
106 |
||
107 |
/*! |
|
108 |
Constructs a QScriptDebuggerCommand that is a copy of the \a other |
|
109 |
command. |
|
110 |
*/ |
|
111 |
QScriptDebuggerCommand::QScriptDebuggerCommand(const QScriptDebuggerCommand &other) |
|
112 |
: d_ptr(new QScriptDebuggerCommandPrivate) |
|
113 |
{ |
|
114 |
*d_ptr = *other.d_ptr; |
|
115 |
} |
|
116 |
||
117 |
/*! |
|
118 |
Destroys this QScriptDebuggerCommand. |
|
119 |
*/ |
|
120 |
QScriptDebuggerCommand::~QScriptDebuggerCommand() |
|
121 |
{ |
|
122 |
} |
|
123 |
||
124 |
/*! |
|
125 |
Assigns the \a other value to this QScriptDebuggerCommand. |
|
126 |
*/ |
|
127 |
QScriptDebuggerCommand &QScriptDebuggerCommand::operator=(const QScriptDebuggerCommand &other) |
|
128 |
{ |
|
129 |
*d_ptr = *other.d_ptr; |
|
130 |
return *this; |
|
131 |
} |
|
132 |
||
133 |
/*! |
|
134 |
Returns the type of this command. |
|
135 |
*/ |
|
136 |
QScriptDebuggerCommand::Type QScriptDebuggerCommand::type() const |
|
137 |
{ |
|
138 |
Q_D(const QScriptDebuggerCommand); |
|
139 |
return d->type; |
|
140 |
} |
|
141 |
||
142 |
/*! |
|
143 |
Returns the value of the given \a attribute, or \a defaultValue |
|
144 |
if the attribute is not defined. |
|
145 |
*/ |
|
146 |
QVariant QScriptDebuggerCommand::attribute(Attribute attribute, |
|
147 |
const QVariant &defaultValue) const |
|
148 |
{ |
|
149 |
Q_D(const QScriptDebuggerCommand); |
|
150 |
return d->attributes.value(attribute, defaultValue); |
|
151 |
} |
|
152 |
||
153 |
/*! |
|
154 |
Sets the \a value of the given \a attribute. |
|
155 |
*/ |
|
156 |
void QScriptDebuggerCommand::setAttribute(Attribute attribute, |
|
157 |
const QVariant &value) |
|
158 |
{ |
|
159 |
Q_D(QScriptDebuggerCommand); |
|
160 |
if (!value.isValid()) |
|
161 |
d->attributes.remove(attribute); |
|
162 |
else |
|
163 |
d->attributes[attribute] = value; |
|
164 |
} |
|
165 |
||
166 |
QHash<QScriptDebuggerCommand::Attribute, QVariant> QScriptDebuggerCommand::attributes() const |
|
167 |
{ |
|
168 |
Q_D(const QScriptDebuggerCommand); |
|
169 |
return d->attributes; |
|
170 |
} |
|
171 |
||
172 |
/*! |
|
173 |
Returns the FileName attribute of this command converted to a string. |
|
174 |
This function is provided for convenience. |
|
175 |
||
176 |
\sa attribute() |
|
177 |
*/ |
|
178 |
QString QScriptDebuggerCommand::fileName() const |
|
179 |
{ |
|
180 |
Q_D(const QScriptDebuggerCommand); |
|
181 |
return d->attributes.value(FileName).toString(); |
|
182 |
} |
|
183 |
||
184 |
void QScriptDebuggerCommand::setFileName(const QString &fileName) |
|
185 |
{ |
|
186 |
Q_D(QScriptDebuggerCommand); |
|
187 |
d->attributes[FileName] = fileName; |
|
188 |
} |
|
189 |
||
190 |
/*! |
|
191 |
Returns the LineNumber attribute of this command converted to an int. |
|
192 |
This function is provided for convenience. |
|
193 |
||
194 |
\sa attribute() |
|
195 |
*/ |
|
196 |
int QScriptDebuggerCommand::lineNumber() const |
|
197 |
{ |
|
198 |
Q_D(const QScriptDebuggerCommand); |
|
199 |
return d->attributes.value(LineNumber, -1).toInt(); |
|
200 |
} |
|
201 |
||
202 |
void QScriptDebuggerCommand::setLineNumber(int lineNumber) |
|
203 |
{ |
|
204 |
Q_D(QScriptDebuggerCommand); |
|
205 |
d->attributes[LineNumber] = lineNumber; |
|
206 |
} |
|
207 |
||
208 |
/*! |
|
209 |
Returns the ScriptID attribute of this command converted to a qint64. |
|
210 |
This function is provided for convenience. |
|
211 |
||
212 |
\sa attribute() |
|
213 |
*/ |
|
214 |
qint64 QScriptDebuggerCommand::scriptId() const |
|
215 |
{ |
|
216 |
Q_D(const QScriptDebuggerCommand); |
|
217 |
return d->attributes.value(ScriptID, -1).toLongLong(); |
|
218 |
} |
|
219 |
||
220 |
void QScriptDebuggerCommand::setScriptId(qint64 id) |
|
221 |
{ |
|
222 |
Q_D(QScriptDebuggerCommand); |
|
223 |
d->attributes[ScriptID] = id; |
|
224 |
} |
|
225 |
||
226 |
QString QScriptDebuggerCommand::program() const |
|
227 |
{ |
|
228 |
Q_D(const QScriptDebuggerCommand); |
|
229 |
return d->attributes.value(Program).toString(); |
|
230 |
} |
|
231 |
||
232 |
void QScriptDebuggerCommand::setProgram(const QString &program) |
|
233 |
{ |
|
234 |
Q_D(QScriptDebuggerCommand); |
|
235 |
d->attributes[Program] = program; |
|
236 |
} |
|
237 |
||
238 |
int QScriptDebuggerCommand::breakpointId() const |
|
239 |
{ |
|
240 |
Q_D(const QScriptDebuggerCommand); |
|
241 |
return d->attributes.value(BreakpointID, -1).toInt(); |
|
242 |
} |
|
243 |
||
244 |
void QScriptDebuggerCommand::setBreakpointId(int id) |
|
245 |
{ |
|
246 |
Q_D(QScriptDebuggerCommand); |
|
247 |
d->attributes[BreakpointID] = id; |
|
248 |
} |
|
249 |
||
250 |
QScriptBreakpointData QScriptDebuggerCommand::breakpointData() const |
|
251 |
{ |
|
252 |
Q_D(const QScriptDebuggerCommand); |
|
253 |
return qvariant_cast<QScriptBreakpointData>(d->attributes.value(BreakpointData)); |
|
254 |
} |
|
255 |
||
256 |
void QScriptDebuggerCommand::setBreakpointData(const QScriptBreakpointData &data) |
|
257 |
{ |
|
258 |
Q_D(QScriptDebuggerCommand); |
|
259 |
d->attributes[BreakpointData] = qVariantFromValue(data); |
|
260 |
} |
|
261 |
||
262 |
QScriptDebuggerValue QScriptDebuggerCommand::scriptValue() const |
|
263 |
{ |
|
264 |
Q_D(const QScriptDebuggerCommand); |
|
265 |
return qvariant_cast<QScriptDebuggerValue>(d->attributes.value(ScriptValue)); |
|
266 |
} |
|
267 |
||
268 |
void QScriptDebuggerCommand::setScriptValue(const QScriptDebuggerValue &value) |
|
269 |
{ |
|
270 |
Q_D(QScriptDebuggerCommand); |
|
271 |
d->attributes[ScriptValue] = qVariantFromValue(value); |
|
272 |
} |
|
273 |
||
274 |
int QScriptDebuggerCommand::contextIndex() const |
|
275 |
{ |
|
276 |
Q_D(const QScriptDebuggerCommand); |
|
277 |
return d->attributes.value(ContextIndex, -1).toInt(); |
|
278 |
} |
|
279 |
||
280 |
void QScriptDebuggerCommand::setContextIndex(int index) |
|
281 |
{ |
|
282 |
Q_D(QScriptDebuggerCommand); |
|
283 |
d->attributes[ContextIndex] = index; |
|
284 |
} |
|
285 |
||
286 |
int QScriptDebuggerCommand::iteratorId() const |
|
287 |
{ |
|
288 |
Q_D(const QScriptDebuggerCommand); |
|
289 |
return d->attributes.value(IteratorID, -1).toInt(); |
|
290 |
} |
|
291 |
||
292 |
void QScriptDebuggerCommand::setIteratorId(int id) |
|
293 |
{ |
|
294 |
Q_D(QScriptDebuggerCommand); |
|
295 |
d->attributes[IteratorID] = id; |
|
296 |
} |
|
297 |
||
298 |
QString QScriptDebuggerCommand::name() const |
|
299 |
{ |
|
300 |
Q_D(const QScriptDebuggerCommand); |
|
301 |
return d->attributes.value(Name).toString(); |
|
302 |
} |
|
303 |
||
304 |
void QScriptDebuggerCommand::setName(const QString &name) |
|
305 |
{ |
|
306 |
Q_D(QScriptDebuggerCommand); |
|
307 |
d->attributes[Name] = name; |
|
308 |
} |
|
309 |
||
310 |
QScriptDebuggerValue QScriptDebuggerCommand::subordinateScriptValue() const |
|
311 |
{ |
|
312 |
Q_D(const QScriptDebuggerCommand); |
|
313 |
return qvariant_cast<QScriptDebuggerValue>(d->attributes.value(SubordinateScriptValue)); |
|
314 |
} |
|
315 |
||
316 |
void QScriptDebuggerCommand::setSubordinateScriptValue(const QScriptDebuggerValue &value) |
|
317 |
{ |
|
318 |
Q_D(QScriptDebuggerCommand); |
|
319 |
d->attributes[SubordinateScriptValue] = qVariantFromValue(value); |
|
320 |
} |
|
321 |
||
322 |
int QScriptDebuggerCommand::snapshotId() const |
|
323 |
{ |
|
324 |
Q_D(const QScriptDebuggerCommand); |
|
325 |
return d->attributes.value(SnapshotID, -1).toInt(); |
|
326 |
} |
|
327 |
||
328 |
void QScriptDebuggerCommand::setSnapshotId(int id) |
|
329 |
{ |
|
330 |
Q_D(QScriptDebuggerCommand); |
|
331 |
d->attributes[SnapshotID] = id; |
|
332 |
} |
|
333 |
||
334 |
/*! |
|
335 |
Returns true if this QScriptDebuggerCommand is equal to the \a other |
|
336 |
command, otherwise returns false. |
|
337 |
*/ |
|
338 |
bool QScriptDebuggerCommand::operator==(const QScriptDebuggerCommand &other) const |
|
339 |
{ |
|
340 |
Q_D(const QScriptDebuggerCommand); |
|
341 |
const QScriptDebuggerCommandPrivate *od = other.d_func(); |
|
342 |
if (d == od) |
|
343 |
return true; |
|
344 |
if (!d || !od) |
|
345 |
return false; |
|
346 |
return ((d->type == od->type) |
|
347 |
&& (d->attributes == od->attributes)); |
|
348 |
} |
|
349 |
||
350 |
/*! |
|
351 |
Returns true if this QScriptDebuggerCommand is not equal to the \a |
|
352 |
other command, otherwise returns false. |
|
353 |
*/ |
|
354 |
bool QScriptDebuggerCommand::operator!=(const QScriptDebuggerCommand &other) const |
|
355 |
{ |
|
356 |
return !(*this == other); |
|
357 |
} |
|
358 |
||
359 |
QScriptDebuggerCommand QScriptDebuggerCommand::interruptCommand() |
|
360 |
{ |
|
361 |
QScriptDebuggerCommand cmd(Interrupt); |
|
362 |
return cmd; |
|
363 |
} |
|
364 |
||
365 |
QScriptDebuggerCommand QScriptDebuggerCommand::continueCommand() |
|
366 |
{ |
|
367 |
QScriptDebuggerCommand cmd(Continue); |
|
368 |
return cmd; |
|
369 |
} |
|
370 |
||
371 |
QScriptDebuggerCommand QScriptDebuggerCommand::stepIntoCommand(int count) |
|
372 |
{ |
|
373 |
QScriptDebuggerCommand cmd(StepInto); |
|
374 |
cmd.setAttribute(StepCount, count); |
|
375 |
return cmd; |
|
376 |
} |
|
377 |
||
378 |
QScriptDebuggerCommand QScriptDebuggerCommand::stepOverCommand(int count) |
|
379 |
{ |
|
380 |
QScriptDebuggerCommand cmd(StepOver); |
|
381 |
cmd.setAttribute(StepCount, count); |
|
382 |
return cmd; |
|
383 |
} |
|
384 |
||
385 |
QScriptDebuggerCommand QScriptDebuggerCommand::stepOutCommand() |
|
386 |
{ |
|
387 |
QScriptDebuggerCommand cmd(StepOut); |
|
388 |
return cmd; |
|
389 |
} |
|
390 |
||
391 |
QScriptDebuggerCommand QScriptDebuggerCommand::runToLocationCommand(const QString &fileName, int lineNumber) |
|
392 |
{ |
|
393 |
QScriptDebuggerCommand cmd(RunToLocation); |
|
394 |
cmd.setFileName(fileName); |
|
395 |
cmd.setLineNumber(lineNumber); |
|
396 |
return cmd; |
|
397 |
} |
|
398 |
||
399 |
QScriptDebuggerCommand QScriptDebuggerCommand::runToLocationCommand(qint64 scriptId, int lineNumber) |
|
400 |
{ |
|
401 |
QScriptDebuggerCommand cmd(RunToLocationByID); |
|
402 |
cmd.setScriptId(scriptId); |
|
403 |
cmd.setLineNumber(lineNumber); |
|
404 |
return cmd; |
|
405 |
} |
|
406 |
||
407 |
QScriptDebuggerCommand QScriptDebuggerCommand::forceReturnCommand(int contextIndex, const QScriptDebuggerValue &value) |
|
408 |
{ |
|
409 |
QScriptDebuggerCommand cmd(ForceReturn); |
|
410 |
cmd.setContextIndex(contextIndex); |
|
411 |
cmd.setScriptValue(value); |
|
412 |
return cmd; |
|
413 |
} |
|
414 |
||
415 |
QScriptDebuggerCommand QScriptDebuggerCommand::resumeCommand() |
|
416 |
{ |
|
417 |
QScriptDebuggerCommand cmd(Resume); |
|
418 |
return cmd; |
|
419 |
} |
|
420 |
||
421 |
QScriptDebuggerCommand QScriptDebuggerCommand::setBreakpointCommand(const QString &fileName, int lineNumber) |
|
422 |
{ |
|
423 |
QScriptDebuggerCommand cmd(SetBreakpoint); |
|
424 |
cmd.setBreakpointData(QScriptBreakpointData(fileName, lineNumber)); |
|
425 |
return cmd; |
|
426 |
} |
|
427 |
||
428 |
QScriptDebuggerCommand QScriptDebuggerCommand::setBreakpointCommand(const QScriptBreakpointData &data) |
|
429 |
{ |
|
430 |
QScriptDebuggerCommand cmd(SetBreakpoint); |
|
431 |
cmd.setBreakpointData(data); |
|
432 |
return cmd; |
|
433 |
} |
|
434 |
||
435 |
QScriptDebuggerCommand QScriptDebuggerCommand::deleteBreakpointCommand(int id) |
|
436 |
{ |
|
437 |
QScriptDebuggerCommand cmd(DeleteBreakpoint); |
|
438 |
cmd.setBreakpointId(id); |
|
439 |
return cmd; |
|
440 |
} |
|
441 |
||
442 |
QScriptDebuggerCommand QScriptDebuggerCommand::deleteAllBreakpointsCommand() |
|
443 |
{ |
|
444 |
QScriptDebuggerCommand cmd(DeleteAllBreakpoints); |
|
445 |
return cmd; |
|
446 |
} |
|
447 |
||
448 |
QScriptDebuggerCommand QScriptDebuggerCommand::getBreakpointsCommand() |
|
449 |
{ |
|
450 |
QScriptDebuggerCommand cmd(GetBreakpoints); |
|
451 |
return cmd; |
|
452 |
} |
|
453 |
||
454 |
QScriptDebuggerCommand QScriptDebuggerCommand::getBreakpointDataCommand(int id) |
|
455 |
{ |
|
456 |
QScriptDebuggerCommand cmd(GetBreakpointData); |
|
457 |
cmd.setBreakpointId(id); |
|
458 |
return cmd; |
|
459 |
} |
|
460 |
||
461 |
QScriptDebuggerCommand QScriptDebuggerCommand::setBreakpointDataCommand(int id, const QScriptBreakpointData &data) |
|
462 |
{ |
|
463 |
QScriptDebuggerCommand cmd(SetBreakpointData); |
|
464 |
cmd.setBreakpointId(id); |
|
465 |
cmd.setBreakpointData(data); |
|
466 |
return cmd; |
|
467 |
} |
|
468 |
||
469 |
QScriptDebuggerCommand QScriptDebuggerCommand::getScriptsCommand() |
|
470 |
{ |
|
471 |
QScriptDebuggerCommand cmd(GetScripts); |
|
472 |
return cmd; |
|
473 |
} |
|
474 |
||
475 |
QScriptDebuggerCommand QScriptDebuggerCommand::getScriptDataCommand(qint64 id) |
|
476 |
{ |
|
477 |
QScriptDebuggerCommand cmd(GetScriptData); |
|
478 |
cmd.setScriptId(id); |
|
479 |
return cmd; |
|
480 |
} |
|
481 |
||
482 |
QScriptDebuggerCommand QScriptDebuggerCommand::scriptsCheckpointCommand() |
|
483 |
{ |
|
484 |
QScriptDebuggerCommand cmd(ScriptsCheckpoint); |
|
485 |
return cmd; |
|
486 |
} |
|
487 |
||
488 |
QScriptDebuggerCommand QScriptDebuggerCommand::getScriptsDeltaCommand() |
|
489 |
{ |
|
490 |
QScriptDebuggerCommand cmd(GetScriptsDelta); |
|
491 |
return cmd; |
|
492 |
} |
|
493 |
||
494 |
QScriptDebuggerCommand QScriptDebuggerCommand::resolveScriptCommand(const QString &fileName) |
|
495 |
{ |
|
496 |
QScriptDebuggerCommand cmd(ResolveScript); |
|
497 |
cmd.setFileName(fileName); |
|
498 |
return cmd; |
|
499 |
} |
|
500 |
||
501 |
QScriptDebuggerCommand QScriptDebuggerCommand::getBacktraceCommand() |
|
502 |
{ |
|
503 |
QScriptDebuggerCommand cmd(GetBacktrace); |
|
504 |
return cmd; |
|
505 |
} |
|
506 |
||
507 |
QScriptDebuggerCommand QScriptDebuggerCommand::getContextCountCommand() |
|
508 |
{ |
|
509 |
QScriptDebuggerCommand cmd(GetContextCount); |
|
510 |
return cmd; |
|
511 |
} |
|
512 |
||
513 |
QScriptDebuggerCommand QScriptDebuggerCommand::getContextStateCommand(int contextIndex) |
|
514 |
{ |
|
515 |
QScriptDebuggerCommand cmd(GetContextState); |
|
516 |
cmd.setContextIndex(contextIndex); |
|
517 |
return cmd; |
|
518 |
} |
|
519 |
||
520 |
QScriptDebuggerCommand QScriptDebuggerCommand::getContextInfoCommand(int contextIndex) |
|
521 |
{ |
|
522 |
QScriptDebuggerCommand cmd(GetContextInfo); |
|
523 |
cmd.setContextIndex(contextIndex); |
|
524 |
return cmd; |
|
525 |
} |
|
526 |
||
527 |
QScriptDebuggerCommand QScriptDebuggerCommand::getContextIdCommand(int contextIndex) |
|
528 |
{ |
|
529 |
QScriptDebuggerCommand cmd(GetContextID); |
|
530 |
cmd.setContextIndex(contextIndex); |
|
531 |
return cmd; |
|
532 |
} |
|
533 |
||
534 |
QScriptDebuggerCommand QScriptDebuggerCommand::getThisObjectCommand(int contextIndex) |
|
535 |
{ |
|
536 |
QScriptDebuggerCommand cmd(GetThisObject); |
|
537 |
cmd.setContextIndex(contextIndex); |
|
538 |
return cmd; |
|
539 |
} |
|
540 |
||
541 |
QScriptDebuggerCommand QScriptDebuggerCommand::getActivationObjectCommand(int contextIndex) |
|
542 |
{ |
|
543 |
QScriptDebuggerCommand cmd(GetActivationObject); |
|
544 |
cmd.setContextIndex(contextIndex); |
|
545 |
return cmd; |
|
546 |
} |
|
547 |
||
548 |
QScriptDebuggerCommand QScriptDebuggerCommand::getScopeChainCommand(int contextIndex) |
|
549 |
{ |
|
550 |
QScriptDebuggerCommand cmd(GetScopeChain); |
|
551 |
cmd.setContextIndex(contextIndex); |
|
552 |
return cmd; |
|
553 |
} |
|
554 |
||
555 |
QScriptDebuggerCommand QScriptDebuggerCommand::contextsCheckpoint() |
|
556 |
{ |
|
557 |
QScriptDebuggerCommand cmd(ContextsCheckpoint); |
|
558 |
return cmd; |
|
559 |
} |
|
560 |
||
561 |
QScriptDebuggerCommand QScriptDebuggerCommand::getPropertyExpressionValue( |
|
562 |
int contextIndex, int lineNumber, const QStringList &path) |
|
563 |
{ |
|
564 |
QScriptDebuggerCommand cmd(GetPropertyExpressionValue); |
|
565 |
cmd.setContextIndex(contextIndex); |
|
566 |
cmd.setLineNumber(lineNumber); |
|
567 |
cmd.setAttribute(UserAttribute, path); |
|
568 |
return cmd; |
|
569 |
} |
|
570 |
||
571 |
QScriptDebuggerCommand QScriptDebuggerCommand::getCompletions( |
|
572 |
int contextIndex, const QStringList &path) |
|
573 |
{ |
|
574 |
QScriptDebuggerCommand cmd(GetCompletions); |
|
575 |
cmd.setContextIndex(contextIndex); |
|
576 |
cmd.setAttribute(UserAttribute, path); |
|
577 |
return cmd; |
|
578 |
} |
|
579 |
||
580 |
QScriptDebuggerCommand QScriptDebuggerCommand::newScriptObjectSnapshotCommand() |
|
581 |
{ |
|
582 |
QScriptDebuggerCommand cmd(NewScriptObjectSnapshot); |
|
583 |
return cmd; |
|
584 |
} |
|
585 |
||
586 |
QScriptDebuggerCommand QScriptDebuggerCommand::scriptObjectSnapshotCaptureCommand(int id, const QScriptDebuggerValue &object) |
|
587 |
{ |
|
588 |
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue); |
|
589 |
QScriptDebuggerCommand cmd(ScriptObjectSnapshotCapture); |
|
590 |
cmd.setSnapshotId(id); |
|
591 |
cmd.setScriptValue(object); |
|
592 |
return cmd; |
|
593 |
} |
|
594 |
||
595 |
QScriptDebuggerCommand QScriptDebuggerCommand::deleteScriptObjectSnapshotCommand(int id) |
|
596 |
{ |
|
597 |
QScriptDebuggerCommand cmd(DeleteScriptObjectSnapshot); |
|
598 |
cmd.setSnapshotId(id); |
|
599 |
return cmd; |
|
600 |
} |
|
601 |
||
602 |
QScriptDebuggerCommand QScriptDebuggerCommand::newScriptValueIteratorCommand(const QScriptDebuggerValue &object) |
|
603 |
{ |
|
604 |
QScriptDebuggerCommand cmd(NewScriptValueIterator); |
|
605 |
Q_ASSERT(object.type() == QScriptDebuggerValue::ObjectValue); |
|
606 |
cmd.setScriptValue(object); |
|
607 |
return cmd; |
|
608 |
} |
|
609 |
||
610 |
QScriptDebuggerCommand QScriptDebuggerCommand::getPropertiesByIteratorCommand(int id, int count) |
|
611 |
{ |
|
612 |
Q_UNUSED(count); |
|
613 |
QScriptDebuggerCommand cmd(GetPropertiesByIterator); |
|
614 |
cmd.setIteratorId(id); |
|
615 |
return cmd; |
|
616 |
} |
|
617 |
||
618 |
QScriptDebuggerCommand QScriptDebuggerCommand::deleteScriptValueIteratorCommand(int id) |
|
619 |
{ |
|
620 |
QScriptDebuggerCommand cmd(DeleteScriptValueIterator); |
|
621 |
cmd.setIteratorId(id); |
|
622 |
return cmd; |
|
623 |
} |
|
624 |
||
625 |
QScriptDebuggerCommand QScriptDebuggerCommand::evaluateCommand( |
|
626 |
int contextIndex, const QString &program, const QString &fileName, int lineNumber) |
|
627 |
{ |
|
628 |
QScriptDebuggerCommand cmd(Evaluate); |
|
629 |
cmd.setContextIndex(contextIndex); |
|
630 |
cmd.setProgram(program); |
|
631 |
cmd.setFileName(fileName); |
|
632 |
cmd.setLineNumber(lineNumber); |
|
633 |
return cmd; |
|
634 |
} |
|
635 |
||
636 |
QScriptDebuggerCommand QScriptDebuggerCommand::scriptValueToStringCommand(const QScriptDebuggerValue &value) |
|
637 |
{ |
|
638 |
QScriptDebuggerCommand cmd(ScriptValueToString); |
|
639 |
cmd.setScriptValue(value); |
|
640 |
return cmd; |
|
641 |
} |
|
642 |
||
643 |
QScriptDebuggerCommand QScriptDebuggerCommand::setScriptValuePropertyCommand( |
|
644 |
const QScriptDebuggerValue &object, const QString &name, |
|
645 |
const QScriptDebuggerValue &value) |
|
646 |
{ |
|
647 |
QScriptDebuggerCommand cmd(SetScriptValueProperty); |
|
648 |
cmd.setScriptValue(object); |
|
649 |
cmd.setName(name); |
|
650 |
cmd.setSubordinateScriptValue(value); |
|
651 |
return cmd; |
|
652 |
} |
|
653 |
||
654 |
QScriptDebuggerCommand QScriptDebuggerCommand::clearExceptionsCommand() |
|
655 |
{ |
|
656 |
QScriptDebuggerCommand cmd(ClearExceptions); |
|
657 |
return cmd; |
|
658 |
} |
|
659 |
||
660 |
/*! |
|
661 |
\fn QDataStream &operator<<(QDataStream &stream, const QScriptDebuggerCommand &command) |
|
662 |
\relates QScriptDebuggerCommand |
|
663 |
||
664 |
Writes the given \a command to the specified \a stream. |
|
665 |
*/ |
|
666 |
QDataStream &operator<<(QDataStream &out, const QScriptDebuggerCommand &command) |
|
667 |
{ |
|
668 |
const QScriptDebuggerCommandPrivate *d = command.d_ptr.data(); |
|
669 |
out << (quint32)d->type; |
|
670 |
out << (qint32)d->attributes.size(); |
|
671 |
QHash<QScriptDebuggerCommand::Attribute, QVariant>::const_iterator it; |
|
672 |
for (it = d->attributes.constBegin(); it != d->attributes.constEnd(); ++it) { |
|
673 |
out << (quint32)it.key(); |
|
674 |
out << it.value(); |
|
675 |
} |
|
676 |
return out; |
|
677 |
} |
|
678 |
||
679 |
/*! |
|
680 |
\fn QDataStream &operator>>(QDataStream &stream, QScriptDebuggerCommand &command) |
|
681 |
\relates QScriptDebuggerCommand |
|
682 |
||
683 |
Reads a QScriptDebuggerCommand from the specified \a stream into the |
|
684 |
given \a command. |
|
685 |
*/ |
|
686 |
QDataStream &operator>>(QDataStream &in, QScriptDebuggerCommand &command) |
|
687 |
{ |
|
688 |
QScriptDebuggerCommandPrivate *d = command.d_ptr.data(); |
|
689 |
||
690 |
quint32 type; |
|
691 |
in >> type; |
|
692 |
d->type = QScriptDebuggerCommand::Type(type); |
|
693 |
||
694 |
qint32 attribCount; |
|
695 |
in >> attribCount; |
|
696 |
QHash<QScriptDebuggerCommand::Attribute, QVariant> attribs; |
|
697 |
for (qint32 i = 0; i < attribCount; ++i) { |
|
698 |
quint32 key; |
|
699 |
in >> key; |
|
700 |
QVariant value; |
|
701 |
in >> value; |
|
702 |
attribs[QScriptDebuggerCommand::Attribute(key)] = value; |
|
703 |
} |
|
704 |
d->attributes = attribs; |
|
705 |
||
706 |
return in; |
|
707 |
} |
|
708 |
||
709 |
QT_END_NAMESPACE |