summaryrefslogtreecommitdiff
path: root/core/packed_data_container.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-02-17 18:06:54 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-18 10:10:36 +0100
commit3205a92ad872f918c8322cdcd1434c231a1fd251 (patch)
treedb44242ca27432eb8ea849679752d0835d2ae41a /core/packed_data_container.cpp
parentfb8c93c10b4b73d5f18f1ed287497728800e22b5 (diff)
PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
Diffstat (limited to 'core/packed_data_container.cpp')
-rw-r--r--core/packed_data_container.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index f8f51c4c75..ae5f89e870 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -80,20 +80,20 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_off
if (pos < 0 || pos >= size)
return Variant();
- PoolVector<uint8_t>::Read rd = data.read();
+ const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_offset];
uint32_t type = decode_uint32(r);
bool err = false;
if (type == TYPE_ARRAY) {
- uint32_t vpos = decode_uint32(rd.ptr() + p_offset + 8 + pos * 4);
- return _get_at_ofs(vpos, rd.ptr(), err);
+ uint32_t vpos = decode_uint32(rd + p_offset + 8 + pos * 4);
+ return _get_at_ofs(vpos, rd, err);
} else if (type == TYPE_DICT) {
- uint32_t vpos = decode_uint32(rd.ptr() + p_offset + 8 + pos * 12 + 4);
- return _get_at_ofs(vpos, rd.ptr(), err);
+ uint32_t vpos = decode_uint32(rd + p_offset + 8 + pos * 12 + 4);
+ return _get_at_ofs(vpos, rd, err);
} else {
ERR_FAIL_V(Variant());
}
@@ -127,7 +127,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b
uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
- PoolVector<uint8_t>::Read rd = data.read();
+ const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
@@ -136,8 +136,8 @@ uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
int PackedDataContainer::_size(uint32_t p_ofs) const {
- PoolVector<uint8_t>::Read rd = data.read();
- ERR_FAIL_COND_V(!rd.ptr(), 0);
+ const uint8_t *rd = data.ptr();
+ ERR_FAIL_COND_V(!rd, 0);
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
@@ -157,7 +157,7 @@ int PackedDataContainer::_size(uint32_t p_ofs) const {
Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, bool &err) const {
- PoolVector<uint8_t>::Read rd = data.read();
+ const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
@@ -172,7 +172,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
return Variant();
}
uint32_t ofs = decode_uint32(r + 8 + 4 * idx);
- return _get_at_ofs(ofs, rd.ptr(), err);
+ return _get_at_ofs(ofs, rd, err);
} else {
err = true;
@@ -188,12 +188,12 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
for (uint32_t i = 0; i < len; i++) {
uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
if (khash == hash) {
- Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd.ptr(), err);
+ Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd, err);
if (err)
return Variant();
if (key == p_key) {
//key matches, return value
- return _get_at_ofs(decode_uint32(r + 8 + i * 12 + 8), rd.ptr(), err);
+ return _get_at_ofs(decode_uint32(r + 8 + i * 12 + 8), rd, err);
}
found = true;
} else {
@@ -240,13 +240,13 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::AABB:
case Variant::BASIS:
case Variant::TRANSFORM:
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_INT_ARRAY:
- case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY:
- case Variant::POOL_VECTOR2_ARRAY:
- case Variant::POOL_VECTOR3_ARRAY:
- case Variant::POOL_COLOR_ARRAY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT_ARRAY:
+ case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
case Variant::NODE_PATH: {
uint32_t pos = tmpdata.size();
@@ -335,19 +335,19 @@ Error PackedDataContainer::pack(const Variant &p_data) {
_pack(p_data, tmpdata, string_cache);
datalen = tmpdata.size();
data.resize(tmpdata.size());
- PoolVector<uint8_t>::Write w = data.write();
- copymem(w.ptr(), tmpdata.ptr(), tmpdata.size());
+ uint8_t *w = data.ptrw();
+ copymem(w, tmpdata.ptr(), tmpdata.size());
return OK;
}
-void PackedDataContainer::_set_data(const PoolVector<uint8_t> &p_data) {
+void PackedDataContainer::_set_data(const Vector<uint8_t> &p_data) {
data = p_data;
datalen = data.size();
}
-PoolVector<uint8_t> PackedDataContainer::_get_data() const {
+Vector<uint8_t> PackedDataContainer::_get_data() const {
return data;
}
@@ -375,7 +375,7 @@ void PackedDataContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("pack", "value"), &PackedDataContainer::pack);
ClassDB::bind_method(D_METHOD("size"), &PackedDataContainer::size);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
}
PackedDataContainer::PackedDataContainer() {