Showing the changes to libraries/script-engine/src/DataViewPrototype.cpp (1 of 2 files). Show all
Unified · Split
| @@ -38,23 +38,31 @@ bool DataViewPrototype::realOffset(quint32& offset, size_t size) const { · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | ///////////////// GETTERS //////////////////////////// |
| 40 | 40 | |
| 41 | −qint8 DataViewPrototype::getInt8(quint32 byteOffset) { | |
| 41 | +qint32 DataViewPrototype::getInt8(quint32 byteOffset) { | |
| 42 | 42 | if (realOffset(byteOffset, sizeof(qint8))) { |
| 43 | − qDebug() << "Value: " << (qint8)thisArrayBuffer()->at(byteOffset); | |
| 44 | − | |
| 45 | − return (qint8)thisArrayBuffer()->at(byteOffset); | |
| 43 | + QDataStream stream(*thisArrayBuffer()); | |
| 44 | + stream.skipRawData(byteOffset); | |
| 45 | + | |
| 46 | + qint8 result; | |
| 47 | + stream >> result; | |
| 48 | + return result; | |
| 46 | 49 | } |
| 47 | − qDebug() << "42 powaaaa!!!"; | |
| 48 | 50 | return 42; |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | −quint8 DataViewPrototype::getUint8(quint32 byteOffset) { | |
| 52 | − if (realOffset(byteOffset, sizeof(quint8))) { return thisArrayBuffer()->at(byteOffset); | |
| 53 | +quint32 DataViewPrototype::getUint8(quint32 byteOffset) { | |
| 54 | + if (realOffset(byteOffset, sizeof(quint8))) { | |
| 55 | + QDataStream stream(*thisArrayBuffer()); | |
| 56 | + stream.skipRawData(byteOffset); | |
| 57 | + | |
| 58 | + quint8 result; | |
| 59 | + stream >> result; | |
| 60 | + return result; | |
| 53 | 61 | } |
| 54 | 62 | return 42; |
| 55 | 63 | } |
| 56 | 64 | |
| 57 | −qint16 DataViewPrototype::getInt16(quint32 byteOffset, bool littleEndian) { | |
| 65 | +qint32 DataViewPrototype::getInt16(quint32 byteOffset, bool littleEndian) { | |
| 58 | 66 | if (realOffset(byteOffset, sizeof(qint16))) { |
| 59 | 67 | QDataStream stream(*thisArrayBuffer()); |
| 60 | 68 | stream.setByteOrder((littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); |
| @@ -67,13 +75,13 @@ qint16 DataViewPrototype::getInt16(quint32 byteOffset, bool littleEndian) { · 6 unmodified lines | ||
| 67 | 75 | return 42; |
| 68 | 76 | } |
| 69 | 77 | |
| 70 | −quint16 DataViewPrototype::getUint16(quint32 byteOffset, bool littleEndian) { | |
| 78 | +quint32 DataViewPrototype::getUint16(quint32 byteOffset, bool littleEndian) { | |
| 71 | 79 | if (realOffset(byteOffset, sizeof(quint16))) { |
| 72 | 80 | QDataStream stream(*thisArrayBuffer()); |
| 73 | 81 | stream.setByteOrder((littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); |
| 74 | 82 | stream.skipRawData(byteOffset); |
| 75 | 83 | |
| 76 | − qint16 result; | |
| 84 | + quint16 result; | |
| 77 | 85 | stream >> result; |
| 78 | 86 | return result; |
| 79 | 87 | } |
| @@ -86,7 +94,7 @@ qint32 DataViewPrototype::getInt32(quint32 byteOffset, bool littleEndian) { · 6 unmodified lines | ||
| 86 | 94 | stream.setByteOrder((littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); |
| 87 | 95 | stream.skipRawData(byteOffset); |
| 88 | 96 | |
| 89 | − qint16 result; | |
| 97 | + qint32 result; | |
| 90 | 98 | stream >> result; |
| 91 | 99 | return result; |
| 92 | 100 | } |
| @@ -99,7 +107,7 @@ quint32 DataViewPrototype::getUint32(quint32 byteOffset, bool littleEndian) { · 6 unmodified lines | ||
| 99 | 107 | stream.setByteOrder((littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); |
| 100 | 108 | stream.skipRawData(byteOffset); |
| 101 | 109 | |
| 102 | − qint16 result; | |
| 110 | + quint32 result; | |
| 103 | 111 | stream >> result; |
| 104 | 112 | return result; |
| 105 | 113 | } |
| @@ -112,7 +120,7 @@ float DataViewPrototype::getFloat32(quint32 byteOffset, bool littleEndian) { · 6 unmodified lines | ||
| 112 | 120 | stream.setByteOrder((littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); |
| 113 | 121 | stream.skipRawData(byteOffset); |
| 114 | 122 | |
| 115 | − qint16 result; | |
| 123 | + float result; | |
| 116 | 124 | stream >> result; |
| 117 | 125 | return result; |
| 118 | 126 | } |
| @@ -125,7 +133,7 @@ double DataViewPrototype::getFloat64(quint32 byteOffset, bool littleEndian) { · 6 unmodified lines | ||
| 125 | 133 | stream.setByteOrder((littleEndian) ? QDataStream::LittleEndian : QDataStream::BigEndian); |
| 126 | 134 | stream.skipRawData(byteOffset); |
| 127 | 135 | |
| 128 | − qint16 result; | |
| 136 | + double result; | |
| 129 | 137 | stream >> result; |
| 130 | 138 | return result; |
| 131 | 139 | } |
| @@ -134,48 +142,48 @@ double DataViewPrototype::getFloat64(quint32 byteOffset, bool littleEndian) { · 2 unmodified lines | ||
| 134 | 142 | |
| 135 | 143 | ///////////////// SETTERS //////////////////////////// |
| 136 | 144 | |
| 137 | −void DataViewPrototype::setInt8(quint32 byteOffset, qint8 value) { | |
| 145 | +void DataViewPrototype::setInt8(quint32 byteOffset, qint32 value) { | |
| 138 | 146 | if (realOffset(byteOffset, sizeof(qint8))) { |
| 139 | 147 | QDataStream stream(thisArrayBuffer(), QIODevice::ReadWrite); |
| 140 | 148 | stream.skipRawData(byteOffset); |
| 141 | 149 | |
| 142 | − stream << value; | |
| 150 | + stream << (qint8)value; | |
| 143 | 151 | } |
| 144 | 152 | } |
| 145 | 153 | |
| 146 | −void DataViewPrototype::setUint8(quint32 byteOffset, quint8 value) { | |
| 154 | +void DataViewPrototype::setUint8(quint32 byteOffset, quint32 value) { | |
| 147 | 155 | if (realOffset(byteOffset, sizeof(quint8))) { |
| 148 | 156 | QDataStream stream(thisArrayBuffer(), QIODevice::ReadWrite); |
| 149 | 157 | stream.skipRawData(byteOffset); |
| 150 | 158 | |
| 151 | − stream << value; | |
| 159 | + stream << (quint8)value; | |
| 152 | 160 | } |
| 153 | 161 | } |
| 154 | 162 | |
| 155 | −void DataViewPrototype::setInt16(quint32 byteOffset, qint16 value, bool littleEndian) { | |
| 163 | +void DataViewPrototype::setInt16(quint32 byteOffset, qint32 value, bool littleEndian) { | |
| 156 | 164 | if (realOffset(byteOffset, sizeof(qint16))) { |
| 157 | 165 | QDataStream stream(thisArrayBuffer(), QIODevice::ReadWrite); |
| 158 | 166 | stream.skipRawData(byteOffset); |
| 159 | 167 | |
| 160 | − stream << value; | |
| 168 | + stream << (qint16)value; | |
| 161 | 169 | } |
| 162 | 170 | } |
| 163 | 171 | |
| 164 | −void DataViewPrototype::setUint16(quint32 byteOffset, quint16 value, bool littleEndian) { | |
| 172 | +void DataViewPrototype::setUint16(quint32 byteOffset, quint32 value, bool littleEndian) { | |
| 165 | 173 | if (realOffset(byteOffset, sizeof(quint16))) { |
| 166 | 174 | QDataStream stream(thisArrayBuffer(), QIODevice::ReadWrite); |
| 167 | 175 | stream.skipRawData(byteOffset); |
| 168 | 176 | |
| 169 | − stream << value; | |
| 177 | + stream << (quint16)value; | |
| 170 | 178 | } |
| 171 | 179 | } |
| 172 | 180 | |
| 173 | −void DataViewPrototype::setInt32(quint32 byteOffset, quint32 value, bool littleEndian) { | |
| 181 | +void DataViewPrototype::setInt32(quint32 byteOffset, qint32 value, bool littleEndian) { | |
| 174 | 182 | if (realOffset(byteOffset, sizeof(qint32))) { |
| 175 | 183 | QDataStream stream(thisArrayBuffer(), QIODevice::ReadWrite); |
| 176 | 184 | stream.skipRawData(byteOffset); |
| 177 | 185 | |
| 178 | − stream << value; | |
| 186 | + stream << (qint32)value; | |
| 179 | 187 | } |
| 180 | 188 | } |
| 181 | 189 | |
| @@ -184,7 +192,7 @@ void DataViewPrototype::setUint32(quint32 byteOffset, quint32 value, bool little · 2 unmodified lines | ||
| 184 | 192 | QDataStream stream(thisArrayBuffer(), QIODevice::ReadWrite); |
| 185 | 193 | stream.skipRawData(byteOffset); |
| 186 | 194 | |
| 187 | − stream << value; | |
| 195 | + stream << (quint32)value; | |
| 188 | 196 | } |
| 189 | 197 | } |
| 190 | 198 | |