summaryrefslogtreecommitdiff
path: root/modules/gdscript
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 /modules/gdscript
parentfb8c93c10b4b73d5f18f1ed287497728800e22b5 (diff)
PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript.cpp10
-rw-r--r--modules/gdscript/gdscript.h2
-rw-r--r--modules/gdscript/gdscript_editor.cpp6
-rw-r--r--modules/gdscript/gdscript_functions.cpp50
-rw-r--r--modules/gdscript/gdscript_parser.cpp42
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp14
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp4
7 files changed, 64 insertions, 64 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 07c74a2e26..a73276dda2 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -902,7 +902,7 @@ Error GDScript::load_byte_code(const String &p_path) {
Error GDScript::load_source_code(const String &p_path) {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
@@ -912,15 +912,15 @@ Error GDScript::load_source_code(const String &p_path) {
int len = f->get_len();
sourcef.resize(len + 1);
- PoolVector<uint8_t>::Write w = sourcef.write();
- int r = f->get_buffer(w.ptr(), len);
+ uint8_t *w = sourcef.ptrw();
+ int r = f->get_buffer(w, len);
f->close();
memdelete(f);
ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN);
w[len] = 0;
String s;
- if (s.parse_utf8((const char *)w.ptr())) {
+ if (s.parse_utf8((const char *)w)) {
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
@@ -1986,7 +1986,7 @@ bool GDScriptLanguage::handles_global_class_type(const String &p_type) const {
String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
Error err;
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 3d24f9b3f5..103de3304e 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -487,7 +487,7 @@ public:
virtual bool supports_builtin_mode() const;
virtual bool can_inherit_from_file() { return true; }
virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result);
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index c2c8ff5b99..52527b7da3 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -457,7 +457,7 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_cons
p_constants->push_back(nan);
}
-String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
#ifdef TOOLS_ENABLED
bool th = EditorSettings::get_singleton()->get_setting("text_editor/completion/add_type_hints");
@@ -2173,8 +2173,8 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
static const char *_type_names[Variant::VARIANT_MAX] = {
"null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform",
- "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray",
- "PoolVector2Array", "PoolVector3Array", "PoolColorArray"
+ "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "PackedByteArray", "PackedIntArray", "PackedRealArray", "PackedStringArray",
+ "PackedVector2Array", "PackedVector3Array", "PackedColorArray"
};
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index a46337d7dd..bd887fd303 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -856,7 +856,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
full_objects = *p_args[1];
}
- PoolByteArray barr;
+ PackedByteArray barr;
int len;
Error err = encode_variant(*p_args[0], NULL, len, full_objects);
if (err) {
@@ -869,8 +869,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
barr.resize(len);
{
- PoolByteArray::Write w = barr.write();
- encode_variant(*p_args[0], w.ptr(), len, full_objects);
+ uint8_t *w = barr.ptrw();
+ encode_variant(*p_args[0], w, len, full_objects);
}
r_ret = barr;
} break;
@@ -896,24 +896,24 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
allow_objects = *p_args[1];
}
- if (p_args[0]->get_type() != Variant::POOL_BYTE_ARRAY) {
+ if (p_args[0]->get_type() != Variant::PACKED_BYTE_ARRAY) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
r_ret = Variant();
return;
}
- PoolByteArray varr = *p_args[0];
+ PackedByteArray varr = *p_args[0];
Variant ret;
{
- PoolByteArray::Read r = varr.read();
- Error err = decode_variant(ret, r.ptr(), varr.size(), NULL, allow_objects);
+ const uint8_t *r = varr.ptr();
+ Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects);
if (err != OK) {
r_ret = RTR("Not enough bytes for decoding bytes, or invalid format.");
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
return;
}
}
@@ -1390,39 +1390,39 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Array d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_BYTE_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY: {
- PoolVector<uint8_t> d = *p_args[0];
+ Vector<uint8_t> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_INT_ARRAY: {
- PoolVector<int> d = *p_args[0];
+ Vector<int> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_REAL_ARRAY: {
+ case Variant::PACKED_REAL_ARRAY: {
- PoolVector<real_t> d = *p_args[0];
+ Vector<real_t> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_STRING_ARRAY: {
+ case Variant::PACKED_STRING_ARRAY: {
- PoolVector<String> d = *p_args[0];
+ Vector<String> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
+ case Variant::PACKED_VECTOR2_ARRAY: {
- PoolVector<Vector2> d = *p_args[0];
+ Vector<Vector2> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_VECTOR3_ARRAY: {
- PoolVector<Vector3> d = *p_args[0];
+ Vector<Vector3> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
- PoolVector<Color> d = *p_args[0];
+ Vector<Color> d = *p_args[0];
r_ret = d.size();
} break;
default: {
@@ -1941,12 +1941,12 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
MethodInfo mi("var2bytes", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::BOOL, "full_objects"));
mi.default_arguments.push_back(false);
- mi.return_val.type = Variant::POOL_BYTE_ARRAY;
+ mi.return_val.type = Variant::PACKED_BYTE_ARRAY;
return mi;
} break;
case BYTES_TO_VAR: {
- MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes"), PropertyInfo(Variant::BOOL, "allow_objects"));
+ MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytes"), PropertyInfo(Variant::BOOL, "allow_objects"));
mi.default_arguments.push_back(false);
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index fae6fbbb0c..33c6a55bfb 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -6596,13 +6596,13 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
if (!error) {
switch (base_type.builtin_type) {
// Expect int or real as index
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_COLOR_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::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_COLOR_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::ARRAY:
case Variant::STRING: {
error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::REAL;
@@ -6646,13 +6646,13 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::STRING:
case Variant::ARRAY:
case Variant::DICTIONARY:
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_COLOR_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::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_COLOR_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: {
break;
}
default: {
@@ -6698,34 +6698,34 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
return DataType();
} break;
// Return int
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT_ARRAY: {
result.builtin_type = Variant::INT;
} break;
// Return real
- case Variant::POOL_REAL_ARRAY:
+ case Variant::PACKED_REAL_ARRAY:
case Variant::VECTOR2:
case Variant::VECTOR3:
case Variant::QUAT: {
result.builtin_type = Variant::REAL;
} break;
// Return color
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
result.builtin_type = Variant::COLOR;
} break;
// Return string
- case Variant::POOL_STRING_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
case Variant::STRING: {
result.builtin_type = Variant::STRING;
} break;
// Return Vector2
- case Variant::POOL_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
case Variant::TRANSFORM2D:
case Variant::RECT2: {
result.builtin_type = Variant::VECTOR2;
} break;
// Return Vector3
- case Variant::POOL_VECTOR3_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
case Variant::AABB:
case Variant::BASIS: {
result.builtin_type = Variant::VECTOR3;
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index a0e0811c1f..b30f81959e 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -163,13 +163,13 @@ static const _bit _type_list[] = {
{ Variant::NODE_PATH, "NodePath" },
{ Variant::DICTIONARY, "Dictionary" },
{ Variant::ARRAY, "Array" },
- { Variant::POOL_BYTE_ARRAY, "PoolByteArray" },
- { Variant::POOL_INT_ARRAY, "PoolIntArray" },
- { Variant::POOL_REAL_ARRAY, "PoolRealArray" },
- { Variant::POOL_STRING_ARRAY, "PoolStringArray" },
- { Variant::POOL_VECTOR2_ARRAY, "PoolVector2Array" },
- { Variant::POOL_VECTOR3_ARRAY, "PoolVector3Array" },
- { Variant::POOL_COLOR_ARRAY, "PoolColorArray" },
+ { Variant::PACKED_BYTE_ARRAY, "PackedByteArray" },
+ { Variant::PACKED_INT_ARRAY, "PackedIntArray" },
+ { Variant::PACKED_REAL_ARRAY, "PackedRealArray" },
+ { Variant::PACKED_STRING_ARRAY, "PackedStringArray" },
+ { Variant::PACKED_VECTOR2_ARRAY, "PackedVector2Array" },
+ { Variant::PACKED_VECTOR3_ARRAY, "PackedVector3Array" },
+ { Variant::PACKED_COLOR_ARRAY, "PackedColorArray" },
{ Variant::VARIANT_MAX, NULL },
};
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index 7133c6b4be..b2da5dfdbc 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -39,10 +39,10 @@ GDScriptLanguageProtocol *GDScriptLanguageProtocol::singleton = NULL;
void GDScriptLanguageProtocol::on_data_received(int p_id) {
lastest_client_id = p_id;
Ref<WebSocketPeer> peer = server->get_peer(p_id);
- PoolByteArray data;
+ PackedByteArray data;
if (OK == peer->get_packet_buffer(data)) {
String message;
- message.parse_utf8((const char *)data.read().ptr(), data.size());
+ message.parse_utf8((const char *)data.ptr(), data.size());
if (message.begins_with("Content-Length:")) return;
String output = process_message(message);
if (!output.empty()) {