PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
This commit is contained in:
parent
fb8c93c10b
commit
3205a92ad8
406 changed files with 5314 additions and 8271 deletions
|
|
@ -861,18 +861,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
}
|
||||
}
|
||||
|
||||
} else if (id == "PoolByteArray" || id == "ByteArray") {
|
||||
} else if (id == "PackedByteArray" || id == "PoolByteArray" || id == "ByteArray") {
|
||||
|
||||
Vector<uint8_t> args;
|
||||
Error err = _parse_construct<uint8_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
PoolVector<uint8_t> arr;
|
||||
Vector<uint8_t> arr;
|
||||
{
|
||||
int len = args.size();
|
||||
arr.resize(len);
|
||||
PoolVector<uint8_t>::Write w = arr.write();
|
||||
uint8_t *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = args[i];
|
||||
}
|
||||
|
|
@ -882,18 +882,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
|
||||
return OK;
|
||||
|
||||
} else if (id == "PoolIntArray" || id == "IntArray") {
|
||||
} else if (id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") {
|
||||
|
||||
Vector<int> args;
|
||||
Error err = _parse_construct<int>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
PoolVector<int> arr;
|
||||
Vector<int> arr;
|
||||
{
|
||||
int len = args.size();
|
||||
arr.resize(len);
|
||||
PoolVector<int>::Write w = arr.write();
|
||||
int *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = int(args[i]);
|
||||
}
|
||||
|
|
@ -903,18 +903,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
|
||||
return OK;
|
||||
|
||||
} else if (id == "PoolRealArray" || id == "FloatArray") {
|
||||
} else if (id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") {
|
||||
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
PoolVector<float> arr;
|
||||
Vector<float> arr;
|
||||
{
|
||||
int len = args.size();
|
||||
arr.resize(len);
|
||||
PoolVector<float>::Write w = arr.write();
|
||||
float *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = args[i];
|
||||
}
|
||||
|
|
@ -923,7 +923,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
value = arr;
|
||||
|
||||
return OK;
|
||||
} else if (id == "PoolStringArray" || id == "StringArray") {
|
||||
} else if (id == "PackedStringArray" || id == "PoolStringArray" || id == "StringArray") {
|
||||
|
||||
get_token(p_stream, token, line, r_err_str);
|
||||
if (token.type != TK_PARENTHESIS_OPEN) {
|
||||
|
|
@ -960,11 +960,11 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
cs.push_back(token.value);
|
||||
}
|
||||
|
||||
PoolVector<String> arr;
|
||||
Vector<String> arr;
|
||||
{
|
||||
int len = cs.size();
|
||||
arr.resize(len);
|
||||
PoolVector<String>::Write w = arr.write();
|
||||
String *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = cs[i];
|
||||
}
|
||||
|
|
@ -974,18 +974,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
|
||||
return OK;
|
||||
|
||||
} else if (id == "PoolVector2Array" || id == "Vector2Array") {
|
||||
} else if (id == "PackedVector2Array" || id == "PoolVector2Array" || id == "Vector2Array") {
|
||||
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
PoolVector<Vector2> arr;
|
||||
Vector<Vector2> arr;
|
||||
{
|
||||
int len = args.size() / 2;
|
||||
arr.resize(len);
|
||||
PoolVector<Vector2>::Write w = arr.write();
|
||||
Vector2 *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = Vector2(args[i * 2 + 0], args[i * 2 + 1]);
|
||||
}
|
||||
|
|
@ -995,18 +995,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
|
||||
return OK;
|
||||
|
||||
} else if (id == "PoolVector3Array" || id == "Vector3Array") {
|
||||
} else if (id == "PackedVector3Array" || id == "PoolVector3Array" || id == "Vector3Array") {
|
||||
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
PoolVector<Vector3> arr;
|
||||
Vector<Vector3> arr;
|
||||
{
|
||||
int len = args.size() / 3;
|
||||
arr.resize(len);
|
||||
PoolVector<Vector3>::Write w = arr.write();
|
||||
Vector3 *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = Vector3(args[i * 3 + 0], args[i * 3 + 1], args[i * 3 + 2]);
|
||||
}
|
||||
|
|
@ -1016,18 +1016,18 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||
|
||||
return OK;
|
||||
|
||||
} else if (id == "PoolColorArray" || id == "ColorArray") {
|
||||
} else if (id == "PackedColorArray" || id == "PoolColorArray" || id == "ColorArray") {
|
||||
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
PoolVector<Color> arr;
|
||||
Vector<Color> arr;
|
||||
{
|
||||
int len = args.size() / 4;
|
||||
arr.resize(len);
|
||||
PoolVector<Color>::Write w = arr.write();
|
||||
Color *w = arr.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
w[i] = Color(args[i * 4 + 0], args[i * 4 + 1], args[i * 4 + 2], args[i * 4 + 3]);
|
||||
}
|
||||
|
|
@ -1609,32 +1609,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
|||
|
||||
} break;
|
||||
|
||||
case Variant::POOL_BYTE_ARRAY: {
|
||||
case Variant::PACKED_BYTE_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolByteArray( ");
|
||||
p_store_string_func(p_store_string_ud, "PackedByteArray( ");
|
||||
String s;
|
||||
PoolVector<uint8_t> data = p_variant;
|
||||
Vector<uint8_t> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<uint8_t>::Read r = data.read();
|
||||
const uint8_t *ptr = r.ptr();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
if (i > 0)
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
|
||||
p_store_string_func(p_store_string_ud, itos(ptr[i]));
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::POOL_INT_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolIntArray( ");
|
||||
PoolVector<int> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<int>::Read r = data.read();
|
||||
const int *ptr = r.ptr();
|
||||
const uint8_t *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
|
|
@ -1647,13 +1628,30 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
|||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::POOL_REAL_ARRAY: {
|
||||
case Variant::PACKED_INT_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolRealArray( ");
|
||||
PoolVector<real_t> data = p_variant;
|
||||
p_store_string_func(p_store_string_ud, "PackedIntArray( ");
|
||||
Vector<int> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<real_t>::Read r = data.read();
|
||||
const real_t *ptr = r.ptr();
|
||||
const int *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
if (i > 0)
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
|
||||
p_store_string_func(p_store_string_ud, itos(ptr[i]));
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::PACKED_REAL_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PackedRealArray( ");
|
||||
Vector<real_t> data = p_variant;
|
||||
int len = data.size();
|
||||
const real_t *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
|
|
@ -1665,13 +1663,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
|||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::POOL_STRING_ARRAY: {
|
||||
case Variant::PACKED_STRING_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolStringArray( ");
|
||||
PoolVector<String> data = p_variant;
|
||||
p_store_string_func(p_store_string_ud, "PackedStringArray( ");
|
||||
Vector<String> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<String>::Read r = data.read();
|
||||
const String *ptr = r.ptr();
|
||||
const String *ptr = data.ptr();
|
||||
|
||||
String s;
|
||||
//write_string("\n");
|
||||
|
||||
|
|
@ -1686,13 +1684,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
|||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::POOL_VECTOR2_ARRAY: {
|
||||
case Variant::PACKED_VECTOR2_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolVector2Array( ");
|
||||
PoolVector<Vector2> data = p_variant;
|
||||
p_store_string_func(p_store_string_ud, "PackedVector2Array( ");
|
||||
Vector<Vector2> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<Vector2>::Read r = data.read();
|
||||
const Vector2 *ptr = r.ptr();
|
||||
const Vector2 *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
|
|
@ -1704,13 +1701,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
|||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::POOL_VECTOR3_ARRAY: {
|
||||
case Variant::PACKED_VECTOR3_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolVector3Array( ");
|
||||
PoolVector<Vector3> data = p_variant;
|
||||
p_store_string_func(p_store_string_ud, "PackedVector3Array( ");
|
||||
Vector<Vector3> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<Vector3>::Read r = data.read();
|
||||
const Vector3 *ptr = r.ptr();
|
||||
const Vector3 *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
|
|
@ -1722,14 +1718,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
|||
p_store_string_func(p_store_string_ud, " )");
|
||||
|
||||
} break;
|
||||
case Variant::POOL_COLOR_ARRAY: {
|
||||
case Variant::PACKED_COLOR_ARRAY: {
|
||||
|
||||
p_store_string_func(p_store_string_ud, "PoolColorArray( ");
|
||||
p_store_string_func(p_store_string_ud, "PackedColorArray( ");
|
||||
|
||||
PoolVector<Color> data = p_variant;
|
||||
Vector<Color> data = p_variant;
|
||||
int len = data.size();
|
||||
PoolVector<Color>::Read r = data.read();
|
||||
const Color *ptr = r.ptr();
|
||||
const Color *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue