0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
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 "qscriptdebuggerresponse_p.h"
|
|
43 |
#include "qscriptdebuggervalue_p.h"
|
|
44 |
|
|
45 |
#include <QtScript/qscriptcontextinfo.h>
|
|
46 |
#include <QtCore/qdatastream.h>
|
|
47 |
|
|
48 |
Q_DECLARE_METATYPE(QScriptBreakpointData)
|
|
49 |
Q_DECLARE_METATYPE(QScriptBreakpointMap)
|
|
50 |
Q_DECLARE_METATYPE(QScriptScriptData)
|
|
51 |
Q_DECLARE_METATYPE(QScriptScriptMap)
|
|
52 |
Q_DECLARE_METATYPE(QScriptDebuggerValue)
|
|
53 |
Q_DECLARE_METATYPE(QScriptDebuggerValueList)
|
|
54 |
Q_DECLARE_METATYPE(QScriptDebuggerValueProperty)
|
|
55 |
Q_DECLARE_METATYPE(QScriptDebuggerValuePropertyList)
|
|
56 |
Q_DECLARE_METATYPE(QScriptContextInfo)
|
|
57 |
|
|
58 |
QT_BEGIN_NAMESPACE
|
|
59 |
|
|
60 |
/*!
|
|
61 |
\since 4.5
|
|
62 |
\class QScriptDebuggerResponse
|
|
63 |
\internal
|
|
64 |
|
|
65 |
\brief The QScriptDebuggerResponse class represents a front-end's response to a QScriptDebuggerCommand.
|
|
66 |
|
|
67 |
A response contains an error code and result.
|
|
68 |
*/
|
|
69 |
|
|
70 |
class QScriptDebuggerResponsePrivate
|
|
71 |
{
|
|
72 |
public:
|
|
73 |
QScriptDebuggerResponsePrivate();
|
|
74 |
~QScriptDebuggerResponsePrivate();
|
|
75 |
|
|
76 |
QScriptDebuggerResponse::Error error;
|
|
77 |
QVariant result;
|
|
78 |
bool async;
|
|
79 |
};
|
|
80 |
|
|
81 |
QScriptDebuggerResponsePrivate::QScriptDebuggerResponsePrivate()
|
|
82 |
{
|
|
83 |
error = QScriptDebuggerResponse::NoError;
|
|
84 |
async = false;
|
|
85 |
}
|
|
86 |
|
|
87 |
QScriptDebuggerResponsePrivate::~QScriptDebuggerResponsePrivate()
|
|
88 |
{
|
|
89 |
}
|
|
90 |
|
|
91 |
QScriptDebuggerResponse::QScriptDebuggerResponse()
|
|
92 |
: d_ptr(new QScriptDebuggerResponsePrivate)
|
|
93 |
{
|
|
94 |
}
|
|
95 |
|
|
96 |
QScriptDebuggerResponse::QScriptDebuggerResponse(const QScriptDebuggerResponse &other)
|
|
97 |
: d_ptr(new QScriptDebuggerResponsePrivate)
|
|
98 |
{
|
|
99 |
*d_ptr = *other.d_ptr;
|
|
100 |
}
|
|
101 |
|
|
102 |
QScriptDebuggerResponse::~QScriptDebuggerResponse()
|
|
103 |
{
|
|
104 |
}
|
|
105 |
|
|
106 |
QScriptDebuggerResponse &QScriptDebuggerResponse::operator=(const QScriptDebuggerResponse &other)
|
|
107 |
{
|
|
108 |
*d_ptr = *other.d_ptr;
|
|
109 |
return *this;
|
|
110 |
}
|
|
111 |
|
|
112 |
/*!
|
|
113 |
Returns the error code of this response.
|
|
114 |
*/
|
|
115 |
QScriptDebuggerResponse::Error QScriptDebuggerResponse::error() const
|
|
116 |
{
|
|
117 |
Q_D(const QScriptDebuggerResponse);
|
|
118 |
return d->error;
|
|
119 |
}
|
|
120 |
|
|
121 |
/*!
|
|
122 |
Sets the \a error code of this response.
|
|
123 |
*/
|
|
124 |
void QScriptDebuggerResponse::setError(Error error)
|
|
125 |
{
|
|
126 |
Q_D(QScriptDebuggerResponse);
|
|
127 |
d->error = error;
|
|
128 |
}
|
|
129 |
|
|
130 |
/*!
|
|
131 |
Returns the result of this response. This function is provided for
|
|
132 |
convenience.
|
|
133 |
*/
|
|
134 |
QVariant QScriptDebuggerResponse::result() const
|
|
135 |
{
|
|
136 |
Q_D(const QScriptDebuggerResponse);
|
|
137 |
return d->result;
|
|
138 |
}
|
|
139 |
|
|
140 |
/*!
|
|
141 |
Sets the Result attribute of this response to the given \a
|
|
142 |
value. This function is provided for convenience.
|
|
143 |
*/
|
|
144 |
void QScriptDebuggerResponse::setResult(const QVariant &value)
|
|
145 |
{
|
|
146 |
Q_D(QScriptDebuggerResponse);
|
|
147 |
d->result = value;
|
|
148 |
}
|
|
149 |
|
|
150 |
void QScriptDebuggerResponse::setResult(int value)
|
|
151 |
{
|
|
152 |
Q_D(QScriptDebuggerResponse);
|
|
153 |
d->result = value;
|
|
154 |
}
|
|
155 |
|
|
156 |
void QScriptDebuggerResponse::setResult(const QString &value)
|
|
157 |
{
|
|
158 |
Q_D(QScriptDebuggerResponse);
|
|
159 |
d->result = value;
|
|
160 |
}
|
|
161 |
|
|
162 |
void QScriptDebuggerResponse::setResult(const QScriptBreakpointData &data)
|
|
163 |
{
|
|
164 |
Q_D(QScriptDebuggerResponse);
|
|
165 |
d->result = qVariantFromValue(data);
|
|
166 |
}
|
|
167 |
|
|
168 |
void QScriptDebuggerResponse::setResult(const QScriptBreakpointMap &breakpoints)
|
|
169 |
{
|
|
170 |
Q_D(QScriptDebuggerResponse);
|
|
171 |
d->result = qVariantFromValue(breakpoints);
|
|
172 |
}
|
|
173 |
|
|
174 |
void QScriptDebuggerResponse::setResult(const QScriptScriptMap &scripts)
|
|
175 |
{
|
|
176 |
Q_D(QScriptDebuggerResponse);
|
|
177 |
d->result = qVariantFromValue(scripts);
|
|
178 |
}
|
|
179 |
|
|
180 |
void QScriptDebuggerResponse::setResult(const QScriptScriptData &data)
|
|
181 |
{
|
|
182 |
Q_D(QScriptDebuggerResponse);
|
|
183 |
d->result = qVariantFromValue(data);
|
|
184 |
}
|
|
185 |
|
|
186 |
void QScriptDebuggerResponse::setResult(const QScriptDebuggerValue &value)
|
|
187 |
{
|
|
188 |
Q_D(QScriptDebuggerResponse);
|
|
189 |
d->result = qVariantFromValue(value);
|
|
190 |
}
|
|
191 |
|
|
192 |
void QScriptDebuggerResponse::setResult(const QScriptDebuggerValueList &values)
|
|
193 |
{
|
|
194 |
Q_D(QScriptDebuggerResponse);
|
|
195 |
d->result = qVariantFromValue(values);
|
|
196 |
}
|
|
197 |
|
|
198 |
void QScriptDebuggerResponse::setResult(const QScriptDebuggerValuePropertyList &props)
|
|
199 |
{
|
|
200 |
Q_D(QScriptDebuggerResponse);
|
|
201 |
d->result = qVariantFromValue(props);
|
|
202 |
}
|
|
203 |
|
|
204 |
void QScriptDebuggerResponse::setResult(const QScriptContextInfo &info)
|
|
205 |
{
|
|
206 |
Q_D(QScriptDebuggerResponse);
|
|
207 |
d->result = qVariantFromValue(info);
|
|
208 |
}
|
|
209 |
|
|
210 |
int QScriptDebuggerResponse::resultAsInt() const
|
|
211 |
{
|
|
212 |
Q_D(const QScriptDebuggerResponse);
|
|
213 |
return d->result.toInt();
|
|
214 |
}
|
|
215 |
|
|
216 |
qint64 QScriptDebuggerResponse::resultAsLongLong() const
|
|
217 |
{
|
|
218 |
Q_D(const QScriptDebuggerResponse);
|
|
219 |
return d->result.toLongLong();
|
|
220 |
}
|
|
221 |
|
|
222 |
QString QScriptDebuggerResponse::resultAsString() const
|
|
223 |
{
|
|
224 |
Q_D(const QScriptDebuggerResponse);
|
|
225 |
return d->result.toString();
|
|
226 |
}
|
|
227 |
|
|
228 |
QScriptBreakpointData QScriptDebuggerResponse::resultAsBreakpointData() const
|
|
229 |
{
|
|
230 |
Q_D(const QScriptDebuggerResponse);
|
|
231 |
return qvariant_cast<QScriptBreakpointData>(d->result);
|
|
232 |
}
|
|
233 |
|
|
234 |
QScriptBreakpointMap QScriptDebuggerResponse::resultAsBreakpoints() const
|
|
235 |
{
|
|
236 |
Q_D(const QScriptDebuggerResponse);
|
|
237 |
return qvariant_cast<QScriptBreakpointMap>(d->result);
|
|
238 |
}
|
|
239 |
|
|
240 |
QScriptScriptMap QScriptDebuggerResponse::resultAsScripts() const
|
|
241 |
{
|
|
242 |
Q_D(const QScriptDebuggerResponse);
|
|
243 |
return qvariant_cast<QScriptScriptMap>(d->result);
|
|
244 |
}
|
|
245 |
|
|
246 |
QScriptScriptData QScriptDebuggerResponse::resultAsScriptData() const
|
|
247 |
{
|
|
248 |
Q_D(const QScriptDebuggerResponse);
|
|
249 |
return qvariant_cast<QScriptScriptData>(d->result);
|
|
250 |
}
|
|
251 |
|
|
252 |
QScriptDebuggerValue QScriptDebuggerResponse::resultAsScriptValue() const
|
|
253 |
{
|
|
254 |
Q_D(const QScriptDebuggerResponse);
|
|
255 |
return qvariant_cast<QScriptDebuggerValue>(d->result);
|
|
256 |
}
|
|
257 |
|
|
258 |
QScriptDebuggerValueList QScriptDebuggerResponse::resultAsScriptValueList() const
|
|
259 |
{
|
|
260 |
Q_D(const QScriptDebuggerResponse);
|
|
261 |
return qvariant_cast<QScriptDebuggerValueList>(d->result);
|
|
262 |
}
|
|
263 |
|
|
264 |
QScriptDebuggerValuePropertyList QScriptDebuggerResponse::resultAsScriptValuePropertyList() const
|
|
265 |
{
|
|
266 |
Q_D(const QScriptDebuggerResponse);
|
|
267 |
return qvariant_cast<QScriptDebuggerValuePropertyList>(d->result);
|
|
268 |
}
|
|
269 |
|
|
270 |
QScriptContextInfo QScriptDebuggerResponse::resultAsContextInfo() const
|
|
271 |
{
|
|
272 |
Q_D(const QScriptDebuggerResponse);
|
|
273 |
return qvariant_cast<QScriptContextInfo>(d->result);
|
|
274 |
}
|
|
275 |
|
|
276 |
bool QScriptDebuggerResponse::async() const
|
|
277 |
{
|
|
278 |
Q_D(const QScriptDebuggerResponse);
|
|
279 |
return d->async;
|
|
280 |
}
|
|
281 |
|
|
282 |
void QScriptDebuggerResponse::setAsync(bool async)
|
|
283 |
{
|
|
284 |
Q_D(QScriptDebuggerResponse);
|
|
285 |
d->async = async;
|
|
286 |
}
|
|
287 |
|
|
288 |
/*!
|
|
289 |
Returns true if this QScriptDebuggerResponse is equal to the \a other
|
|
290 |
response, otherwise returns false.
|
|
291 |
*/
|
|
292 |
bool QScriptDebuggerResponse::operator==(const QScriptDebuggerResponse &other) const
|
|
293 |
{
|
|
294 |
Q_D(const QScriptDebuggerResponse);
|
|
295 |
const QScriptDebuggerResponsePrivate *od = other.d_func();
|
|
296 |
if (d == od)
|
|
297 |
return true;
|
|
298 |
if (!d || !od)
|
|
299 |
return false;
|
|
300 |
return ((d->error == od->error)
|
|
301 |
&& (d->result == od->result)
|
|
302 |
&& (d->async == od->async));
|
|
303 |
}
|
|
304 |
|
|
305 |
/*!
|
|
306 |
Returns true if this QScriptDebuggerResponse is not equal to the \a
|
|
307 |
other response, otherwise returns false.
|
|
308 |
*/
|
|
309 |
bool QScriptDebuggerResponse::operator!=(const QScriptDebuggerResponse &other) const
|
|
310 |
{
|
|
311 |
return !(*this == other);
|
|
312 |
}
|
|
313 |
|
|
314 |
/*!
|
|
315 |
\fn QDataStream &operator<<(QDataStream &stream, const QScriptDebuggerResponse &response)
|
|
316 |
\relates QScriptDebuggerResponse
|
|
317 |
|
|
318 |
Writes the given \a response to the specified \a stream.
|
|
319 |
*/
|
|
320 |
QDataStream &operator<<(QDataStream &out, const QScriptDebuggerResponse &response)
|
|
321 |
{
|
|
322 |
const QScriptDebuggerResponsePrivate *d = response.d_ptr.data();
|
|
323 |
out << (quint32)d->error;
|
|
324 |
out << d->result;
|
|
325 |
out << d->async;
|
|
326 |
return out;
|
|
327 |
}
|
|
328 |
|
|
329 |
/*!
|
|
330 |
\fn QDataStream &operator>>(QDataStream &stream, QScriptDebuggerResponse &response)
|
|
331 |
\relates QScriptDebuggerResponse
|
|
332 |
|
|
333 |
Reads a QScriptDebuggerResponse from the specified \a stream into the
|
|
334 |
given \a response.
|
|
335 |
*/
|
|
336 |
QDataStream &operator>>(QDataStream &in, QScriptDebuggerResponse &response)
|
|
337 |
{
|
|
338 |
QScriptDebuggerResponsePrivate *d = response.d_ptr.data();
|
|
339 |
|
|
340 |
quint32 error;
|
|
341 |
in >> error;
|
|
342 |
d->error = QScriptDebuggerResponse::Error(error);
|
|
343 |
in >> d->result;
|
|
344 |
in >> d->async;
|
|
345 |
|
|
346 |
return in;
|
|
347 |
}
|
|
348 |
|
|
349 |
QT_END_NAMESPACE
|