summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/config/engine.cpp6
-rw-r--r--core/config/engine.h3
-rw-r--r--core/config/project_settings.cpp5
-rw-r--r--core/config/project_settings.h2
-rw-r--r--core/core_bind.cpp4
-rw-r--r--core/core_bind.h4
-rw-r--r--core/crypto/aes_context.cpp4
-rw-r--r--core/crypto/aes_context.h4
-rw-r--r--core/crypto/crypto.cpp8
-rw-r--r--core/crypto/crypto.h32
-rw-r--r--core/crypto/hashing_context.cpp2
-rw-r--r--core/crypto/hashing_context.h2
-rw-r--r--core/debugger/engine_debugger.cpp2
-rw-r--r--core/debugger/engine_debugger.h2
-rw-r--r--core/debugger/remote_debugger.cpp2
-rw-r--r--core/debugger/remote_debugger.h2
-rw-r--r--core/doc_data.h110
-rw-r--r--core/extension/gdextension.cpp2
-rw-r--r--core/input/input.cpp14
-rw-r--r--core/input/input.h14
-rw-r--r--core/io/config_file.cpp2
-rw-r--r--core/io/config_file.h2
-rw-r--r--core/io/dir_access.cpp14
-rw-r--r--core/io/dir_access.h14
-rw-r--r--core/io/file_access_memory.cpp2
-rw-r--r--core/io/file_access_memory.h2
-rw-r--r--core/io/file_access_pack.cpp2
-rw-r--r--core/io/file_access_pack.h2
-rw-r--r--core/io/file_access_zip.cpp4
-rw-r--r--core/io/file_access_zip.h6
-rw-r--r--core/io/image.cpp12
-rw-r--r--core/io/image.h4
-rw-r--r--core/io/image_loader.cpp2
-rw-r--r--core/io/image_loader.h2
-rw-r--r--core/io/ip.cpp2
-rw-r--r--core/io/logger.cpp2
-rw-r--r--core/io/logger.h2
-rw-r--r--core/io/net_socket.h4
-rw-r--r--core/io/packet_peer_udp.cpp4
-rw-r--r--core/io/packet_peer_udp.h4
-rw-r--r--core/io/resource_loader.cpp4
-rw-r--r--core/io/resource_loader.h4
-rw-r--r--core/io/resource_saver.cpp4
-rw-r--r--core/io/resource_saver.h4
-rw-r--r--core/io/zip_io.cpp2
-rw-r--r--core/io/zip_io.h2
-rw-r--r--core/math/expression.cpp2
-rw-r--r--core/math/expression.h2
-rw-r--r--core/math/geometry_2d.cpp2
-rw-r--r--core/math/geometry_2d.h2
-rw-r--r--core/math/geometry_3d.cpp2
-rw-r--r--core/math/geometry_3d.h2
-rw-r--r--core/object/object.h2
-rw-r--r--core/object/script_language.h3
-rw-r--r--core/object/script_language_extension.cpp1
-rw-r--r--core/object/script_language_extension.h3
-rw-r--r--core/os/os.cpp2
-rw-r--r--core/os/os.h12
-rw-r--r--core/os/time.cpp8
-rw-r--r--core/os/time.h8
-rw-r--r--core/string/print_string.cpp8
-rw-r--r--core/string/print_string.h18
-rw-r--r--core/string/string_name.h5
-rw-r--r--core/string/ustring.cpp2
-rw-r--r--core/string/ustring.h2
-rw-r--r--core/templates/vector.h4
-rw-r--r--core/variant/method_ptrcall.h244
-rw-r--r--core/variant/variant.cpp2
-rw-r--r--core/variant/variant_utility.cpp6
-rw-r--r--core/variant/variant_utility.h6
70 files changed, 397 insertions, 283 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index 203f8c3882..2bb8837849 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -258,6 +258,12 @@ bool Engine::is_printing_error_messages() const {
return CoreGlobals::print_error_enabled;
}
+void Engine::print_header(const String &p_string) const {
+ if (_print_header) {
+ print_line(p_string);
+ }
+}
+
void Engine::add_singleton(const Singleton &p_singleton) {
ERR_FAIL_COND_MSG(singleton_ptrs.has(p_singleton.name), vformat("Can't register singleton '%s' because it already exists.", p_singleton.name));
singletons.push_back(p_singleton);
diff --git a/core/config/engine.h b/core/config/engine.h
index b64309a9e8..be7cd62f66 100644
--- a/core/config/engine.h
+++ b/core/config/engine.h
@@ -84,6 +84,8 @@ private:
bool project_manager_hint = false;
bool extension_reloading = false;
+ bool _print_header = true;
+
static Engine *singleton;
String write_movie_path;
@@ -123,6 +125,7 @@ public:
void set_print_error_messages(bool p_enabled);
bool is_printing_error_messages() const;
+ void print_header(const String &p_string) const;
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 974fd5283b..4fd6ab9028 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -688,7 +688,7 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo
return err;
}
-bool ProjectSettings::has_setting(String p_var) const {
+bool ProjectSettings::has_setting(const String &p_var) const {
_THREAD_SAFE_METHOD_
return props.has(p_var);
@@ -971,7 +971,7 @@ Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other par
}
#ifdef TOOLS_ENABLED
-bool _csproj_exists(String p_root_dir) {
+bool _csproj_exists(const String &p_root_dir) {
Ref<DirAccess> dir = DirAccess::open(p_root_dir);
ERR_FAIL_COND_V(dir.is_null(), false);
@@ -1393,6 +1393,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/run/main_scene", PROPERTY_HINT_FILE, "*.tscn,*.scn,*.res"), "");
GLOBAL_DEF("application/run/disable_stdout", false);
GLOBAL_DEF("application/run/disable_stderr", false);
+ GLOBAL_DEF("application/run/print_header", true);
GLOBAL_DEF_RST("application/config/use_hidden_project_data_directory", true);
GLOBAL_DEF("application/config/use_custom_user_dir", false);
GLOBAL_DEF("application/config/custom_user_dir_name", "");
diff --git a/core/config/project_settings.h b/core/config/project_settings.h
index 55d5957ad1..385f93e91e 100644
--- a/core/config/project_settings.h
+++ b/core/config/project_settings.h
@@ -161,7 +161,7 @@ public:
void store_global_class_list(const Array &p_classes);
String get_global_class_list_path() const;
- bool has_setting(String p_var) const;
+ bool has_setting(const String &p_var) const;
String localize_path(const String &p_path) const;
String globalize_path(const String &p_path) const;
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index e5363f9acc..f5c69b9b98 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -257,7 +257,7 @@ String OS::get_executable_path() const {
return ::OS::get_singleton()->get_executable_path();
}
-Error OS::shell_open(String p_uri) {
+Error OS::shell_open(const String &p_uri) {
if (p_uri.begins_with("res://")) {
WARN_PRINT("Attempting to open an URL with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`.");
} else if (p_uri.begins_with("user://")) {
@@ -266,7 +266,7 @@ Error OS::shell_open(String p_uri) {
return ::OS::get_singleton()->shell_open(p_uri);
}
-Error OS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
+Error OS::shell_show_in_file_manager(const String &p_path, bool p_open_folder) {
if (p_path.begins_with("res://")) {
WARN_PRINT("Attempting to explore file path with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_show_in_file_manager()`.");
} else if (p_path.begins_with("user://")) {
diff --git a/core/core_bind.h b/core/core_bind.h
index 94d95f2ce9..f884426881 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -157,8 +157,8 @@ public:
int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
int create_instance(const Vector<String> &p_arguments);
Error kill(int p_pid);
- Error shell_open(String p_uri);
- Error shell_show_in_file_manager(String p_path, bool p_open_folder = true);
+ Error shell_open(const String &p_uri);
+ Error shell_show_in_file_manager(const String &p_path, bool p_open_folder = true);
bool is_process_running(int p_pid) const;
int get_process_id() const;
diff --git a/core/crypto/aes_context.cpp b/core/crypto/aes_context.cpp
index 8a8d3f875e..7596f4e0e2 100644
--- a/core/crypto/aes_context.cpp
+++ b/core/crypto/aes_context.cpp
@@ -30,7 +30,7 @@
#include "core/crypto/aes_context.h"
-Error AESContext::start(Mode p_mode, PackedByteArray p_key, PackedByteArray p_iv) {
+Error AESContext::start(Mode p_mode, const PackedByteArray &p_key, const PackedByteArray &p_iv) {
ERR_FAIL_COND_V_MSG(mode != MODE_MAX, ERR_ALREADY_IN_USE, "AESContext already started. Call 'finish' before starting a new one.");
ERR_FAIL_COND_V_MSG(p_mode < 0 || p_mode >= MODE_MAX, ERR_INVALID_PARAMETER, "Invalid mode requested.");
// Key check.
@@ -52,7 +52,7 @@ Error AESContext::start(Mode p_mode, PackedByteArray p_key, PackedByteArray p_iv
return OK;
}
-PackedByteArray AESContext::update(PackedByteArray p_src) {
+PackedByteArray AESContext::update(const PackedByteArray &p_src) {
ERR_FAIL_COND_V_MSG(mode < 0 || mode >= MODE_MAX, PackedByteArray(), "AESContext not started. Call 'start' before calling 'update'.");
int len = p_src.size();
ERR_FAIL_COND_V_MSG(len % 16, PackedByteArray(), "The number of bytes to be encrypted must be multiple of 16. Add padding if needed");
diff --git a/core/crypto/aes_context.h b/core/crypto/aes_context.h
index c4d26d815a..f6aeab221f 100644
--- a/core/crypto/aes_context.h
+++ b/core/crypto/aes_context.h
@@ -55,8 +55,8 @@ protected:
static void _bind_methods();
public:
- Error start(Mode p_mode, PackedByteArray p_key, PackedByteArray p_iv = PackedByteArray());
- PackedByteArray update(PackedByteArray p_src);
+ Error start(Mode p_mode, const PackedByteArray &p_key, const PackedByteArray &p_iv = PackedByteArray());
+ PackedByteArray update(const PackedByteArray &p_src);
PackedByteArray get_iv_state();
void finish();
diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp
index 6b1c2a9cb2..7fef819159 100644
--- a/core/crypto/crypto.cpp
+++ b/core/crypto/crypto.cpp
@@ -124,7 +124,7 @@ HMACContext *HMACContext::create() {
/// Crypto
-void (*Crypto::_load_default_certificates)(String p_path) = nullptr;
+void (*Crypto::_load_default_certificates)(const String &p_path) = nullptr;
Crypto *(*Crypto::_create)() = nullptr;
Crypto *Crypto::create() {
if (_create) {
@@ -133,13 +133,13 @@ Crypto *Crypto::create() {
ERR_FAIL_V_MSG(nullptr, "Crypto is not available when the mbedtls module is disabled.");
}
-void Crypto::load_default_certificates(String p_path) {
+void Crypto::load_default_certificates(const String &p_path) {
if (_load_default_certificates) {
_load_default_certificates(p_path);
}
}
-PackedByteArray Crypto::hmac_digest(HashingContext::HashType p_hash_type, PackedByteArray p_key, PackedByteArray p_msg) {
+PackedByteArray Crypto::hmac_digest(HashingContext::HashType p_hash_type, const PackedByteArray &p_key, const PackedByteArray &p_msg) {
Ref<HMACContext> ctx = Ref<HMACContext>(HMACContext::create());
ERR_FAIL_COND_V_MSG(ctx.is_null(), PackedByteArray(), "HMAC is not available without mbedtls module.");
Error err = ctx->start(p_hash_type, p_key);
@@ -151,7 +151,7 @@ PackedByteArray Crypto::hmac_digest(HashingContext::HashType p_hash_type, Packed
// Compares two HMACS for equality without leaking timing information in order to prevent timing attacks.
// @see: https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy
-bool Crypto::constant_time_compare(PackedByteArray p_trusted, PackedByteArray p_received) {
+bool Crypto::constant_time_compare(const PackedByteArray &p_trusted, const PackedByteArray &p_received) {
const uint8_t *t = p_trusted.ptr();
const uint8_t *r = p_received.ptr();
int tlen = p_trusted.size();
diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h
index 4b5bf8305f..0248b04034 100644
--- a/core/crypto/crypto.h
+++ b/core/crypto/crypto.h
@@ -46,10 +46,10 @@ protected:
public:
static CryptoKey *create();
- virtual Error load(String p_path, bool p_public_only = false) = 0;
- virtual Error save(String p_path, bool p_public_only = false) = 0;
+ virtual Error load(const String &p_path, bool p_public_only = false) = 0;
+ virtual Error save(const String &p_path, bool p_public_only = false) = 0;
virtual String save_to_string(bool p_public_only = false) = 0;
- virtual Error load_from_string(String p_string_key, bool p_public_only = false) = 0;
+ virtual Error load_from_string(const String &p_string_key, bool p_public_only = false) = 0;
virtual bool is_public_only() const = 0;
};
@@ -62,9 +62,9 @@ protected:
public:
static X509Certificate *create();
- virtual Error load(String p_path) = 0;
+ virtual Error load(const String &p_path) = 0;
virtual Error load_from_memory(const uint8_t *p_buffer, int p_len) = 0;
- virtual Error save(String p_path) = 0;
+ virtual Error save(const String &p_path) = 0;
virtual String save_to_string() = 0;
virtual Error load_from_string(const String &string) = 0;
};
@@ -113,8 +113,8 @@ protected:
public:
static HMACContext *create();
- virtual Error start(HashingContext::HashType p_hash_type, PackedByteArray p_key) = 0;
- virtual Error update(PackedByteArray p_data) = 0;
+ virtual Error start(HashingContext::HashType p_hash_type, const PackedByteArray &p_key) = 0;
+ virtual Error update(const PackedByteArray &p_data) = 0;
virtual PackedByteArray finish() = 0;
HMACContext() {}
@@ -127,26 +127,26 @@ class Crypto : public RefCounted {
protected:
static void _bind_methods();
static Crypto *(*_create)();
- static void (*_load_default_certificates)(String p_path);
+ static void (*_load_default_certificates)(const String &p_path);
public:
static Crypto *create();
- static void load_default_certificates(String p_path);
+ static void load_default_certificates(const String &p_path);
virtual PackedByteArray generate_random_bytes(int p_bytes) = 0;
virtual Ref<CryptoKey> generate_rsa(int p_bytes) = 0;
- virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) = 0;
+ virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, const String &p_issuer_name, const String &p_not_before, const String &p_not_after) = 0;
- virtual Vector<uint8_t> sign(HashingContext::HashType p_hash_type, Vector<uint8_t> p_hash, Ref<CryptoKey> p_key) = 0;
- virtual bool verify(HashingContext::HashType p_hash_type, Vector<uint8_t> p_hash, Vector<uint8_t> p_signature, Ref<CryptoKey> p_key) = 0;
- virtual Vector<uint8_t> encrypt(Ref<CryptoKey> p_key, Vector<uint8_t> p_plaintext) = 0;
- virtual Vector<uint8_t> decrypt(Ref<CryptoKey> p_key, Vector<uint8_t> p_ciphertext) = 0;
+ virtual Vector<uint8_t> sign(HashingContext::HashType p_hash_type, const Vector<uint8_t> &p_hash, Ref<CryptoKey> p_key) = 0;
+ virtual bool verify(HashingContext::HashType p_hash_type, const Vector<uint8_t> &p_hash, const Vector<uint8_t> &p_signature, Ref<CryptoKey> p_key) = 0;
+ virtual Vector<uint8_t> encrypt(Ref<CryptoKey> p_key, const Vector<uint8_t> &p_plaintext) = 0;
+ virtual Vector<uint8_t> decrypt(Ref<CryptoKey> p_key, const Vector<uint8_t> &p_ciphertext) = 0;
- PackedByteArray hmac_digest(HashingContext::HashType p_hash_type, PackedByteArray p_key, PackedByteArray p_msg);
+ PackedByteArray hmac_digest(HashingContext::HashType p_hash_type, const PackedByteArray &p_key, const PackedByteArray &p_msg);
// Compares two PackedByteArrays for equality without leaking timing information in order to prevent timing attacks.
// @see: https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy
- bool constant_time_compare(PackedByteArray p_trusted, PackedByteArray p_received);
+ bool constant_time_compare(const PackedByteArray &p_trusted, const PackedByteArray &p_received);
Crypto() {}
};
diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp
index 157a0c091b..01acbdbc17 100644
--- a/core/crypto/hashing_context.cpp
+++ b/core/crypto/hashing_context.cpp
@@ -47,7 +47,7 @@ Error HashingContext::start(HashType p_type) {
return ERR_UNAVAILABLE;
}
-Error HashingContext::update(PackedByteArray p_chunk) {
+Error HashingContext::update(const PackedByteArray &p_chunk) {
ERR_FAIL_NULL_V(ctx, ERR_UNCONFIGURED);
size_t len = p_chunk.size();
ERR_FAIL_COND_V(len == 0, FAILED);
diff --git a/core/crypto/hashing_context.h b/core/crypto/hashing_context.h
index 464261935a..ab7affabaa 100644
--- a/core/crypto/hashing_context.h
+++ b/core/crypto/hashing_context.h
@@ -54,7 +54,7 @@ protected:
public:
Error start(HashType p_type);
- Error update(PackedByteArray p_chunk);
+ Error update(const PackedByteArray &p_chunk);
PackedByteArray finish();
HashingContext() {}
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp
index 0cce44d02f..a7655c874a 100644
--- a/core/debugger/engine_debugger.cpp
+++ b/core/debugger/engine_debugger.cpp
@@ -127,7 +127,7 @@ void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_process_ticks,
singleton->poll_events(true);
}
-void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints, void (*p_allow_focus_steal_fn)()) {
+void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, const Vector<String> &p_breakpoints, void (*p_allow_focus_steal_fn)()) {
register_uri_handler("tcp://", RemoteDebuggerPeerTCP::create); // TCP is the default protocol. Platforms/modules can add more.
if (p_uri.is_empty()) {
return;
diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h
index 88d5490794..16050778aa 100644
--- a/core/debugger/engine_debugger.h
+++ b/core/debugger/engine_debugger.h
@@ -108,7 +108,7 @@ public:
_FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; };
- static void initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints, void (*p_allow_focus_steal_fn)());
+ static void initialize(const String &p_uri, bool p_skip_breakpoints, const Vector<String> &p_breakpoints, void (*p_allow_focus_steal_fn)());
static void deinitialize();
static void register_profiler(const StringName &p_name, const Profiler &p_profiler);
static void unregister_profiler(const StringName &p_name);
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp
index 6f2036705d..1973663c72 100644
--- a/core/debugger/remote_debugger.cpp
+++ b/core/debugger/remote_debugger.cpp
@@ -92,7 +92,7 @@ public:
}
};
-Error RemoteDebugger::_put_msg(String p_message, Array p_data) {
+Error RemoteDebugger::_put_msg(const String &p_message, const Array &p_data) {
Array msg;
msg.push_back(p_message);
msg.push_back(Thread::get_caller_id());
diff --git a/core/debugger/remote_debugger.h b/core/debugger/remote_debugger.h
index 519a90e7cc..e91d09be17 100644
--- a/core/debugger/remote_debugger.h
+++ b/core/debugger/remote_debugger.h
@@ -98,7 +98,7 @@ private:
static void _err_handler(void *p_this, const char *p_func, const char *p_file, int p_line, const char *p_err, const char *p_descr, bool p_editor_notify, ErrorHandlerType p_type);
ErrorMessage _create_overflow_error(const String &p_what, const String &p_descr);
- Error _put_msg(String p_message, Array p_data);
+ Error _put_msg(const String &p_message, const Array &p_data);
bool is_peer_connected() { return peer->is_peer_connected(); }
void flush_output();
diff --git a/core/doc_data.h b/core/doc_data.h
index 45463f5931..04bd55eaba 100644
--- a/core/doc_data.h
+++ b/core/doc_data.h
@@ -114,7 +114,9 @@ public:
String qualifiers;
String description;
bool is_deprecated = false;
+ String deprecated_message;
bool is_experimental = false;
+ String experimental_message;
Vector<ArgumentDoc> arguments;
Vector<int> errors_returned;
String keywords;
@@ -172,6 +174,7 @@ public:
doc.description = p_dict["description"];
}
+#ifndef DISABLE_DEPRECATED
if (p_dict.has("is_deprecated")) {
doc.is_deprecated = p_dict["is_deprecated"];
}
@@ -179,6 +182,17 @@ public:
if (p_dict.has("is_experimental")) {
doc.is_experimental = p_dict["is_experimental"];
}
+#endif
+
+ if (p_dict.has("deprecated")) {
+ doc.is_deprecated = true;
+ doc.deprecated_message = p_dict["deprecated"];
+ }
+
+ if (p_dict.has("experimental")) {
+ doc.is_experimental = true;
+ doc.experimental_message = p_dict["experimental"];
+ }
Array arguments;
if (p_dict.has("arguments")) {
@@ -226,9 +240,13 @@ public:
dict["description"] = p_doc.description;
}
- dict["is_deprecated"] = p_doc.is_deprecated;
+ if (p_doc.is_deprecated) {
+ dict["deprecated"] = p_doc.deprecated_message;
+ }
- dict["is_experimental"] = p_doc.is_experimental;
+ if (p_doc.is_experimental) {
+ dict["experimental"] = p_doc.experimental_message;
+ }
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
@@ -262,7 +280,9 @@ public:
bool is_bitfield = false;
String description;
bool is_deprecated = false;
+ String deprecated_message;
bool is_experimental = false;
+ String experimental_message;
String keywords;
bool operator<(const ConstantDoc &p_const) const {
return name < p_const.name;
@@ -293,6 +313,7 @@ public:
doc.description = p_dict["description"];
}
+#ifndef DISABLE_DEPRECATED
if (p_dict.has("is_deprecated")) {
doc.is_deprecated = p_dict["is_deprecated"];
}
@@ -300,6 +321,17 @@ public:
if (p_dict.has("is_experimental")) {
doc.is_experimental = p_dict["is_experimental"];
}
+#endif
+
+ if (p_dict.has("deprecated")) {
+ doc.is_deprecated = true;
+ doc.deprecated_message = p_dict["deprecated"];
+ }
+
+ if (p_dict.has("experimental")) {
+ doc.is_experimental = true;
+ doc.experimental_message = p_dict["experimental"];
+ }
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
@@ -329,9 +361,13 @@ public:
dict["description"] = p_doc.description;
}
- dict["is_deprecated"] = p_doc.is_deprecated;
+ if (p_doc.is_deprecated) {
+ dict["deprecated"] = p_doc.deprecated_message;
+ }
- dict["is_experimental"] = p_doc.is_experimental;
+ if (p_doc.is_experimental) {
+ dict["experimental"] = p_doc.experimental_message;
+ }
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
@@ -352,7 +388,9 @@ public:
bool overridden = false;
String overrides;
bool is_deprecated = false;
+ String deprecated_message;
bool is_experimental = false;
+ String experimental_message;
String keywords;
bool operator<(const PropertyDoc &p_prop) const {
return name.naturalcasecmp_to(p_prop.name) < 0;
@@ -399,6 +437,7 @@ public:
doc.overrides = p_dict["overrides"];
}
+#ifndef DISABLE_DEPRECATED
if (p_dict.has("is_deprecated")) {
doc.is_deprecated = p_dict["is_deprecated"];
}
@@ -406,6 +445,17 @@ public:
if (p_dict.has("is_experimental")) {
doc.is_experimental = p_dict["is_experimental"];
}
+#endif
+
+ if (p_dict.has("deprecated")) {
+ doc.is_deprecated = true;
+ doc.deprecated_message = p_dict["deprecated"];
+ }
+
+ if (p_dict.has("experimental")) {
+ doc.is_experimental = true;
+ doc.experimental_message = p_dict["experimental"];
+ }
if (p_dict.has("keywords")) {
doc.keywords = p_dict["keywords"];
@@ -451,9 +501,13 @@ public:
dict["overrides"] = p_doc.overrides;
}
- dict["is_deprecated"] = p_doc.is_deprecated;
+ if (p_doc.is_deprecated) {
+ dict["deprecated"] = p_doc.deprecated_message;
+ }
- dict["is_experimental"] = p_doc.is_experimental;
+ if (p_doc.is_experimental) {
+ dict["experimental"] = p_doc.experimental_message;
+ }
if (!p_doc.keywords.is_empty()) {
dict["keywords"] = p_doc.keywords;
@@ -571,7 +625,9 @@ public:
struct EnumDoc {
String description;
bool is_deprecated = false;
+ String deprecated_message;
bool is_experimental = false;
+ String experimental_message;
static EnumDoc from_dict(const Dictionary &p_dict) {
EnumDoc doc;
@@ -579,6 +635,7 @@ public:
doc.description = p_dict["description"];
}
+#ifndef DISABLE_DEPRECATED
if (p_dict.has("is_deprecated")) {
doc.is_deprecated = p_dict["is_deprecated"];
}
@@ -586,6 +643,17 @@ public:
if (p_dict.has("is_experimental")) {
doc.is_experimental = p_dict["is_experimental"];
}
+#endif
+
+ if (p_dict.has("deprecated")) {
+ doc.is_deprecated = true;
+ doc.deprecated_message = p_dict["deprecated"];
+ }
+
+ if (p_dict.has("experimental")) {
+ doc.is_experimental = true;
+ doc.experimental_message = p_dict["experimental"];
+ }
return doc;
}
@@ -596,9 +664,13 @@ public:
dict["description"] = p_doc.description;
}
- dict["is_deprecated"] = p_doc.is_deprecated;
+ if (p_doc.is_deprecated) {
+ dict["deprecated"] = p_doc.deprecated_message;
+ }
- dict["is_experimental"] = p_doc.is_experimental;
+ if (p_doc.is_experimental) {
+ dict["experimental"] = p_doc.experimental_message;
+ }
return dict;
}
@@ -621,7 +693,9 @@ public:
Vector<MethodDoc> annotations;
Vector<ThemeItemDoc> theme_properties;
bool is_deprecated = false;
+ String deprecated_message;
bool is_experimental = false;
+ String experimental_message;
bool is_script_doc = false;
String script_path;
bool operator<(const ClassDoc &p_class) const {
@@ -730,6 +804,7 @@ public:
doc.theme_properties.push_back(ThemeItemDoc::from_dict(theme_properties[i]));
}
+#ifndef DISABLE_DEPRECATED
if (p_dict.has("is_deprecated")) {
doc.is_deprecated = p_dict["is_deprecated"];
}
@@ -737,6 +812,17 @@ public:
if (p_dict.has("is_experimental")) {
doc.is_experimental = p_dict["is_experimental"];
}
+#endif
+
+ if (p_dict.has("deprecated")) {
+ doc.is_deprecated = true;
+ doc.deprecated_message = p_dict["deprecated"];
+ }
+
+ if (p_dict.has("experimental")) {
+ doc.is_experimental = true;
+ doc.experimental_message = p_dict["experimental"];
+ }
if (p_dict.has("is_script_doc")) {
doc.is_script_doc = p_dict["is_script_doc"];
@@ -847,9 +933,13 @@ public:
dict["theme_properties"] = theme_properties;
}
- dict["is_deprecated"] = p_doc.is_deprecated;
+ if (p_doc.is_deprecated) {
+ dict["deprecated"] = p_doc.deprecated_message;
+ }
- dict["is_experimental"] = p_doc.is_experimental;
+ if (p_doc.is_experimental) {
+ dict["experimental"] = p_doc.experimental_message;
+ }
dict["is_script_doc"] = p_doc.is_script_doc;
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp
index 53007bf5bf..fa4e7eb2e2 100644
--- a/core/extension/gdextension.cpp
+++ b/core/extension/gdextension.cpp
@@ -914,7 +914,7 @@ Error GDExtensionResourceLoader::load_gdextension_resource(const String &p_path,
return ERR_INVALID_DATA;
}
- String library_path = GDExtension::find_extension_library(p_path, config, [](String p_feature) { return OS::get_singleton()->has_feature(p_feature); });
+ String library_path = GDExtension::find_extension_library(p_path, config, [](const String &p_feature) { return OS::get_singleton()->has_feature(p_feature); });
if (library_path.is_empty()) {
const String os_arch = OS::get_singleton()->get_name().to_lower() + "." + Engine::get_singleton()->get_architecture_name();
diff --git a/core/input/input.cpp b/core/input/input.cpp
index d87a8824f7..4117cc8c9c 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -455,7 +455,7 @@ static String _hex_str(uint8_t p_byte) {
return ret;
}
-void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid, Dictionary p_joypad_info) {
+void Input::joy_connection_changed(int p_idx, bool p_connected, const String &p_name, const String &p_guid, const Dictionary &p_joypad_info) {
_THREAD_SAFE_METHOD_
// Clear the pressed status if a Joypad gets disconnected.
@@ -1414,7 +1414,7 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat
}
}
-JoyButton Input::_get_output_button(String output) {
+JoyButton Input::_get_output_button(const String &output) {
for (int i = 0; i < (int)JoyButton::SDL_MAX; i++) {
if (output == _joy_buttons[i]) {
return JoyButton(i);
@@ -1423,7 +1423,7 @@ JoyButton Input::_get_output_button(String output) {
return JoyButton::INVALID;
}
-JoyAxis Input::_get_output_axis(String output) {
+JoyAxis Input::_get_output_axis(const String &output) {
for (int i = 0; i < (int)JoyAxis::SDL_MAX; i++) {
if (output == _joy_axes[i]) {
return JoyAxis(i);
@@ -1432,7 +1432,7 @@ JoyAxis Input::_get_output_axis(String output) {
return JoyAxis::INVALID;
}
-void Input::parse_mapping(String p_mapping) {
+void Input::parse_mapping(const String &p_mapping) {
_THREAD_SAFE_METHOD_;
JoyDeviceMapping mapping;
@@ -1535,7 +1535,7 @@ void Input::parse_mapping(String p_mapping) {
map_db.push_back(mapping);
}
-void Input::add_joy_mapping(String p_mapping, bool p_update_existing) {
+void Input::add_joy_mapping(const String &p_mapping, bool p_update_existing) {
parse_mapping(p_mapping);
if (p_update_existing) {
Vector<String> entry = p_mapping.split(",");
@@ -1549,7 +1549,7 @@ void Input::add_joy_mapping(String p_mapping, bool p_update_existing) {
}
}
-void Input::remove_joy_mapping(String p_guid) {
+void Input::remove_joy_mapping(const String &p_guid) {
for (int i = map_db.size() - 1; i >= 0; i--) {
if (p_guid == map_db[i].uid) {
map_db.remove_at(i);
@@ -1563,7 +1563,7 @@ void Input::remove_joy_mapping(String p_guid) {
}
}
-void Input::set_fallback_mapping(String p_guid) {
+void Input::set_fallback_mapping(const String &p_guid) {
for (int i = 0; i < map_db.size(); i++) {
if (map_db[i].uid == p_guid) {
fallback_mapping = i;
diff --git a/core/input/input.h b/core/input/input.h
index a7ae3349b2..367bb93188 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -239,8 +239,8 @@ private:
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button);
JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value, JoyAxisRange &r_range);
void _get_mapped_hat_events(const JoyDeviceMapping &mapping, HatDir p_hat, JoyEvent r_events[(size_t)HatDir::MAX]);
- JoyButton _get_output_button(String output);
- JoyAxis _get_output_axis(String output);
+ JoyButton _get_output_button(const String &output);
+ JoyAxis _get_output_axis(const String &output);
void _button_event(int p_device, JoyButton p_index, bool p_pressed);
void _axis_event(int p_device, JoyAxis p_axis, float p_value);
void _update_action_cache(const StringName &p_action_name, ActionState &r_action_state);
@@ -295,7 +295,7 @@ public:
Vector2 get_joy_vibration_strength(int p_device);
float get_joy_vibration_duration(int p_device);
uint64_t get_joy_vibration_timestamp(int p_device);
- void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = "", Dictionary p_joypad_info = Dictionary());
+ void joy_connection_changed(int p_idx, bool p_connected, const String &p_name, const String &p_guid = "", const Dictionary &p_joypad_info = Dictionary());
Vector3 get_gravity() const;
Vector3 get_accelerometer() const;
@@ -339,13 +339,13 @@ public:
CursorShape get_current_cursor_shape() const;
void set_custom_mouse_cursor(const Ref<Resource> &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
- void parse_mapping(String p_mapping);
+ void parse_mapping(const String &p_mapping);
void joy_button(int p_device, JoyButton p_button, bool p_pressed);
void joy_axis(int p_device, JoyAxis p_axis, float p_value);
void joy_hat(int p_device, BitField<HatMask> p_val);
- void add_joy_mapping(String p_mapping, bool p_update_existing = false);
- void remove_joy_mapping(String p_guid);
+ void add_joy_mapping(const String &p_mapping, bool p_update_existing = false);
+ void remove_joy_mapping(const String &p_guid);
int get_unused_joy_id();
@@ -353,7 +353,7 @@ public:
String get_joy_guid(int p_device) const;
bool should_ignore_device(int p_vendor_id, int p_product_id) const;
Dictionary get_joy_info(int p_device) const;
- void set_fallback_mapping(String p_guid);
+ void set_fallback_mapping(const String &p_guid);
void flush_buffered_events();
bool is_using_input_buffering();
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 98f8c3de41..0a4d5a3be6 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -81,7 +81,7 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V
}
}
-Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const {
+Variant ConfigFile::get_value(const String &p_section, const String &p_key, const Variant &p_default) const {
if (!values.has(p_section) || !values[p_section].has(p_key)) {
ERR_FAIL_COND_V_MSG(p_default.get_type() == Variant::NIL, Variant(),
vformat("Couldn't find the given section \"%s\" and key \"%s\", and no default was given.", p_section, p_key));
diff --git a/core/io/config_file.h b/core/io/config_file.h
index 80973ab9d0..05b4ed899e 100644
--- a/core/io/config_file.h
+++ b/core/io/config_file.h
@@ -53,7 +53,7 @@ protected:
public:
void set_value(const String &p_section, const String &p_key, const Variant &p_value);
- Variant get_value(const String &p_section, const String &p_key, Variant p_default = Variant()) const;
+ Variant get_value(const String &p_section, const String &p_key, const Variant &p_default = Variant()) const;
bool has_section(const String &p_section) const;
bool has_section_key(const String &p_section, const String &p_key) const;
diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp
index 40c1a53958..680a653dfc 100644
--- a/core/io/dir_access.cpp
+++ b/core/io/dir_access.cpp
@@ -131,7 +131,7 @@ Error DirAccess::erase_contents_recursive() {
return _erase_recursive(this);
}
-Error DirAccess::make_dir_recursive(String p_dir) {
+Error DirAccess::make_dir_recursive(const String &p_dir) {
if (p_dir.length() < 1) {
return OK;
}
@@ -188,7 +188,7 @@ DirAccess::AccessType DirAccess::get_access_type() const {
return _access_type;
}
-String DirAccess::fix_path(String p_path) const {
+String DirAccess::fix_path(const String &p_path) const {
switch (_access_type) {
case ACCESS_RESOURCES: {
if (ProjectSettings::get_singleton()) {
@@ -338,7 +338,7 @@ String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
return full;
}
-Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
+Error DirAccess::copy(const String &p_from, const String &p_to, int p_chmod_flags) {
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
Error err;
{
@@ -396,7 +396,7 @@ class DirChanger {
String original_dir;
public:
- DirChanger(DirAccess *p_da, String p_dir) :
+ DirChanger(DirAccess *p_da, const String &p_dir) :
da(p_da),
original_dir(p_da->get_current_dir()) {
p_da->change_dir(p_dir);
@@ -407,7 +407,7 @@ public:
}
};
-Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, String p_to, int p_chmod_flags, bool p_copy_links) {
+Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, const String &p_to, int p_chmod_flags, bool p_copy_links) {
List<String> dirs;
String curdir = get_current_dir();
@@ -460,7 +460,7 @@ Error DirAccess::_copy_dir(Ref<DirAccess> &p_target_da, String p_to, int p_chmod
return OK;
}
-Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_copy_links) {
+Error DirAccess::copy_dir(const String &p_from, String p_to, int p_chmod_flags, bool p_copy_links) {
ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist.");
Ref<DirAccess> target_da = DirAccess::create_for_path(p_to);
@@ -481,7 +481,7 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags, bool p_
return err;
}
-bool DirAccess::exists(String p_dir) {
+bool DirAccess::exists(const String &p_dir) {
Ref<DirAccess> da = DirAccess::create_for_path(p_dir);
return da->change_dir(p_dir) == OK;
}
diff --git a/core/io/dir_access.h b/core/io/dir_access.h
index 4ee69571f2..d175235b98 100644
--- a/core/io/dir_access.h
+++ b/core/io/dir_access.h
@@ -54,7 +54,7 @@ private:
static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object
static Ref<DirAccess> _open(const String &p_path);
- Error _copy_dir(Ref<DirAccess> &p_target_da, String p_to, int p_chmod_flags, bool p_copy_links);
+ Error _copy_dir(Ref<DirAccess> &p_target_da, const String &p_to, int p_chmod_flags, bool p_copy_links);
PackedStringArray _get_contents(bool p_directories);
thread_local static Error last_dir_open_error;
@@ -68,7 +68,7 @@ protected:
virtual String _get_root_string() const;
AccessType get_access_type() const;
- virtual String fix_path(String p_path) const;
+ virtual String fix_path(const String &p_path) const;
template <class T>
static Ref<DirAccess> _create_builtin() {
@@ -91,18 +91,18 @@ public:
virtual Error change_dir(String p_dir) = 0; ///< can be relative or absolute, return false on success
virtual String get_current_dir(bool p_include_drive = true) const = 0; ///< return current dir location
virtual Error make_dir(String p_dir) = 0;
- virtual Error make_dir_recursive(String p_dir);
+ virtual Error make_dir_recursive(const String &p_dir);
virtual Error erase_contents_recursive(); //super dangerous, use with care!
virtual bool file_exists(String p_file) = 0;
virtual bool dir_exists(String p_dir) = 0;
virtual bool is_readable(String p_dir) { return true; };
virtual bool is_writable(String p_dir) { return true; };
- static bool exists(String p_dir);
+ static bool exists(const String &p_dir);
virtual uint64_t get_space_left() = 0;
- Error copy_dir(String p_from, String p_to, int p_chmod_flags = -1, bool p_copy_links = false);
- virtual Error copy(String p_from, String p_to, int p_chmod_flags = -1);
+ Error copy_dir(const String &p_from, String p_to, int p_chmod_flags = -1, bool p_copy_links = false);
+ virtual Error copy(const String &p_from, const String &p_to, int p_chmod_flags = -1);
virtual Error rename(String p_from, String p_to) = 0;
virtual Error remove(String p_name) = 0;
@@ -112,7 +112,7 @@ public:
// Meant for editor code when we want to quickly remove a file without custom
// handling (e.g. removing a cache file).
- static void remove_file_or_error(String p_path) {
+ static void remove_file_or_error(const String &p_path) {
Ref<DirAccess> da = create(ACCESS_FILESYSTEM);
if (da->file_exists(p_path)) {
if (da->remove(p_path) != OK) {
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index da02c883e8..9521a4f666 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -36,7 +36,7 @@
static HashMap<String, Vector<uint8_t>> *files = nullptr;
-void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
+void FileAccessMemory::register_file(const String &p_name, const Vector<uint8_t> &p_data) {
if (!files) {
files = memnew((HashMap<String, Vector<uint8_t>>));
}
diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h
index ac08e5406f..d9efb354c3 100644
--- a/core/io/file_access_memory.h
+++ b/core/io/file_access_memory.h
@@ -41,7 +41,7 @@ class FileAccessMemory : public FileAccess {
static Ref<FileAccess> create();
public:
- static void register_file(String p_name, Vector<uint8_t> p_data);
+ static void register_file(const String &p_name, const Vector<uint8_t> &p_data);
static void cleanup();
virtual Error open_custom(const uint8_t *p_data, uint64_t p_len); ///< open a file
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 5a4d6dd099..7595bc41f5 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -455,7 +455,7 @@ String DirAccessPack::get_drive(int p_drive) {
return "";
}
-PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) {
+PackedData::PackedDir *DirAccessPack::_find_dir(const String &p_dir) {
String nd = p_dir.replace("\\", "/");
// Special handling since simplify_path() will forbid it
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index 97391a5611..c65e65d17d 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -222,7 +222,7 @@ class DirAccessPack : public DirAccess {
List<String> list_files;
bool cdir = false;
- PackedData::PackedDir *_find_dir(String p_dir);
+ PackedData::PackedDir *_find_dir(const String &p_dir);
public:
virtual Error list_dir_begin() override;
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index dd45332412..3c7f67664d 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -115,7 +115,7 @@ void ZipArchive::close_handle(unzFile p_file) const {
unzClose(p_file);
}
-unzFile ZipArchive::get_file_handle(String p_file) const {
+unzFile ZipArchive::get_file_handle(const String &p_file) const {
ERR_FAIL_COND_V_MSG(!file_exists(p_file), nullptr, "File '" + p_file + " doesn't exist.");
File file = files[p_file];
@@ -206,7 +206,7 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6
return true;
}
-bool ZipArchive::file_exists(String p_name) const {
+bool ZipArchive::file_exists(const String &p_name) const {
return files.has(p_name);
}
diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h
index 1062a06238..e9ea74e01d 100644
--- a/core/io/file_access_zip.h
+++ b/core/io/file_access_zip.h
@@ -61,11 +61,11 @@ private:
public:
void close_handle(unzFile p_file) const;
- unzFile get_file_handle(String p_file) const;
+ unzFile get_file_handle(const String &p_file) const;
- Error add_package(String p_name);
+ Error add_package(const String &p_name);
- bool file_exists(String p_name) const;
+ bool file_exists(const String &p_name) const;
virtual bool try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset) override;
Ref<FileAccess> get_file(const String &p_path, PackedData::PackedFile *p_file) override;
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 24caccca5f..b094290ac8 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -3300,6 +3300,18 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
_set_color_at_ofs(data.ptrw(), ofs, p_color);
}
+const uint8_t *Image::ptr() const {
+ return data.ptr();
+}
+
+uint8_t *Image::ptrw() {
+ return data.ptrw();
+}
+
+int64_t Image::data_size() const {
+ return data.size();
+}
+
void Image::adjust_bcs(float p_brightness, float p_contrast, float p_saturation) {
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot adjust_bcs in compressed or custom image formats.");
diff --git a/core/io/image.h b/core/io/image.h
index e35b359a79..2cabbb767a 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -426,6 +426,10 @@ public:
void set_pixelv(const Point2i &p_point, const Color &p_color);
void set_pixel(int p_x, int p_y, const Color &p_color);
+ const uint8_t *ptr() const;
+ uint8_t *ptrw();
+ int64_t data_size() const;
+
void adjust_bcs(float p_brightness, float p_contrast, float p_saturation);
void set_as_black();
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index bef515f259..92c690dc2a 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -80,7 +80,7 @@ void ImageFormatLoaderExtension::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_format_loader"), &ImageFormatLoaderExtension::remove_format_loader);
}
-Error ImageLoader::load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> p_custom, BitField<ImageFormatLoader::LoaderFlags> p_flags, float p_scale) {
+Error ImageLoader::load_image(const String &p_file, Ref<Image> p_image, Ref<FileAccess> p_custom, BitField<ImageFormatLoader::LoaderFlags> p_flags, float p_scale) {
ERR_FAIL_COND_V_MSG(p_image.is_null(), ERR_INVALID_PARAMETER, "Can't load an image: invalid Image object.");
Ref<FileAccess> f = p_custom;
diff --git a/core/io/image_loader.h b/core/io/image_loader.h
index ac51f13376..e9b434522d 100644
--- a/core/io/image_loader.h
+++ b/core/io/image_loader.h
@@ -91,7 +91,7 @@ class ImageLoader {
protected:
public:
- static Error load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> p_custom = Ref<FileAccess>(), BitField<ImageFormatLoader::LoaderFlags> p_flags = ImageFormatLoader::FLAG_NONE, float p_scale = 1.0);
+ static Error load_image(const String &p_file, Ref<Image> p_image, Ref<FileAccess> p_custom = Ref<FileAccess>(), BitField<ImageFormatLoader::LoaderFlags> p_flags = ImageFormatLoader::FLAG_NONE, float p_scale = 1.0);
static void get_recognized_extensions(List<String> *p_extensions);
static Ref<ImageFormatLoader> recognize(const String &p_extension);
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 254351897d..ec86104926 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -117,7 +117,7 @@ struct _IP_ResolverPrivate {
HashMap<String, List<IPAddress>> cache;
- static String get_cache_key(String p_hostname, IP::Type p_type) {
+ static String get_cache_key(const String &p_hostname, IP::Type p_type) {
return itos(p_type) + p_hostname;
}
};
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index b262c1cf28..441df7f5d1 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -230,7 +230,7 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) {
}
}
-CompositeLogger::CompositeLogger(Vector<Logger *> p_loggers) :
+CompositeLogger::CompositeLogger(const Vector<Logger *> &p_loggers) :
loggers(p_loggers) {
}
diff --git a/core/io/logger.h b/core/io/logger.h
index 943d61e2e8..3cd18965c5 100644
--- a/core/io/logger.h
+++ b/core/io/logger.h
@@ -96,7 +96,7 @@ class CompositeLogger : public Logger {
Vector<Logger *> loggers;
public:
- explicit CompositeLogger(Vector<Logger *> p_loggers);
+ explicit CompositeLogger(const Vector<Logger *> &p_loggers);
virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0;
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR) override;
diff --git a/core/io/net_socket.h b/core/io/net_socket.h
index 2c1a020a46..120ad5e85b 100644
--- a/core/io/net_socket.h
+++ b/core/io/net_socket.h
@@ -74,8 +74,8 @@ public:
virtual void set_ipv6_only_enabled(bool p_enabled) = 0;
virtual void set_tcp_no_delay_enabled(bool p_enabled) = 0;
virtual void set_reuse_address_enabled(bool p_enabled) = 0;
- virtual Error join_multicast_group(const IPAddress &p_multi_address, String p_if_name) = 0;
- virtual Error leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) = 0;
+ virtual Error join_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) = 0;
+ virtual Error leave_multicast_group(const IPAddress &p_multi_address, const String &p_if_name) = 0;
};
#endif // NET_SOCKET_H
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index dfd4798d2e..32030146bb 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -45,7 +45,7 @@ void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) {
}
}
-Error PacketPeerUDP::join_multicast_group(IPAddress p_multi_address, String p_if_name) {
+Error PacketPeerUDP::join_multicast_group(IPAddress p_multi_address, const String &p_if_name) {
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!p_multi_address.is_valid(), ERR_INVALID_PARAMETER);
@@ -60,7 +60,7 @@ Error PacketPeerUDP::join_multicast_group(IPAddress p_multi_address, String p_if
return _sock->join_multicast_group(p_multi_address, p_if_name);
}
-Error PacketPeerUDP::leave_multicast_group(IPAddress p_multi_address, String p_if_name) {
+Error PacketPeerUDP::leave_multicast_group(IPAddress p_multi_address, const String &p_if_name) {
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!_sock->is_open(), ERR_UNCONFIGURED);
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 3e0e3b437e..c69a138c53 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -91,8 +91,8 @@ public:
int get_available_packet_count() const override;
int get_max_packet_size() const override;
void set_broadcast_enabled(bool p_enabled);
- Error join_multicast_group(IPAddress p_multi_address, String p_if_name);
- Error leave_multicast_group(IPAddress p_multi_address, String p_if_name);
+ Error join_multicast_group(IPAddress p_multi_address, const String &p_if_name);
+ Error leave_multicast_group(IPAddress p_multi_address, const String &p_if_name);
PacketPeerUDP();
~PacketPeerUDP();
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 64b47ad19d..5344266a9c 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -1114,7 +1114,7 @@ void ResourceLoader::set_load_callback(ResourceLoadedCallback p_callback) {
ResourceLoadedCallback ResourceLoader::_loaded_callback = nullptr;
-Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(String path) {
+Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(const String &path) {
for (int i = 0; i < loader_count; ++i) {
if (loader[i]->get_script_instance() && loader[i]->get_script_instance()->get_script()->get_path() == path) {
return loader[i];
@@ -1123,7 +1123,7 @@ Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(St
return Ref<ResourceFormatLoader>();
}
-bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
+bool ResourceLoader::add_custom_resource_format_loader(const String &script_path) {
if (_find_custom_resource_format_loader(script_path).is_valid()) {
return false;
}
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 3099d9aab3..1f79b83f11 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -158,7 +158,7 @@ private:
static ResourceLoadedCallback _loaded_callback;
- static Ref<ResourceFormatLoader> _find_custom_resource_format_loader(String path);
+ static Ref<ResourceFormatLoader> _find_custom_resource_format_loader(const String &path);
struct ThreadLoadTask {
WorkerThreadPool::TaskID task_id = 0; // Used if run on a worker thread from the pool.
@@ -263,7 +263,7 @@ public:
static void set_load_callback(ResourceLoadedCallback p_callback);
static ResourceLoaderImport import;
- static bool add_custom_resource_format_loader(String script_path);
+ static bool add_custom_resource_format_loader(const String &script_path);
static void add_custom_loaders();
static void remove_custom_loaders();
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 51ebea7f2c..e4022b2073 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -215,7 +215,7 @@ void ResourceSaver::remove_resource_format_saver(Ref<ResourceFormatSaver> p_form
--saver_count;
}
-Ref<ResourceFormatSaver> ResourceSaver::_find_custom_resource_format_saver(String path) {
+Ref<ResourceFormatSaver> ResourceSaver::_find_custom_resource_format_saver(const String &path) {
for (int i = 0; i < saver_count; ++i) {
if (saver[i]->get_script_instance() && saver[i]->get_script_instance()->get_script()->get_path() == path) {
return saver[i];
@@ -224,7 +224,7 @@ Ref<ResourceFormatSaver> ResourceSaver::_find_custom_resource_format_saver(Strin
return Ref<ResourceFormatSaver>();
}
-bool ResourceSaver::add_custom_resource_format_saver(String script_path) {
+bool ResourceSaver::add_custom_resource_format_saver(const String &script_path) {
if (_find_custom_resource_format_saver(script_path).is_valid()) {
return false;
}
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index 4828df297a..3e0821926a 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -70,7 +70,7 @@ class ResourceSaver {
static ResourceSavedCallback save_callback;
static ResourceSaverGetResourceIDForPath save_get_id_for_path;
- static Ref<ResourceFormatSaver> _find_custom_resource_format_saver(String path);
+ static Ref<ResourceFormatSaver> _find_custom_resource_format_saver(const String &path);
public:
enum SaverFlags {
@@ -99,7 +99,7 @@ public:
static void set_save_callback(ResourceSavedCallback p_callback);
static void set_get_resource_id_for_path(ResourceSaverGetResourceIDForPath p_callback);
- static bool add_custom_resource_format_saver(String script_path);
+ static bool add_custom_resource_format_saver(const String &script_path);
static void add_custom_savers();
static void remove_custom_savers();
};
diff --git a/core/io/zip_io.cpp b/core/io/zip_io.cpp
index a89c6253f1..972656e237 100644
--- a/core/io/zip_io.cpp
+++ b/core/io/zip_io.cpp
@@ -53,7 +53,7 @@ int godot_unzip_get_current_file_info(unzFile p_zip_file, unz_file_info64 &r_fil
return err;
}
-int godot_unzip_locate_file(unzFile p_zip_file, String p_filepath, bool p_case_sensitive) {
+int godot_unzip_locate_file(unzFile p_zip_file, const String &p_filepath, bool p_case_sensitive) {
int err = unzGoToFirstFile(p_zip_file);
while (err == UNZ_OK) {
unz_file_info64 current_file_info;
diff --git a/core/io/zip_io.h b/core/io/zip_io.h
index c59b981373..cd5c873c4b 100644
--- a/core/io/zip_io.h
+++ b/core/io/zip_io.h
@@ -42,7 +42,7 @@
// Get the current file info and safely convert the full filepath to a String.
int godot_unzip_get_current_file_info(unzFile p_zip_file, unz_file_info64 &r_file_info, String &r_filepath);
// Try to locate the file in the archive specified by the filepath (works with large paths and Unicode).
-int godot_unzip_locate_file(unzFile p_zip_file, String p_filepath, bool p_case_sensitive = true);
+int godot_unzip_locate_file(unzFile p_zip_file, const String &p_filepath, bool p_case_sensitive = true);
//
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index d1ec987d56..636c2c16bf 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -1494,7 +1494,7 @@ Error Expression::parse(const String &p_expression, const Vector<String> &p_inpu
return OK;
}
-Variant Expression::execute(Array p_inputs, Object *p_base, bool p_show_error, bool p_const_calls_only) {
+Variant Expression::execute(const Array &p_inputs, Object *p_base, bool p_show_error, bool p_const_calls_only) {
ERR_FAIL_COND_V_MSG(error_set, Variant(), "There was previously a parse error: " + error_str + ".");
execution_error = false;
diff --git a/core/math/expression.h b/core/math/expression.h
index 175db4e25e..c6ad1bd634 100644
--- a/core/math/expression.h
+++ b/core/math/expression.h
@@ -264,7 +264,7 @@ protected:
public:
Error parse(const String &p_expression, const Vector<String> &p_input_names = Vector<String>());
- Variant execute(Array p_inputs = Array(), Object *p_base = nullptr, bool p_show_error = true, bool p_const_calls_only = false);
+ Variant execute(const Array &p_inputs = Array(), Object *p_base = nullptr, bool p_show_error = true, bool p_const_calls_only = false);
bool has_execute_failed() const;
String get_error_text() const;
diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp
index 1e5f12bebf..602e95bc13 100644
--- a/core/math/geometry_2d.cpp
+++ b/core/math/geometry_2d.cpp
@@ -37,7 +37,7 @@
#define SCALE_FACTOR 100000.0 // Based on CMP_EPSILON.
-Vector<Vector<Vector2>> Geometry2D::decompose_polygon_in_convex(Vector<Point2> polygon) {
+Vector<Vector<Vector2>> Geometry2D::decompose_polygon_in_convex(const Vector<Point2> &polygon) {
Vector<Vector<Vector2>> decomp;
List<TPPLPoly> in_poly, out_poly;
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
index 9907d579a5..fbcaa018a8 100644
--- a/core/math/geometry_2d.h
+++ b/core/math/geometry_2d.h
@@ -489,7 +489,7 @@ public:
return points;
}
- static Vector<Vector<Vector2>> decompose_polygon_in_convex(Vector<Point2> polygon);
+ static Vector<Vector<Vector2>> decompose_polygon_in_convex(const Vector<Point2> &polygon);
static void make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size);
static Vector<Vector3i> partial_pack_rects(const Vector<Vector2i> &p_sizes, const Size2i &p_atlas_size);
diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp
index 9dd88485f9..e2edf8b23e 100644
--- a/core/math/geometry_3d.cpp
+++ b/core/math/geometry_3d.cpp
@@ -449,7 +449,7 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
}
}
-Vector<Face3> Geometry3D::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
+Vector<Face3> Geometry3D::wrap_geometry(const Vector<Face3> &p_array, real_t *p_error) {
int face_count = p_array.size();
const Face3 *faces = p_array.ptr();
constexpr double min_size = 1.0;
diff --git a/core/math/geometry_3d.h b/core/math/geometry_3d.h
index 305a64e39c..d9788d036f 100644
--- a/core/math/geometry_3d.h
+++ b/core/math/geometry_3d.h
@@ -549,7 +549,7 @@ public:
}
// Create a "wrap" that encloses the given geometry.
- static Vector<Face3> wrap_geometry(Vector<Face3> p_array, real_t *p_error = nullptr);
+ static Vector<Face3> wrap_geometry(const Vector<Face3> &p_array, real_t *p_error = nullptr);
struct MeshData {
struct Face {
diff --git a/core/object/object.h b/core/object/object.h
index d697f14b7e..27f28b4aae 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -165,7 +165,7 @@ struct PropertyInfo {
PropertyInfo() {}
- PropertyInfo(const Variant::Type p_type, const String p_name, const PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", const uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) :
+ PropertyInfo(const Variant::Type p_type, const String &p_name, const PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", const uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) :
type(p_type),
name(p_name),
hint(p_hint),
diff --git a/core/object/script_language.h b/core/object/script_language.h
index 294231a3e7..4217bc9f96 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -239,7 +239,7 @@ public:
void get_core_type_words(List<String> *p_core_type_words) const;
virtual void get_reserved_words(List<String> *p_words) const = 0;
- virtual bool is_control_flow_keyword(String p_string) const = 0;
+ virtual bool is_control_flow_keyword(const String &p_string) const = 0;
virtual void get_comment_delimiters(List<String> *p_delimiters) const = 0;
virtual void get_doc_comment_delimiters(List<String> *p_delimiters) const = 0;
virtual void get_string_delimiters(List<String> *p_delimiters) const = 0;
@@ -257,6 +257,7 @@ public:
virtual bool can_inherit_from_file() const { return false; }
virtual int find_function(const String &p_function, const String &p_code) const = 0;
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const = 0;
+ virtual bool can_make_function() const { return true; }
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
virtual bool overrides_external_editor() { return false; }
diff --git a/core/object/script_language_extension.cpp b/core/object/script_language_extension.cpp
index be62cabe25..3a9b171f28 100644
--- a/core/object/script_language_extension.cpp
+++ b/core/object/script_language_extension.cpp
@@ -109,6 +109,7 @@ void ScriptLanguageExtension::_bind_methods() {
GDVIRTUAL_BIND(_can_inherit_from_file);
GDVIRTUAL_BIND(_find_function, "function", "code");
GDVIRTUAL_BIND(_make_function, "class_name", "function_name", "function_args");
+ GDVIRTUAL_BIND(_can_make_function);
GDVIRTUAL_BIND(_open_in_external_editor, "script", "line", "column");
GDVIRTUAL_BIND(_overrides_external_editor);
diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h
index 5b10739486..b7222a159a 100644
--- a/core/object/script_language_extension.h
+++ b/core/object/script_language_extension.h
@@ -229,7 +229,7 @@ public:
p_words->push_back(ret[i]);
}
}
- EXBIND1RC(bool, is_control_flow_keyword, String)
+ EXBIND1RC(bool, is_control_flow_keyword, const String &)
GDVIRTUAL0RC(Vector<String>, _get_comment_delimiters)
@@ -373,6 +373,7 @@ public:
EXBIND2RC(int, find_function, const String &, const String &)
EXBIND3RC(String, make_function, const String &, const String &, const PackedStringArray &)
+ EXBIND0RC(bool, can_make_function)
EXBIND3R(Error, open_in_external_editor, const Ref<Script> &, int, int)
EXBIND0R(bool, overrides_external_editor)
diff --git a/core/os/os.cpp b/core/os/os.cpp
index d5d9988cc1..8582888740 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -298,7 +298,7 @@ String OS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
return ".";
}
-Error OS::shell_open(String p_uri) {
+Error OS::shell_open(const String &p_uri) {
return ERR_UNAVAILABLE;
}
diff --git a/core/os/os.h b/core/os/os.h
index e22514dce3..e0dda0b155 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -86,7 +86,7 @@ protected:
void _set_logger(CompositeLogger *p_logger);
public:
- typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection);
+ typedef void (*ImeCallback)(void *p_inp, const String &p_text, Point2 p_selection);
typedef bool (*HasServerFeatureCallback)(const String &p_feature);
enum RenderThreadMode {
@@ -109,8 +109,8 @@ protected:
virtual void initialize() = 0;
virtual void initialize_joypads() = 0;
- void set_current_rendering_driver_name(String p_driver_name) { _current_rendering_driver_name = p_driver_name; }
- void set_current_rendering_method(String p_name) { _current_rendering_method = p_name; }
+ void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; }
+ void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; }
void set_display_driver_id(int p_display_driver_id) { _display_driver_id = p_display_driver_id; }
@@ -152,9 +152,9 @@ public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
- virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) { return ERR_UNAVAILABLE; }
+ virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) { return ERR_UNAVAILABLE; }
virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; }
- virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; }
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String &p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; }
virtual void set_low_processor_usage_mode(bool p_enabled);
virtual bool is_in_low_processor_usage_mode() const;
@@ -176,7 +176,7 @@ public:
virtual bool is_process_running(const ProcessID &p_pid) const = 0;
virtual void vibrate_handheld(int p_duration_ms = 500) {}
- virtual Error shell_open(String p_uri);
+ virtual Error shell_open(const String &p_uri);
virtual Error shell_show_in_file_manager(String p_path, bool p_open_folder = true);
virtual Error set_cwd(const String &p_cwd);
diff --git a/core/os/time.cpp b/core/os/time.cpp
index 7068935d36..d1d3588d09 100644
--- a/core/os/time.cpp
+++ b/core/os/time.cpp
@@ -255,7 +255,7 @@ String Time::get_time_string_from_unix_time(int64_t p_unix_time_val) const {
return vformat("%02d:%02d:%02d", hour, minute, second);
}
-Dictionary Time::get_datetime_dict_from_datetime_string(String p_datetime, bool p_weekday) const {
+Dictionary Time::get_datetime_dict_from_datetime_string(const String &p_datetime, bool p_weekday) const {
PARSE_ISO8601_STRING(Dictionary())
Dictionary dict;
dict[YEAR_KEY] = year;
@@ -273,7 +273,7 @@ Dictionary Time::get_datetime_dict_from_datetime_string(String p_datetime, bool
return dict;
}
-String Time::get_datetime_string_from_datetime_dict(const Dictionary p_datetime, bool p_use_space) const {
+String Time::get_datetime_string_from_datetime_dict(const Dictionary &p_datetime, bool p_use_space) const {
ERR_FAIL_COND_V_MSG(p_datetime.is_empty(), "", "Invalid datetime Dictionary: Dictionary is empty.");
EXTRACT_FROM_DICTIONARY
VALIDATE_YMDHMS("")
@@ -287,7 +287,7 @@ String Time::get_datetime_string_from_datetime_dict(const Dictionary p_datetime,
return timestamp;
}
-int64_t Time::get_unix_time_from_datetime_dict(const Dictionary p_datetime) const {
+int64_t Time::get_unix_time_from_datetime_dict(const Dictionary &p_datetime) const {
ERR_FAIL_COND_V_MSG(p_datetime.is_empty(), 0, "Invalid datetime Dictionary: Dictionary is empty");
EXTRACT_FROM_DICTIONARY
VALIDATE_YMDHMS(0)
@@ -295,7 +295,7 @@ int64_t Time::get_unix_time_from_datetime_dict(const Dictionary p_datetime) cons
return day_number * SECONDS_PER_DAY + hour * 3600 + minute * 60 + second;
}
-int64_t Time::get_unix_time_from_datetime_string(String p_datetime) const {
+int64_t Time::get_unix_time_from_datetime_string(const String &p_datetime) const {
PARSE_ISO8601_STRING(-1)
VALIDATE_YMDHMS(0)
YMD_TO_DAY_NUMBER
diff --git a/core/os/time.h b/core/os/time.h
index ccd2d92b8b..6550cd905e 100644
--- a/core/os/time.h
+++ b/core/os/time.h
@@ -59,10 +59,10 @@ public:
String get_datetime_string_from_unix_time(int64_t p_unix_time_val, bool p_use_space = false) const;
String get_date_string_from_unix_time(int64_t p_unix_time_val) const;
String get_time_string_from_unix_time(int64_t p_unix_time_val) const;
- Dictionary get_datetime_dict_from_datetime_string(String p_datetime, bool p_weekday = true) const;
- String get_datetime_string_from_datetime_dict(const Dictionary p_datetime, bool p_use_space = false) const;
- int64_t get_unix_time_from_datetime_dict(const Dictionary p_datetime) const;
- int64_t get_unix_time_from_datetime_string(String p_datetime) const;
+ Dictionary get_datetime_dict_from_datetime_string(const String &p_datetime, bool p_weekday = true) const;
+ String get_datetime_string_from_datetime_dict(const Dictionary &p_datetime, bool p_use_space = false) const;
+ int64_t get_unix_time_from_datetime_dict(const Dictionary &p_datetime) const;
+ int64_t get_unix_time_from_datetime_string(const String &p_datetime) const;
String get_offset_string_from_offset_minutes(int64_t p_offset_minutes) const;
// Methods that get information from OS.
diff --git a/core/string/print_string.cpp b/core/string/print_string.cpp
index e3614be359..0f019c405f 100644
--- a/core/string/print_string.cpp
+++ b/core/string/print_string.cpp
@@ -68,7 +68,7 @@ void remove_print_handler(const PrintHandlerList *p_handler) {
ERR_FAIL_NULL(l);
}
-void __print_line(String p_string) {
+void __print_line(const String &p_string) {
if (!CoreGlobals::print_line_enabled) {
return;
}
@@ -85,7 +85,7 @@ void __print_line(String p_string) {
_global_unlock();
}
-void __print_line_rich(String p_string) {
+void __print_line_rich(const String &p_string) {
if (!CoreGlobals::print_line_enabled) {
return;
}
@@ -178,7 +178,7 @@ void __print_line_rich(String p_string) {
_global_unlock();
}
-void print_error(String p_string) {
+void print_error(const String &p_string) {
if (!CoreGlobals::print_error_enabled) {
return;
}
@@ -199,6 +199,6 @@ bool is_print_verbose_enabled() {
return OS::get_singleton()->is_stdout_verbose();
}
-String stringify_variants(Variant p_var) {
+String stringify_variants(const Variant &p_var) {
return p_var.operator String();
}
diff --git a/core/string/print_string.h b/core/string/print_string.h
index 7656e9bfa1..570e08c5fb 100644
--- a/core/string/print_string.h
+++ b/core/string/print_string.h
@@ -46,19 +46,19 @@ struct PrintHandlerList {
PrintHandlerList() {}
};
-String stringify_variants(Variant p_var);
+String stringify_variants(const Variant &p_var);
template <typename... Args>
-String stringify_variants(Variant p_var, Args... p_args) {
+String stringify_variants(const Variant &p_var, Args... p_args) {
return p_var.operator String() + " " + stringify_variants(p_args...);
}
void add_print_handler(PrintHandlerList *p_handler);
void remove_print_handler(const PrintHandlerList *p_handler);
-extern void __print_line(String p_string);
-extern void __print_line_rich(String p_string);
-extern void print_error(String p_string);
+extern void __print_line(const String &p_string);
+extern void __print_line_rich(const String &p_string);
+extern void print_error(const String &p_string);
extern bool is_print_verbose_enabled();
// This version avoids processing the text to be printed until it actually has to be printed, saving some CPU usage.
@@ -69,21 +69,21 @@ extern bool is_print_verbose_enabled();
} \
}
-inline void print_line(Variant v) {
+inline void print_line(const Variant &v) {
__print_line(stringify_variants(v));
}
-inline void print_line_rich(Variant v) {
+inline void print_line_rich(const Variant &v) {
__print_line_rich(stringify_variants(v));
}
template <typename... Args>
-void print_line(Variant p_var, Args... p_args) {
+void print_line(const Variant &p_var, Args... p_args) {
__print_line(stringify_variants(p_var, p_args...));
}
template <typename... Args>
-void print_line_rich(Variant p_var, Args... p_args) {
+void print_line_rich(const Variant &p_var, Args... p_args) {
__print_line_rich(stringify_variants(p_var, p_args...));
}
diff --git a/core/string/string_name.h b/core/string/string_name.h
index 4ed58d8286..89b4c07e0e 100644
--- a/core/string/string_name.h
+++ b/core/string/string_name.h
@@ -71,11 +71,6 @@ class StringName {
_Data *_data = nullptr;
- union _HashUnion {
- _Data *ptr = nullptr;
- uint32_t hash;
- };
-
void unref();
friend void register_core_types();
friend void unregister_core_types();
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index d094184c4b..67b0fdee20 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -1438,7 +1438,7 @@ Vector<int> String::split_ints_mk(const Vector<String> &p_splitters, bool p_allo
return ret;
}
-String String::join(Vector<String> parts) const {
+String String::join(const Vector<String> &parts) const {
String ret;
for (int i = 0; i < parts.size(); ++i) {
if (i > 0) {
diff --git a/core/string/ustring.h b/core/string/ustring.h
index 5ed20396d6..b1348ceb48 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -361,7 +361,7 @@ public:
Vector<int> split_ints(const String &p_splitter, bool p_allow_empty = true) const;
Vector<int> split_ints_mk(const Vector<String> &p_splitters, bool p_allow_empty = true) const;
- String join(Vector<String> parts) const;
+ String join(const Vector<String> &parts) const;
static char32_t char_uppercase(char32_t p_char);
static char32_t char_lowercase(char32_t p_char);
diff --git a/core/templates/vector.h b/core/templates/vector.h
index 361a7f56d5..0de6a34ced 100644
--- a/core/templates/vector.h
+++ b/core/templates/vector.h
@@ -100,7 +100,7 @@ public:
Size rfind(const T &p_val, Size p_from = -1) const { return _cowdata.rfind(p_val, p_from); }
Size count(const T &p_val) const { return _cowdata.count(p_val); }
- void append_array(Vector<T> p_other);
+ void append_array(const Vector<T> &p_other);
_FORCE_INLINE_ bool has(const T &p_val) const { return find(p_val) != -1; }
@@ -300,7 +300,7 @@ void Vector<T>::reverse() {
}
template <class T>
-void Vector<T>::append_array(Vector<T> p_other) {
+void Vector<T>::append_array(const Vector<T> &p_other) {
const Size ds = p_other.size();
if (ds == 0) {
return;
diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h
index 79be85cae6..1be54ba3fd 100644
--- a/core/variant/method_ptrcall.h
+++ b/core/variant/method_ptrcall.h
@@ -216,7 +216,7 @@ struct PtrToArg<ObjectID> {
} \
return ret; \
} \
- _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void *p_ptr) { \
+ _FORCE_INLINE_ static void encode(const Vector<m_type> &p_vec, void *p_ptr) { \
Vector<m_type> *dv = reinterpret_cast<Vector<m_type> *>(p_ptr); \
int len = p_vec.size(); \
dv->resize(len); \
@@ -246,49 +246,49 @@ struct PtrToArg<ObjectID> {
}
// No EncodeT because direct pointer conversion not possible.
-#define MAKE_VECARG_ALT(m_type, m_type_alt) \
- template <> \
- struct PtrToArg<Vector<m_type_alt>> { \
- _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
- const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
- Vector<m_type_alt> ret; \
- int len = dvs->size(); \
- ret.resize(len); \
- { \
- const m_type *r = dvs->ptr(); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = r[i]; \
- } \
- } \
- return ret; \
- } \
- _FORCE_INLINE_ static void encode(Vector<m_type_alt> p_vec, void *p_ptr) { \
- Vector<m_type> *dv = reinterpret_cast<Vector<m_type> *>(p_ptr); \
- int len = p_vec.size(); \
- dv->resize(len); \
- { \
- m_type *w = dv->ptrw(); \
- for (int i = 0; i < len; i++) { \
- w[i] = p_vec[i]; \
- } \
- } \
- } \
- }; \
- template <> \
- struct PtrToArg<const Vector<m_type_alt> &> { \
- _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
- const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
- Vector<m_type_alt> ret; \
- int len = dvs->size(); \
- ret.resize(len); \
- { \
- const m_type *r = dvs->ptr(); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = r[i]; \
- } \
- } \
- return ret; \
- } \
+#define MAKE_VECARG_ALT(m_type, m_type_alt) \
+ template <> \
+ struct PtrToArg<Vector<m_type_alt>> { \
+ _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
+ const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
+ Vector<m_type_alt> ret; \
+ int len = dvs->size(); \
+ ret.resize(len); \
+ { \
+ const m_type *r = dvs->ptr(); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = r[i]; \
+ } \
+ } \
+ return ret; \
+ } \
+ _FORCE_INLINE_ static void encode(const Vector<m_type_alt> &p_vec, void *p_ptr) { \
+ Vector<m_type> *dv = reinterpret_cast<Vector<m_type> *>(p_ptr); \
+ int len = p_vec.size(); \
+ dv->resize(len); \
+ { \
+ m_type *w = dv->ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = p_vec[i]; \
+ } \
+ } \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const Vector<m_type_alt> &> { \
+ _FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
+ const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
+ Vector<m_type_alt> ret; \
+ int len = dvs->size(); \
+ ret.resize(len); \
+ { \
+ const m_type *r = dvs->ptr(); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = r[i]; \
+ } \
+ } \
+ return ret; \
+ } \
}
MAKE_VECARG_ALT(String, StringName);
@@ -296,40 +296,40 @@ MAKE_VECARG_ALT(String, StringName);
// For stuff that gets converted to Array vectors.
// No EncodeT because direct pointer conversion not possible.
-#define MAKE_VECARR(m_type) \
- template <> \
- struct PtrToArg<Vector<m_type>> { \
- _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
- const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
- Vector<m_type> ret; \
- int len = arr->size(); \
- ret.resize(len); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = (*arr)[i]; \
- } \
- return ret; \
- } \
- _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void *p_ptr) { \
- Array *arr = reinterpret_cast<Array *>(p_ptr); \
- int len = p_vec.size(); \
- arr->resize(len); \
- for (int i = 0; i < len; i++) { \
- (*arr)[i] = p_vec[i]; \
- } \
- } \
- }; \
- template <> \
- struct PtrToArg<const Vector<m_type> &> { \
- _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
- const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
- Vector<m_type> ret; \
- int len = arr->size(); \
- ret.resize(len); \
- for (int i = 0; i < len; i++) { \
- ret.write[i] = (*arr)[i]; \
- } \
- return ret; \
- } \
+#define MAKE_VECARR(m_type) \
+ template <> \
+ struct PtrToArg<Vector<m_type>> { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = arr->size(); \
+ ret.resize(len); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = (*arr)[i]; \
+ } \
+ return ret; \
+ } \
+ _FORCE_INLINE_ static void encode(const Vector<m_type> &p_vec, void *p_ptr) { \
+ Array *arr = reinterpret_cast<Array *>(p_ptr); \
+ int len = p_vec.size(); \
+ arr->resize(len); \
+ for (int i = 0; i < len; i++) { \
+ (*arr)[i] = p_vec[i]; \
+ } \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const Vector<m_type> &> { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = arr->size(); \
+ ret.resize(len); \
+ for (int i = 0; i < len; i++) { \
+ ret.write[i] = (*arr)[i]; \
+ } \
+ return ret; \
+ } \
}
MAKE_VECARR(Variant);
@@ -337,49 +337,49 @@ MAKE_VECARR(RID);
MAKE_VECARR(Plane);
// No EncodeT because direct pointer conversion not possible.
-#define MAKE_DVECARR(m_type) \
- template <> \
- struct PtrToArg<Vector<m_type>> { \
- _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
- const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
- Vector<m_type> ret; \
- int len = arr->size(); \
- ret.resize(len); \
- { \
- m_type *w = ret.ptrw(); \
- for (int i = 0; i < len; i++) { \
- w[i] = (*arr)[i]; \
- } \
- } \
- return ret; \
- } \
- _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void *p_ptr) { \
- Array *arr = reinterpret_cast<Array *>(p_ptr); \
- int len = p_vec.size(); \
- arr->resize(len); \
- { \
- const m_type *r = p_vec.ptr(); \
- for (int i = 0; i < len; i++) { \
- (*arr)[i] = r[i]; \
- } \
- } \
- } \
- }; \
- template <> \
- struct PtrToArg<const Vector<m_type> &> { \
- _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
- const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
- Vector<m_type> ret; \
- int len = arr->size(); \
- ret.resize(len); \
- { \
- m_type *w = ret.ptrw(); \
- for (int i = 0; i < len; i++) { \
- w[i] = (*arr)[i]; \
- } \
- } \
- return ret; \
- } \
+#define MAKE_DVECARR(m_type) \
+ template <> \
+ struct PtrToArg<Vector<m_type>> { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = arr->size(); \
+ ret.resize(len); \
+ { \
+ m_type *w = ret.ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = (*arr)[i]; \
+ } \
+ } \
+ return ret; \
+ } \
+ _FORCE_INLINE_ static void encode(const Vector<m_type> &p_vec, void *p_ptr) { \
+ Array *arr = reinterpret_cast<Array *>(p_ptr); \
+ int len = p_vec.size(); \
+ arr->resize(len); \
+ { \
+ const m_type *r = p_vec.ptr(); \
+ for (int i = 0; i < len; i++) { \
+ (*arr)[i] = r[i]; \
+ } \
+ } \
+ } \
+ }; \
+ template <> \
+ struct PtrToArg<const Vector<m_type> &> { \
+ _FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
+ Vector<m_type> ret; \
+ int len = arr->size(); \
+ ret.resize(len); \
+ { \
+ m_type *w = ret.ptrw(); \
+ for (int i = 0; i < len; i++) { \
+ w[i] = (*arr)[i]; \
+ } \
+ } \
+ return ret; \
+ } \
}
// Special case for IPAddress.
@@ -427,7 +427,7 @@ struct PtrToArg<Vector<Face3>> {
}
return ret;
}
- _FORCE_INLINE_ static void encode(Vector<Face3> p_vec, void *p_ptr) {
+ _FORCE_INLINE_ static void encode(const Vector<Face3> &p_vec, void *p_ptr) {
Vector<Vector3> *arr = reinterpret_cast<Vector<Vector3> *>(p_ptr);
int len = p_vec.size();
arr->resize(len * 3);
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 67f2c10099..ce5423fafc 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -1676,7 +1676,7 @@ Variant::operator String() const {
return stringify(0);
}
-String stringify_variant_clean(const Variant p_variant, int recursion_count) {
+String stringify_variant_clean(const Variant &p_variant, int recursion_count) {
String s = p_variant.stringify(recursion_count);
// Wrap strings in quotes to avoid ambiguity.
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index cc48394b64..7136fa00c4 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -109,7 +109,7 @@ int64_t VariantUtilityFunctions::posmod(int64_t b, int64_t r) {
return Math::posmod(b, r);
}
-Variant VariantUtilityFunctions::floor(Variant x, Callable::CallError &r_error) {
+Variant VariantUtilityFunctions::floor(const Variant &x, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
switch (x.get_type()) {
case Variant::INT: {
@@ -153,7 +153,7 @@ int64_t VariantUtilityFunctions::floori(double x) {
return int64_t(Math::floor(x));
}
-Variant VariantUtilityFunctions::ceil(Variant x, Callable::CallError &r_error) {
+Variant VariantUtilityFunctions::ceil(const Variant &x, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
switch (x.get_type()) {
case Variant::INT: {
@@ -197,7 +197,7 @@ int64_t VariantUtilityFunctions::ceili(double x) {
return int64_t(Math::ceil(x));
}
-Variant VariantUtilityFunctions::round(Variant x, Callable::CallError &r_error) {
+Variant VariantUtilityFunctions::round(const Variant &x, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
switch (x.get_type()) {
case Variant::INT: {
diff --git a/core/variant/variant_utility.h b/core/variant/variant_utility.h
index a56c84a8e9..75cde4942b 100644
--- a/core/variant/variant_utility.h
+++ b/core/variant/variant_utility.h
@@ -52,13 +52,13 @@ struct VariantUtilityFunctions {
static double fmod(double b, double r);
static double fposmod(double b, double r);
static int64_t posmod(int64_t b, int64_t r);
- static Variant floor(Variant x, Callable::CallError &r_error);
+ static Variant floor(const Variant &x, Callable::CallError &r_error);
static double floorf(double x);
static int64_t floori(double x);
- static Variant ceil(Variant x, Callable::CallError &r_error);
+ static Variant ceil(const Variant &x, Callable::CallError &r_error);
static double ceilf(double x);
static int64_t ceili(double x);
- static Variant round(Variant x, Callable::CallError &r_error);
+ static Variant round(const Variant &x, Callable::CallError &r_error);
static double roundf(double x);
static int64_t roundi(double x);
static Variant abs(const Variant &x, Callable::CallError &r_error);