summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/SCsub2
-rw-r--r--core/doc_data.h2
-rw-r--r--core/input/input_event.cpp21
-rw-r--r--core/io/compression.cpp4
-rw-r--r--core/io/file_access_buffered.cpp150
-rw-r--r--core/io/file_access_buffered.h91
-rw-r--r--core/io/file_access_buffered_fa.h139
-rw-r--r--core/io/file_access_compressed.cpp4
-rw-r--r--core/io/file_access_encrypted.cpp6
-rw-r--r--core/io/file_access_zip.h2
-rw-r--r--core/io/image.cpp71
-rw-r--r--core/io/image.h16
-rw-r--r--core/io/marshalls.cpp5
-rw-r--r--core/io/packet_peer.cpp9
-rw-r--r--core/io/packet_peer.h1
-rw-r--r--core/io/resource_importer.cpp4
-rw-r--r--core/io/resource_importer.h1
-rw-r--r--core/math/expression.cpp27
-rw-r--r--core/math/random_number_generator.cpp7
-rw-r--r--core/math/random_number_generator.h8
-rw-r--r--core/math/random_pcg.h7
-rw-r--r--core/math/vector3.cpp33
-rw-r--r--core/math/vector3.h1
-rw-r--r--core/object/class_db.cpp5
-rw-r--r--core/object/object.cpp4
-rw-r--r--core/object/object.h2
-rw-r--r--core/object/script_language.h2
-rw-r--r--core/os/file_access.cpp2
-rw-r--r--core/os/os.cpp4
-rw-r--r--core/os/os.h2
-rw-r--r--core/string/node_path.cpp2
-rw-r--r--core/variant/variant.h12
-rw-r--r--core/variant/variant_construct.cpp60
-rw-r--r--core/variant/variant_setget.cpp224
34 files changed, 231 insertions, 699 deletions
diff --git a/core/SCsub b/core/SCsub
index 78a4395619..45918fb520 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -25,7 +25,7 @@ if "SCRIPT_AES256_ENCRYPTION_KEY" in os.environ:
txts = "0x" + e[i * 2 : i * 2 + 2]
try:
int(txts, 16)
- except:
+ except Exception:
ec_valid = False
txt += txts
if not ec_valid:
diff --git a/core/doc_data.h b/core/doc_data.h
index bf016792ea..65b57d1381 100644
--- a/core/doc_data.h
+++ b/core/doc_data.h
@@ -89,7 +89,7 @@ public:
struct ConstantDoc {
String name;
String value;
- bool is_value_valid;
+ bool is_value_valid = false;
String enumeration;
String description;
bool operator<(const ConstantDoc &p_const) const {
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index e04e642f6b..82bfaa82a5 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -213,7 +213,7 @@ String InputEventWithModifiers::as_text() const {
if (!mod_names.empty()) {
return String("+").join(mod_names);
} else {
- return "None";
+ return "";
}
}
@@ -369,11 +369,19 @@ String InputEventKey::to_string() {
String p = is_pressed() ? "true" : "false";
String e = is_echo() ? "true" : "false";
+ String kc = "";
+ String physical = "false";
if (keycode == 0) {
- return vformat("InputEventKey: keycode=%s mods=%s physical=%s pressed=%s echo=%s", itos(physical_keycode) + " " + keycode_get_string(physical_keycode), InputEventWithModifiers::as_text(), "true", p, e);
+ kc = itos(physical_keycode) + " " + keycode_get_string(physical_keycode);
+ physical = "true";
} else {
- return vformat("InputEventKey: keycode=%s mods=%s physical=%s pressed=%s echo=%s", itos(keycode) + " " + keycode_get_string(keycode), InputEventWithModifiers::as_text(), "false", p, e);
+ kc = itos(keycode) + " " + keycode_get_string(keycode);
}
+
+ String mods = InputEventWithModifiers::as_text();
+ mods = mods == "" ? TTR("None") : mods;
+
+ return vformat("InputEventKey: keycode=%s mods=%s physical=%s pressed=%s echo=%s", kc, mods, physical, p, e);
}
bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const {
@@ -633,7 +641,12 @@ String InputEventMouseButton::to_string() {
break;
}
- return vformat("InputEventMouseButton: button_index=%s pressed=%s position=(%s) button_mask=%s doubleclick=%s", button_index, p, String(get_position()), itos(get_button_mask()), d);
+ String mods = InputEventWithModifiers::as_text();
+ mods = mods == "" ? TTR("None") : mods;
+
+ // Work around the fact vformat can only take 5 substitutions but 6 need to be passed.
+ String index_and_mods = vformat("button_index=%s mods=%s", button_index, mods);
+ return vformat("InputEventMouseButton: %s pressed=%s position=(%s) button_mask=%s doubleclick=%s", index_and_mods, p, String(get_position()), itos(get_button_mask()), d);
}
void InputEventMouseButton::_bind_methods() {
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index cd8793bb0a..8e613cb3ce 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -257,13 +257,13 @@ int Compression::decompress_dynamic(Vector<uint8_t> *p_dst_vect, int p_max_dst_s
} while (ret != Z_STREAM_END);
// If all done successfully, resize the output if it's larger than the actual output
- if (ret == Z_STREAM_END && (unsigned long)p_dst_vect->size() > strm.total_out) {
+ if ((unsigned long)p_dst_vect->size() > strm.total_out) {
p_dst_vect->resize(strm.total_out);
}
// clean up and return
(void)inflateEnd(&strm);
- return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
+ return Z_OK;
}
int Compression::zlib_level = Z_DEFAULT_COMPRESSION;
diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp
deleted file mode 100644
index 714f3b6099..0000000000
--- a/core/io/file_access_buffered.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*************************************************************************/
-/* file_access_buffered.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "file_access_buffered.h"
-
-#include "core/error/error_macros.h"
-
-Error FileAccessBuffered::set_error(Error p_error) const {
- return (last_error = p_error);
-}
-
-void FileAccessBuffered::set_cache_size(int p_size) {
- cache_size = p_size;
-}
-
-int FileAccessBuffered::get_cache_size() {
- return cache_size;
-}
-
-int FileAccessBuffered::cache_data_left() const {
- if (file.offset >= file.size) {
- return 0;
- }
-
- if (cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size()) {
- return read_data_block(file.offset, cache_size);
- }
-
- return cache.buffer.size() - (file.offset - cache.offset);
-}
-
-void FileAccessBuffered::seek(size_t p_position) {
- file.offset = p_position;
-}
-
-void FileAccessBuffered::seek_end(int64_t p_position) {
- file.offset = file.size + p_position;
-}
-
-size_t FileAccessBuffered::get_position() const {
- return file.offset;
-}
-
-size_t FileAccessBuffered::get_len() const {
- return file.size;
-}
-
-bool FileAccessBuffered::eof_reached() const {
- return file.offset > file.size;
-}
-
-uint8_t FileAccessBuffered::get_8() const {
- ERR_FAIL_COND_V_MSG(!file.open, 0, "Can't get data, when file is not opened.");
-
- uint8_t byte = 0;
- if (cache_data_left() >= 1) {
- byte = cache.buffer[file.offset - cache.offset];
- }
-
- ++file.offset;
-
- return byte;
-}
-
-int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
- ERR_FAIL_COND_V_MSG(!file.open, -1, "Can't get buffer, when file is not opened.");
-
- if (p_length > cache_size) {
- int total_read = 0;
-
- if (!(cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size())) {
- int size = (cache.buffer.size() - (file.offset - cache.offset));
- size = size - (size % 4);
- //const uint8_t* read = cache.buffer.ptr();
- //memcpy(p_dest, read.ptr() + (file.offset - cache.offset), size);
- memcpy(p_dest, cache.buffer.ptr() + (file.offset - cache.offset), size);
- p_dest += size;
- p_length -= size;
- file.offset += size;
- total_read += size;
- }
-
- int err = read_data_block(file.offset, p_length, p_dest);
- if (err >= 0) {
- total_read += err;
- file.offset += err;
- }
-
- return total_read;
- }
-
- int to_read = p_length;
- int total_read = 0;
- while (to_read > 0) {
- int left = cache_data_left();
- if (left == 0) {
- file.offset += to_read;
- return total_read;
- }
- if (left < 0) {
- return left;
- }
-
- int r = MIN(left, to_read);
- //const uint8_t* read = cache.buffer.ptr();
- //memcpy(p_dest+total_read, &read.ptr()[file.offset - cache.offset], r);
- memcpy(p_dest + total_read, cache.buffer.ptr() + (file.offset - cache.offset), r);
-
- file.offset += r;
- total_read += r;
- to_read -= r;
- }
-
- return p_length;
-}
-
-bool FileAccessBuffered::is_open() const {
- return file.open;
-}
-
-Error FileAccessBuffered::get_error() const {
- return last_error;
-}
diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h
deleted file mode 100644
index 7fd99b6373..0000000000
--- a/core/io/file_access_buffered.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*************************************************************************/
-/* file_access_buffered.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef FILE_ACCESS_BUFFERED_H
-#define FILE_ACCESS_BUFFERED_H
-
-#include "core/os/file_access.h"
-
-#include "core/string/ustring.h"
-
-class FileAccessBuffered : public FileAccess {
-public:
- enum {
- DEFAULT_CACHE_SIZE = 128 * 1024,
- };
-
-private:
- int cache_size = DEFAULT_CACHE_SIZE;
-
- int cache_data_left() const;
- mutable Error last_error;
-
-protected:
- Error set_error(Error p_error) const;
-
- mutable struct File {
- bool open = false;
- int size = 0;
- int offset = 0;
- String name;
- int access_flags = 0;
- } file;
-
- mutable struct Cache {
- Vector<uint8_t> buffer;
- int offset = 0;
- } cache;
-
- virtual int read_data_block(int p_offset, int p_size, uint8_t *p_dest = nullptr) const = 0;
-
- void set_cache_size(int p_size);
- int get_cache_size();
-
-public:
- virtual size_t get_position() const; ///< get position in the file
- virtual size_t get_len() const; ///< get size of the file
-
- virtual void seek(size_t p_position); ///< seek to a given position
- virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file
-
- virtual bool eof_reached() const;
-
- virtual uint8_t get_8() const;
- virtual int get_buffer(uint8_t *p_dest, int p_length) const; ///< get an array of bytes
-
- virtual bool is_open() const;
-
- virtual Error get_error() const;
-
- FileAccessBuffered() {}
- virtual ~FileAccessBuffered() {}
-};
-
-#endif
diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h
deleted file mode 100644
index f22e54e154..0000000000
--- a/core/io/file_access_buffered_fa.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*************************************************************************/
-/* file_access_buffered_fa.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef FILE_ACCESS_BUFFERED_FA_H
-#define FILE_ACCESS_BUFFERED_FA_H
-
-#include "core/io/file_access_buffered.h"
-
-template <class T>
-class FileAccessBufferedFA : public FileAccessBuffered {
- T f;
-
- int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const {
- ERR_FAIL_COND_V_MSG(!f.is_open(), -1, "Can't read data block when file is not opened.");
-
- ((T *)&f)->seek(p_offset);
-
- if (p_dest) {
- f.get_buffer(p_dest, p_size);
- return p_size;
-
- } else {
- cache.offset = p_offset;
- cache.buffer.resize(p_size);
-
- // on Vector
- //uint8_t* write = cache.buffer.ptrw();
- //f.get_buffer(write.ptrw(), p_size);
-
- // on vector
- f.get_buffer(cache.buffer.ptrw(), p_size);
-
- return p_size;
- }
- }
-
- static FileAccess *create() {
- return memnew(FileAccessBufferedFA<T>());
- }
-
-protected:
- virtual void _set_access_type(AccessType p_access) {
- f._set_access_type(p_access);
- FileAccessBuffered::_set_access_type(p_access);
- }
-
-public:
- void flush() {
- f.flush();
- }
-
- void store_8(uint8_t p_dest) {
- f.store_8(p_dest);
- }
-
- void store_buffer(const uint8_t *p_src, int p_length) {
- f.store_buffer(p_src, p_length);
- }
-
- bool file_exists(const String &p_name) {
- return f.file_exists(p_name);
- }
-
- Error _open(const String &p_path, int p_mode_flags) {
- close();
-
- Error ret = f._open(p_path, p_mode_flags);
- if (ret != OK)
- return ret;
- //ERR_FAIL_COND_V( ret != OK, ret );
-
- file.size = f.get_len();
- file.offset = 0;
- file.open = true;
- file.name = p_path;
- file.access_flags = p_mode_flags;
-
- cache.buffer.resize(0);
- cache.offset = 0;
-
- return set_error(OK);
- }
-
- void close() {
- f.close();
-
- file.offset = 0;
- file.size = 0;
- file.open = false;
- file.name = "";
-
- cache.buffer.resize(0);
- cache.offset = 0;
- set_error(OK);
- }
-
- virtual uint64_t _get_modified_time(const String &p_file) {
- return f._get_modified_time(p_file);
- }
-
- virtual uint32_t _get_unix_permissions(const String &p_file) {
- return f._get_unix_permissions(p_file);
- }
-
- virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) {
- return f._set_unix_permissions(p_file, p_permissions);
- }
-
- FileAccessBufferedFA() {}
-};
-
-#endif // FILE_ACCESS_BUFFERED_FA_H
diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp
index 4424192af2..b06b3c078f 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -327,14 +327,14 @@ Error FileAccessCompressed::get_error() const {
void FileAccessCompressed::flush() {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
- ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
+ ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
// compressed files keep data in memory till close()
}
void FileAccessCompressed::store_8(uint8_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
- ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
+ ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
WRITE_FIT(1);
write_ptr[write_pos++] = p_dest;
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index 2ac24d5169..cf5800b472 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -256,7 +256,7 @@ Error FileAccessEncrypted::get_error() const {
}
void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
- ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
+ ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
if (pos < data.size()) {
for (int i = 0; i < p_length; i++) {
@@ -272,13 +272,13 @@ void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
}
void FileAccessEncrypted::flush() {
- ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
+ ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
// encrypted files keep data in memory till close()
}
void FileAccessEncrypted::store_8(uint8_t p_dest) {
- ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
+ ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
if (pos < data.size()) {
data.write[pos] = p_dest;
diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h
index eff07c60e2..f8e7c1e587 100644
--- a/core/io/file_access_zip.h
+++ b/core/io/file_access_zip.h
@@ -59,8 +59,6 @@ private:
static ZipArchive *instance;
- FileAccess::CreateFunc fa_create_func;
-
public:
void close_handle(unzFile p_file) const;
unzFile get_file_handle(String p_file) const;
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 6dde25af32..7c32c02701 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -66,10 +66,10 @@ const char *Image::format_names[Image::FORMAT_MAX] = {
"BPTC_RGBA",
"BPTC_RGBF",
"BPTC_RGBFU",
- "PVRTC2", //pvrtc
- "PVRTC2A",
- "PVRTC4",
- "PVRTC4A",
+ "PVRTC1_2", //pvrtc
+ "PVRTC1_2A",
+ "PVRTC1_4",
+ "PVRTC1_4A",
"ETC", //etc1
"ETC2_R11", //etc2
"ETC2_R11S", //signed", NOT srgb.
@@ -155,13 +155,13 @@ int Image::get_format_pixel_size(Format p_format) {
return 1; //float /
case FORMAT_BPTC_RGBFU:
return 1; //unsigned float
- case FORMAT_PVRTC2:
+ case FORMAT_PVRTC1_2:
return 1; //pvrtc
- case FORMAT_PVRTC2A:
+ case FORMAT_PVRTC1_2A:
return 1;
- case FORMAT_PVRTC4:
+ case FORMAT_PVRTC1_4:
return 1;
- case FORMAT_PVRTC4A:
+ case FORMAT_PVRTC1_4A:
return 1;
case FORMAT_ETC:
return 1; //etc1
@@ -200,13 +200,13 @@ void Image::get_format_min_pixel_size(Format p_format, int &r_w, int &r_h) {
r_w = 4;
r_h = 4;
} break;
- case FORMAT_PVRTC2:
- case FORMAT_PVRTC2A: {
+ case FORMAT_PVRTC1_2:
+ case FORMAT_PVRTC1_2A: {
r_w = 16;
r_h = 8;
} break;
- case FORMAT_PVRTC4A:
- case FORMAT_PVRTC4: {
+ case FORMAT_PVRTC1_4A:
+ case FORMAT_PVRTC1_4: {
r_w = 8;
r_h = 8;
} break;
@@ -242,9 +242,9 @@ void Image::get_format_min_pixel_size(Format p_format, int &r_w, int &r_h) {
}
int Image::get_format_pixel_rshift(Format p_format) {
- if (p_format == FORMAT_DXT1 || p_format == FORMAT_RGTC_R || p_format == FORMAT_PVRTC4 || p_format == FORMAT_PVRTC4A || p_format == FORMAT_ETC || p_format == FORMAT_ETC2_R11 || p_format == FORMAT_ETC2_R11S || p_format == FORMAT_ETC2_RGB8 || p_format == FORMAT_ETC2_RGB8A1) {
+ if (p_format == FORMAT_DXT1 || p_format == FORMAT_RGTC_R || p_format == FORMAT_PVRTC1_4 || p_format == FORMAT_PVRTC1_4A || p_format == FORMAT_ETC || p_format == FORMAT_ETC2_R11 || p_format == FORMAT_ETC2_R11S || p_format == FORMAT_ETC2_RGB8 || p_format == FORMAT_ETC2_RGB8A1) {
return 1;
- } else if (p_format == FORMAT_PVRTC2 || p_format == FORMAT_PVRTC2A) {
+ } else if (p_format == FORMAT_PVRTC1_2 || p_format == FORMAT_PVRTC1_2A) {
return 2;
} else {
return 0;
@@ -261,12 +261,12 @@ int Image::get_format_block_size(Format p_format) {
return 4;
}
- case FORMAT_PVRTC2:
- case FORMAT_PVRTC2A: {
+ case FORMAT_PVRTC1_2:
+ case FORMAT_PVRTC1_2A: {
return 4;
}
- case FORMAT_PVRTC4A:
- case FORMAT_PVRTC4: {
+ case FORMAT_PVRTC1_4A:
+ case FORMAT_PVRTC1_4: {
return 4;
}
case FORMAT_ETC: {
@@ -2216,8 +2216,8 @@ bool Image::is_invisible() const {
} break;
- case FORMAT_PVRTC2A:
- case FORMAT_PVRTC4A:
+ case FORMAT_PVRTC1_2A:
+ case FORMAT_PVRTC1_4A:
case FORMAT_DXT3:
case FORMAT_DXT5: {
detected = true;
@@ -2258,8 +2258,8 @@ Image::AlphaMode Image::detect_alpha() const {
}
} break;
- case FORMAT_PVRTC2A:
- case FORMAT_PVRTC4A:
+ case FORMAT_PVRTC1_2A:
+ case FORMAT_PVRTC1_4A:
case FORMAT_DXT3:
case FORMAT_DXT5: {
detected = true;
@@ -2355,7 +2355,7 @@ Error Image::decompress() {
_image_decompress_bc(this);
} else if (format >= FORMAT_BPTC_RGBA && format <= FORMAT_BPTC_RGBFU && _image_decompress_bptc) {
_image_decompress_bptc(this);
- } else if (format >= FORMAT_PVRTC2 && format <= FORMAT_PVRTC4A && _image_decompress_pvrtc) {
+ } else if (format >= FORMAT_PVRTC1_2 && format <= FORMAT_PVRTC1_4A && _image_decompress_pvrtc) {
_image_decompress_pvrtc(this);
} else if (format == FORMAT_ETC && _image_decompress_etc1) {
_image_decompress_etc1(this);
@@ -2377,13 +2377,9 @@ Error Image::compress_from_channels(CompressMode p_mode, UsedChannels p_channels
ERR_FAIL_COND_V(!_image_compress_bc_func, ERR_UNAVAILABLE);
_image_compress_bc_func(this, p_lossy_quality, p_channels);
} break;
- case COMPRESS_PVRTC2: {
- ERR_FAIL_COND_V(!_image_compress_pvrtc2_func, ERR_UNAVAILABLE);
- _image_compress_pvrtc2_func(this);
- } break;
- case COMPRESS_PVRTC4: {
- ERR_FAIL_COND_V(!_image_compress_pvrtc4_func, ERR_UNAVAILABLE);
- _image_compress_pvrtc4_func(this);
+ case COMPRESS_PVRTC1_4: {
+ ERR_FAIL_COND_V(!_image_compress_pvrtc1_4bpp_func, ERR_UNAVAILABLE);
+ _image_compress_pvrtc1_4bpp_func(this);
} break;
case COMPRESS_ETC: {
ERR_FAIL_COND_V(!_image_compress_etc1_func, ERR_UNAVAILABLE);
@@ -2714,8 +2710,7 @@ ImageMemLoadFunc Image::_bmp_mem_loader_func = nullptr;
void (*Image::_image_compress_bc_func)(Image *, float, Image::UsedChannels) = nullptr;
void (*Image::_image_compress_bptc_func)(Image *, float, Image::UsedChannels) = nullptr;
-void (*Image::_image_compress_pvrtc2_func)(Image *) = nullptr;
-void (*Image::_image_compress_pvrtc4_func)(Image *) = nullptr;
+void (*Image::_image_compress_pvrtc1_4bpp_func)(Image *) = nullptr;
void (*Image::_image_compress_etc1_func)(Image *, float) = nullptr;
void (*Image::_image_compress_etc2_func)(Image *, float, Image::UsedChannels) = nullptr;
void (*Image::_image_decompress_pvrtc)(Image *) = nullptr;
@@ -3173,10 +3168,10 @@ void Image::_bind_methods() {
BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBA); //btpc bc6h
BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBF); //float /
BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBFU); //unsigned float
- BIND_ENUM_CONSTANT(FORMAT_PVRTC2); //pvrtc
- BIND_ENUM_CONSTANT(FORMAT_PVRTC2A);
- BIND_ENUM_CONSTANT(FORMAT_PVRTC4);
- BIND_ENUM_CONSTANT(FORMAT_PVRTC4A);
+ BIND_ENUM_CONSTANT(FORMAT_PVRTC1_2); //pvrtc
+ BIND_ENUM_CONSTANT(FORMAT_PVRTC1_2A);
+ BIND_ENUM_CONSTANT(FORMAT_PVRTC1_4);
+ BIND_ENUM_CONSTANT(FORMAT_PVRTC1_4A);
BIND_ENUM_CONSTANT(FORMAT_ETC); //etc1
BIND_ENUM_CONSTANT(FORMAT_ETC2_R11); //etc2
BIND_ENUM_CONSTANT(FORMAT_ETC2_R11S); //signed ); NOT srgb.
@@ -3200,10 +3195,10 @@ void Image::_bind_methods() {
BIND_ENUM_CONSTANT(ALPHA_BLEND);
BIND_ENUM_CONSTANT(COMPRESS_S3TC);
- BIND_ENUM_CONSTANT(COMPRESS_PVRTC2);
- BIND_ENUM_CONSTANT(COMPRESS_PVRTC4);
+ BIND_ENUM_CONSTANT(COMPRESS_PVRTC1_4);
BIND_ENUM_CONSTANT(COMPRESS_ETC);
BIND_ENUM_CONSTANT(COMPRESS_ETC2);
+ BIND_ENUM_CONSTANT(COMPRESS_BPTC);
BIND_ENUM_CONSTANT(USED_CHANNELS_L);
BIND_ENUM_CONSTANT(USED_CHANNELS_LA);
diff --git a/core/io/image.h b/core/io/image.h
index c4c84589e5..0151df0cf9 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -91,10 +91,10 @@ public:
FORMAT_BPTC_RGBA, //btpc bc7
FORMAT_BPTC_RGBF, //float bc6h
FORMAT_BPTC_RGBFU, //unsigned float bc6hu
- FORMAT_PVRTC2, //pvrtc
- FORMAT_PVRTC2A,
- FORMAT_PVRTC4,
- FORMAT_PVRTC4A,
+ FORMAT_PVRTC1_2, //pvrtc1
+ FORMAT_PVRTC1_2A,
+ FORMAT_PVRTC1_4,
+ FORMAT_PVRTC1_4A,
FORMAT_ETC, //etc1
FORMAT_ETC2_R11, //etc2
FORMAT_ETC2_R11S, //signed, NOT srgb.
@@ -138,8 +138,7 @@ public:
static void (*_image_compress_bc_func)(Image *, float, UsedChannels p_channels);
static void (*_image_compress_bptc_func)(Image *, float p_lossy_quality, UsedChannels p_channels);
- static void (*_image_compress_pvrtc2_func)(Image *);
- static void (*_image_compress_pvrtc4_func)(Image *);
+ static void (*_image_compress_pvrtc1_4bpp_func)(Image *);
static void (*_image_compress_etc1_func)(Image *, float);
static void (*_image_compress_etc2_func)(Image *, float, UsedChannels p_channels);
@@ -332,11 +331,10 @@ public:
enum CompressMode {
COMPRESS_S3TC,
- COMPRESS_PVRTC2,
- COMPRESS_PVRTC4,
+ COMPRESS_PVRTC1_4,
COMPRESS_ETC,
COMPRESS_ETC2,
- COMPRESS_BPTC
+ COMPRESS_BPTC,
};
enum CompressSource {
COMPRESS_SOURCE_GENERIC,
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 3cf4acaf39..db12fcb7f7 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -1003,10 +1003,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
- case Variant::STRING: {
- _encode_string(p_variant, buf, r_len);
-
- } break;
+ case Variant::STRING:
case Variant::STRING_NAME: {
_encode_string(p_variant, buf, r_len);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index b6cc5bf42a..3da494a8ef 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -151,11 +151,6 @@ void PacketPeer::_bind_methods() {
/***************/
-void PacketPeerStream::_set_stream_peer(REF p_peer) {
- ERR_FAIL_COND_MSG(p_peer.is_null(), "It's not a reference to a valid Resource object.");
- set_stream_peer(p_peer);
-}
-
void PacketPeerStream::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::set_stream_peer);
ClassDB::bind_method(D_METHOD("get_stream_peer"), &PacketPeerStream::get_stream_peer);
@@ -263,10 +258,8 @@ int PacketPeerStream::get_max_packet_size() const {
}
void PacketPeerStream::set_stream_peer(const Ref<StreamPeer> &p_peer) {
- //ERR_FAIL_COND(p_peer.is_null());
-
if (p_peer.ptr() != peer.ptr()) {
- ring_buffer.advance_read(ring_buffer.data_left()); // reset the ring buffer
+ ring_buffer.advance_read(ring_buffer.data_left()); // Reset the ring buffer.
}
peer = p_peer;
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index f7f080aa43..a25fa03875 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -86,7 +86,6 @@ class PacketPeerStream : public PacketPeer {
Error _poll_buffer() const;
protected:
- void _set_stream_peer(REF p_peer);
static void _bind_methods();
public:
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index c88331cf9e..9b14d2c763 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -192,10 +192,6 @@ bool ResourceFormatImporter::recognize_path(const String &p_path, const String &
return FileAccess::exists(p_path + ".import");
}
-bool ResourceFormatImporter::can_be_imported(const String &p_path) const {
- return ResourceFormatLoader::recognize_path(p_path);
-}
-
int ResourceFormatImporter::get_import_order(const String &p_path) const {
Ref<ResourceImporter> importer;
diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h
index 30bbd43c18..1b300bf656 100644
--- a/core/io/resource_importer.h
+++ b/core/io/resource_importer.h
@@ -70,7 +70,6 @@ public:
virtual String get_import_group_file(const String &p_path) const;
virtual bool exists(const String &p_path) const;
- virtual bool can_be_imported(const String &p_path) const;
virtual int get_import_order(const String &p_path) const;
String get_internal_resource_path(const String &p_path) const;
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index d1f15caa5e..29b706a3a9 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -1003,31 +1003,19 @@ Expression::ENode *Expression::_parse_expression() {
priority = 1;
unary = true;
break;
-
case Variant::OP_MULTIPLY:
- priority = 2;
- break;
case Variant::OP_DIVIDE:
- priority = 2;
- break;
case Variant::OP_MODULE:
priority = 2;
break;
-
case Variant::OP_ADD:
- priority = 3;
- break;
case Variant::OP_SUBTRACT:
priority = 3;
break;
-
case Variant::OP_SHIFT_LEFT:
- priority = 4;
- break;
case Variant::OP_SHIFT_RIGHT:
priority = 4;
break;
-
case Variant::OP_BIT_AND:
priority = 5;
break;
@@ -1037,31 +1025,17 @@ Expression::ENode *Expression::_parse_expression() {
case Variant::OP_BIT_OR:
priority = 7;
break;
-
case Variant::OP_LESS:
- priority = 8;
- break;
case Variant::OP_LESS_EQUAL:
- priority = 8;
- break;
case Variant::OP_GREATER:
- priority = 8;
- break;
case Variant::OP_GREATER_EQUAL:
- priority = 8;
- break;
-
case Variant::OP_EQUAL:
- priority = 8;
- break;
case Variant::OP_NOT_EQUAL:
priority = 8;
break;
-
case Variant::OP_IN:
priority = 10;
break;
-
case Variant::OP_NOT:
priority = 11;
unary = true;
@@ -1072,7 +1046,6 @@ Expression::ENode *Expression::_parse_expression() {
case Variant::OP_OR:
priority = 13;
break;
-
default: {
_set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op));
return nullptr;
diff --git a/core/math/random_number_generator.cpp b/core/math/random_number_generator.cpp
index a124f63030..f045213fb9 100644
--- a/core/math/random_number_generator.cpp
+++ b/core/math/random_number_generator.cpp
@@ -34,6 +34,9 @@ void RandomNumberGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &RandomNumberGenerator::set_seed);
ClassDB::bind_method(D_METHOD("get_seed"), &RandomNumberGenerator::get_seed);
+ ClassDB::bind_method(D_METHOD("set_state", "state"), &RandomNumberGenerator::set_state);
+ ClassDB::bind_method(D_METHOD("get_state"), &RandomNumberGenerator::get_state);
+
ClassDB::bind_method(D_METHOD("randi"), &RandomNumberGenerator::randi);
ClassDB::bind_method(D_METHOD("randf"), &RandomNumberGenerator::randf);
ClassDB::bind_method(D_METHOD("randfn", "mean", "deviation"), &RandomNumberGenerator::randfn, DEFVAL(0.0), DEFVAL(1.0));
@@ -42,6 +45,8 @@ void RandomNumberGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("randomize"), &RandomNumberGenerator::randomize);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
- // Default value is non-deterministic, override it for doc generation purposes.
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "state"), "set_state", "get_state");
+ // Default values are non-deterministic, override for doc generation purposes.
ADD_PROPERTY_DEFAULT("seed", 0);
+ ADD_PROPERTY_DEFAULT("state", 0);
}
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h
index 0d0ea17205..7728fd09c0 100644
--- a/core/math/random_number_generator.h
+++ b/core/math/random_number_generator.h
@@ -44,19 +44,17 @@ protected:
public:
_FORCE_INLINE_ void set_seed(uint64_t p_seed) { randbase.seed(p_seed); }
-
_FORCE_INLINE_ uint64_t get_seed() { return randbase.get_seed(); }
+ _FORCE_INLINE_ void set_state(uint64_t p_state) { randbase.set_state(p_state); }
+ _FORCE_INLINE_ uint64_t get_state() const { return randbase.get_state(); }
+
_FORCE_INLINE_ void randomize() { randbase.randomize(); }
_FORCE_INLINE_ uint32_t randi() { return randbase.rand(); }
-
_FORCE_INLINE_ real_t randf() { return randbase.randf(); }
-
_FORCE_INLINE_ real_t randf_range(real_t p_from, real_t p_to) { return randbase.random(p_from, p_to); }
-
_FORCE_INLINE_ real_t randfn(real_t p_mean = 0.0, real_t p_deviation = 1.0) { return randbase.randfn(p_mean, p_deviation); }
-
_FORCE_INLINE_ int randi_range(int p_from, int p_to) { return randbase.random(p_from, p_to); }
RandomNumberGenerator() {}
diff --git a/core/math/random_pcg.h b/core/math/random_pcg.h
index fe6b1b5639..2e257cb5b7 100644
--- a/core/math/random_pcg.h
+++ b/core/math/random_pcg.h
@@ -61,7 +61,7 @@ static int __bsr_clz32(uint32_t x) {
class RandomPCG {
pcg32_random_t pcg;
- uint64_t current_seed; // seed with this to get the same state
+ uint64_t current_seed; // The seed the current generator state started from.
uint64_t current_inc;
public:
@@ -76,13 +76,14 @@ public:
}
_FORCE_INLINE_ uint64_t get_seed() { return current_seed; }
+ _FORCE_INLINE_ void set_state(uint64_t p_state) { pcg.state = p_state; }
+ _FORCE_INLINE_ uint64_t get_state() const { return pcg.state; }
+
void randomize();
_FORCE_INLINE_ uint32_t rand() {
- current_seed = pcg.state;
return pcg32_random_r(&pcg);
}
_FORCE_INLINE_ uint32_t rand(uint32_t bounds) {
- current_seed = pcg.state;
return pcg32_boundedrand_r(&pcg, bounds);
}
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 23f5bb88fe..09354d8e79 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -72,39 +72,6 @@ Vector3 Vector3::snapped(Vector3 p_val) const {
return v;
}
-Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
- Vector3 p0 = p_pre_a;
- Vector3 p1 = *this;
- Vector3 p2 = p_b;
- Vector3 p3 = p_post_b;
-
- {
- //normalize
-
- real_t ab = p0.distance_to(p1);
- real_t bc = p1.distance_to(p2);
- real_t cd = p2.distance_to(p3);
-
- if (ab > 0) {
- p0 = p1 + (p0 - p1) * (bc / ab);
- }
- if (cd > 0) {
- p3 = p2 + (p3 - p2) * (bc / cd);
- }
- }
-
- real_t t = p_weight;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- Vector3 out;
- out = 0.5 * ((p1 * 2.0) +
- (-p0 + p2) * t +
- (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3) * t2 +
- (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3);
- return out;
-}
-
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
Vector3 p0 = p_pre_a;
Vector3 p1 = *this;
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 69e79627f3..5af84377fd 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -89,7 +89,6 @@ struct Vector3 {
_FORCE_INLINE_ Vector3 lerp(const Vector3 &p_to, real_t p_weight) const;
_FORCE_INLINE_ Vector3 slerp(const Vector3 &p_to, real_t p_weight) const;
Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
- Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
Vector3 move_toward(const Vector3 &p_to, const real_t p_delta) const;
_FORCE_INLINE_ Vector3 cross(const Vector3 &p_b) const;
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index dc28fa10de..f5171f60ec 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -243,8 +243,11 @@ HashMap<StringName, StringName> ClassDB::resource_base_extensions;
HashMap<StringName, StringName> ClassDB::compat_classes;
bool ClassDB::_is_parent_class(const StringName &p_class, const StringName &p_inherits) {
- StringName inherits = p_class;
+ if (!classes.has(p_class)) {
+ return false;
+ }
+ StringName inherits = p_class;
while (inherits.operator String().length()) {
if (inherits == p_inherits) {
return true;
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 3764316122..681e1188ff 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -823,10 +823,6 @@ void Object::property_list_changed_notify() {
_change_notify();
}
-void Object::cancel_delete() {
- _predelete_ok = true;
-}
-
void Object::set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance) {
//this function is not meant to be used in any of these ways
ERR_FAIL_COND(p_script.is_null());
diff --git a/core/object/object.h b/core/object/object.h
index 5bf9600c5a..dc004f38a9 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -525,8 +525,6 @@ protected:
static void get_valid_parents_static(List<String> *p_parents);
static void _get_valid_parents_static(List<String> *p_parents);
- void cancel_delete();
-
virtual void _changed_callback(Object *p_changed, const char *p_prop);
//Variant _call_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant());
diff --git a/core/object/script_language.h b/core/object/script_language.h
index ddd884a4f3..f5d65cf42d 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -274,8 +274,6 @@ class ScriptCodeCompletionCache {
static ScriptCodeCompletionCache *singleton;
public:
- virtual RES get_cached_resource(const String &p_path) = 0;
-
static ScriptCodeCompletionCache *get_singleton() { return singleton; }
ScriptCodeCompletionCache();
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index b962f61e1f..aa95f06cff 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -349,7 +349,7 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
strings.push_back(current);
current = String();
} else if (c == '"') {
- if (l[i + 1] == '"') {
+ if (l[i + 1] == '"' && in_quote) {
s[0] = '"';
current += s;
i++;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 552bf043bf..9400565484 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -505,12 +505,8 @@ void OS::add_frame_delay(bool p_can_draw) {
}
OS::OS() {
- void *volatile stack_bottom;
-
singleton = this;
- _stack_bottom = (void *)(&stack_bottom);
-
Vector<Logger *> loggers;
loggers.push_back(memnew(StdLogger));
_set_logger(memnew(CompositeLogger(loggers)));
diff --git a/core/os/os.h b/core/os/os.h
index 40104b479b..3c79d7bb87 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -62,8 +62,6 @@ class OS {
char *last_error;
- void *_stack_bottom;
-
CompositeLogger *_logger = nullptr;
bool restart_on_exit = false;
diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp
index 4d152d9258..a63dde5b41 100644
--- a/core/string/node_path.cpp
+++ b/core/string/node_path.cpp
@@ -288,7 +288,7 @@ void NodePath::simplify() {
if (data->path[i].operator String() == ".") {
data->path.remove(i);
i--;
- } else if (data->path[i].operator String() == ".." && i > 0 && data->path[i - 1].operator String() != "." && data->path[i - 1].operator String() != "..") {
+ } else if (i > 0 && data->path[i].operator String() == ".." && data->path[i - 1].operator String() != "." && data->path[i - 1].operator String() != "..") {
//remove both
data->path.remove(i - 1);
data->path.remove(i - 1);
diff --git a/core/variant/variant.h b/core/variant/variant.h
index d87078b5da..76c936a7bd 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -511,7 +511,7 @@ public:
/* Constructors */
- typedef void (*ValidatedConstructor)(Variant &r_base, const Variant **p_args);
+ typedef void (*ValidatedConstructor)(Variant *r_base, const Variant **p_args);
typedef void (*PTRConstructor)(void *base, const void **p_args);
static int get_constructor_count(Variant::Type p_type);
@@ -550,8 +550,8 @@ public:
static bool has_indexing(Variant::Type p_type);
static Variant::Type get_indexed_element_type(Variant::Type p_type);
- typedef void (*ValidatedIndexedSetter)(Variant *base, int64_t index, const Variant *value, bool &oob);
- typedef void (*ValidatedIndexedGetter)(const Variant *base, int64_t index, Variant *value, bool &oob);
+ typedef void (*ValidatedIndexedSetter)(Variant *base, int64_t index, const Variant *value, bool *oob);
+ typedef void (*ValidatedIndexedGetter)(const Variant *base, int64_t index, Variant *value, bool *oob);
static ValidatedIndexedSetter get_member_validated_indexed_setter(Variant::Type p_type);
static ValidatedIndexedGetter get_member_validated_indexed_getter(Variant::Type p_type);
@@ -571,9 +571,9 @@ public:
static bool is_keyed(Variant::Type p_type);
- typedef void (*ValidatedKeyedSetter)(Variant *base, const Variant *key, const Variant *value, bool &valid);
- typedef void (*ValidatedKeyedGetter)(const Variant *base, const Variant *key, Variant *value, bool &valid);
- typedef bool (*ValidatedKeyedChecker)(const Variant *base, const Variant *key, bool &valid);
+ typedef void (*ValidatedKeyedSetter)(Variant *base, const Variant *key, const Variant *value, bool *valid);
+ typedef void (*ValidatedKeyedGetter)(const Variant *base, const Variant *key, Variant *value, bool *valid);
+ typedef bool (*ValidatedKeyedChecker)(const Variant *base, const Variant *key, bool *valid);
static ValidatedKeyedSetter get_member_validated_keyed_setter(Variant::Type p_type);
static ValidatedKeyedGetter get_member_validated_keyed_getter(Variant::Type p_type);
diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp
index 02866b4475..732e7a26f2 100644
--- a/core/variant/variant_construct.cpp
+++ b/core/variant/variant_construct.cpp
@@ -123,9 +123,9 @@ public:
construct_helper(*VariantGetInternalPtr<T>::get_ptr(&r_ret), p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantTypeChanger<T>::change(&r_ret);
- validated_construct_helper(*VariantGetInternalPtr<T>::get_ptr(&r_ret), p_args, BuildIndexSequence<sizeof...(P)>{});
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<T>::change(r_ret);
+ validated_construct_helper(*VariantGetInternalPtr<T>::get_ptr(r_ret), p_args, BuildIndexSequence<sizeof...(P)>{});
}
static void ptr_construct(void *base, const void **p_args) {
ptr_construct_helper(base, p_args, BuildIndexSequence<sizeof...(P)>{});
@@ -161,9 +161,9 @@ public:
}
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantInternal::clear(&r_ret);
- VariantInternal::object_assign(&r_ret, p_args[0]);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ VariantInternal::object_assign(r_ret, p_args[0]);
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<Object *>::construct(PtrToArg<Object *>::convert(p_args[0]), base);
@@ -195,9 +195,9 @@ public:
VariantInternal::object_assign_null(&r_ret);
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantInternal::clear(&r_ret);
- VariantInternal::object_assign_null(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ VariantInternal::object_assign_null(r_ret);
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<Object *>::construct(nullptr, base);
@@ -248,9 +248,9 @@ public:
*VariantGetInternalPtr<Callable>::get_ptr(&r_ret) = Callable(object_id, method);
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantTypeChanger<Callable>::change(&r_ret);
- *VariantGetInternalPtr<Callable>::get_ptr(&r_ret) = Callable(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<Callable>::change(r_ret);
+ *VariantGetInternalPtr<Callable>::get_ptr(r_ret) = Callable(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<Callable>::construct(Callable(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base);
@@ -305,9 +305,9 @@ public:
*VariantGetInternalPtr<Signal>::get_ptr(&r_ret) = Signal(object_id, method);
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantTypeChanger<Signal>::change(&r_ret);
- *VariantGetInternalPtr<Signal>::get_ptr(&r_ret) = Signal(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<Signal>::change(r_ret);
+ *VariantGetInternalPtr<Signal>::get_ptr(r_ret) = Signal(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]));
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<Signal>::construct(Signal(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base);
@@ -352,9 +352,9 @@ public:
}
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantTypeChanger<Array>::change(&r_ret);
- Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<Array>::change(r_ret);
+ Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(r_ret);
const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]);
int size = src_arr.size();
@@ -411,10 +411,10 @@ public:
}
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantTypeChanger<T>::change(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<T>::change(r_ret);
const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]);
- T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(&r_ret);
+ T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(r_ret);
int size = src_arr.size();
dst_arr.resize(size);
@@ -462,8 +462,8 @@ public:
VariantInternal::clear(&r_ret);
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantInternal::clear(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<Variant>::construct(Variant(), base);
@@ -490,8 +490,8 @@ public:
r_error.error = Callable::CallError::CALL_OK;
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantTypeChanger<T>::change_and_reset(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantTypeChanger<T>::change_and_reset(r_ret);
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<T>::construct(T(), base);
@@ -517,8 +517,8 @@ public:
r_error.error = Callable::CallError::CALL_OK;
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantInternal::clear(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
}
static void ptr_construct(void *base, const void **p_args) {
ERR_FAIL_MSG("can't ptrcall nil constructor");
@@ -545,9 +545,9 @@ public:
r_error.error = Callable::CallError::CALL_OK;
}
- static void validated_construct(Variant &r_ret, const Variant **p_args) {
- VariantInternal::clear(&r_ret);
- VariantInternal::object_assign_null(&r_ret);
+ static void validated_construct(Variant *r_ret, const Variant **p_args) {
+ VariantInternal::clear(r_ret);
+ VariantInternal::object_assign_null(r_ret);
}
static void ptr_construct(void *base, const void **p_args) {
PtrConstruct<Object *>::construct(nullptr, base);
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index f6a2c11830..cee7465205 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -582,18 +582,18 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_TYPED(m_base_type, m_elem_type) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
+ *oob = true; \
return; \
} \
VariantTypeAdjust<m_elem_type>::adjust(value); \
*VariantGetInternalPtr<m_elem_type>::get_ptr(value) = (*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index]; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -603,10 +603,10 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, v.size()); \
PtrToArg<m_elem_type>::encode(v[index], member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
if (value->get_type() != GetTypeInfo<m_elem_type>::VARIANT_TYPE) { \
- oob = false; \
- valid = false; \
+ *oob = false; \
+ *valid = false; \
return; \
} \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
@@ -614,25 +614,25 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
- valid = false; \
+ *oob = true; \
+ *valid = false; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base)).write[index] = *VariantGetInternalPtr<m_elem_type>::get_ptr(value); \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
+ *oob = true; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base)).write[index] = *VariantGetInternalPtr<m_elem_type>::get_ptr(value); \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -648,18 +648,18 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_TYPED_NUMERIC(m_base_type, m_elem_type, m_assign_type) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
+ *oob = true; \
return; \
} \
VariantTypeAdjust<m_elem_type>::adjust(value); \
*VariantGetInternalPtr<m_elem_type>::get_ptr(value) = (*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index]; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -669,14 +669,14 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, v.size()); \
PtrToArg<m_elem_type>::encode(v[index], member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
- valid = false; \
+ *oob = true; \
+ *valid = false; \
return; \
} \
m_assign_type num; \
@@ -685,25 +685,25 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
} else if (value->get_type() == Variant::FLOAT) { \
num = (m_assign_type)*VariantGetInternalPtr<double>::get_ptr(value); \
} else { \
- oob = false; \
- valid = false; \
+ *oob = false; \
+ *valid = false; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base)).write[index] = num; \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
+ *oob = true; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base)).write[index] = *VariantGetInternalPtr<m_elem_type>::get_ptr(value); \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -719,14 +719,14 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(m_base_type, m_elem_type, m_assign_type, m_max) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
+ *oob = true; \
return; \
} \
VariantTypeAdjust<m_elem_type>::adjust(value); \
*VariantGetInternalPtr<m_elem_type>::get_ptr(value) = (*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index]; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -734,10 +734,10 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, m_max); \
PtrToArg<m_elem_type>::encode(v[index], member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
- valid = false; \
+ *oob = true; \
+ *valid = false; \
return; \
} \
m_assign_type num; \
@@ -746,21 +746,21 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
} else if (value->get_type() == Variant::FLOAT) { \
num = (m_assign_type)*VariantGetInternalPtr<double>::get_ptr(value); \
} else { \
- oob = false; \
- valid = false; \
+ *oob = false; \
+ *valid = false; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index] = num; \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
+ *oob = true; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index] = *VariantGetInternalPtr<m_elem_type>::get_ptr(value); \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -774,14 +774,14 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_BULTIN_ACCESSOR(m_base_type, m_elem_type, m_accessor, m_max) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
+ *oob = true; \
return; \
} \
VariantTypeAdjust<m_elem_type>::adjust(value); \
*VariantGetInternalPtr<m_elem_type>::get_ptr(value) = (*VariantGetInternalPtr<m_base_type>::get_ptr(base))m_accessor[index]; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -789,27 +789,27 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, m_max); \
PtrToArg<m_elem_type>::encode(v m_accessor[index], member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
if (value->get_type() != GetTypeInfo<m_elem_type>::VARIANT_TYPE) { \
- oob = false; \
- valid = false; \
+ *oob = false; \
+ *valid = false; \
} \
if (index < 0 || index >= m_max) { \
- oob = true; \
- valid = false; \
+ *oob = true; \
+ *valid = false; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base)) m_accessor[index] = *VariantGetInternalPtr<m_elem_type>::get_ptr(value); \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
+ *oob = true; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base)) m_accessor[index] = *VariantGetInternalPtr<m_elem_type>::get_ptr(value); \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -823,14 +823,14 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_BULTIN_FUNC(m_base_type, m_elem_type, m_set, m_get, m_max) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
+ *oob = true; \
return; \
} \
VariantTypeAdjust<m_elem_type>::adjust(value); \
*VariantGetInternalPtr<m_elem_type>::get_ptr(value) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_get(index); \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -838,27 +838,27 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, m_max); \
PtrToArg<m_elem_type>::encode(v.m_get(index), member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
if (value->get_type() != GetTypeInfo<m_elem_type>::VARIANT_TYPE) { \
- oob = false; \
- valid = false; \
+ *oob = false; \
+ *valid = false; \
} \
if (index < 0 || index >= m_max) { \
- oob = true; \
- valid = false; \
+ *oob = true; \
+ *valid = false; \
return; \
} \
VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_set(index, *VariantGetInternalPtr<m_elem_type>::get_ptr(value)); \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
if (index < 0 || index >= m_max) { \
- oob = true; \
+ *oob = true; \
return; \
} \
VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_set(index, *VariantGetInternalPtr<m_elem_type>::get_ptr(value)); \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -872,17 +872,17 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_VARIANT(m_base_type) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
+ *oob = true; \
return; \
} \
*value = (*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index]; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -892,31 +892,31 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
OOB_TEST(index, v.size()); \
PtrToArg<Variant>::encode(v[index], member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
- valid = false; \
+ *oob = true; \
+ *valid = false; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index] = *value; \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
int64_t size = VariantGetInternalPtr<m_base_type>::get_ptr(base)->size(); \
if (index < 0) { \
index += size; \
} \
if (index < 0 || index >= size) { \
- oob = true; \
+ *oob = true; \
return; \
} \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index] = *value; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -932,14 +932,14 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
#define INDEXED_SETGET_STRUCT_DICT(m_base_type) \
struct VariantIndexedSetGet_##m_base_type { \
- static void get(const Variant *base, int64_t index, Variant *value, bool &oob) { \
+ static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \
const Variant *ptr = VariantGetInternalPtr<m_base_type>::get_ptr(base)->getptr(index); \
if (!ptr) { \
- oob = true; \
+ *oob = true; \
return; \
} \
*value = *ptr; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_get(const void *base, int64_t index, void *member) { \
/* avoid ptrconvert for performance*/ \
@@ -948,14 +948,14 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const {
NULL_TEST(ptr); \
PtrToArg<Variant>::encode(*ptr, member); \
} \
- static void set(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob) { \
+ static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index] = *value; \
- oob = false; \
- valid = true; \
+ *oob = false; \
+ *valid = true; \
} \
- static void validated_set(Variant *base, int64_t index, const Variant *value, bool &oob) { \
+ static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \
(*VariantGetInternalPtr<m_base_type>::get_ptr(base))[index] = *value; \
- oob = false; \
+ *oob = false; \
} \
static void ptr_set(void *base, int64_t index, const void *member) { \
m_base_type &v = *reinterpret_cast<m_base_type *>(base); \
@@ -989,8 +989,8 @@ INDEXED_SETGET_STRUCT_VARIANT(Array)
INDEXED_SETGET_STRUCT_DICT(Dictionary)
struct VariantIndexedSetterGetterInfo {
- void (*setter)(Variant *base, int64_t index, const Variant *value, bool &valid, bool &oob);
- void (*getter)(const Variant *base, int64_t index, Variant *value, bool &oob);
+ void (*setter)(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob);
+ void (*getter)(const Variant *base, int64_t index, Variant *value, bool *oob);
Variant::ValidatedIndexedSetter validated_setter;
Variant::ValidatedIndexedGetter validated_getter;
@@ -1083,7 +1083,7 @@ Variant::PTRIndexedGetter Variant::get_member_ptr_indexed_getter(Variant::Type p
void Variant::set_indexed(int64_t p_index, const Variant &p_value, bool &r_valid, bool &r_oob) {
if (likely(variant_indexed_setters_getters[type].valid)) {
- variant_indexed_setters_getters[type].setter(this, p_index, &p_value, r_valid, r_oob);
+ variant_indexed_setters_getters[type].setter(this, p_index, &p_value, &r_valid, &r_oob);
} else {
r_valid = false;
r_oob = false;
@@ -1092,7 +1092,7 @@ void Variant::set_indexed(int64_t p_index, const Variant &p_value, bool &r_valid
Variant Variant::get_indexed(int64_t p_index, bool &r_valid, bool &r_oob) const {
if (likely(variant_indexed_setters_getters[type].valid)) {
Variant ret;
- variant_indexed_setters_getters[type].getter(this, p_index, &ret, r_oob);
+ variant_indexed_setters_getters[type].getter(this, p_index, &ret, &r_oob);
r_valid = !r_oob;
return ret;
} else {
@@ -1111,14 +1111,14 @@ uint64_t Variant::get_indexed_size() const {
}
struct VariantKeyedSetGetDictionary {
- static void get(const Variant *base, const Variant *key, Variant *value, bool &r_valid) {
+ static void get(const Variant *base, const Variant *key, Variant *value, bool *r_valid) {
const Variant *ptr = VariantGetInternalPtr<Dictionary>::get_ptr(base)->getptr(*key);
if (!ptr) {
- r_valid = false;
+ *r_valid = false;
return;
}
*value = *ptr;
- r_valid = true;
+ *r_valid = true;
}
static void ptr_get(const void *base, const void *key, void *value) {
/* avoid ptrconvert for performance*/
@@ -1127,17 +1127,17 @@ struct VariantKeyedSetGetDictionary {
NULL_TEST(ptr);
PtrToArg<Variant>::encode(*ptr, value);
}
- static void set(Variant *base, const Variant *key, const Variant *value, bool &r_valid) {
+ static void set(Variant *base, const Variant *key, const Variant *value, bool *r_valid) {
(*VariantGetInternalPtr<Dictionary>::get_ptr(base))[*key] = *value;
- r_valid = true;
+ *r_valid = true;
}
static void ptr_set(void *base, const void *key, const void *value) {
Dictionary &v = *reinterpret_cast<Dictionary *>(base);
v[PtrToArg<Variant>::convert(key)] = PtrToArg<Variant>::convert(value);
}
- static bool has(const Variant *base, const Variant *key, bool &r_valid) {
- r_valid = true;
+ static bool has(const Variant *base, const Variant *key, bool *r_valid) {
+ *r_valid = true;
return VariantGetInternalPtr<Dictionary>::get_ptr(base)->has(*key);
}
static bool ptr_has(const void *base, const void *key) {
@@ -1148,15 +1148,15 @@ struct VariantKeyedSetGetDictionary {
};
struct VariantKeyedSetGetObject {
- static void get(const Variant *base, const Variant *key, Variant *value, bool &r_valid) {
+ static void get(const Variant *base, const Variant *key, Variant *value, bool *r_valid) {
Object *obj = base->get_validated_object();
if (!obj) {
- r_valid = false;
+ *r_valid = false;
*value = Variant();
return;
}
- *value = obj->getvar(*key, &r_valid);
+ *value = obj->getvar(*key, r_valid);
}
static void ptr_get(const void *base, const void *key, void *value) {
const Object *obj = PtrToArg<Object *>::convert(base);
@@ -1164,14 +1164,14 @@ struct VariantKeyedSetGetObject {
Variant v = obj->getvar(PtrToArg<Variant>::convert(key));
PtrToArg<Variant>::encode(v, value);
}
- static void set(Variant *base, const Variant *key, const Variant *value, bool &r_valid) {
+ static void set(Variant *base, const Variant *key, const Variant *value, bool *r_valid) {
Object *obj = base->get_validated_object();
if (!obj) {
- r_valid = false;
+ *r_valid = false;
return;
}
- obj->setvar(*key, *value, &r_valid);
+ obj->setvar(*key, *value, r_valid);
}
static void ptr_set(void *base, const void *key, const void *value) {
Object *obj = PtrToArg<Object *>::convert(base);
@@ -1179,13 +1179,13 @@ struct VariantKeyedSetGetObject {
obj->setvar(PtrToArg<Variant>::convert(key), PtrToArg<Variant>::convert(value));
}
- static bool has(const Variant *base, const Variant *key, bool &r_valid) {
+ static bool has(const Variant *base, const Variant *key, bool *r_valid) {
Object *obj = base->get_validated_object();
- if (obj != nullptr) {
- r_valid = false;
+ if (!obj) {
+ *r_valid = false;
return false;
}
- r_valid = true;
+ *r_valid = true;
bool exists;
obj->getvar(*key, &exists);
return exists;
@@ -1199,14 +1199,6 @@ struct VariantKeyedSetGetObject {
}
};
-/*typedef void (*ValidatedKeyedSetter)(Variant *base, const Variant *key, const Variant *value);
-typedef void (*ValidatedKeyedGetter)(const Variant *base, const Variant *key, Variant *value, bool &valid);
-typedef bool (*ValidatedKeyedChecker)(const Variant *base, const Variant *key);
-
-typedef void (*PTRKeyedSetter)(void *base, const void *key, const void *value);
-typedef void (*PTRKeyedGetter)(const void *base, const void *key, void *value);
-typedef bool (*PTRKeyedChecker)(const void *base, const void *key);*/
-
struct VariantKeyedSetterGetterInfo {
Variant::ValidatedKeyedSetter validated_setter;
Variant::ValidatedKeyedGetter validated_getter;
@@ -1274,7 +1266,7 @@ Variant::PTRKeyedChecker Variant::get_member_ptr_keyed_checker(Variant::Type p_t
void Variant::set_keyed(const Variant &p_key, const Variant &p_value, bool &r_valid) {
if (likely(variant_keyed_setters_getters[type].valid)) {
- variant_keyed_setters_getters[type].validated_setter(this, &p_key, &p_value, r_valid);
+ variant_keyed_setters_getters[type].validated_setter(this, &p_key, &p_value, &r_valid);
} else {
r_valid = false;
}
@@ -1282,7 +1274,7 @@ void Variant::set_keyed(const Variant &p_key, const Variant &p_value, bool &r_va
Variant Variant::get_keyed(const Variant &p_key, bool &r_valid) const {
if (likely(variant_keyed_setters_getters[type].valid)) {
Variant ret;
- variant_keyed_setters_getters[type].validated_getter(this, &p_key, &ret, r_valid);
+ variant_keyed_setters_getters[type].validated_getter(this, &p_key, &ret, &r_valid);
return ret;
} else {
r_valid = false;
@@ -1291,7 +1283,7 @@ Variant Variant::get_keyed(const Variant &p_key, bool &r_valid) const {
}
bool Variant::has_key(const Variant &p_key, bool &r_valid) const {
if (likely(variant_keyed_setters_getters[type].valid)) {
- return variant_keyed_setters_getters[type].validated_checker(this, &p_key, r_valid);
+ return variant_keyed_setters_getters[type].validated_checker(this, &p_key, &r_valid);
} else {
r_valid = false;
return false;