Qt 4.8
qscriptdebuggerconsoleglobalobject.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 
48 
49 #include <private/qobject_p.h>
50 
51 #include <QtScript/qscriptengine.h>
52 
54 
56 {
58 public:
61 
66 };
67 
69 {
70  scheduler = 0;
71  responseHandler = 0;
72  messageHandler = 0;
73  console = 0;
74 }
75 
77 {
78 }
79 
82 {
83 }
84 
86 {
87 }
88 
90 {
92  return d->scheduler;
93 }
94 
96 {
98  d->scheduler = scheduler;
99 }
100 
102 {
104  return d->responseHandler;
105 }
106 
109 {
111  d->responseHandler = responseHandler;
112 }
113 
115 {
117  return d->messageHandler;
118 }
119 
121 {
123  d->messageHandler = messageHandler;
124 }
125 
127 {
129  return d->console;
130 }
131 
133 {
135  d->console = console;
136 }
137 
138 // ### the scheduleXXX functions could take a callback function as argument (rather than using the
139 // global handleResponse() function)
140 
142 {
144  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
145  return frontend.scheduleInterrupt();
146 }
147 
149 {
151  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
152  return frontend.scheduleContinue();
153 }
154 
156 {
158  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
159  return frontend.scheduleStepInto(count);
160 }
161 
163 {
165  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
166  return frontend.scheduleStepOver(count);
167 }
168 
170 {
172  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
173  return frontend.scheduleStepOut();
174 }
175 
177 {
179  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
180  return frontend.scheduleRunToLocation(fileName, lineNumber);
181 }
182 
184 {
186  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
187  return frontend.scheduleRunToLocation(scriptId, lineNumber);
188 }
189 
191 {
193  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
194  return frontend.scheduleForceReturn(contextIndex, value);
195 }
196 
198 {
200  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
201  return frontend.scheduleSetBreakpoint(data);
202 }
203 
205 {
207  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
208  return frontend.scheduleDeleteBreakpoint(id);
209 }
210 
212 {
214  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
215  return frontend.scheduleDeleteAllBreakpoints();
216 }
217 
219 {
221  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
222  return frontend.scheduleGetBreakpoints();
223 }
224 
226 {
228  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
229  return frontend.scheduleGetBreakpointData(id);
230 }
231 
233 {
235  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
236  return frontend.scheduleSetBreakpointData(id, data);
237 }
238 
240 {
242  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
243  return frontend.scheduleGetScripts();
244 }
245 
247 {
249  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
250  return frontend.scheduleGetScriptData(id);
251 }
252 
254 {
256  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
257  return frontend.scheduleScriptsCheckpoint();
258 }
259 
261 {
263  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
264  return frontend.scheduleGetScriptsDelta();
265 }
266 
268 {
270  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
271  return frontend.scheduleResolveScript(fileName);
272 }
273 
275 {
277  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
278  return frontend.scheduleGetBacktrace();
279 }
280 
282 {
284  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
285  return frontend.scheduleGetThisObject(contextIndex);
286 }
287 
289 {
291  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
292  return frontend.scheduleGetActivationObject(contextIndex);
293 }
294 
296 {
298  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
299  return frontend.scheduleGetContextCount();
300 }
301 
303 {
305  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
306  return frontend.scheduleGetContextInfo(contextIndex);
307 }
308 
310 {
312  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
313  return frontend.scheduleNewScriptValueIterator(object);
314 }
315 
317 {
319  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
320  return frontend.scheduleGetPropertiesByIterator(id, count);
321 }
322 
324 {
326  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
327  return frontend.scheduleDeleteScriptValueIterator(id);
328 }
329 
331  const QString &fileName,
332  int lineNumber)
333 {
335  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
336  return frontend.scheduleEvaluate(contextIndex, program, fileName, lineNumber);
337 }
338 
340 {
342  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
343  return frontend.scheduleScriptValueToString(value);
344 }
345 
347 {
349  QScriptDebuggerCommandSchedulerFrontend frontend(d->scheduler, d->responseHandler);
350  return frontend.scheduleClearExceptions();
351 }
352 
354 {
356  return d->scheduler->scheduleCommand(command, d->responseHandler);
357 }
358 
360  const QString &fileName,
361  int lineNumber, int columnNumber)
362 {
364  Q_ASSERT(d->messageHandler != 0);
365  d->messageHandler->message(QtWarningMsg, text, fileName, lineNumber, columnNumber);
366 }
367 
369  const QString &fileName,
370  int lineNumber, int columnNumber)
371 {
373  Q_ASSERT(d->messageHandler != 0);
374  d->messageHandler->message(QtDebugMsg, text, fileName, lineNumber, columnNumber);
375 }
376 
378  const QString &fileName,
379  int lineNumber, int columnNumber)
380 {
382  Q_ASSERT(d->messageHandler != 0);
383  d->messageHandler->message(QtCriticalMsg, text, fileName, lineNumber, columnNumber);
384 }
385 
387 {
389  return d->console->currentFrameIndex();
390 }
391 
393 {
395  d->console->setCurrentFrameIndex(index);
396 }
397 
399 {
401  return d->console->currentLineNumber();
402 }
403 
405 {
407  d->console->setCurrentLineNumber(lineNumber);
408 }
409 
411 {
413  return d->console->currentScriptId();
414 }
415 
417 {
419  d->console->setCurrentScriptId(id);
420 }
421 
423 {
425  return d->console->sessionId();
426 }
427 
429 {
431  return d->console->commandManager()->commandGroups();
432 }
433 
435 {
437  return d->console->commandManager()->findCommand(name);
438 }
439 
441 {
443  return d->console->commandManager()->commandsInGroup(name);
444 }
445 
447 {
449  return d->console->commandManager()->completions(prefix);
450 }
451 
453 {
454  return (QScriptEngine::checkSyntax(program).state() == QScriptSyntaxCheckResult::Valid);
455 }
456 
458 {
460  d->console->setEvaluateAction(action);
461 }
462 
double d
Definition: qnumeric_p.h:62
int scheduleStepOver(int count=1)
Instructs the front-end to step over the next script statement, and returns a unique identifier assoc...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QScriptMessageHandlerInterface * messageHandler() const
QScriptDebuggerResponseHandlerInterface * responseHandler() const
int scheduleSetBreakpoint(const QString &fileName, int lineNumber)
int scheduleCommand(const QScriptDebuggerCommand &command)
QScriptDebuggerConsoleCommandGroupMap getCommandGroups() const
void error(const QString &text, const QString &fileName=QString(), int lineNumber=-1, int columnNumber=-1)
int scheduleEvaluate(int contextIndex, const QString &program, const QString &fileName=QString(), int lineNumber=1)
int scheduleSetBreakpointData(int id, const QScriptBreakpointData &data)
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
void setConsole(QScriptDebuggerConsole *console)
The QScriptDebuggerConsole class provides the core functionality of a debugger console.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int scheduleNewScriptValueIterator(const QScriptDebuggerValue &object)
void setScheduler(QScriptDebuggerCommandSchedulerInterface *scheduler)
int scheduleRunToLocation(const QString &fileName, int lineNumber)
int scheduleScriptValueToString(const QScriptDebuggerValue &value)
const char * name
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void warning(const QString &text, const QString &fileName=QString(), int lineNumber=-1, int columnNumber=-1)
static const char * data(const QByteArray &arr)
QScriptDebuggerConsoleCommandList getCommandsInGroup(const QString &name) const
__int64 qint64
Definition: qglobal.h:942
The QScriptBreakpointData class contains data associated with a breakpoint.
int scheduleSetBreakpoint(const QScriptBreakpointData &data)
void setResponseHandler(QScriptDebuggerResponseHandlerInterface *responseHandler)
int scheduleNewScriptValueIterator(const QScriptDebuggerValue &object)
The QScriptDebuggerCommand class represents a command issued to a QScriptDebuggerFrontend.
int scheduleForceReturn(int contextIndex, const QScriptDebuggerValue &value)
The QScriptDebuggerValue class represents a script value.
QScriptDebuggerResponseHandlerInterface * responseHandler
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
The QScriptDebuggerConsoleCommand class is the base class of console commands.
void setMessageHandler(QScriptMessageHandlerInterface *messageHandler)
int scheduleStepOut()
Instructs the front-end to step out of the current script function, and returns a unique identifier a...
QStringList getCommandCompletions(const QString &prefix) const
void message(const QString &text, const QString &fileName=QString(), int lineNumber=-1, int columnNumber=-1)
int scheduleScriptValueToString(const QScriptDebuggerValue &value)
quint16 index
QObject * parent
Definition: qobject.h:92
static QScriptSyntaxCheckResult checkSyntax(const QString &program)
Checks the syntax of the given program.
QScriptDebuggerCommandSchedulerInterface * scheduler() const
int scheduleStepInto(int count=1)
Instructs the front-end to step into the next script statement, and returns a unique identifier assoc...
QScriptDebuggerCommandSchedulerInterface * scheduler
QScriptDebuggerConsoleCommand * findCommand(const QString &command) const
int scheduleEvaluate(int contextIndex, const QString &program, const QString &fileName=QString(), int lineNumber=1)
int scheduleSetBreakpointData(int id, const QScriptBreakpointData &data)
int scheduleInterrupt()
Instructs the front-end to break at the next script statement, and returns a unique identifier associ...
int scheduleForceReturn(int contextIndex, const QScriptDebuggerValue &value)
static QString fileName(const QString &fileUrl)
int scheduleContinue()
Instructs the front-end to continue evaluation, and returns a unique identifier associated with this ...
int scheduleRunToLocation(const QString &fileName, int lineNumber)
Instructs the front-end to continue evaluation until the location specified by the given fileName and...
#define text
Definition: qobjectdefs.h:80