| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 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 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 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 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #include "qscriptdebuggervalueproperty_p.h" | 
|---|
| 43 | #include "qscriptdebuggervalue_p.h" | 
|---|
| 44 | #include "qscriptdebuggerobjectsnapshotdelta_p.h" | 
|---|
| 45 |  | 
|---|
| 46 | #include <QtCore/qatomic.h> | 
|---|
| 47 | #include <QtCore/qdatastream.h> | 
|---|
| 48 | #include <QtCore/qstring.h> | 
|---|
| 49 |  | 
|---|
| 50 | QT_BEGIN_NAMESPACE | 
|---|
| 51 |  | 
|---|
| 52 | /*! | 
|---|
| 53 | \internal | 
|---|
| 54 | \class QScriptDebuggerValueProperty | 
|---|
| 55 | */ | 
|---|
| 56 |  | 
|---|
| 57 | class QScriptDebuggerValuePropertyPrivate | 
|---|
| 58 | { | 
|---|
| 59 | public: | 
|---|
| 60 | QScriptDebuggerValuePropertyPrivate(); | 
|---|
| 61 | ~QScriptDebuggerValuePropertyPrivate(); | 
|---|
| 62 |  | 
|---|
| 63 | QString name; | 
|---|
| 64 | QScriptDebuggerValue value; | 
|---|
| 65 | QString valueAsString; | 
|---|
| 66 | QScriptValue::PropertyFlags flags; | 
|---|
| 67 |  | 
|---|
| 68 | QBasicAtomicInt ref; | 
|---|
| 69 | }; | 
|---|
| 70 |  | 
|---|
| 71 | QScriptDebuggerValuePropertyPrivate::QScriptDebuggerValuePropertyPrivate() | 
|---|
| 72 | { | 
|---|
| 73 | ref = 0; | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | QScriptDebuggerValuePropertyPrivate::~QScriptDebuggerValuePropertyPrivate() | 
|---|
| 77 | { | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | /*! | 
|---|
| 81 | Constructs an invalid QScriptDebuggerValueProperty. | 
|---|
| 82 | */ | 
|---|
| 83 | QScriptDebuggerValueProperty::QScriptDebuggerValueProperty() | 
|---|
| 84 | : d_ptr(0) | 
|---|
| 85 | { | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | /*! | 
|---|
| 89 | Constructs a QScriptDebuggerValueProperty with the given \a name, | 
|---|
| 90 | \a value and \a flags. | 
|---|
| 91 | */ | 
|---|
| 92 | QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QString &name, | 
|---|
| 93 | const QScriptDebuggerValue &value, | 
|---|
| 94 | const QString &valueAsString, | 
|---|
| 95 | QScriptValue::PropertyFlags flags) | 
|---|
| 96 | : d_ptr(new QScriptDebuggerValuePropertyPrivate) | 
|---|
| 97 | { | 
|---|
| 98 | d_ptr->name = name; | 
|---|
| 99 | d_ptr->value = value; | 
|---|
| 100 | d_ptr->valueAsString = valueAsString; | 
|---|
| 101 | d_ptr->flags = flags; | 
|---|
| 102 | d_ptr->ref.ref(); | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | /*! | 
|---|
| 106 | Constructs a QScriptDebuggerValueProperty that is a copy of the \a other property. | 
|---|
| 107 | */ | 
|---|
| 108 | QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebuggerValueProperty &other) | 
|---|
| 109 | : d_ptr(other.d_ptr.data()) | 
|---|
| 110 | { | 
|---|
| 111 | if (d_ptr) | 
|---|
| 112 | d_ptr->ref.ref(); | 
|---|
| 113 | } | 
|---|
| 114 |  | 
|---|
| 115 | /*! | 
|---|
| 116 | Destroys this QScriptDebuggerValueProperty. | 
|---|
| 117 | */ | 
|---|
| 118 | QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty() | 
|---|
| 119 | { | 
|---|
| 120 | } | 
|---|
| 121 |  | 
|---|
| 122 | /*! | 
|---|
| 123 | Assigns the \a other property to this QScriptDebuggerValueProperty. | 
|---|
| 124 | */ | 
|---|
| 125 | QScriptDebuggerValueProperty &QScriptDebuggerValueProperty::operator=(const QScriptDebuggerValueProperty &other) | 
|---|
| 126 | { | 
|---|
| 127 | d_ptr.assign(other.d_ptr.data()); | 
|---|
| 128 | return *this; | 
|---|
| 129 | } | 
|---|
| 130 |  | 
|---|
| 131 | /*! | 
|---|
| 132 | Returns the name of this QScriptDebuggerValueProperty. | 
|---|
| 133 | */ | 
|---|
| 134 | QString QScriptDebuggerValueProperty::name() const | 
|---|
| 135 | { | 
|---|
| 136 | Q_D(const QScriptDebuggerValueProperty); | 
|---|
| 137 | if (!d) | 
|---|
| 138 | return QString(); | 
|---|
| 139 | return d->name; | 
|---|
| 140 | } | 
|---|
| 141 |  | 
|---|
| 142 | /*! | 
|---|
| 143 | Returns the value of this QScriptDebuggerValueProperty. | 
|---|
| 144 | */ | 
|---|
| 145 | QScriptDebuggerValue QScriptDebuggerValueProperty::value() const | 
|---|
| 146 | { | 
|---|
| 147 | Q_D(const QScriptDebuggerValueProperty); | 
|---|
| 148 | if (!d) | 
|---|
| 149 | return QScriptDebuggerValue(); | 
|---|
| 150 | return d->value; | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 | QString QScriptDebuggerValueProperty::valueAsString() const | 
|---|
| 154 | { | 
|---|
| 155 | Q_D(const QScriptDebuggerValueProperty); | 
|---|
| 156 | if (!d) | 
|---|
| 157 | return QString(); | 
|---|
| 158 | return d->valueAsString; | 
|---|
| 159 | } | 
|---|
| 160 |  | 
|---|
| 161 | /*! | 
|---|
| 162 | Returns the flags of this QScriptDebuggerValueProperty. | 
|---|
| 163 | */ | 
|---|
| 164 | QScriptValue::PropertyFlags QScriptDebuggerValueProperty::flags() const | 
|---|
| 165 | { | 
|---|
| 166 | Q_D(const QScriptDebuggerValueProperty); | 
|---|
| 167 | if (!d) | 
|---|
| 168 | return 0; | 
|---|
| 169 | return d->flags; | 
|---|
| 170 | } | 
|---|
| 171 |  | 
|---|
| 172 | /*! | 
|---|
| 173 | Returns true if this QScriptDebuggerValueProperty is valid, otherwise | 
|---|
| 174 | returns false. | 
|---|
| 175 | */ | 
|---|
| 176 | bool QScriptDebuggerValueProperty::isValid() const | 
|---|
| 177 | { | 
|---|
| 178 | Q_D(const QScriptDebuggerValueProperty); | 
|---|
| 179 | return (d != 0); | 
|---|
| 180 | } | 
|---|
| 181 |  | 
|---|
| 182 | /*! | 
|---|
| 183 | \fn QDataStream &operator<<(QDataStream &stream, const QScriptDebuggerValueProperty &property) | 
|---|
| 184 | \relates QScriptDebuggerValueProperty | 
|---|
| 185 |  | 
|---|
| 186 | Writes the given \a property to the specified \a stream. | 
|---|
| 187 | */ | 
|---|
| 188 | QDataStream &operator<<(QDataStream &out, const QScriptDebuggerValueProperty &property) | 
|---|
| 189 | { | 
|---|
| 190 | out << property.name(); | 
|---|
| 191 | out << property.value(); | 
|---|
| 192 | out << property.valueAsString(); | 
|---|
| 193 | out << (quint32)property.flags(); | 
|---|
| 194 | return out; | 
|---|
| 195 | } | 
|---|
| 196 |  | 
|---|
| 197 | /*! | 
|---|
| 198 | \fn QDataStream &operator>>(QDataStream &stream, QScriptDebuggerValueProperty &property) | 
|---|
| 199 | \relates QScriptDebuggerValueProperty | 
|---|
| 200 |  | 
|---|
| 201 | Reads a QScriptDebuggerValueProperty from the specified \a stream into the | 
|---|
| 202 | given \a property. | 
|---|
| 203 | */ | 
|---|
| 204 | QDataStream &operator>>(QDataStream &in, QScriptDebuggerValueProperty &property) | 
|---|
| 205 | { | 
|---|
| 206 | QString name; | 
|---|
| 207 | QScriptDebuggerValue value; | 
|---|
| 208 | QString valueAsString; | 
|---|
| 209 | quint32 flags; | 
|---|
| 210 | in >> name; | 
|---|
| 211 | in >> value; | 
|---|
| 212 | in >> valueAsString; | 
|---|
| 213 | in >> flags; | 
|---|
| 214 | property = QScriptDebuggerValueProperty( | 
|---|
| 215 | name, value, valueAsString, QScriptValue::PropertyFlags(flags)); | 
|---|
| 216 | return in; | 
|---|
| 217 | } | 
|---|
| 218 |  | 
|---|
| 219 | QDataStream &operator<<(QDataStream &out, const QScriptDebuggerObjectSnapshotDelta &delta) | 
|---|
| 220 | { | 
|---|
| 221 | out << delta.removedProperties; | 
|---|
| 222 | out << delta.changedProperties; | 
|---|
| 223 | out << delta.addedProperties; | 
|---|
| 224 | return out; | 
|---|
| 225 | } | 
|---|
| 226 |  | 
|---|
| 227 | QDataStream &operator>>(QDataStream &in, QScriptDebuggerObjectSnapshotDelta &delta) | 
|---|
| 228 | { | 
|---|
| 229 | in >> delta.removedProperties; | 
|---|
| 230 | in >> delta.changedProperties; | 
|---|
| 231 | in >> delta.addedProperties; | 
|---|
| 232 | return in; | 
|---|
| 233 | } | 
|---|
| 234 |  | 
|---|
| 235 | QT_END_NAMESPACE | 
|---|