summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp4
-rw-r--r--core/bind/core_bind.h4
-rw-r--r--core/callable_method_pointer.h17
-rw-r--r--core/compressed_translation.cpp4
-rw-r--r--core/global_constants.cpp28
-rw-r--r--core/io/json.cpp8
-rw-r--r--core/io/marshalls.cpp127
-rw-r--r--core/io/multiplayer_api.cpp111
-rw-r--r--core/io/resource_format_binary.cpp111
-rw-r--r--core/math/a_star.cpp4
-rw-r--r--core/math/expression.cpp12
-rw-r--r--core/method_ptrcall.h6
-rw-r--r--core/object.cpp14
-rw-r--r--core/os/input_event.cpp12
-rw-r--r--core/os/main_loop.cpp4
-rw-r--r--core/packed_data_container.cpp8
-rw-r--r--core/reference.h1
-rw-r--r--core/type_info.h24
-rw-r--r--core/variant.cpp512
-rw-r--r--core/variant.h122
-rw-r--r--core/variant_call.cpp473
-rw-r--r--core/variant_op.cpp779
-rw-r--r--core/variant_parser.cpp120
23 files changed, 1686 insertions, 819 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index f5a351f16a..c1cf061854 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -3101,8 +3101,8 @@ void _Engine::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_hint"), "set_editor_hint", "is_editor_hint");
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations_per_second"), "set_iterations_per_second", "get_iterations_per_second");
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_scale"), "set_time_scale", "get_time_scale");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_scale"), "set_time_scale", "get_time_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix");
}
_Engine *_Engine::singleton = NULL;
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 342c43802e..ae569ea189 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -581,9 +581,9 @@ private:
bool _list_skip_hidden;
};
-class _Marshalls : public Reference {
+class _Marshalls : public Object {
- GDCLASS(_Marshalls, Reference);
+ GDCLASS(_Marshalls, Object);
static _Marshalls *singleton;
diff --git a/core/callable_method_pointer.h b/core/callable_method_pointer.h
index fed793dfca..a931a344e6 100644
--- a/core/callable_method_pointer.h
+++ b/core/callable_method_pointer.h
@@ -134,7 +134,7 @@ void call_with_variant_args_helper(T *p_instance, void (T::*p_method)(P...), con
#ifdef DEBUG_METHODS_ENABLED
(p_instance->*p_method)(VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...);
#else
- (p_instance->*p_method)(VariantCaster<P...>::cast(p_args[Is])...);
+ (p_instance->*p_method)(VariantCaster<P>::cast(p_args[Is])...);
#endif
}
@@ -201,6 +201,15 @@ Callable create_custom_callable_function_pointer(T *p_instance,
// VERSION WITH RETURN
+// GCC 8 raises "parameter 'p_args' set but not used" here, probably using a
+// template version that does not have arguments and thus sees it unused, but
+// obviously the template can be used for functions with and without them, and
+// the optimizer will get rid of it anyway.
+#if defined(DEBUG_METHODS_ENABLED) && defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
+#endif
+
template <class T, class R, class... P, size_t... Is>
void call_with_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, Variant &r_ret, Callable::CallError &r_error, IndexSequence<Is...>) {
r_error.error = Callable::CallError::CALL_OK;
@@ -208,10 +217,14 @@ void call_with_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), co
#ifdef DEBUG_METHODS_ENABLED
r_ret = (p_instance->*p_method)(VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...);
#else
- (p_instance->*p_method)(VariantCaster<P...>::cast(p_args[Is])...);
+ (p_instance->*p_method)(VariantCaster<P>::cast(p_args[Is])...);
#endif
}
+#if defined(DEBUG_METHODS_ENABLED) && defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
template <class T, class R, class... P>
void call_with_variant_args_ret(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
#ifdef DEBUG_METHODS_ENABLED
diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp
index ea84ded3b4..ed307fd3ac 100644
--- a/core/compressed_translation.cpp
+++ b/core/compressed_translation.cpp
@@ -279,8 +279,8 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
void PHashTranslation::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::PACKED_INT_ARRAY, "hash_table"));
- p_list->push_back(PropertyInfo(Variant::PACKED_INT_ARRAY, "bucket_table"));
+ p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "hash_table"));
+ p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "bucket_table"));
p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "strings"));
p_list->push_back(PropertyInfo(Variant::OBJECT, "load_from", PROPERTY_HINT_RESOURCE_TYPE, "Translation", PROPERTY_USAGE_EDITOR));
}
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 3de36dcb9d..0945240c1f 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -92,9 +92,6 @@ VARIANT_ENUM_CAST(JoystickList);
VARIANT_ENUM_CAST(MidiMessageList);
void register_global_constants() {
-
- //{ KEY_BACKSPACE, VK_BACK },// (0x08) // backspace
-
BIND_GLOBAL_ENUM_CONSTANT(MARGIN_LEFT);
BIND_GLOBAL_ENUM_CONSTANT(MARGIN_TOP);
BIND_GLOBAL_ENUM_CONSTANT(MARGIN_RIGHT);
@@ -116,7 +113,7 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(VALIGN_CENTER);
BIND_GLOBAL_ENUM_CONSTANT(VALIGN_BOTTOM);
- // hueg list of keys
+ // huge list of keys
BIND_GLOBAL_CONSTANT(SPKEY);
BIND_GLOBAL_ENUM_CONSTANT(KEY_ESCAPE);
@@ -594,31 +591,36 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NIL", Variant::NIL);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BOOL", Variant::BOOL);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT", Variant::INT);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL", Variant::REAL);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL", Variant::FLOAT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING", Variant::STRING);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2", Variant::VECTOR2); // 5
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2", Variant::VECTOR2);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2I", Variant::VECTOR2I);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT2", Variant::RECT2);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT2I", Variant::RECT2I);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3", Variant::VECTOR3);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3I", Variant::VECTOR3I);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_NAME", Variant::STRING_NAME); // 15
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NODE_PATH", Variant::NODE_PATH); // 15
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_NAME", Variant::STRING_NAME);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NODE_PATH", Variant::NODE_PATH);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RID", Variant::_RID);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_OBJECT", Variant::OBJECT);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_CALLABLE", Variant::CALLABLE);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_SIGNAL", Variant::SIGNAL);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY); // 20
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_ARRAY", Variant::ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RAW_ARRAY", Variant::PACKED_BYTE_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT_ARRAY", Variant::PACKED_INT_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL_ARRAY", Variant::PACKED_REAL_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT32_ARRAY", Variant::PACKED_INT32_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT64_ARRAY", Variant::PACKED_INT64_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_FLOAT32_ARRAY", Variant::PACKED_FLOAT32_ARRAY);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_FLOAT64_ARRAY", Variant::PACKED_FLOAT64_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_ARRAY", Variant::PACKED_STRING_ARRAY);
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::PACKED_VECTOR2_ARRAY); // 25
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::PACKED_VECTOR2_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3_ARRAY", Variant::PACKED_VECTOR3_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR_ARRAY", Variant::PACKED_COLOR_ARRAY);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_MAX", Variant::VARIANT_MAX);
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 08a147032f..3a0edceb81 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -70,9 +70,11 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
case Variant::NIL: return "null";
case Variant::BOOL: return p_var.operator bool() ? "true" : "false";
case Variant::INT: return itos(p_var);
- case Variant::REAL: return rtos(p_var);
- case Variant::PACKED_INT_ARRAY:
- case Variant::PACKED_REAL_ARRAY:
+ case Variant::FLOAT: return rtos(p_var);
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::ARRAY: {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index e97c26e05d..fbcaa582b7 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -147,7 +147,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
} break;
- case Variant::REAL: {
+ case Variant::FLOAT: {
if (type & ENCODE_FLAG_64) {
ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
@@ -186,7 +186,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += 4 * 2;
- } break; // 5
+ } break;
case Variant::VECTOR2I: {
ERR_FAIL_COND_V(len < 4 * 2, ERR_INVALID_DATA);
@@ -198,7 +198,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += 4 * 2;
- } break; // 5
+ } break;
case Variant::RECT2: {
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
@@ -621,7 +621,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
} break;
- case Variant::PACKED_INT_ARRAY: {
+ case Variant::PACKED_INT32_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -630,12 +630,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_MUL_OF(count, 4, ERR_INVALID_DATA);
ERR_FAIL_COND_V(count < 0 || count * 4 > len, ERR_INVALID_DATA);
- Vector<int> data;
+ Vector<int32_t> data;
if (count) {
//const int*rbuf=(const int*)buf;
data.resize(count);
- int *w = data.ptrw();
+ int32_t *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
w[i] = decode_uint32(&buf[i * 4]);
@@ -643,11 +643,37 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
r_variant = Variant(data);
if (r_len) {
- (*r_len) += 4 + count * sizeof(int);
+ (*r_len) += 4 + count * sizeof(int32_t);
}
} break;
- case Variant::PACKED_REAL_ARRAY: {
+ case Variant::PACKED_INT64_ARRAY: {
+
+ ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+ int64_t count = decode_uint64(buf);
+ buf += 4;
+ len -= 4;
+ ERR_FAIL_MUL_OF(count, 8, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(count < 0 || count * 8 > len, ERR_INVALID_DATA);
+
+ Vector<int64_t> data;
+
+ if (count) {
+ //const int*rbuf=(const int*)buf;
+ data.resize(count);
+ int64_t *w = data.ptrw();
+ for (int64_t i = 0; i < count; i++) {
+
+ w[i] = decode_uint64(&buf[i * 8]);
+ }
+ }
+ r_variant = Variant(data);
+ if (r_len) {
+ (*r_len) += 4 + count * sizeof(int64_t);
+ }
+
+ } break;
+ case Variant::PACKED_FLOAT32_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -674,6 +700,33 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
} break;
+ case Variant::PACKED_FLOAT64_ARRAY: {
+
+ ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+ int64_t count = decode_uint64(buf);
+ buf += 4;
+ len -= 4;
+ ERR_FAIL_MUL_OF(count, 8, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(count < 0 || count * 8 > len, ERR_INVALID_DATA);
+
+ Vector<double> data;
+
+ if (count) {
+ //const double*rbuf=(const double*)buf;
+ data.resize(count);
+ double *w = data.ptrw();
+ for (int64_t i = 0; i < count; i++) {
+
+ w[i] = decode_double(&buf[i * 8]);
+ }
+ }
+ r_variant = data;
+
+ if (r_len) {
+ (*r_len) += 4 + count * sizeof(double);
+ }
+
+ } break;
case Variant::PACKED_STRING_ARRAY: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
@@ -851,7 +904,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
flags |= ENCODE_FLAG_64;
}
} break;
- case Variant::REAL: {
+ case Variant::FLOAT: {
double d = p_variant;
float f = d;
@@ -918,7 +971,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
}
} break;
- case Variant::REAL: {
+ case Variant::FLOAT: {
if (flags & ENCODE_FLAG_64) {
if (buf) {
@@ -1005,7 +1058,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 2 * 4;
- } break; // 5
+ } break;
case Variant::VECTOR2I: {
if (buf) {
@@ -1016,7 +1069,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 2 * 4;
- } break; // 5
+ } break;
case Variant::RECT2: {
if (buf) {
@@ -1333,33 +1386,50 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
- case Variant::PACKED_INT_ARRAY: {
+ case Variant::PACKED_INT32_ARRAY: {
- Vector<int> data = p_variant;
+ Vector<int32_t> data = p_variant;
int datalen = data.size();
int datasize = sizeof(int32_t);
if (buf) {
encode_uint32(datalen, buf);
buf += 4;
- const int *r = data.ptr();
- for (int i = 0; i < datalen; i++)
+ const int32_t *r = data.ptr();
+ for (int32_t i = 0; i < datalen; i++)
encode_uint32(r[i], &buf[i * datasize]);
}
r_len += 4 + datalen * datasize;
} break;
- case Variant::PACKED_REAL_ARRAY: {
+ case Variant::PACKED_INT64_ARRAY: {
+
+ Vector<int64_t> data = p_variant;
+ int datalen = data.size();
+ int datasize = sizeof(int64_t);
+
+ if (buf) {
+ encode_uint64(datalen, buf);
+ buf += 4;
+ const int64_t *r = data.ptr();
+ for (int64_t i = 0; i < datalen; i++)
+ encode_uint64(r[i], &buf[i * datasize]);
+ }
+
+ r_len += 4 + datalen * datasize;
+
+ } break;
+ case Variant::PACKED_FLOAT32_ARRAY: {
- Vector<real_t> data = p_variant;
+ Vector<float> data = p_variant;
int datalen = data.size();
- int datasize = sizeof(real_t);
+ int datasize = sizeof(float);
if (buf) {
encode_uint32(datalen, buf);
buf += 4;
- const real_t *r = data.ptr();
+ const float *r = data.ptr();
for (int i = 0; i < datalen; i++)
encode_float(r[i], &buf[i * datasize]);
}
@@ -1367,6 +1437,23 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 + datalen * datasize;
} break;
+ case Variant::PACKED_FLOAT64_ARRAY: {
+
+ Vector<double> data = p_variant;
+ int datalen = data.size();
+ int datasize = sizeof(double);
+
+ if (buf) {
+ encode_uint32(datalen, buf);
+ buf += 4;
+ const double *r = data.ptr();
+ for (int i = 0; i < datalen; i++)
+ encode_double(r[i], &buf[i * datasize]);
+ }
+
+ r_len += 4 + datalen * datasize;
+
+ } break;
case Variant::PACKED_STRING_ARRAY: {
Vector<String> data = p_variant;
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 6a0eeea513..2aef0a3274 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -34,6 +34,10 @@
#include "scene/main/node.h"
#include <stdint.h>
+#define NODE_ID_COMPRESSION_SHIFT 3
+#define NAME_ID_COMPRESSION_SHIFT 5
+#define BYTE_ONLY_OR_NO_ARGS_SHIFT 6
+
#ifdef DEBUG_ENABLED
#include "core/os/os.h"
#endif
@@ -168,6 +172,16 @@ Ref<NetworkedMultiplayerPeer> MultiplayerAPI::get_network_peer() const {
return network_peer;
}
+// Returns the packet size stripping the node path added when the node is not yet cached.
+int get_packet_len(uint32_t p_node_target, int p_packet_len) {
+ if (p_node_target & 0x80000000) {
+ int ofs = p_node_target & 0x7FFFFFFF;
+ return p_packet_len - (p_packet_len - ofs);
+ } else {
+ return p_packet_len;
+ }
+}
+
void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_FAIL_COND_MSG(root_node == NULL, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it.");
@@ -204,8 +218,8 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
int name_id_offset = 1;
ERR_FAIL_COND_MSG(p_packet_len < packet_min_size, "Invalid packet received. Size too small.");
// Compute the meta size, which depends on the compression level.
- int node_id_compression = (p_packet[0] & 24) >> 3;
- int name_id_compression = (p_packet[0] & 32) >> 5;
+ int node_id_compression = (p_packet[0] & 24) >> NODE_ID_COMPRESSION_SHIFT;
+ int name_id_compression = (p_packet[0] & 32) >> NAME_ID_COMPRESSION_SHIFT;
switch (node_id_compression) {
case NETWORK_NODE_ID_COMPRESSION_8:
@@ -250,6 +264,7 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
// Unreachable, checked before.
CRASH_NOW();
}
+
Node *node = _process_get_node(p_from, p_packet, node_target, p_packet_len);
ERR_FAIL_COND_MSG(node == NULL, "Invalid packet received. Requested node was not found.");
@@ -266,13 +281,14 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
CRASH_NOW();
}
+ const int packet_len = get_packet_len(node_target, p_packet_len);
if (packet_type == NETWORK_COMMAND_REMOTE_CALL) {
- _process_rpc(node, name_id, p_from, p_packet, p_packet_len, packet_min_size);
+ _process_rpc(node, name_id, p_from, p_packet, packet_len, packet_min_size);
} else {
- _process_rset(node, name_id, p_from, p_packet, p_packet_len, packet_min_size);
+ _process_rset(node, name_id, p_from, p_packet, packet_len, packet_min_size);
}
} break;
@@ -326,7 +342,7 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uin
void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
- ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
+ ERR_FAIL_COND_MSG(p_offset > p_packet_len, "Invalid packet received. Size too small.");
// Check that remote can call the RPC on this node.
StringName name = p_node->get_node_rpc_method(p_rpc_method_id);
@@ -340,14 +356,30 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id,
bool can_call = _can_call_mode(p_node, rpc_mode, p_from);
ERR_FAIL_COND_MSG(!can_call, "RPC '" + String(name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rpc_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
- int argc = p_packet[p_offset];
+ int argc = 0;
+ bool byte_only = false;
+
+ const bool byte_only_or_no_args = ((p_packet[0] & 64) >> BYTE_ONLY_OR_NO_ARGS_SHIFT) == 1;
+ if (byte_only_or_no_args) {
+ if (p_offset < p_packet_len) {
+ // This packet contains only bytes.
+ argc = 1;
+ byte_only = true;
+ } else {
+ // This rpc calls a method without parameters.
+ }
+ } else {
+ // Normal variant, takes the argument count from the packet.
+ ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
+ argc = p_packet[p_offset];
+ p_offset += 1;
+ }
+
Vector<Variant> args;
Vector<const Variant *> argp;
args.resize(argc);
argp.resize(argc);
- p_offset++;
-
#ifdef DEBUG_ENABLED
if (profiling) {
ObjectID id = p_node->get_instance_id();
@@ -356,16 +388,26 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id,
}
#endif
- for (int i = 0; i < argc; i++) {
+ if (byte_only) {
+ Vector<uint8_t> pure_data;
+ const int len = p_packet_len - p_offset;
+ pure_data.resize(len);
+ memcpy(pure_data.ptrw(), &p_packet[p_offset], len);
+ args.write[0] = pure_data;
+ argp.write[0] = &args[0];
+ p_offset += len;
+ } else {
+ for (int i = 0; i < argc; i++) {
- ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
+ ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
- int vlen;
- Error err = _decode_and_decompress_variant(args.write[i], &p_packet[p_offset], p_packet_len - p_offset, &vlen);
- ERR_FAIL_COND_MSG(err != OK, "Invalid packet received. Unable to decode RPC argument.");
+ int vlen;
+ Error err = _decode_and_decompress_variant(args.write[i], &p_packet[p_offset], p_packet_len - p_offset, &vlen);
+ ERR_FAIL_COND_MSG(err != OK, "Invalid packet received. Unable to decode RPC argument.");
- argp.write[i] = &args[i];
- p_offset += vlen;
+ argp.write[i] = &args[i];
+ p_offset += vlen;
+ }
}
Callable::CallError ce;
@@ -742,10 +784,12 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
// - `NetworkCommands` in the first three bits.
// - `NetworkNodeIdCompression` in the next 2 bits.
// - `NetworkNameIdCompression` in the next 1 bit.
- // - So we still have the last two bits free!
+ // - `byte_only_or_no_args` in the next 1 bit.
+ // - So we still have the last bit free!
uint8_t command_type = p_set ? NETWORK_COMMAND_REMOTE_SET : NETWORK_COMMAND_REMOTE_CALL;
uint8_t node_id_compression = UINT8_MAX;
uint8_t name_id_compression = UINT8_MAX;
+ bool byte_only_or_no_args = false;
MAKE_ROOM(1);
// The meta is composed along the way, so just set 0 for now.
@@ -835,17 +879,28 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
ofs += 2;
}
- // Call arguments.
- MAKE_ROOM(ofs + 1);
- packet_cache.write[ofs] = p_argcount;
- ofs += 1;
- for (int i = 0; i < p_argcount; i++) {
- int len(0);
- Error err = _encode_and_compress_variant(*p_arg[i], NULL, len);
- ERR_FAIL_COND_MSG(err != OK, "Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!");
- MAKE_ROOM(ofs + len);
- _encode_and_compress_variant(*p_arg[i], &(packet_cache.write[ofs]), len);
- ofs += len;
+ if (p_argcount == 0) {
+ byte_only_or_no_args = true;
+ } else if (p_argcount == 1 && p_arg[0]->get_type() == Variant::PACKED_BYTE_ARRAY) {
+ byte_only_or_no_args = true;
+ // Special optimization when only the byte vector is sent.
+ const Vector<uint8_t> data = *p_arg[0];
+ MAKE_ROOM(ofs + data.size());
+ copymem(&(packet_cache.write[ofs]), data.ptr(), sizeof(uint8_t) * data.size());
+ ofs += data.size();
+ } else {
+ // Arguments
+ MAKE_ROOM(ofs + 1);
+ packet_cache.write[ofs] = p_argcount;
+ ofs += 1;
+ for (int i = 0; i < p_argcount; i++) {
+ int len(0);
+ Error err = _encode_and_compress_variant(*p_arg[i], NULL, len);
+ ERR_FAIL_COND_MSG(err != OK, "Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!");
+ MAKE_ROOM(ofs + len);
+ _encode_and_compress_variant(*p_arg[i], &(packet_cache.write[ofs]), len);
+ ofs += len;
+ }
}
}
@@ -854,7 +909,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
ERR_FAIL_COND(name_id_compression > 1);
// We can now set the meta
- packet_cache.write[0] = command_type + (node_id_compression << 3) + (name_id_compression << 5);
+ packet_cache.write[0] = command_type + (node_id_compression << NODE_ID_COMPRESSION_SHIFT) + (name_id_compression << NAME_ID_COMPRESSION_SHIFT) + ((byte_only_or_no_args ? 1 : 0) << BYTE_ONLY_OR_NO_ARGS_SHIFT);
#ifdef DEBUG_ENABLED
if (profiling) {
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 518323c5c4..8c343a0f43 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -46,7 +46,7 @@ enum {
VARIANT_NIL = 1,
VARIANT_BOOL = 2,
VARIANT_INT = 3,
- VARIANT_REAL = 4,
+ VARIANT_FLOAT = 4,
VARIANT_STRING = 5,
VARIANT_VECTOR2 = 10,
VARIANT_RECT2 = 11,
@@ -65,8 +65,8 @@ enum {
VARIANT_DICTIONARY = 26,
VARIANT_ARRAY = 30,
VARIANT_RAW_ARRAY = 31,
- VARIANT_INT_ARRAY = 32,
- VARIANT_REAL_ARRAY = 33,
+ VARIANT_INT32_ARRAY = 32,
+ VARIANT_FLOAT32_ARRAY = 33,
VARIANT_STRING_ARRAY = 34,
VARIANT_VECTOR3_ARRAY = 35,
VARIANT_COLOR_ARRAY = 36,
@@ -79,6 +79,8 @@ enum {
VARIANT_VECTOR2I = 45,
VARIANT_RECT2I = 46,
VARIANT_VECTOR3I = 47,
+ VARIANT_INT64_ARRAY = 48,
+ VARIANT_FLOAT64_ARRAY = 49,
OBJECT_EMPTY = 0,
OBJECT_EXTERNAL_RESOURCE = 1,
OBJECT_INTERNAL_RESOURCE = 2,
@@ -142,7 +144,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = int64_t(f->get_64());
} break;
- case VARIANT_REAL: {
+ case VARIANT_FLOAT: {
r_v = f->get_real();
} break;
@@ -452,14 +454,14 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
- case VARIANT_INT_ARRAY: {
+ case VARIANT_INT32_ARRAY: {
uint32_t len = f->get_32();
- Vector<int> array;
+ Vector<int32_t> array;
array.resize(len);
- int *w = array.ptrw();
- f->get_buffer((uint8_t *)w, len * 4);
+ int32_t *w = array.ptrw();
+ f->get_buffer((uint8_t *)w, len * sizeof(int32_t));
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -473,14 +475,35 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
- case VARIANT_REAL_ARRAY: {
+ case VARIANT_INT64_ARRAY: {
uint32_t len = f->get_32();
- Vector<real_t> array;
+ Vector<int64_t> array;
array.resize(len);
- real_t *w = array.ptrw();
- f->get_buffer((uint8_t *)w, len * sizeof(real_t));
+ int64_t *w = array.ptrw();
+ f->get_buffer((uint8_t *)w, len * sizeof(int64_t));
+#ifdef BIG_ENDIAN_ENABLED
+ {
+ uint64_t *ptr = (uint64_t *)w.ptr();
+ for (int i = 0; i < len; i++) {
+
+ ptr[i] = BSWAP64(ptr[i]);
+ }
+ }
+
+#endif
+
+ r_v = array;
+ } break;
+ case VARIANT_FLOAT32_ARRAY: {
+
+ uint32_t len = f->get_32();
+
+ Vector<float> array;
+ array.resize(len);
+ float *w = array.ptrw();
+ f->get_buffer((uint8_t *)w, len * sizeof(float));
#ifdef BIG_ENDIAN_ENABLED
{
uint32_t *ptr = (uint32_t *)w.ptr();
@@ -494,6 +517,27 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
+ case VARIANT_FLOAT64_ARRAY: {
+
+ uint32_t len = f->get_32();
+
+ Vector<double> array;
+ array.resize(len);
+ double *w = array.ptrw();
+ f->get_buffer((uint8_t *)w, len * sizeof(double));
+#ifdef BIG_ENDIAN_ENABLED
+ {
+ uint64_t *ptr = (uint64_t *)w.ptr();
+ for (int i = 0; i < len; i++) {
+
+ ptr[i] = BSWAP64(ptr[i]);
+ }
+ }
+
+#endif
+
+ r_v = array;
+ } break;
case VARIANT_STRING_ARRAY: {
uint32_t len = f->get_32();
@@ -1293,7 +1337,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
}
} break;
- case Variant::REAL: {
+ case Variant::FLOAT: {
double d = p_property;
float fl = d;
@@ -1302,7 +1346,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
f->store_double(d);
} else {
- f->store_32(VARIANT_REAL);
+ f->store_32(VARIANT_FLOAT);
f->store_real(fl);
}
@@ -1573,29 +1617,52 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
_pad_buffer(f, len);
} break;
- case Variant::PACKED_INT_ARRAY: {
+ case Variant::PACKED_INT32_ARRAY: {
- f->store_32(VARIANT_INT_ARRAY);
- Vector<int> arr = p_property;
+ f->store_32(VARIANT_INT32_ARRAY);
+ Vector<int32_t> arr = p_property;
int len = arr.size();
f->store_32(len);
- const int *r = arr.ptr();
+ const int32_t *r = arr.ptr();
for (int i = 0; i < len; i++)
f->store_32(r[i]);
} break;
- case Variant::PACKED_REAL_ARRAY: {
+ case Variant::PACKED_INT64_ARRAY: {
- f->store_32(VARIANT_REAL_ARRAY);
- Vector<real_t> arr = p_property;
+ f->store_32(VARIANT_INT64_ARRAY);
+ Vector<int64_t> arr = p_property;
int len = arr.size();
f->store_32(len);
- const real_t *r = arr.ptr();
+ const int64_t *r = arr.ptr();
+ for (int i = 0; i < len; i++)
+ f->store_64(r[i]);
+
+ } break;
+ case Variant::PACKED_FLOAT32_ARRAY: {
+
+ f->store_32(VARIANT_FLOAT32_ARRAY);
+ Vector<float> arr = p_property;
+ int len = arr.size();
+ f->store_32(len);
+ const float *r = arr.ptr();
for (int i = 0; i < len; i++) {
f->store_real(r[i]);
}
} break;
+ case Variant::PACKED_FLOAT64_ARRAY: {
+
+ f->store_32(VARIANT_FLOAT64_ARRAY);
+ Vector<double> arr = p_property;
+ int len = arr.size();
+ f->store_32(len);
+ const double *r = arr.ptr();
+ for (int i = 0; i < len; i++) {
+ f->store_double(r[i]);
+ }
+
+ } break;
case Variant::PACKED_STRING_ARRAY: {
f->store_32(VARIANT_STRING_ARRAY);
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index b26903e45a..847d4d8681 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -576,8 +576,8 @@ void AStar::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_point_path", "from_id", "to_id"), &AStar::get_point_path);
ClassDB::bind_method(D_METHOD("get_id_path", "from_id", "to_id"), &AStar::get_id_path);
- BIND_VMETHOD(MethodInfo(Variant::REAL, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
- BIND_VMETHOD(MethodInfo(Variant::REAL, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
+ BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
+ BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
}
AStar::AStar() {
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index 1130935567..058673b681 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -212,7 +212,7 @@ int Expression::get_func_argument_count(BuiltinFunc p_func) {
if (!p_inputs[m_arg]->is_num()) { \
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; \
r_error.argument = m_arg; \
- r_error.expected = Variant::REAL; \
+ r_error.expected = Variant::FLOAT; \
return; \
}
@@ -314,7 +314,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
int64_t i = *p_inputs[0];
*r_return = ABS(i);
- } else if (p_inputs[0]->get_type() == Variant::REAL) {
+ } else if (p_inputs[0]->get_type() == Variant::FLOAT) {
real_t r = *p_inputs[0];
*r_return = Math::abs(r);
@@ -322,7 +322,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
}
} break;
case MATH_SIGN: {
@@ -331,7 +331,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
int64_t i = *p_inputs[0];
*r_return = i < 0 ? -1 : (i > 0 ? +1 : 0);
- } else if (p_inputs[0]->get_type() == Variant::REAL) {
+ } else if (p_inputs[0]->get_type() == Variant::FLOAT) {
real_t r = *p_inputs[0];
*r_return = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
@@ -339,7 +339,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
}
} break;
case MATH_POW: {
@@ -1161,7 +1161,7 @@ Error Expression::_get_token(Token &r_token) {
if (is_float)
r_token.value = num.to_double();
else
- r_token.value = num.to_int();
+ r_token.value = num.to_int64();
return OK;
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index 7e21c2cc24..3db186ca69 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -133,8 +133,10 @@ MAKE_PTRARG(Callable);
MAKE_PTRARG(Signal);
MAKE_PTRARG(Array);
MAKE_PTRARG(PackedByteArray);
-MAKE_PTRARG(PackedIntArray);
-MAKE_PTRARG(PackedRealArray);
+MAKE_PTRARG(PackedInt32Array);
+MAKE_PTRARG(PackedInt64Array);
+MAKE_PTRARG(PackedFloat32Array);
+MAKE_PTRARG(PackedFloat64Array);
MAKE_PTRARG(PackedStringArray);
MAKE_PTRARG(PackedVector2Array);
MAKE_PTRARG(PackedVector3Array);
diff --git a/core/object.cpp b/core/object.cpp
index a61c4ae392..140ee811fe 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1405,6 +1405,9 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, co
ERR_FAIL_COND_V(p_callable.is_null(), ERR_INVALID_PARAMETER);
+ Object *target_object = p_callable.get_object();
+ ERR_FAIL_COND_V(!target_object, ERR_INVALID_PARAMETER);
+
SignalData *s = signal_map.getptr(p_signal);
if (!s) {
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
@@ -1449,7 +1452,7 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, co
conn.flags = p_flags;
conn.binds = p_binds;
slot.conn = conn;
- slot.cE = p_callable.get_object()->connections.push_back(conn);
+ slot.cE = target_object->connections.push_back(conn);
if (p_flags & CONNECT_REFERENCE_COUNTED) {
slot.reference_count = 1;
}
@@ -1498,6 +1501,10 @@ void Object::disconnect(const StringName &p_signal, const Callable &p_callable)
void Object::_disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force) {
ERR_FAIL_COND(p_callable.is_null());
+
+ Object *target_object = p_callable.get_object();
+ ERR_FAIL_COND(!target_object);
+
SignalData *s = signal_map.getptr(p_signal);
ERR_FAIL_COND_MSG(!s, vformat("Nonexistent signal '%s' in %s.", p_signal, to_string()));
@@ -1511,9 +1518,8 @@ void Object::_disconnect(const StringName &p_signal, const Callable &p_callable,
return;
}
}
- Object *object = p_callable.get_object();
- ERR_FAIL_COND(!object);
- object->connections.erase(slot->cE);
+
+ target_object->connections.erase(slot->cE);
s->slot_map.erase(p_callable);
if (s->slot_map.empty() && ClassDB::has_signal(get_class_name(), p_signal)) {
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 7d1ae872f4..3cb9c2c1c2 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -541,7 +541,7 @@ void InputEventMouseButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_doubleclick", "doubleclick"), &InputEventMouseButton::set_doubleclick);
ClassDB::bind_method(D_METHOD("is_doubleclick"), &InputEventMouseButton::is_doubleclick);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick");
@@ -702,7 +702,7 @@ void InputEventMouseMotion::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tilt"), "set_tilt", "get_tilt");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
}
@@ -780,7 +780,7 @@ void InputEventJoypadMotion::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_axis_value"), &InputEventJoypadMotion::get_axis_value);
ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "axis_value"), "set_axis_value", "get_axis_value");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "axis_value"), "set_axis_value", "get_axis_value");
}
InputEventJoypadMotion::InputEventJoypadMotion() {
@@ -861,7 +861,7 @@ void InputEventJoypadButton::_bind_methods() {
// ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventJoypadButton::is_pressed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
}
@@ -1100,7 +1100,7 @@ void InputEventAction::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "action"), "set_action", "get_action");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength");
}
InputEventAction::InputEventAction() {
@@ -1162,7 +1162,7 @@ void InputEventMagnifyGesture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor);
ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
}
InputEventMagnifyGesture::InputEventMagnifyGesture() {
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 61bcb7dd32..ab43ce4af7 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -44,8 +44,8 @@ void MainLoop::_bind_methods() {
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo("_input_text", PropertyInfo(Variant::STRING, "text")));
BIND_VMETHOD(MethodInfo("_initialize"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::REAL, "delta")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::REAL, "delta")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::FLOAT, "delta")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta")));
BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "from_screen")));
BIND_VMETHOD(MethodInfo("_finalize"));
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 6a4fac971c..b82a366ef2 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -230,7 +230,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::NIL:
case Variant::BOOL:
case Variant::INT:
- case Variant::REAL:
+ case Variant::FLOAT:
case Variant::VECTOR2:
case Variant::RECT2:
case Variant::VECTOR3:
@@ -241,8 +241,10 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::BASIS:
case Variant::TRANSFORM:
case Variant::PACKED_BYTE_ARRAY:
- case Variant::PACKED_INT_ARRAY:
- case Variant::PACKED_REAL_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
diff --git a/core/reference.h b/core/reference.h
index 36e7d5c6a6..fd42c4e537 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -38,7 +38,6 @@
class Reference : public Object {
GDCLASS(Reference, Object);
- friend class RefBase;
SafeRefCount refcount;
SafeRefCount refcount_init;
diff --git a/core/type_info.h b/core/type_info.h
index 6861531fbd..5dacf67de4 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -137,8 +137,8 @@ MAKE_TYPE_INFO_WITH_META(int32_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_I
MAKE_TYPE_INFO_WITH_META(uint64_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_UINT64)
MAKE_TYPE_INFO_WITH_META(int64_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_INT64)
MAKE_TYPE_INFO(wchar_t, Variant::INT)
-MAKE_TYPE_INFO_WITH_META(float, Variant::REAL, GodotTypeInfo::METADATA_REAL_IS_FLOAT)
-MAKE_TYPE_INFO_WITH_META(double, Variant::REAL, GodotTypeInfo::METADATA_REAL_IS_DOUBLE)
+MAKE_TYPE_INFO_WITH_META(float, Variant::FLOAT, GodotTypeInfo::METADATA_REAL_IS_FLOAT)
+MAKE_TYPE_INFO_WITH_META(double, Variant::FLOAT, GodotTypeInfo::METADATA_REAL_IS_DOUBLE)
MAKE_TYPE_INFO(String, Variant::STRING)
MAKE_TYPE_INFO(Vector2, Variant::VECTOR2)
@@ -159,8 +159,10 @@ MAKE_TYPE_INFO(Signal, Variant::SIGNAL)
MAKE_TYPE_INFO(Dictionary, Variant::DICTIONARY)
MAKE_TYPE_INFO(Array, Variant::ARRAY)
MAKE_TYPE_INFO(PackedByteArray, Variant::PACKED_BYTE_ARRAY)
-MAKE_TYPE_INFO(PackedIntArray, Variant::PACKED_INT_ARRAY)
-MAKE_TYPE_INFO(PackedRealArray, Variant::PACKED_REAL_ARRAY)
+MAKE_TYPE_INFO(PackedInt32Array, Variant::PACKED_INT32_ARRAY)
+MAKE_TYPE_INFO(PackedInt64Array, Variant::PACKED_INT64_ARRAY)
+MAKE_TYPE_INFO(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY)
+MAKE_TYPE_INFO(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY)
MAKE_TYPE_INFO(PackedStringArray, Variant::PACKED_STRING_ARRAY)
MAKE_TYPE_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY)
MAKE_TYPE_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY)
@@ -221,20 +223,6 @@ MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, StringName, Variant::PACKED_STRING_ARRAY)
-/*
-MAKE_TEMPLATE_TYPE_INFO(Vector, uint8_t, Variant::PACKED_BYTE_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, int, Variant::PACKED_INT_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, float, Variant::PACKED_REAL_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, String, Variant::PACKED_STRING_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Vector2, Variant::PACKED_VECTOR2_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Vector3, Variant::PACKED_VECTOR3_ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Color, Variant::PACKED_COLOR_ARRAY)
-
-
-MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY)
-MAKE_TEMPLATE_TYPE_INFO(Vector, Face3, Variant::PACKED_VECTOR3_ARRAY)
-*/
-
template <typename T>
struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
diff --git a/core/variant.cpp b/core/variant.cpp
index 1acb0e7a73..7bdaab8fa8 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -57,7 +57,7 @@ String Variant::get_type_name(Variant::Type p_type) {
return "int";
} break;
- case REAL: {
+ case FLOAT: {
return "float";
@@ -175,14 +175,24 @@ String Variant::get_type_name(Variant::Type p_type) {
return "PackedByteArray";
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
- return "PackedIntArray";
+ return "PackedInt32Array";
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_INT64_ARRAY: {
- return "PackedRealArray";
+ return "PackedInt64Array";
+
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+
+ return "PackedFloat32Array";
+
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+
+ return "PackedFloat64Array";
} break;
case PACKED_STRING_ARRAY: {
@@ -230,7 +240,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
static const Type valid[] = {
INT,
- REAL,
+ FLOAT,
STRING,
NIL,
};
@@ -241,7 +251,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
static const Type valid[] = {
BOOL,
- REAL,
+ FLOAT,
STRING,
NIL,
};
@@ -249,7 +259,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
- case REAL: {
+ case FLOAT: {
static const Type valid[] = {
BOOL,
@@ -425,9 +435,11 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
static const Type valid[] = {
PACKED_BYTE_ARRAY,
- PACKED_INT_ARRAY,
+ PACKED_INT32_ARRAY,
+ PACKED_INT64_ARRAY,
+ PACKED_FLOAT32_ARRAY,
+ PACKED_FLOAT64_ARRAY,
PACKED_STRING_ARRAY,
- PACKED_REAL_ARRAY,
PACKED_COLOR_ARRAY,
PACKED_VECTOR2_ARRAY,
PACKED_VECTOR3_ARRAY,
@@ -446,15 +458,32 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
+
+ static const Type valid[] = {
+ ARRAY,
+ NIL
+ };
+ valid_types = valid;
+ } break;
+ case PACKED_INT64_ARRAY: {
+
+ static const Type valid[] = {
+ ARRAY,
+ NIL
+ };
+ valid_types = valid;
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
static const Type valid[] = {
ARRAY,
NIL
};
+
valid_types = valid;
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_FLOAT64_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -547,7 +576,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
static const Type valid[] = {
INT,
- REAL,
+ FLOAT,
//STRING,
NIL,
};
@@ -558,7 +587,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
static const Type valid[] = {
BOOL,
- REAL,
+ FLOAT,
//STRING,
NIL,
};
@@ -566,7 +595,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
- case REAL: {
+ case FLOAT: {
static const Type valid[] = {
BOOL,
@@ -743,9 +772,11 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
static const Type valid[] = {
PACKED_BYTE_ARRAY,
- PACKED_INT_ARRAY,
+ PACKED_INT32_ARRAY,
+ PACKED_INT64_ARRAY,
+ PACKED_FLOAT32_ARRAY,
+ PACKED_FLOAT64_ARRAY,
PACKED_STRING_ARRAY,
- PACKED_REAL_ARRAY,
PACKED_COLOR_ARRAY,
PACKED_VECTOR2_ARRAY,
PACKED_VECTOR3_ARRAY,
@@ -764,7 +795,15 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
+
+ static const Type valid[] = {
+ ARRAY,
+ NIL
+ };
+ valid_types = valid;
+ } break;
+ case PACKED_INT64_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -772,7 +811,16 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
};
valid_types = valid;
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_FLOAT32_ARRAY: {
+
+ static const Type valid[] = {
+ ARRAY,
+ NIL
+ };
+
+ valid_types = valid;
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
static const Type valid[] = {
ARRAY,
@@ -882,9 +930,9 @@ bool Variant::is_zero() const {
return _data._int == 0;
} break;
- case REAL: {
+ case FLOAT: {
- return _data._real == 0;
+ return _data._float == 0;
} break;
case STRING: {
@@ -1005,37 +1053,47 @@ bool Variant::is_zero() const {
// arrays
case PACKED_BYTE_ARRAY: {
- return reinterpret_cast<const Vector<uint8_t> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<uint8_t>::get_array(_data.packed_array).size() == 0;
+
+ } break;
+ case PACKED_INT32_ARRAY: {
+
+ return PackedArrayRef<int32_t>::get_array(_data.packed_array).size() == 0;
+
+ } break;
+ case PACKED_INT64_ARRAY: {
+
+ return PackedArrayRef<int64_t>::get_array(_data.packed_array).size() == 0;
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_FLOAT32_ARRAY: {
- return reinterpret_cast<const Vector<int> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<float>::get_array(_data.packed_array).size() == 0;
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_FLOAT64_ARRAY: {
- return reinterpret_cast<const Vector<real_t> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<double>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_STRING_ARRAY: {
- return reinterpret_cast<const Vector<String> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<String>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_VECTOR2_ARRAY: {
- return reinterpret_cast<const Vector<Vector2> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<Vector2>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_VECTOR3_ARRAY: {
- return reinterpret_cast<const Vector<Vector3> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<Vector3>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_COLOR_ARRAY: {
- return reinterpret_cast<const Vector<Color> *>(_data._mem)->size() == 0;
+ return PackedArrayRef<Color>::get_array(_data.packed_array).size() == 0;
} break;
default: {
@@ -1063,9 +1121,9 @@ bool Variant::is_one() const {
return _data._int == 1;
} break;
- case REAL: {
+ case FLOAT: {
- return _data._real == 1;
+ return _data._float == 1;
} break;
case VECTOR2: {
@@ -1131,7 +1189,7 @@ void Variant::reference(const Variant &p_variant) {
case NIL:
case BOOL:
case INT:
- case REAL:
+ case FLOAT:
break;
default:
clear();
@@ -1154,9 +1212,9 @@ void Variant::reference(const Variant &p_variant) {
_data._int = p_variant._data._int;
} break;
- case REAL: {
+ case FLOAT: {
- _data._real = p_variant._data._real;
+ _data._float = p_variant._data._float;
} break;
case STRING: {
@@ -1275,37 +1333,74 @@ void Variant::reference(const Variant &p_variant) {
// arrays
case PACKED_BYTE_ARRAY: {
- memnew_placement(_data._mem, Vector<uint8_t>(*reinterpret_cast<const Vector<uint8_t> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<uint8_t> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<uint8_t>::create();
+ }
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
- memnew_placement(_data._mem, Vector<int>(*reinterpret_cast<const Vector<int> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<int32_t> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<int32_t>::create();
+ }
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_INT64_ARRAY: {
- memnew_placement(_data._mem, Vector<real_t>(*reinterpret_cast<const Vector<real_t> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<int64_t> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<int64_t>::create();
+ }
+
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+
+ _data.packed_array = static_cast<PackedArrayRef<float> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<float>::create();
+ }
+
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+
+ _data.packed_array = static_cast<PackedArrayRef<double> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<double>::create();
+ }
} break;
case PACKED_STRING_ARRAY: {
- memnew_placement(_data._mem, Vector<String>(*reinterpret_cast<const Vector<String> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<String> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<String>::create();
+ }
} break;
case PACKED_VECTOR2_ARRAY: {
- memnew_placement(_data._mem, Vector<Vector2>(*reinterpret_cast<const Vector<Vector2> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<Vector2> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<Vector2>::create();
+ }
} break;
case PACKED_VECTOR3_ARRAY: {
- memnew_placement(_data._mem, Vector<Vector3>(*reinterpret_cast<const Vector<Vector3> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<Vector3> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<Vector3>::create();
+ }
} break;
case PACKED_COLOR_ARRAY: {
- memnew_placement(_data._mem, Vector<Color>(*reinterpret_cast<const Vector<Color> *>(p_variant._data._mem)));
+ _data.packed_array = static_cast<PackedArrayRef<Color> *>(p_variant._data.packed_array)->reference();
+ if (!_data.packed_array) {
+ _data.packed_array = PackedArrayRef<Color>::create();
+ }
} break;
default: {
@@ -1318,7 +1413,7 @@ void Variant::zero() {
case NIL: break;
case BOOL: this->_data._bool = false; break;
case INT: this->_data._int = 0; break;
- case REAL: this->_data._real = 0; break;
+ case FLOAT: this->_data._float = 0; break;
case VECTOR2: *reinterpret_cast<Vector2 *>(this->_data._mem) = Vector2(); break;
case VECTOR2I: *reinterpret_cast<Vector2i *>(this->_data._mem) = Vector2i(); break;
case RECT2: *reinterpret_cast<Rect2 *>(this->_data._mem) = Rect2(); break;
@@ -1409,31 +1504,39 @@ void Variant::clear() {
// arrays
case PACKED_BYTE_ARRAY: {
- reinterpret_cast<Vector<uint8_t> *>(_data._mem)->~Vector<uint8_t>();
+ PackedArrayRefBase::destroy(_data.packed_array);
+ } break;
+ case PACKED_INT32_ARRAY: {
+
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT64_ARRAY: {
- reinterpret_cast<Vector<int> *>(_data._mem)->~Vector<int>();
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_FLOAT32_ARRAY: {
- reinterpret_cast<Vector<real_t> *>(_data._mem)->~Vector<real_t>();
+ PackedArrayRefBase::destroy(_data.packed_array);
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_STRING_ARRAY: {
- reinterpret_cast<Vector<String> *>(_data._mem)->~Vector<String>();
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_VECTOR2_ARRAY: {
- reinterpret_cast<Vector<Vector2> *>(_data._mem)->~Vector<Vector2>();
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_VECTOR3_ARRAY: {
- reinterpret_cast<Vector<Vector3> *>(_data._mem)->~Vector<Vector3>();
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_COLOR_ARRAY: {
- reinterpret_cast<Vector<Color> *>(_data._mem)->~Vector<Color>();
+ PackedArrayRefBase::destroy(_data.packed_array);
} break;
default: {
} /* not needed */
@@ -1449,7 +1552,7 @@ Variant::operator signed int() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1464,7 +1567,7 @@ Variant::operator unsigned int() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1480,7 +1583,7 @@ Variant::operator int64_t() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int64();
default: {
@@ -1497,7 +1600,7 @@ Variant::operator long unsigned int() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._real;
case STRING: return operator String().to_int();
default: {
@@ -1516,7 +1619,7 @@ Variant::operator uint64_t() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1528,6 +1631,8 @@ Variant::operator uint64_t() const {
Variant::operator ObjectID() const {
if (type == INT) {
return ObjectID(_data._int);
+ } else if (type == OBJECT) {
+ return _get_obj().id;
} else {
return ObjectID();
}
@@ -1541,7 +1646,7 @@ Variant::operator signed long() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._real;
case STRING: return operator String().to_int();
default: {
@@ -1559,7 +1664,7 @@ Variant::operator unsigned long() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._real;
case STRING: return operator String().to_int();
default: {
@@ -1578,7 +1683,7 @@ Variant::operator signed short() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1593,7 +1698,7 @@ Variant::operator unsigned short() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1608,7 +1713,7 @@ Variant::operator signed char() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1623,7 +1728,7 @@ Variant::operator unsigned char() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1 : 0;
case INT: return _data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_int();
default: {
@@ -1644,7 +1749,7 @@ Variant::operator float() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1.0 : 0.0;
case INT: return (float)_data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_double();
default: {
@@ -1659,7 +1764,7 @@ Variant::operator double() const {
case NIL: return 0;
case BOOL: return _data._bool ? 1.0 : 0.0;
case INT: return (double)_data._int;
- case REAL: return _data._real;
+ case FLOAT: return _data._float;
case STRING: return operator String().to_double();
default: {
@@ -1702,7 +1807,7 @@ String Variant::stringify(List<const void *> &stack) const {
case NIL: return "Null";
case BOOL: return _data._bool ? "True" : "False";
case INT: return itos(_data._int);
- case REAL: return rtos(_data._real);
+ case FLOAT: return rtos(_data._float);
case STRING: return *reinterpret_cast<const String *>(_data._mem);
case VECTOR2: return "(" + operator Vector2() + ")";
case VECTOR2I: return "(" + operator Vector2i() + ")";
@@ -1824,9 +1929,9 @@ String Variant::stringify(List<const void *> &stack) const {
str += "]";
return str;
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
- Vector<int> vec = operator Vector<int>();
+ Vector<int32_t> vec = operator Vector<int32_t>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -1837,9 +1942,35 @@ String Variant::stringify(List<const void *> &stack) const {
str += "]";
return str;
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_INT64_ARRAY: {
- Vector<real_t> vec = operator Vector<real_t>();
+ Vector<int64_t> vec = operator Vector<int64_t>();
+ String str("[");
+ for (int i = 0; i < vec.size(); i++) {
+
+ if (i > 0)
+ str += ", ";
+ str = str + itos(vec[i]);
+ }
+ str += "]";
+ return str;
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+
+ Vector<float> vec = operator Vector<float>();
+ String str("[");
+ for (int i = 0; i < vec.size(); i++) {
+
+ if (i > 0)
+ str += ", ";
+ str = str + rtos(vec[i]);
+ }
+ str += "]";
+ return str;
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+
+ Vector<double> vec = operator Vector<double>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
@@ -2195,11 +2326,17 @@ inline DA _convert_array_from_variant(const Variant &p_variant) {
case Variant::PACKED_BYTE_ARRAY: {
return _convert_array<DA, Vector<uint8_t> >(p_variant.operator Vector<uint8_t>());
}
- case Variant::PACKED_INT_ARRAY: {
- return _convert_array<DA, Vector<int> >(p_variant.operator Vector<int>());
+ case Variant::PACKED_INT32_ARRAY: {
+ return _convert_array<DA, Vector<int32_t> >(p_variant.operator Vector<int32_t>());
}
- case Variant::PACKED_REAL_ARRAY: {
- return _convert_array<DA, Vector<real_t> >(p_variant.operator Vector<real_t>());
+ case Variant::PACKED_INT64_ARRAY: {
+ return _convert_array<DA, Vector<int64_t> >(p_variant.operator Vector<int64_t>());
+ }
+ case Variant::PACKED_FLOAT32_ARRAY: {
+ return _convert_array<DA, Vector<float> >(p_variant.operator Vector<float>());
+ }
+ case Variant::PACKED_FLOAT64_ARRAY: {
+ return _convert_array<DA, Vector<double> >(p_variant.operator Vector<double>());
}
case Variant::PACKED_STRING_ARRAY: {
return _convert_array<DA, Vector<String> >(p_variant.operator Vector<String>());
@@ -2230,43 +2367,59 @@ Variant::operator Array() const {
Variant::operator Vector<uint8_t>() const {
if (type == PACKED_BYTE_ARRAY)
- return *reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
+ return static_cast<PackedArrayRef<uint8_t> *>(_data.packed_array)->array;
else
return _convert_array_from_variant<Vector<uint8_t> >(*this);
}
-Variant::operator Vector<int>() const {
+Variant::operator Vector<int32_t>() const {
- if (type == PACKED_INT_ARRAY)
- return *reinterpret_cast<const Vector<int> *>(_data._mem);
+ if (type == PACKED_INT32_ARRAY)
+ return static_cast<PackedArrayRef<int32_t> *>(_data.packed_array)->array;
else
return _convert_array_from_variant<Vector<int> >(*this);
}
-Variant::operator Vector<real_t>() const {
+Variant::operator Vector<int64_t>() const {
- if (type == PACKED_REAL_ARRAY)
- return *reinterpret_cast<const Vector<real_t> *>(_data._mem);
+ if (type == PACKED_INT64_ARRAY)
+ return static_cast<PackedArrayRef<int64_t> *>(_data.packed_array)->array;
else
- return _convert_array_from_variant<Vector<real_t> >(*this);
+ return _convert_array_from_variant<Vector<int64_t> >(*this);
+}
+
+Variant::operator Vector<float>() const {
+
+ if (type == PACKED_FLOAT32_ARRAY)
+ return static_cast<PackedArrayRef<float> *>(_data.packed_array)->array;
+ else
+ return _convert_array_from_variant<Vector<float> >(*this);
+}
+
+Variant::operator Vector<double>() const {
+
+ if (type == PACKED_FLOAT64_ARRAY)
+ return static_cast<PackedArrayRef<double> *>(_data.packed_array)->array;
+ else
+ return _convert_array_from_variant<Vector<double> >(*this);
}
Variant::operator Vector<String>() const {
if (type == PACKED_STRING_ARRAY)
- return *reinterpret_cast<const Vector<String> *>(_data._mem);
+ return static_cast<PackedArrayRef<String> *>(_data.packed_array)->array;
else
return _convert_array_from_variant<Vector<String> >(*this);
}
Variant::operator Vector<Vector3>() const {
if (type == PACKED_VECTOR3_ARRAY)
- return *reinterpret_cast<const Vector<Vector3> *>(_data._mem);
+ return static_cast<PackedArrayRef<Vector3> *>(_data.packed_array)->array;
else
return _convert_array_from_variant<Vector<Vector3> >(*this);
}
Variant::operator Vector<Vector2>() const {
if (type == PACKED_VECTOR2_ARRAY)
- return *reinterpret_cast<const Vector<Vector2> *>(_data._mem);
+ return static_cast<PackedArrayRef<Vector2> *>(_data.packed_array)->array;
else
return _convert_array_from_variant<Vector<Vector2> >(*this);
}
@@ -2274,7 +2427,7 @@ Variant::operator Vector<Vector2>() const {
Variant::operator Vector<Color>() const {
if (type == PACKED_COLOR_ARRAY)
- return *reinterpret_cast<const Vector<Color> *>(_data._mem);
+ return static_cast<PackedArrayRef<Color> *>(_data.packed_array)->array;
else
return _convert_array_from_variant<Vector<Color> >(*this);
}
@@ -2365,7 +2518,7 @@ Variant::operator Orientation() const {
Variant::operator IP_Address() const {
- if (type == PACKED_REAL_ARRAY || type == PACKED_INT_ARRAY || type == PACKED_BYTE_ARRAY) {
+ if (type == PACKED_FLOAT32_ARRAY || type == PACKED_INT32_ARRAY || type == PACKED_FLOAT64_ARRAY || type == PACKED_INT64_ARRAY || type == PACKED_BYTE_ARRAY) {
Vector<int> addr = operator Vector<int>();
if (addr.size() == 4) {
@@ -2449,13 +2602,13 @@ Variant::Variant(unsigned char p_char) {
}
Variant::Variant(float p_float) {
- type = REAL;
- _data._real = p_float;
+ type = FLOAT;
+ _data._float = p_float;
}
Variant::Variant(double p_double) {
- type = REAL;
- _data._real = p_double;
+ type = FLOAT;
+ _data._float = p_double;
}
Variant::Variant(const ObjectID &p_id) {
@@ -2647,41 +2800,56 @@ Variant::Variant(const Vector<RID> &p_array) {
}
}
-Variant::Variant(const Vector<uint8_t> &p_raw_array) {
+Variant::Variant(const Vector<uint8_t> &p_byte_array) {
type = PACKED_BYTE_ARRAY;
- memnew_placement(_data._mem, Vector<uint8_t>(p_raw_array));
+
+ _data.packed_array = PackedArrayRef<uint8_t>::create(p_byte_array);
}
-Variant::Variant(const Vector<int> &p_int_array) {
+Variant::Variant(const Vector<int32_t> &p_int32_array) {
- type = PACKED_INT_ARRAY;
- memnew_placement(_data._mem, Vector<int>(p_int_array));
+ type = PACKED_INT32_ARRAY;
+ _data.packed_array = PackedArrayRef<int32_t>::create(p_int32_array);
}
-Variant::Variant(const Vector<real_t> &p_real_array) {
- type = PACKED_REAL_ARRAY;
- memnew_placement(_data._mem, Vector<real_t>(p_real_array));
+Variant::Variant(const Vector<int64_t> &p_int64_array) {
+
+ type = PACKED_INT64_ARRAY;
+ _data.packed_array = PackedArrayRef<int64_t>::create(p_int64_array);
+}
+
+Variant::Variant(const Vector<float> &p_float32_array) {
+
+ type = PACKED_FLOAT32_ARRAY;
+ _data.packed_array = PackedArrayRef<float>::create(p_float32_array);
}
+
+Variant::Variant(const Vector<double> &p_float64_array) {
+
+ type = PACKED_FLOAT64_ARRAY;
+ _data.packed_array = PackedArrayRef<double>::create(p_float64_array);
+}
+
Variant::Variant(const Vector<String> &p_string_array) {
type = PACKED_STRING_ARRAY;
- memnew_placement(_data._mem, Vector<String>(p_string_array));
+ _data.packed_array = PackedArrayRef<String>::create(p_string_array);
}
Variant::Variant(const Vector<Vector3> &p_vector3_array) {
type = PACKED_VECTOR3_ARRAY;
- memnew_placement(_data._mem, Vector<Vector3>(p_vector3_array));
+ _data.packed_array = PackedArrayRef<Vector3>::create(p_vector3_array);
}
Variant::Variant(const Vector<Vector2> &p_vector2_array) {
type = PACKED_VECTOR2_ARRAY;
- memnew_placement(_data._mem, Vector<Vector2>(p_vector2_array));
+ _data.packed_array = PackedArrayRef<Vector2>::create(p_vector2_array);
}
Variant::Variant(const Vector<Color> &p_color_array) {
type = PACKED_COLOR_ARRAY;
- memnew_placement(_data._mem, Vector<Color>(p_color_array));
+ _data.packed_array = PackedArrayRef<Color>::create(p_color_array);
}
Variant::Variant(const Vector<Face3> &p_face_array) {
@@ -2753,9 +2921,9 @@ void Variant::operator=(const Variant &p_variant) {
_data._int = p_variant._data._int;
} break;
- case REAL: {
+ case FLOAT: {
- _data._real = p_variant._data._real;
+ _data._float = p_variant._data._float;
} break;
case STRING: {
@@ -2874,31 +3042,39 @@ void Variant::operator=(const Variant &p_variant) {
// arrays
case PACKED_BYTE_ARRAY: {
- *reinterpret_cast<Vector<uint8_t> *>(_data._mem) = *reinterpret_cast<const Vector<uint8_t> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<uint8_t>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
- *reinterpret_cast<Vector<int> *>(_data._mem) = *reinterpret_cast<const Vector<int> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<int32_t>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_INT64_ARRAY: {
- *reinterpret_cast<Vector<real_t> *>(_data._mem) = *reinterpret_cast<const Vector<real_t> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<int64_t>::reference_from(_data.packed_array, p_variant._data.packed_array);
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+
+ _data.packed_array = PackedArrayRef<float>::reference_from(_data.packed_array, p_variant._data.packed_array);
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+
+ _data.packed_array = PackedArrayRef<double>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_STRING_ARRAY: {
- *reinterpret_cast<Vector<String> *>(_data._mem) = *reinterpret_cast<const Vector<String> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<String>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_VECTOR2_ARRAY: {
- *reinterpret_cast<Vector<Vector2> *>(_data._mem) = *reinterpret_cast<const Vector<Vector2> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<Vector2>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_VECTOR3_ARRAY: {
- *reinterpret_cast<Vector<Vector3> *>(_data._mem) = *reinterpret_cast<const Vector<Vector3> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<Vector3>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_COLOR_ARRAY: {
- *reinterpret_cast<Vector<Color> *>(_data._mem) = *reinterpret_cast<const Vector<Color> *>(p_variant._data._mem);
+ _data.packed_array = PackedArrayRef<Color>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
default: {
}
@@ -2938,9 +3114,9 @@ uint32_t Variant::hash() const {
return _data._int;
} break;
- case REAL: {
+ case FLOAT: {
- return hash_djb2_one_float(_data._real);
+ return hash_djb2_one_float(_data._float);
} break;
case STRING: {
@@ -3106,7 +3282,7 @@ uint32_t Variant::hash() const {
} break;
case PACKED_BYTE_ARRAY: {
- const Vector<uint8_t> &arr = *reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> &arr = PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
const uint8_t *r = arr.ptr();
@@ -3116,26 +3292,51 @@ uint32_t Variant::hash() const {
}
} break;
- case PACKED_INT_ARRAY: {
+ case PACKED_INT32_ARRAY: {
- const Vector<int> &arr = *reinterpret_cast<const Vector<int> *>(_data._mem);
+ const Vector<int32_t> &arr = PackedArrayRef<int32_t>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
- const int *r = arr.ptr();
- return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int));
+ const int32_t *r = arr.ptr();
+ return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int32_t));
} else {
return hash_djb2_one_64(0);
}
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_INT64_ARRAY: {
- const Vector<real_t> &arr = *reinterpret_cast<const Vector<real_t> *>(_data._mem);
+ const Vector<int64_t> &arr = PackedArrayRef<int64_t>::get_array(_data.packed_array);
+ int len = arr.size();
+ if (likely(len)) {
+ const int64_t *r = arr.ptr();
+ return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(int64_t));
+ } else {
+ return hash_djb2_one_64(0);
+ }
+
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+
+ const Vector<float> &arr = PackedArrayRef<float>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
- const real_t *r = arr.ptr();
- return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(real_t));
+ const float *r = arr.ptr();
+ return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(float));
+ } else {
+ return hash_djb2_one_float(0.0);
+ }
+
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+
+ const Vector<double> &arr = PackedArrayRef<double>::get_array(_data.packed_array);
+ int len = arr.size();
+
+ if (likely(len)) {
+ const double *r = arr.ptr();
+ return hash_djb2_buffer((uint8_t *)&r[0], len * sizeof(double));
} else {
return hash_djb2_one_float(0.0);
}
@@ -3144,7 +3345,7 @@ uint32_t Variant::hash() const {
case PACKED_STRING_ARRAY: {
uint32_t hash = 5831;
- const Vector<String> &arr = *reinterpret_cast<const Vector<String> *>(_data._mem);
+ const Vector<String> &arr = PackedArrayRef<String>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3160,7 +3361,7 @@ uint32_t Variant::hash() const {
case PACKED_VECTOR2_ARRAY: {
uint32_t hash = 5831;
- const Vector<Vector2> &arr = *reinterpret_cast<const Vector<Vector2> *>(_data._mem);
+ const Vector<Vector2> &arr = PackedArrayRef<Vector2>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3177,7 +3378,7 @@ uint32_t Variant::hash() const {
case PACKED_VECTOR3_ARRAY: {
uint32_t hash = 5831;
- const Vector<Vector3> &arr = *reinterpret_cast<const Vector<Vector3> *>(_data._mem);
+ const Vector<Vector3> &arr = PackedArrayRef<Vector3>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3195,7 +3396,7 @@ uint32_t Variant::hash() const {
case PACKED_COLOR_ARRAY: {
uint32_t hash = 5831;
- const Vector<Color> &arr = *reinterpret_cast<const Vector<Color> *>(_data._mem);
+ const Vector<Color> &arr = PackedArrayRef<Color>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3242,21 +3443,21 @@ uint32_t Variant::hash() const {
(hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \
(hash_compare_scalar((p_lhs).a, (p_rhs).a))
-#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func) \
- const Vector<p_type> &l = *reinterpret_cast<const Vector<p_type> *>(p_lhs); \
- const Vector<p_type> &r = *reinterpret_cast<const Vector<p_type> *>(p_rhs); \
- \
- if (l.size() != r.size()) \
- return false; \
- \
- const p_type *lr = l.ptr(); \
- const p_type *rr = r.ptr(); \
- \
- for (int i = 0; i < l.size(); ++i) { \
- if (!p_compare_func((lr[i]), (rr[i]))) \
- return false; \
- } \
- \
+#define hash_compare_packed_array(p_lhs, p_rhs, p_type, p_compare_func) \
+ const Vector<p_type> &l = PackedArrayRef<p_type>::get_array(p_lhs); \
+ const Vector<p_type> &r = PackedArrayRef<p_type>::get_array(p_rhs); \
+ \
+ if (l.size() != r.size()) \
+ return false; \
+ \
+ const p_type *lr = l.ptr(); \
+ const p_type *rr = r.ptr(); \
+ \
+ for (int i = 0; i < l.size(); ++i) { \
+ if (!p_compare_func((lr[i]), (rr[i]))) \
+ return false; \
+ } \
+ \
return true
bool Variant::hash_compare(const Variant &p_variant) const {
@@ -3264,8 +3465,8 @@ bool Variant::hash_compare(const Variant &p_variant) const {
return false;
switch (type) {
- case REAL: {
- return hash_compare_scalar(_data._real, p_variant._data._real);
+ case FLOAT: {
+ return hash_compare_scalar(_data._float, p_variant._data._float);
} break;
case VECTOR2: {
@@ -3389,20 +3590,25 @@ bool Variant::hash_compare(const Variant &p_variant) const {
return true;
} break;
- case PACKED_REAL_ARRAY: {
- hash_compare_pool_array(_data._mem, p_variant._data._mem, real_t, hash_compare_scalar);
+ // This is for floating point comparisons only.
+ case PACKED_FLOAT32_ARRAY: {
+ hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, float, hash_compare_scalar);
+ } break;
+
+ case PACKED_FLOAT64_ARRAY: {
+ hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, double, hash_compare_scalar);
} break;
case PACKED_VECTOR2_ARRAY: {
- hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2, hash_compare_vector2);
+ hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, Vector2, hash_compare_vector2);
} break;
case PACKED_VECTOR3_ARRAY: {
- hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3, hash_compare_vector3);
+ hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, Vector3, hash_compare_vector3);
} break;
case PACKED_COLOR_ARRAY: {
- hash_compare_pool_array(_data._mem, p_variant._data._mem, Color, hash_compare_color);
+ hash_compare_packed_array(_data.packed_array, p_variant._data.packed_array, Color, hash_compare_color);
} break;
default:
diff --git a/core/variant.h b/core/variant.h
index b1be95de12..614d39e84a 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -58,8 +58,10 @@ struct PropertyInfo;
struct MethodInfo;
typedef Vector<uint8_t> PackedByteArray;
-typedef Vector<int> PackedIntArray;
-typedef Vector<real_t> PackedRealArray;
+typedef Vector<int32_t> PackedInt32Array;
+typedef Vector<int64_t> PackedInt64Array;
+typedef Vector<float> PackedFloat32Array;
+typedef Vector<double> PackedFloat64Array;
typedef Vector<String> PackedStringArray;
typedef Vector<Vector2> PackedVector2Array;
typedef Vector<Vector3> PackedVector3Array;
@@ -76,18 +78,16 @@ class Variant {
public:
// If this changes the table in variant_op must be updated
enum Type {
-
NIL,
// atomic types
BOOL,
INT,
- REAL,
+ FLOAT,
STRING,
// math types
-
- VECTOR2, // 5
+ VECTOR2,
VECTOR2I,
RECT2,
RECT2I,
@@ -95,7 +95,7 @@ public:
VECTOR3I,
TRANSFORM2D,
PLANE,
- QUAT, // 10
+ QUAT,
AABB,
BASIS,
TRANSFORM,
@@ -103,24 +103,26 @@ public:
// misc types
COLOR,
STRING_NAME,
- NODE_PATH, // 15
+ NODE_PATH,
_RID,
OBJECT,
CALLABLE,
SIGNAL,
DICTIONARY,
ARRAY,
- // arrays
- PACKED_BYTE_ARRAY, // 20
- PACKED_INT_ARRAY,
- PACKED_REAL_ARRAY,
+
+ // typed arrays
+ PACKED_BYTE_ARRAY,
+ PACKED_INT32_ARRAY,
+ PACKED_INT64_ARRAY,
+ PACKED_FLOAT32_ARRAY,
+ PACKED_FLOAT64_ARRAY,
PACKED_STRING_ARRAY,
PACKED_VECTOR2_ARRAY,
- PACKED_VECTOR3_ARRAY, // 25
+ PACKED_VECTOR3_ARRAY,
PACKED_COLOR_ARRAY,
VARIANT_MAX
-
};
private:
@@ -136,17 +138,77 @@ private:
Object *obj;
};
+ /* array helpers */
+ struct PackedArrayRefBase {
+ SafeRefCount refcount;
+ _FORCE_INLINE_ PackedArrayRefBase *reference() {
+ if (this->refcount.ref()) {
+ return this;
+ } else {
+ return nullptr;
+ }
+ }
+ static _FORCE_INLINE_ PackedArrayRefBase *reference_from(PackedArrayRefBase *p_base, PackedArrayRefBase *p_from) {
+ if (p_base == p_from) {
+ return p_base; //same thing, do nothing
+ }
+
+ if (p_from->reference()) {
+ if (p_base->refcount.unref()) {
+ memdelete(p_base);
+ }
+ return p_from;
+ } else {
+ return p_base; //keep, could not reference new
+ }
+ }
+ static _FORCE_INLINE_ void destroy(PackedArrayRefBase *p_array) {
+ if (p_array->refcount.unref()) {
+ memdelete(p_array);
+ }
+ }
+ _FORCE_INLINE_ virtual ~PackedArrayRefBase() {} //needs virtual destructor, but make inline
+ };
+
+ template <class T>
+ struct PackedArrayRef : public PackedArrayRefBase {
+ Vector<T> array;
+ static _FORCE_INLINE_ PackedArrayRef<T> *create() {
+ return memnew(PackedArrayRef<T>);
+ }
+ static _FORCE_INLINE_ PackedArrayRef<T> *create(const Vector<T> &p_from) {
+ return memnew(PackedArrayRef<T>(p_from));
+ }
+
+ static _FORCE_INLINE_ const Vector<T> &get_array(PackedArrayRefBase *p_base) {
+ return static_cast<PackedArrayRef<T> *>(p_base)->array;
+ }
+ static _FORCE_INLINE_ Vector<T> *get_array_ptr(const PackedArrayRefBase *p_base) {
+ return &const_cast<PackedArrayRef<T> *>(static_cast<const PackedArrayRef<T> *>(p_base))->array;
+ }
+
+ _FORCE_INLINE_ PackedArrayRef(const Vector<T> &p_from) {
+ array = p_from;
+ refcount.init();
+ }
+ _FORCE_INLINE_ PackedArrayRef() {
+ refcount.init();
+ }
+ };
+
+ /* end of array helpers */
_ALWAYS_INLINE_ ObjData &_get_obj();
_ALWAYS_INLINE_ const ObjData &_get_obj() const;
union {
bool _bool;
int64_t _int;
- double _real;
+ double _float;
Transform2D *_transform2d;
::AABB *_aabb;
Basis *_basis;
Transform *_transform;
+ PackedArrayRefBase *packed_array;
void *_ptr; //generic pointer
uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)];
} _data GCC_ALIGNED_8;
@@ -155,14 +217,20 @@ private:
void clear();
public:
- _FORCE_INLINE_ Type get_type() const { return type; }
+ _FORCE_INLINE_ Type get_type() const {
+ return type;
+ }
static String get_type_name(Variant::Type p_type);
static bool can_convert(Type p_type_from, Type p_type_to);
static bool can_convert_strict(Type p_type_from, Type p_type_to);
bool is_ref() const;
- _FORCE_INLINE_ bool is_num() const { return type == INT || type == REAL; };
- _FORCE_INLINE_ bool is_array() const { return type >= ARRAY; };
+ _FORCE_INLINE_ bool is_num() const {
+ return type == INT || type == FLOAT;
+ };
+ _FORCE_INLINE_ bool is_array() const {
+ return type >= ARRAY;
+ };
bool is_shared() const;
bool is_zero() const;
bool is_one() const;
@@ -218,8 +286,10 @@ public:
operator Array() const;
operator Vector<uint8_t>() const;
- operator Vector<int>() const;
- operator Vector<real_t>() const;
+ operator Vector<int32_t>() const;
+ operator Vector<int64_t>() const;
+ operator Vector<float>() const;
+ operator Vector<double>() const;
operator Vector<String>() const;
operator Vector<Vector3>() const;
operator Vector<Color>() const;
@@ -283,9 +353,11 @@ public:
Variant(const Array &p_array);
Variant(const Vector<Plane> &p_array); // helper
- Variant(const Vector<uint8_t> &p_raw_array);
- Variant(const Vector<int> &p_int_array);
- Variant(const Vector<real_t> &p_real_array);
+ Variant(const Vector<uint8_t> &p_byte_array);
+ Variant(const Vector<int32_t> &p_int32_array);
+ Variant(const Vector<int64_t> &p_int64_array);
+ Variant(const Vector<float> &p_float32_array);
+ Variant(const Vector<double> &p_float64_array);
Variant(const Vector<String> &p_string_array);
Variant(const Vector<Vector3> &p_vector3_array);
Variant(const Vector<Color> &p_color_array);
@@ -405,7 +477,9 @@ public:
void operator=(const Variant &p_variant); // only this is enough for all the other types
Variant(const Variant &p_variant);
- _FORCE_INLINE_ Variant() { type = NIL; }
+ _FORCE_INLINE_ Variant() {
+ type = NIL;
+ }
_FORCE_INLINE_ ~Variant() {
if (type != Variant::NIL) clear();
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 0f7c1275ef..9cc08b54e6 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -666,90 +666,139 @@ struct _VariantCall {
r_ret = s;
}
- VCALL_LOCALMEM0R(PackedByteArray, size);
- VCALL_LOCALMEM0R(PackedByteArray, empty);
- VCALL_LOCALMEM2(PackedByteArray, set);
- VCALL_LOCALMEM1R(PackedByteArray, get);
- VCALL_LOCALMEM1(PackedByteArray, push_back);
- VCALL_LOCALMEM1(PackedByteArray, resize);
- VCALL_LOCALMEM2R(PackedByteArray, insert);
- VCALL_LOCALMEM1(PackedByteArray, remove);
- VCALL_LOCALMEM1(PackedByteArray, append);
- VCALL_LOCALMEM1(PackedByteArray, append_array);
- VCALL_LOCALMEM0(PackedByteArray, invert);
- VCALL_LOCALMEM2R(PackedByteArray, subarray);
-
- VCALL_LOCALMEM0R(PackedIntArray, size);
- VCALL_LOCALMEM0R(PackedIntArray, empty);
- VCALL_LOCALMEM2(PackedIntArray, set);
- VCALL_LOCALMEM1R(PackedIntArray, get);
- VCALL_LOCALMEM1(PackedIntArray, push_back);
- VCALL_LOCALMEM1(PackedIntArray, resize);
- VCALL_LOCALMEM2R(PackedIntArray, insert);
- VCALL_LOCALMEM1(PackedIntArray, remove);
- VCALL_LOCALMEM1(PackedIntArray, append);
- VCALL_LOCALMEM1(PackedIntArray, append_array);
- VCALL_LOCALMEM0(PackedIntArray, invert);
-
- VCALL_LOCALMEM0R(PackedRealArray, size);
- VCALL_LOCALMEM0R(PackedRealArray, empty);
- VCALL_LOCALMEM2(PackedRealArray, set);
- VCALL_LOCALMEM1R(PackedRealArray, get);
- VCALL_LOCALMEM1(PackedRealArray, push_back);
- VCALL_LOCALMEM1(PackedRealArray, resize);
- VCALL_LOCALMEM2R(PackedRealArray, insert);
- VCALL_LOCALMEM1(PackedRealArray, remove);
- VCALL_LOCALMEM1(PackedRealArray, append);
- VCALL_LOCALMEM1(PackedRealArray, append_array);
- VCALL_LOCALMEM0(PackedRealArray, invert);
-
- VCALL_LOCALMEM0R(PackedStringArray, size);
- VCALL_LOCALMEM0R(PackedStringArray, empty);
- VCALL_LOCALMEM2(PackedStringArray, set);
- VCALL_LOCALMEM1R(PackedStringArray, get);
- VCALL_LOCALMEM1(PackedStringArray, push_back);
- VCALL_LOCALMEM1(PackedStringArray, resize);
- VCALL_LOCALMEM2R(PackedStringArray, insert);
- VCALL_LOCALMEM1(PackedStringArray, remove);
- VCALL_LOCALMEM1(PackedStringArray, append);
- VCALL_LOCALMEM1(PackedStringArray, append_array);
- VCALL_LOCALMEM0(PackedStringArray, invert);
-
- VCALL_LOCALMEM0R(PackedVector2Array, size);
- VCALL_LOCALMEM0R(PackedVector2Array, empty);
- VCALL_LOCALMEM2(PackedVector2Array, set);
- VCALL_LOCALMEM1R(PackedVector2Array, get);
- VCALL_LOCALMEM1(PackedVector2Array, push_back);
- VCALL_LOCALMEM1(PackedVector2Array, resize);
- VCALL_LOCALMEM2R(PackedVector2Array, insert);
- VCALL_LOCALMEM1(PackedVector2Array, remove);
- VCALL_LOCALMEM1(PackedVector2Array, append);
- VCALL_LOCALMEM1(PackedVector2Array, append_array);
- VCALL_LOCALMEM0(PackedVector2Array, invert);
-
- VCALL_LOCALMEM0R(PackedVector3Array, size);
- VCALL_LOCALMEM0R(PackedVector3Array, empty);
- VCALL_LOCALMEM2(PackedVector3Array, set);
- VCALL_LOCALMEM1R(PackedVector3Array, get);
- VCALL_LOCALMEM1(PackedVector3Array, push_back);
- VCALL_LOCALMEM1(PackedVector3Array, resize);
- VCALL_LOCALMEM2R(PackedVector3Array, insert);
- VCALL_LOCALMEM1(PackedVector3Array, remove);
- VCALL_LOCALMEM1(PackedVector3Array, append);
- VCALL_LOCALMEM1(PackedVector3Array, append_array);
- VCALL_LOCALMEM0(PackedVector3Array, invert);
-
- VCALL_LOCALMEM0R(PackedColorArray, size);
- VCALL_LOCALMEM0R(PackedColorArray, empty);
- VCALL_LOCALMEM2(PackedColorArray, set);
- VCALL_LOCALMEM1R(PackedColorArray, get);
- VCALL_LOCALMEM1(PackedColorArray, push_back);
- VCALL_LOCALMEM1(PackedColorArray, resize);
- VCALL_LOCALMEM2R(PackedColorArray, insert);
- VCALL_LOCALMEM1(PackedColorArray, remove);
- VCALL_LOCALMEM1(PackedColorArray, append);
- VCALL_LOCALMEM1(PackedColorArray, append_array);
- VCALL_LOCALMEM0(PackedColorArray, invert);
+#define VCALL_PARRMEM0(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(); }
+#define VCALL_PARRMEM0R(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(); }
+#define VCALL_PARRMEM1(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0]); }
+#define VCALL_PARRMEM1R(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0]); }
+#define VCALL_PARRMEM2(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1]); }
+#define VCALL_PARRMEM2R(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1]); }
+#define VCALL_PARRMEM3(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2]); }
+#define VCALL_PARRMEM3R(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2]); }
+#define VCALL_PARRMEM4(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); }
+#define VCALL_PARRMEM4R(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); }
+#define VCALL_PARRMEM5(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
+#define VCALL_PARRMEM5R(m_type, m_elemtype, m_method) \
+ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = Variant::PackedArrayRef<m_elemtype>::get_array_ptr(p_self._data.packed_array)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
+
+ VCALL_PARRMEM0R(PackedByteArray, uint8_t, size);
+ VCALL_PARRMEM0R(PackedByteArray, uint8_t, empty);
+ VCALL_PARRMEM2(PackedByteArray, uint8_t, set);
+ VCALL_PARRMEM1R(PackedByteArray, uint8_t, get);
+ VCALL_PARRMEM1(PackedByteArray, uint8_t, push_back);
+ VCALL_PARRMEM1(PackedByteArray, uint8_t, resize);
+ VCALL_PARRMEM2R(PackedByteArray, uint8_t, insert);
+ VCALL_PARRMEM1(PackedByteArray, uint8_t, remove);
+ VCALL_PARRMEM1(PackedByteArray, uint8_t, append);
+ VCALL_PARRMEM1(PackedByteArray, uint8_t, append_array);
+ VCALL_PARRMEM0(PackedByteArray, uint8_t, invert);
+ VCALL_PARRMEM2R(PackedByteArray, uint8_t, subarray);
+
+ VCALL_PARRMEM0R(PackedInt32Array, int32_t, size);
+ VCALL_PARRMEM0R(PackedInt32Array, int32_t, empty);
+ VCALL_PARRMEM2(PackedInt32Array, int32_t, set);
+ VCALL_PARRMEM1R(PackedInt32Array, int32_t, get);
+ VCALL_PARRMEM1(PackedInt32Array, int32_t, push_back);
+ VCALL_PARRMEM1(PackedInt32Array, int32_t, resize);
+ VCALL_PARRMEM2R(PackedInt32Array, int32_t, insert);
+ VCALL_PARRMEM1(PackedInt32Array, int32_t, remove);
+ VCALL_PARRMEM1(PackedInt32Array, int32_t, append);
+ VCALL_PARRMEM1(PackedInt32Array, int32_t, append_array);
+ VCALL_PARRMEM0(PackedInt32Array, int32_t, invert);
+
+ VCALL_PARRMEM0R(PackedInt64Array, int64_t, size);
+ VCALL_PARRMEM0R(PackedInt64Array, int64_t, empty);
+ VCALL_PARRMEM2(PackedInt64Array, int64_t, set);
+ VCALL_PARRMEM1R(PackedInt64Array, int64_t, get);
+ VCALL_PARRMEM1(PackedInt64Array, int64_t, push_back);
+ VCALL_PARRMEM1(PackedInt64Array, int64_t, resize);
+ VCALL_PARRMEM2R(PackedInt64Array, int64_t, insert);
+ VCALL_PARRMEM1(PackedInt64Array, int64_t, remove);
+ VCALL_PARRMEM1(PackedInt64Array, int64_t, append);
+ VCALL_PARRMEM1(PackedInt64Array, int64_t, append_array);
+ VCALL_PARRMEM0(PackedInt64Array, int64_t, invert);
+
+ VCALL_PARRMEM0R(PackedFloat32Array, float, size);
+ VCALL_PARRMEM0R(PackedFloat32Array, float, empty);
+ VCALL_PARRMEM2(PackedFloat32Array, float, set);
+ VCALL_PARRMEM1R(PackedFloat32Array, float, get);
+ VCALL_PARRMEM1(PackedFloat32Array, float, push_back);
+ VCALL_PARRMEM1(PackedFloat32Array, float, resize);
+ VCALL_PARRMEM2R(PackedFloat32Array, float, insert);
+ VCALL_PARRMEM1(PackedFloat32Array, float, remove);
+ VCALL_PARRMEM1(PackedFloat32Array, float, append);
+ VCALL_PARRMEM1(PackedFloat32Array, float, append_array);
+ VCALL_PARRMEM0(PackedFloat32Array, float, invert);
+
+ VCALL_PARRMEM0R(PackedFloat64Array, double, size);
+ VCALL_PARRMEM0R(PackedFloat64Array, double, empty);
+ VCALL_PARRMEM2(PackedFloat64Array, double, set);
+ VCALL_PARRMEM1R(PackedFloat64Array, double, get);
+ VCALL_PARRMEM1(PackedFloat64Array, double, push_back);
+ VCALL_PARRMEM1(PackedFloat64Array, double, resize);
+ VCALL_PARRMEM2R(PackedFloat64Array, double, insert);
+ VCALL_PARRMEM1(PackedFloat64Array, double, remove);
+ VCALL_PARRMEM1(PackedFloat64Array, double, append);
+ VCALL_PARRMEM1(PackedFloat64Array, double, append_array);
+ VCALL_PARRMEM0(PackedFloat64Array, double, invert);
+
+ VCALL_PARRMEM0R(PackedStringArray, String, size);
+ VCALL_PARRMEM0R(PackedStringArray, String, empty);
+ VCALL_PARRMEM2(PackedStringArray, String, set);
+ VCALL_PARRMEM1R(PackedStringArray, String, get);
+ VCALL_PARRMEM1(PackedStringArray, String, push_back);
+ VCALL_PARRMEM1(PackedStringArray, String, resize);
+ VCALL_PARRMEM2R(PackedStringArray, String, insert);
+ VCALL_PARRMEM1(PackedStringArray, String, remove);
+ VCALL_PARRMEM1(PackedStringArray, String, append);
+ VCALL_PARRMEM1(PackedStringArray, String, append_array);
+ VCALL_PARRMEM0(PackedStringArray, String, invert);
+
+ VCALL_PARRMEM0R(PackedVector2Array, Vector2, size);
+ VCALL_PARRMEM0R(PackedVector2Array, Vector2, empty);
+ VCALL_PARRMEM2(PackedVector2Array, Vector2, set);
+ VCALL_PARRMEM1R(PackedVector2Array, Vector2, get);
+ VCALL_PARRMEM1(PackedVector2Array, Vector2, push_back);
+ VCALL_PARRMEM1(PackedVector2Array, Vector2, resize);
+ VCALL_PARRMEM2R(PackedVector2Array, Vector2, insert);
+ VCALL_PARRMEM1(PackedVector2Array, Vector2, remove);
+ VCALL_PARRMEM1(PackedVector2Array, Vector2, append);
+ VCALL_PARRMEM1(PackedVector2Array, Vector2, append_array);
+ VCALL_PARRMEM0(PackedVector2Array, Vector2, invert);
+
+ VCALL_PARRMEM0R(PackedVector3Array, Vector3, size);
+ VCALL_PARRMEM0R(PackedVector3Array, Vector3, empty);
+ VCALL_PARRMEM2(PackedVector3Array, Vector3, set);
+ VCALL_PARRMEM1R(PackedVector3Array, Vector3, get);
+ VCALL_PARRMEM1(PackedVector3Array, Vector3, push_back);
+ VCALL_PARRMEM1(PackedVector3Array, Vector3, resize);
+ VCALL_PARRMEM2R(PackedVector3Array, Vector3, insert);
+ VCALL_PARRMEM1(PackedVector3Array, Vector3, remove);
+ VCALL_PARRMEM1(PackedVector3Array, Vector3, append);
+ VCALL_PARRMEM1(PackedVector3Array, Vector3, append_array);
+ VCALL_PARRMEM0(PackedVector3Array, Vector3, invert);
+
+ VCALL_PARRMEM0R(PackedColorArray, Color, size);
+ VCALL_PARRMEM0R(PackedColorArray, Color, empty);
+ VCALL_PARRMEM2(PackedColorArray, Color, set);
+ VCALL_PARRMEM1R(PackedColorArray, Color, get);
+ VCALL_PARRMEM1(PackedColorArray, Color, push_back);
+ VCALL_PARRMEM1(PackedColorArray, Color, resize);
+ VCALL_PARRMEM2R(PackedColorArray, Color, insert);
+ VCALL_PARRMEM1(PackedColorArray, Color, remove);
+ VCALL_PARRMEM1(PackedColorArray, Color, append);
+ VCALL_PARRMEM1(PackedColorArray, Color, append_array);
+ VCALL_PARRMEM0(PackedColorArray, Color, invert);
#define VCALL_PTR0(m_type, m_method) \
static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(); }
@@ -1236,20 +1285,20 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// atomic types
case BOOL: return Variant(false);
case INT: return 0;
- case REAL: return 0.0f;
+ case FLOAT: return 0.0f;
case STRING:
return String();
// math types
case VECTOR2:
- return Vector2(); // 5
+ return Vector2();
case RECT2: return Rect2();
case VECTOR3: return Vector3();
case TRANSFORM2D: return Transform2D();
case PLANE: return Plane();
case QUAT: return Quat();
case AABB:
- return ::AABB(); // 10
+ return ::AABB();
case BASIS: return Basis();
case TRANSFORM:
return Transform();
@@ -1257,22 +1306,24 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// misc types
case COLOR: return Color();
case STRING_NAME:
- return StringName(); // 15
+ return StringName();
case NODE_PATH:
- return NodePath(); // 15
+ return NodePath();
case _RID: return RID();
case OBJECT: return (Object *)NULL;
case CALLABLE: return Callable();
case SIGNAL: return Signal();
case DICTIONARY: return Dictionary();
case ARRAY:
- return Array(); // 20
+ return Array();
case PACKED_BYTE_ARRAY: return PackedByteArray();
- case PACKED_INT_ARRAY: return PackedIntArray();
- case PACKED_REAL_ARRAY: return PackedRealArray();
+ case PACKED_INT32_ARRAY: return PackedInt32Array();
+ case PACKED_INT64_ARRAY: return PackedInt64Array();
+ case PACKED_FLOAT32_ARRAY: return PackedFloat32Array();
+ case PACKED_FLOAT64_ARRAY: return PackedFloat64Array();
case PACKED_STRING_ARRAY: return PackedStringArray();
case PACKED_VECTOR2_ARRAY:
- return PackedVector2Array(); // 25
+ return PackedVector2Array();
case PACKED_VECTOR3_ARRAY: return PackedVector3Array();
case PACKED_COLOR_ARRAY: return PackedColorArray();
default: return Variant();
@@ -1294,7 +1345,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case INT: {
return (int64_t(*p_args[0]));
}
- case REAL: {
+ case FLOAT: {
return real_t(*p_args[0]);
}
case STRING: {
@@ -1313,7 +1364,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case PLANE: return (Plane(*p_args[0]));
case QUAT: return (p_args[0]->operator Quat());
case AABB:
- return (::AABB(*p_args[0])); // 10
+ return (::AABB(*p_args[0]));
case BASIS: return (Basis(p_args[0]->operator Basis()));
case TRANSFORM:
return (Transform(p_args[0]->operator Transform()));
@@ -1321,24 +1372,26 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// misc types
case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]);
case STRING_NAME:
- return (StringName(p_args[0]->operator StringName())); // 15
+ return (StringName(p_args[0]->operator StringName()));
case NODE_PATH:
- return (NodePath(p_args[0]->operator NodePath())); // 15
+ return (NodePath(p_args[0]->operator NodePath()));
case _RID: return (RID(*p_args[0]));
case OBJECT: return ((Object *)(p_args[0]->operator Object *()));
case CALLABLE: return ((Callable)(p_args[0]->operator Callable()));
case SIGNAL: return ((Signal)(p_args[0]->operator Signal()));
case DICTIONARY: return p_args[0]->operator Dictionary();
case ARRAY:
- return p_args[0]->operator Array(); // 20
+ return p_args[0]->operator Array();
// arrays
case PACKED_BYTE_ARRAY: return (PackedByteArray(*p_args[0]));
- case PACKED_INT_ARRAY: return (PackedIntArray(*p_args[0]));
- case PACKED_REAL_ARRAY: return (PackedRealArray(*p_args[0]));
+ case PACKED_INT32_ARRAY: return (PackedInt32Array(*p_args[0]));
+ case PACKED_INT64_ARRAY: return (PackedInt64Array(*p_args[0]));
+ case PACKED_FLOAT32_ARRAY: return (PackedFloat32Array(*p_args[0]));
+ case PACKED_FLOAT64_ARRAY: return (PackedFloat64Array(*p_args[0]));
case PACKED_STRING_ARRAY: return (PackedStringArray(*p_args[0]));
case PACKED_VECTOR2_ARRAY:
- return (PackedVector2Array(*p_args[0])); // 25
+ return (PackedVector2Array(*p_args[0]));
case PACKED_VECTOR3_ARRAY: return (PackedVector3Array(*p_args[0]));
case PACKED_COLOR_ARRAY: return (PackedColorArray(*p_args[0]));
default: return Variant();
@@ -1672,7 +1725,7 @@ void register_variant_methods() {
ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray());
ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray());
ADDFUNC0R(STRING, PACKED_STRING_ARRAY, String, bigrams, varray());
- ADDFUNC1R(STRING, REAL, String, similarity, STRING, "text", varray());
+ ADDFUNC1R(STRING, FLOAT, String, similarity, STRING, "text", varray());
ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}"));
ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray());
@@ -1682,7 +1735,7 @@ void register_variant_methods() {
ADDFUNC0R(STRING, STRING, String, capitalize, varray());
ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, rsplit, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
- ADDFUNC2R(STRING, PACKED_REAL_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true));
+ ADDFUNC2R(STRING, PACKED_FLOAT32_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true));
ADDFUNC0R(STRING, STRING, String, to_upper, varray());
ADDFUNC0R(STRING, STRING, String, to_lower, varray());
@@ -1729,7 +1782,7 @@ void register_variant_methods() {
ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray());
ADDFUNC0R(STRING, BOOL, String, is_valid_filename, varray());
ADDFUNC0R(STRING, INT, String, to_int, varray());
- ADDFUNC0R(STRING, REAL, String, to_float, varray());
+ ADDFUNC0R(STRING, FLOAT, String, to_float, varray());
ADDFUNC0R(STRING, INT, String, hex_to_int, varray());
ADDFUNC1R(STRING, STRING, String, pad_decimals, INT, "digits", varray());
ADDFUNC1R(STRING, STRING, String, pad_zeros, INT, "digits", varray());
@@ -1739,45 +1792,45 @@ void register_variant_methods() {
ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_ascii, varray());
ADDFUNC0R(STRING, PACKED_BYTE_ARRAY, String, to_utf8, varray());
- ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray());
- ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray());
- ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray());
+ ADDFUNC0R(VECTOR2, FLOAT, Vector2, angle, varray());
+ ADDFUNC1R(VECTOR2, FLOAT, Vector2, angle_to, VECTOR2, "to", varray());
+ ADDFUNC1R(VECTOR2, FLOAT, Vector2, angle_to_point, VECTOR2, "to", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, direction_to, VECTOR2, "b", varray());
- ADDFUNC1R(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray());
- ADDFUNC1R(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray());
- ADDFUNC0R(VECTOR2, REAL, Vector2, length, varray());
- ADDFUNC0R(VECTOR2, REAL, Vector2, length_squared, varray());
+ ADDFUNC1R(VECTOR2, FLOAT, Vector2, distance_to, VECTOR2, "to", varray());
+ ADDFUNC1R(VECTOR2, FLOAT, Vector2, distance_squared_to, VECTOR2, "to", varray());
+ ADDFUNC0R(VECTOR2, FLOAT, Vector2, length, varray());
+ ADDFUNC0R(VECTOR2, FLOAT, Vector2, length_squared, varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray());
ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray());
ADDFUNC1R(VECTOR2, BOOL, Vector2, is_equal_approx, VECTOR2, "v", varray());
- ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, REAL, "mod", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, FLOAT, "mod", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray());
- ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray());
- ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", REAL, "t", varray());
- ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray());
- ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", REAL, "delta", varray());
- ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray());
+ ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", FLOAT, "t", varray());
+ ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", FLOAT, "t", varray());
+ ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", FLOAT, "t", varray());
+ ADDFUNC2R(VECTOR2, VECTOR2, Vector2, move_toward, VECTOR2, "to", FLOAT, "delta", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, FLOAT, "phi", varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, floor, varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, ceil, varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, round, varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray());
- ADDFUNC0R(VECTOR2, REAL, Vector2, aspect, varray());
- ADDFUNC1R(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray());
+ ADDFUNC0R(VECTOR2, FLOAT, Vector2, aspect, varray());
+ ADDFUNC1R(VECTOR2, FLOAT, Vector2, dot, VECTOR2, "with", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray());
- ADDFUNC1R(VECTOR2, REAL, Vector2, cross, VECTOR2, "with", varray());
+ ADDFUNC1R(VECTOR2, FLOAT, Vector2, cross, VECTOR2, "with", varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray());
- ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, FLOAT, "length", varray());
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, sign, varray());
- ADDFUNC0R(VECTOR2I, REAL, Vector2i, aspect, varray());
+ ADDFUNC0R(VECTOR2I, FLOAT, Vector2i, aspect, varray());
ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, sign, varray());
ADDFUNC0R(VECTOR2I, VECTOR2I, Vector2i, abs, varray());
- ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray());
+ ADDFUNC0R(RECT2, FLOAT, Rect2, get_area, varray());
ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray());
ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray());
ADDFUNC1R(RECT2, BOOL, Rect2, is_equal_approx, RECT2, "rect", varray());
@@ -1786,9 +1839,9 @@ void register_variant_methods() {
ADDFUNC1R(RECT2, RECT2, Rect2, clip, RECT2, "b", varray());
ADDFUNC1R(RECT2, RECT2, Rect2, merge, RECT2, "b", varray());
ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray());
- ADDFUNC1R(RECT2, RECT2, Rect2, grow, REAL, "by", varray());
- ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray());
- ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray());
+ ADDFUNC1R(RECT2, RECT2, Rect2, grow, FLOAT, "by", varray());
+ ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", FLOAT, "by", varray());
+ ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, FLOAT, "left", FLOAT, "top", FLOAT, "right", FLOAT, " bottom", varray());
ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray());
ADDFUNC0R(RECT2I, INT, Rect2i, get_area, varray());
@@ -1806,23 +1859,23 @@ void register_variant_methods() {
ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray());
ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray());
- ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray());
+ ADDFUNC1R(VECTOR3, FLOAT, Vector3, angle_to, VECTOR3, "to", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, direction_to, VECTOR3, "b", varray());
- ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray());
- ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray());
- ADDFUNC0R(VECTOR3, REAL, Vector3, length, varray());
- ADDFUNC0R(VECTOR3, REAL, Vector3, length_squared, varray());
+ ADDFUNC1R(VECTOR3, FLOAT, Vector3, distance_to, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, FLOAT, Vector3, distance_squared_to, VECTOR3, "b", varray());
+ ADDFUNC0R(VECTOR3, FLOAT, Vector3, length, varray());
+ ADDFUNC0R(VECTOR3, FLOAT, Vector3, length_squared, varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray());
ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray());
ADDFUNC1R(VECTOR3, BOOL, Vector3, is_equal_approx, VECTOR3, "v", varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray());
- ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
- ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray());
- ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", REAL, "t", varray());
- ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray());
- ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", REAL, "delta", varray());
- ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
+ ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", FLOAT, "phi", varray());
+ ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", FLOAT, "t", varray());
+ ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", FLOAT, "t", varray());
+ ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", FLOAT, "t", varray());
+ ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", FLOAT, "delta", varray());
+ ADDFUNC1R(VECTOR3, FLOAT, Vector3, dot, VECTOR3, "b", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
ADDFUNC1R(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray());
ADDFUNC0R(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray());
@@ -1830,7 +1883,7 @@ void register_variant_methods() {
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, round, varray());
- ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmod, REAL, "mod", varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmod, FLOAT, "mod", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmodv, VECTOR3, "modv", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, project, VECTOR3, "b", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray());
@@ -1847,27 +1900,27 @@ void register_variant_methods() {
ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray());
ADDFUNC1R(PLANE, BOOL, Plane, is_equal_approx, PLANE, "plane", varray());
ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray());
- ADDFUNC1R(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray());
- ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON));
+ ADDFUNC1R(PLANE, FLOAT, Plane, distance_to, VECTOR3, "point", varray());
+ ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", FLOAT, "epsilon", varray(CMP_EPSILON));
ADDFUNC1R(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray());
ADDFUNC2R(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray());
ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray());
ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray());
- ADDFUNC0R(QUAT, REAL, Quat, length, varray());
- ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray());
+ ADDFUNC0R(QUAT, FLOAT, Quat, length, varray());
+ ADDFUNC0R(QUAT, FLOAT, Quat, length_squared, varray());
ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray());
ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray());
ADDFUNC1R(QUAT, BOOL, Quat, is_equal_approx, QUAT, "quat", varray());
ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
- ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
+ ADDFUNC1R(QUAT, FLOAT, Quat, dot, QUAT, "b", varray());
ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
- ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray());
- ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray());
- ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray());
+ ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", FLOAT, "t", varray());
+ ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", FLOAT, "t", varray());
+ ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", FLOAT, "t", varray());
ADDFUNC0R(QUAT, VECTOR3, Quat, get_euler, varray());
ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray());
- ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
+ ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", FLOAT, "angle", varray());
ADDFUNC0R(COLOR, INT, Color, to_argb32, varray());
ADDFUNC0R(COLOR, INT, Color, to_abgr32, varray());
@@ -1877,12 +1930,12 @@ void register_variant_methods() {
ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray());
ADDFUNC0R(COLOR, COLOR, Color, inverted, varray());
ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());
- ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray());
+ ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", FLOAT, "t", varray());
ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray());
- ADDFUNC1R(COLOR, COLOR, Color, lightened, REAL, "amount", varray());
- ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray());
+ ADDFUNC1R(COLOR, COLOR, Color, lightened, FLOAT, "amount", varray());
+ ADDFUNC1R(COLOR, COLOR, Color, darkened, FLOAT, "amount", varray());
ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true));
- ADDFUNC4R(COLOR, COLOR, Color, from_hsv, REAL, "h", REAL, "s", REAL, "v", REAL, "a", varray(1.0));
+ ADDFUNC4R(COLOR, COLOR, Color, from_hsv, FLOAT, "h", FLOAT, "s", FLOAT, "v", FLOAT, "a", varray(1.0));
ADDFUNC1R(COLOR, BOOL, Color, is_equal_approx, COLOR, "color", varray());
ADDFUNC0R(_RID, INT, RID, get_id, varray());
@@ -1976,27 +2029,49 @@ void register_variant_methods() {
ADDFUNC1R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, compress, INT, "compression_mode", varray(0));
ADDFUNC2R(PACKED_BYTE_ARRAY, PACKED_BYTE_ARRAY, PackedByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
- ADDFUNC0R(PACKED_INT_ARRAY, INT, PackedIntArray, size, varray());
- ADDFUNC0R(PACKED_INT_ARRAY, BOOL, PackedIntArray, empty, varray());
- ADDFUNC2(PACKED_INT_ARRAY, NIL, PackedIntArray, set, INT, "idx", INT, "integer", varray());
- ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, push_back, INT, "integer", varray());
- ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, append, INT, "integer", varray());
- ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, append_array, PACKED_INT_ARRAY, "array", varray());
- ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, remove, INT, "idx", varray());
- ADDFUNC2R(PACKED_INT_ARRAY, INT, PackedIntArray, insert, INT, "idx", INT, "integer", varray());
- ADDFUNC1(PACKED_INT_ARRAY, NIL, PackedIntArray, resize, INT, "idx", varray());
- ADDFUNC0(PACKED_INT_ARRAY, NIL, PackedIntArray, invert, varray());
-
- ADDFUNC0R(PACKED_REAL_ARRAY, INT, PackedRealArray, size, varray());
- ADDFUNC0R(PACKED_REAL_ARRAY, BOOL, PackedRealArray, empty, varray());
- ADDFUNC2(PACKED_REAL_ARRAY, NIL, PackedRealArray, set, INT, "idx", REAL, "value", varray());
- ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, push_back, REAL, "value", varray());
- ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, append, REAL, "value", varray());
- ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, append_array, PACKED_REAL_ARRAY, "array", varray());
- ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, remove, INT, "idx", varray());
- ADDFUNC2R(PACKED_REAL_ARRAY, INT, PackedRealArray, insert, INT, "idx", REAL, "value", varray());
- ADDFUNC1(PACKED_REAL_ARRAY, NIL, PackedRealArray, resize, INT, "idx", varray());
- ADDFUNC0(PACKED_REAL_ARRAY, NIL, PackedRealArray, invert, varray());
+ ADDFUNC0R(PACKED_INT32_ARRAY, INT, PackedInt32Array, size, varray());
+ ADDFUNC0R(PACKED_INT32_ARRAY, BOOL, PackedInt32Array, empty, varray());
+ ADDFUNC2(PACKED_INT32_ARRAY, NIL, PackedInt32Array, set, INT, "idx", INT, "integer", varray());
+ ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, push_back, INT, "integer", varray());
+ ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, append, INT, "integer", varray());
+ ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, append_array, PACKED_INT32_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_INT32_ARRAY, INT, PackedInt32Array, insert, INT, "idx", INT, "integer", varray());
+ ADDFUNC1(PACKED_INT32_ARRAY, NIL, PackedInt32Array, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_INT32_ARRAY, NIL, PackedInt32Array, invert, varray());
+
+ ADDFUNC0R(PACKED_INT64_ARRAY, INT, PackedInt64Array, size, varray());
+ ADDFUNC0R(PACKED_INT64_ARRAY, BOOL, PackedInt64Array, empty, varray());
+ ADDFUNC2(PACKED_INT64_ARRAY, NIL, PackedInt64Array, set, INT, "idx", INT, "integer", varray());
+ ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, push_back, INT, "integer", varray());
+ ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, append, INT, "integer", varray());
+ ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, append_array, PACKED_INT64_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_INT64_ARRAY, INT, PackedInt64Array, insert, INT, "idx", INT, "integer", varray());
+ ADDFUNC1(PACKED_INT64_ARRAY, NIL, PackedInt64Array, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_INT64_ARRAY, NIL, PackedInt64Array, invert, varray());
+
+ ADDFUNC0R(PACKED_FLOAT32_ARRAY, INT, PackedFloat32Array, size, varray());
+ ADDFUNC0R(PACKED_FLOAT32_ARRAY, BOOL, PackedFloat32Array, empty, varray());
+ ADDFUNC2(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, set, INT, "idx", FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, push_back, FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, append, FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, append_array, PACKED_FLOAT32_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_FLOAT32_ARRAY, INT, PackedFloat32Array, insert, INT, "idx", FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_FLOAT32_ARRAY, NIL, PackedFloat32Array, invert, varray());
+
+ ADDFUNC0R(PACKED_FLOAT64_ARRAY, INT, PackedFloat64Array, size, varray());
+ ADDFUNC0R(PACKED_FLOAT64_ARRAY, BOOL, PackedFloat64Array, empty, varray());
+ ADDFUNC2(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, set, INT, "idx", FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, push_back, FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, append, FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, append_array, PACKED_FLOAT64_ARRAY, "array", varray());
+ ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, remove, INT, "idx", varray());
+ ADDFUNC2R(PACKED_FLOAT64_ARRAY, INT, PackedFloat64Array, insert, INT, "idx", FLOAT, "value", varray());
+ ADDFUNC1(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, resize, INT, "idx", varray());
+ ADDFUNC0(PACKED_FLOAT64_ARRAY, NIL, PackedFloat64Array, invert, varray());
ADDFUNC0R(PACKED_STRING_ARRAY, INT, PackedStringArray, size, varray());
ADDFUNC0R(PACKED_STRING_ARRAY, BOOL, PackedStringArray, empty, varray());
@@ -2044,7 +2119,7 @@ void register_variant_methods() {
//pointerbased
- ADDFUNC0R(AABB, REAL, AABB, get_area, varray());
+ ADDFUNC0R(AABB, FLOAT, AABB, get_area, varray());
ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray());
ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray());
ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray());
@@ -2056,94 +2131,94 @@ void register_variant_methods() {
ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray());
ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray());
ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray());
- ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray());
+ ADDFUNC1R(AABB, AABB, AABB, grow, FLOAT, "by", varray());
ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray());
ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray());
ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray());
- ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray());
+ ADDFUNC0R(AABB, FLOAT, AABB, get_longest_axis_size, varray());
ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray());
ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray());
- ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray());
+ ADDFUNC0R(AABB, FLOAT, AABB, get_shortest_axis_size, varray());
ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray());
ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray());
ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray());
- ADDFUNC0R(TRANSFORM2D, REAL, Transform2D, get_rotation, varray());
+ ADDFUNC0R(TRANSFORM2D, FLOAT, Transform2D, get_rotation, varray());
ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray());
ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray());
ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray());
- ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, FLOAT, "phi", varray());
ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray());
ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray());
ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform, NIL, "v", varray());
ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform_inv, NIL, "v", varray());
ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform, VECTOR2, "v", varray());
ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform_inv, VECTOR2, "v", varray());
- ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray());
+ ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", FLOAT, "weight", varray());
ADDFUNC1R(TRANSFORM2D, BOOL, Transform2D, is_equal_approx, TRANSFORM2D, "transform", varray());
ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray());
ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray());
ADDFUNC0R(BASIS, BASIS, Basis, orthonormalized, varray());
- ADDFUNC0R(BASIS, REAL, Basis, determinant, varray());
- ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray());
+ ADDFUNC0R(BASIS, FLOAT, Basis, determinant, varray());
+ ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", FLOAT, "phi", varray());
ADDFUNC1R(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray());
ADDFUNC0R(BASIS, VECTOR3, Basis, get_scale, varray());
ADDFUNC0R(BASIS, VECTOR3, Basis, get_euler, varray());
- ADDFUNC1R(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray());
- ADDFUNC1R(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray());
- ADDFUNC1R(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray());
+ ADDFUNC1R(BASIS, FLOAT, Basis, tdotx, VECTOR3, "with", varray());
+ ADDFUNC1R(BASIS, FLOAT, Basis, tdoty, VECTOR3, "with", varray());
+ ADDFUNC1R(BASIS, FLOAT, Basis, tdotz, VECTOR3, "with", varray());
ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray());
ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray());
- ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", REAL, "t", varray());
- ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", REAL, "epsilon", varray(CMP_EPSILON)); // TODO: Replace in 4.0, see other TODO.
+ ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", FLOAT, "t", varray());
+ ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", FLOAT, "epsilon", varray(CMP_EPSILON)); // TODO: Replace in 4.0, see other TODO.
ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray());
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray());
- ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray());
+ ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", FLOAT, "phi", varray());
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray());
ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "offset", varray());
ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray());
- ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray());
+ ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", FLOAT, "weight", varray());
ADDFUNC1R(TRANSFORM, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray());
ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());
/* REGISTER CONSTRUCTORS */
- _VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::REAL, "y", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::FLOAT, "y", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::Vector2i_init1, Variant::VECTOR2I, "x", Variant::INT, "y", Variant::INT);
_VariantCall::add_constructor(_VariantCall::Rect2_init1, Variant::RECT2, "position", Variant::VECTOR2, "size", Variant::VECTOR2);
- _VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::REAL, "y", Variant::REAL, "width", Variant::REAL, "height", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::FLOAT, "y", Variant::FLOAT, "width", Variant::FLOAT, "height", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::Rect2i_init1, Variant::RECT2I, "position", Variant::VECTOR2, "size", Variant::VECTOR2);
_VariantCall::add_constructor(_VariantCall::Rect2i_init2, Variant::RECT2I, "x", Variant::INT, "y", Variant::INT, "width", Variant::INT, "height", Variant::INT);
- _VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::REAL, "position", Variant::VECTOR2);
+ _VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::FLOAT, "position", Variant::VECTOR2);
_VariantCall::add_constructor(_VariantCall::Transform2D_init3, Variant::TRANSFORM2D, "x_axis", Variant::VECTOR2, "y_axis", Variant::VECTOR2, "origin", Variant::VECTOR2);
- _VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::FLOAT, "y", Variant::FLOAT, "z", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::Vector3i_init1, Variant::VECTOR3I, "x", Variant::INT, "y", Variant::INT, "z", Variant::INT);
- _VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::REAL, "b", Variant::REAL, "c", Variant::REAL, "d", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::FLOAT, "b", Variant::FLOAT, "c", Variant::FLOAT, "d", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::Plane_init2, Variant::PLANE, "v1", Variant::VECTOR3, "v2", Variant::VECTOR3, "v3", Variant::VECTOR3);
- _VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::FLOAT);
- _VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL, "w", Variant::REAL);
- _VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::FLOAT, "y", Variant::FLOAT, "z", Variant::FLOAT, "w", Variant::FLOAT);
+ _VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::Quat_init3, Variant::QUAT, "euler", Variant::VECTOR3);
- _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL);
- _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::FLOAT, "g", Variant::FLOAT, "b", Variant::FLOAT, "a", Variant::FLOAT);
+ _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::FLOAT, "g", Variant::FLOAT, "b", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3);
- _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::FLOAT);
_VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3);
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 6af4b3887c..36d1278929 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -41,7 +41,7 @@
#define CASE_TYPE_ALL_BUT_INT(PREFIX, OP) \
CASE_TYPE(PREFIX, OP, NIL) \
CASE_TYPE(PREFIX, OP, BOOL) \
- CASE_TYPE(PREFIX, OP, REAL) \
+ CASE_TYPE(PREFIX, OP, FLOAT) \
CASE_TYPE(PREFIX, OP, STRING) \
CASE_TYPE(PREFIX, OP, VECTOR2) \
CASE_TYPE(PREFIX, OP, VECTOR2I) \
@@ -65,8 +65,10 @@
CASE_TYPE(PREFIX, OP, DICTIONARY) \
CASE_TYPE(PREFIX, OP, ARRAY) \
CASE_TYPE(PREFIX, OP, PACKED_BYTE_ARRAY) \
- CASE_TYPE(PREFIX, OP, PACKED_INT_ARRAY) \
- CASE_TYPE(PREFIX, OP, PACKED_REAL_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_INT32_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_INT64_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_FLOAT32_ARRAY) \
+ CASE_TYPE(PREFIX, OP, PACKED_FLOAT64_ARRAY) \
CASE_TYPE(PREFIX, OP, PACKED_STRING_ARRAY) \
CASE_TYPE(PREFIX, OP, PACKED_VECTOR2_ARRAY) \
CASE_TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY) \
@@ -80,7 +82,7 @@
TYPE(PREFIX, OP, NIL), \
TYPE(PREFIX, OP, BOOL), \
TYPE(PREFIX, OP, INT), \
- TYPE(PREFIX, OP, REAL), \
+ TYPE(PREFIX, OP, FLOAT), \
TYPE(PREFIX, OP, STRING), \
TYPE(PREFIX, OP, VECTOR2), \
TYPE(PREFIX, OP, VECTOR2I), \
@@ -104,8 +106,10 @@
TYPE(PREFIX, OP, DICTIONARY), \
TYPE(PREFIX, OP, ARRAY), \
TYPE(PREFIX, OP, PACKED_BYTE_ARRAY), \
- TYPE(PREFIX, OP, PACKED_INT_ARRAY), \
- TYPE(PREFIX, OP, PACKED_REAL_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_INT32_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_INT64_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_FLOAT32_ARRAY), \
+ TYPE(PREFIX, OP, PACKED_FLOAT64_ARRAY), \
TYPE(PREFIX, OP, PACKED_STRING_ARRAY), \
TYPE(PREFIX, OP, PACKED_VECTOR2_ARRAY), \
TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY), \
@@ -177,21 +181,21 @@ bool Variant::booleanize() const {
return; \
}
-#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \
- CASE_TYPE(m_prefix, m_op_name, m_name) { \
- if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \
- if (p_b.type == REAL) _RETURN(p_a._data.m_type m_op p_b._data._real); \
- \
- _RETURN_FAIL \
+#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \
+ if (p_b.type == FLOAT) _RETURN(p_a._data.m_type m_op p_b._data._float); \
+ \
+ _RETURN_FAIL \
};
-#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \
- CASE_TYPE(m_prefix, m_op_name, m_name) { \
- if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \
- if (p_b.type == REAL) _RETURN(p_a._data.m_type m_op p_b._data._real); \
- if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \
- \
- _RETURN_FAIL \
+#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \
+ if (p_b.type == FLOAT) _RETURN(p_a._data.m_type m_op p_b._data._float); \
+ if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \
+ \
+ _RETURN_FAIL \
};
#ifdef DEBUG_ENABLED
@@ -204,23 +208,23 @@ bool Variant::booleanize() const {
} \
_RETURN(p_a._data.m_type / p_b._data._int); \
} \
- if (p_b.type == REAL) { \
- if (p_b._data._real == 0) { \
+ if (p_b.type == FLOAT) { \
+ if (p_b._data._float == 0) { \
r_valid = false; \
_RETURN("Division By Zero"); \
} \
- _RETURN(p_a._data.m_type / p_b._data._real); \
+ _RETURN(p_a._data.m_type / p_b._data._float); \
} \
\
_RETURN_FAIL \
};
#else
-#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \
- CASE_TYPE(m_prefix, m_op_name, m_name) { \
- if (p_b.type == INT) _RETURN(p_a._data.m_type / p_b._data._int); \
- if (p_b.type == REAL) _RETURN(p_a._data.m_type / p_b._data._real); \
- \
- _RETURN_FAIL \
+#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \
+ CASE_TYPE(m_prefix, m_op_name, m_name) { \
+ if (p_b.type == INT) _RETURN(p_a._data.m_type / p_b._data._int); \
+ if (p_b.type == FLOAT) _RETURN(p_a._data.m_type / p_b._data._float); \
+ \
+ _RETURN_FAIL \
};
#endif
@@ -237,7 +241,7 @@ bool Variant::booleanize() const {
#define DEFAULT_OP_NUM_VEC(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \
- if (p_b.type == REAL) _RETURN(p_a._data.m_type m_op p_b._data._real); \
+ if (p_b.type == FLOAT) _RETURN(p_a._data.m_type m_op p_b._data._float); \
if (p_b.type == VECTOR2) _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector2 *>(p_b._data._mem)); \
if (p_b.type == VECTOR3) _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector3 *>(p_b._data._mem)); \
if (p_b.type == VECTOR2I) _RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector2 *>(p_b._data._mem)); \
@@ -332,7 +336,7 @@ bool Variant::booleanize() const {
CASE_TYPE(m_prefix, m_op_name, m_name) { \
if (p_b.type == m_name) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const m_type *>(p_b._data._mem)); \
if (p_b.type == INT) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._int); \
- if (p_b.type == REAL) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._real); \
+ if (p_b.type == FLOAT) _RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op p_b._data._float); \
\
_RETURN_FAIL \
}
@@ -392,8 +396,8 @@ bool Variant::booleanize() const {
if (p_a.type != p_b.type) \
_RETURN_FAIL \
\
- const Vector<m_type> &array_a = *reinterpret_cast<const Vector<m_type> *>(p_a._data._mem); \
- const Vector<m_type> &array_b = *reinterpret_cast<const Vector<m_type> *>(p_b._data._mem); \
+ const Vector<m_type> &array_a = PackedArrayRef<m_type>::get_array(p_a._data.packed_array); \
+ const Vector<m_type> &array_b = PackedArrayRef<m_type>::get_array(p_b._data.packed_array); \
\
int a_len = array_a.size(); \
if (a_len m_opa array_b.size()) { \
@@ -416,8 +420,8 @@ bool Variant::booleanize() const {
if (p_a.type != p_b.type) \
_RETURN_FAIL; \
\
- const Vector<m_type> &array_a = *reinterpret_cast<const Vector<m_type> *>(p_a._data._mem); \
- const Vector<m_type> &array_b = *reinterpret_cast<const Vector<m_type> *>(p_b._data._mem); \
+ const Vector<m_type> &array_a = PackedArrayRef<m_type>::get_array(p_a._data.packed_array); \
+ const Vector<m_type> &array_b = PackedArrayRef<m_type>::get_array(p_b._data.packed_array); \
Vector<m_type> sum = array_a; \
sum.append_array(array_b); \
_RETURN(sum); \
@@ -496,7 +500,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM_NULL(math, OP_EQUAL, INT, ==, _int);
- DEFAULT_OP_NUM_NULL(math, OP_EQUAL, REAL, ==, _real);
+ DEFAULT_OP_NUM_NULL(math, OP_EQUAL, FLOAT, ==, _float);
DEFAULT_OP_STR_NULL(math, OP_EQUAL, STRING, ==, String);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR2, ==, Vector2);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR2I, ==, Vector2i);
@@ -516,8 +520,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, _RID, ==, RID);
DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT32_ARRAY, int32_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_INT64_ARRAY, int64_t);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_FLOAT32_ARRAY, float);
+ DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_FLOAT64_ARRAY, double);
DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_STRING_ARRAY, String);
DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_VECTOR2_ARRAY, Vector2);
DEFAULT_OP_ARRAY_EQ(math, OP_EQUAL, PACKED_VECTOR3_ARRAY, Vector3);
@@ -593,7 +599,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, INT, !=, _int);
- DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, REAL, !=, _real);
+ DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, FLOAT, !=, _float);
DEFAULT_OP_STR_NULL(math, OP_NOT_EQUAL, STRING, !=, String);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR2, !=, Vector2);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR2I, !=, Vector2i);
@@ -613,8 +619,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, _RID, !=, RID);
DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT32_ARRAY, int32_t);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_INT64_ARRAY, int64_t);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_FLOAT32_ARRAY, float);
+ DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_FLOAT64_ARRAY, double);
DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_STRING_ARRAY, String);
DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_VECTOR2_ARRAY, Vector2);
DEFAULT_OP_ARRAY_NEQ(math, OP_NOT_EQUAL, PACKED_VECTOR3_ARRAY, Vector3);
@@ -664,7 +672,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM(math, OP_LESS, INT, <, _int);
- DEFAULT_OP_NUM(math, OP_LESS, REAL, <, _real);
+ DEFAULT_OP_NUM(math, OP_LESS, FLOAT, <, _float);
DEFAULT_OP_STR(math, OP_LESS, STRING, <, String);
DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2, <, Vector2);
DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR2I, <, Vector2i);
@@ -672,8 +680,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM(math, OP_LESS, VECTOR3I, <, Vector3i);
DEFAULT_OP_LOCALMEM(math, OP_LESS, _RID, <, RID);
DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT32_ARRAY, int32_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_INT64_ARRAY, int64_t);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_FLOAT32_ARRAY, float);
+ DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_FLOAT64_ARRAY, double);
DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_STRING_ARRAY, String);
DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_VECTOR2_ARRAY, Vector3);
DEFAULT_OP_ARRAY_LT(math, OP_LESS, PACKED_VECTOR3_ARRAY, Vector3);
@@ -703,7 +713,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM(math, OP_LESS_EQUAL, INT, <=, _int);
- DEFAULT_OP_NUM(math, OP_LESS_EQUAL, REAL, <=, _real);
+ DEFAULT_OP_NUM(math, OP_LESS_EQUAL, FLOAT, <=, _float);
DEFAULT_OP_STR(math, OP_LESS_EQUAL, STRING, <=, String);
DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR2, <=, Vector2);
DEFAULT_OP_LOCALMEM(math, OP_LESS_EQUAL, VECTOR2I, <=, Vector2i);
@@ -730,8 +740,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_LESS_EQUAL, DICTIONARY)
CASE_TYPE(math, OP_LESS_EQUAL, ARRAY)
CASE_TYPE(math, OP_LESS_EQUAL, PACKED_BYTE_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT_ARRAY);
- CASE_TYPE(math, OP_LESS_EQUAL, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT32_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_INT64_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_FLOAT32_ARRAY);
+ CASE_TYPE(math, OP_LESS_EQUAL, PACKED_FLOAT64_ARRAY);
CASE_TYPE(math, OP_LESS_EQUAL, PACKED_STRING_ARRAY);
CASE_TYPE(math, OP_LESS_EQUAL, PACKED_VECTOR2_ARRAY);
CASE_TYPE(math, OP_LESS_EQUAL, PACKED_VECTOR3_ARRAY);
@@ -779,7 +791,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM(math, OP_GREATER, INT, >, _int);
- DEFAULT_OP_NUM(math, OP_GREATER, REAL, >, _real);
+ DEFAULT_OP_NUM(math, OP_GREATER, FLOAT, >, _float);
DEFAULT_OP_STR_REV(math, OP_GREATER, STRING, <, String);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR2, <, Vector2);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR2I, <, Vector2i);
@@ -787,8 +799,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, VECTOR3I, <, Vector3i);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER, _RID, <, RID);
DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT32_ARRAY, int32_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_INT64_ARRAY, int64_t);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_FLOAT32_ARRAY, float);
+ DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_FLOAT64_ARRAY, double);
DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_STRING_ARRAY, String);
DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_VECTOR2_ARRAY, Vector3);
DEFAULT_OP_ARRAY_GT(math, OP_GREATER, PACKED_VECTOR3_ARRAY, Vector3);
@@ -821,7 +835,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, INT, >=, _int);
- DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, REAL, >=, _real);
+ DEFAULT_OP_NUM(math, OP_GREATER_EQUAL, FLOAT, >=, _float);
DEFAULT_OP_STR_REV(math, OP_GREATER_EQUAL, STRING, <=, String);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR2, <=, Vector2);
DEFAULT_OP_LOCALMEM_REV(math, OP_GREATER_EQUAL, VECTOR2I, <=, Vector2i);
@@ -848,8 +862,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_GREATER_EQUAL, DICTIONARY)
CASE_TYPE(math, OP_GREATER_EQUAL, ARRAY)
CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_BYTE_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT_ARRAY);
- CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT32_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_INT64_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_FLOAT32_ARRAY);
+ CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_FLOAT64_ARRAY);
CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_STRING_ARRAY);
CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_VECTOR2_ARRAY);
CASE_TYPE(math, OP_GREATER_EQUAL, PACKED_VECTOR3_ARRAY);
@@ -876,7 +892,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM(math, OP_ADD, INT, +, _int);
- DEFAULT_OP_NUM(math, OP_ADD, REAL, +, _real);
+ DEFAULT_OP_NUM(math, OP_ADD, FLOAT, +, _float);
DEFAULT_OP_STR(math, OP_ADD, STRING, +, String);
DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2, +, Vector2);
DEFAULT_OP_LOCALMEM(math, OP_ADD, VECTOR2I, +, Vector2i);
@@ -886,8 +902,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM(math, OP_ADD, COLOR, +, Color);
DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_BYTE_ARRAY, uint8_t);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT_ARRAY, int);
- DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_REAL_ARRAY, real_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT32_ARRAY, int32_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_INT64_ARRAY, int64_t);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_FLOAT32_ARRAY, float);
+ DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_FLOAT64_ARRAY, double);
DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_STRING_ARRAY, String);
DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_VECTOR2_ARRAY, Vector2);
DEFAULT_OP_ARRAY_ADD(math, OP_ADD, PACKED_VECTOR3_ARRAY, Vector3);
@@ -915,7 +933,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
SWITCH_OP(math, OP_SUBTRACT, p_a.type) {
DEFAULT_OP_NUM(math, OP_SUBTRACT, INT, -, _int);
- DEFAULT_OP_NUM(math, OP_SUBTRACT, REAL, -, _real);
+ DEFAULT_OP_NUM(math, OP_SUBTRACT, FLOAT, -, _float);
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2, -, Vector2);
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR2I, -, Vector2i);
DEFAULT_OP_LOCALMEM(math, OP_SUBTRACT, VECTOR3, -, Vector3);
@@ -943,8 +961,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_SUBTRACT, DICTIONARY)
CASE_TYPE(math, OP_SUBTRACT, ARRAY)
CASE_TYPE(math, OP_SUBTRACT, PACKED_BYTE_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, PACKED_INT_ARRAY);
- CASE_TYPE(math, OP_SUBTRACT, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_INT32_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_INT64_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_FLOAT32_ARRAY);
+ CASE_TYPE(math, OP_SUBTRACT, PACKED_FLOAT64_ARRAY);
CASE_TYPE(math, OP_SUBTRACT, PACKED_STRING_ARRAY);
CASE_TYPE(math, OP_SUBTRACT, PACKED_VECTOR2_ARRAY);
CASE_TYPE(math, OP_SUBTRACT, PACKED_VECTOR3_ARRAY);
@@ -973,8 +993,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
case QUAT: {
_RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * *reinterpret_cast<const Quat *>(p_b._data._mem));
}
- case REAL: {
- _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._real);
+ case FLOAT: {
+ _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) * p_b._data._float);
}
default: _RETURN_FAIL;
}
@@ -1005,7 +1025,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, INT, *, _int);
- DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, REAL, *, _real);
+ DEFAULT_OP_NUM_VEC(math, OP_MULTIPLY, FLOAT, *, _float);
DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR2, *, Vector2);
DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR2I, *, Vector2i);
DEFAULT_OP_LOCALMEM_NUM(math, OP_MULTIPLY, VECTOR3, *, Vector3);
@@ -1029,8 +1049,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MULTIPLY, DICTIONARY)
CASE_TYPE(math, OP_MULTIPLY, ARRAY)
CASE_TYPE(math, OP_MULTIPLY, PACKED_BYTE_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, PACKED_INT_ARRAY);
- CASE_TYPE(math, OP_MULTIPLY, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_INT32_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_INT64_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_FLOAT32_ARRAY);
+ CASE_TYPE(math, OP_MULTIPLY, PACKED_FLOAT64_ARRAY);
CASE_TYPE(math, OP_MULTIPLY, PACKED_STRING_ARRAY);
CASE_TYPE(math, OP_MULTIPLY, PACKED_VECTOR2_ARRAY);
CASE_TYPE(math, OP_MULTIPLY, PACKED_VECTOR3_ARRAY);
@@ -1040,19 +1062,19 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
SWITCH_OP(math, OP_DIVIDE, p_a.type) {
CASE_TYPE(math, OP_DIVIDE, QUAT) {
- if (p_b.type != REAL)
+ if (p_b.type != FLOAT)
_RETURN_FAIL;
#ifdef DEBUG_ENABLED
- if (p_b._data._real == 0) {
+ if (p_b._data._float == 0) {
r_valid = false;
_RETURN("Division By Zero");
}
#endif
- _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._real);
+ _RETURN(*reinterpret_cast<const Quat *>(p_a._data._mem) / p_b._data._float);
}
DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, INT, _int);
- DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, REAL, _real);
+ DEFAULT_OP_NUM_DIV(math, OP_DIVIDE, FLOAT, _float);
DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR2, /, Vector2);
DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR2I, /, Vector2i);
DEFAULT_OP_LOCALMEM_NUM(math, OP_DIVIDE, VECTOR3, /, Vector3);
@@ -1079,8 +1101,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_DIVIDE, DICTIONARY)
CASE_TYPE(math, OP_DIVIDE, ARRAY)
CASE_TYPE(math, OP_DIVIDE, PACKED_BYTE_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, PACKED_INT_ARRAY);
- CASE_TYPE(math, OP_DIVIDE, PACKED_REAL_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_INT32_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_INT64_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_FLOAT32_ARRAY);
+ CASE_TYPE(math, OP_DIVIDE, PACKED_FLOAT64_ARRAY);
CASE_TYPE(math, OP_DIVIDE, PACKED_STRING_ARRAY);
CASE_TYPE(math, OP_DIVIDE, PACKED_VECTOR2_ARRAY);
CASE_TYPE(math, OP_DIVIDE, PACKED_VECTOR3_ARRAY);
@@ -1090,7 +1114,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
SWITCH_OP(math, OP_POSITIVE, p_a.type) {
DEFAULT_OP_NUM_POS(math, OP_POSITIVE, INT, _int);
- DEFAULT_OP_NUM_POS(math, OP_POSITIVE, REAL, _real);
+ DEFAULT_OP_NUM_POS(math, OP_POSITIVE, FLOAT, _float);
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3, Vector3);
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, VECTOR3I, Vector3i);
DEFAULT_OP_LOCALMEM_POS(math, OP_POSITIVE, PLANE, Plane);
@@ -1118,8 +1142,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_POSITIVE, DICTIONARY)
CASE_TYPE(math, OP_POSITIVE, ARRAY)
CASE_TYPE(math, OP_POSITIVE, PACKED_BYTE_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, PACKED_INT_ARRAY)
- CASE_TYPE(math, OP_POSITIVE, PACKED_REAL_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_INT32_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_INT64_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_FLOAT32_ARRAY)
+ CASE_TYPE(math, OP_POSITIVE, PACKED_FLOAT64_ARRAY)
CASE_TYPE(math, OP_POSITIVE, PACKED_STRING_ARRAY)
CASE_TYPE(math, OP_POSITIVE, PACKED_VECTOR2_ARRAY)
CASE_TYPE(math, OP_POSITIVE, PACKED_VECTOR3_ARRAY)
@@ -1129,7 +1155,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
SWITCH_OP(math, OP_NEGATE, p_a.type) {
DEFAULT_OP_NUM_NEG(math, OP_NEGATE, INT, _int);
- DEFAULT_OP_NUM_NEG(math, OP_NEGATE, REAL, _real);
+ DEFAULT_OP_NUM_NEG(math, OP_NEGATE, FLOAT, _float);
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2, Vector2);
DEFAULT_OP_LOCALMEM_NEG(math, OP_NEGATE, VECTOR2I, Vector2i);
@@ -1158,8 +1184,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_NEGATE, DICTIONARY)
CASE_TYPE(math, OP_NEGATE, ARRAY)
CASE_TYPE(math, OP_NEGATE, PACKED_BYTE_ARRAY)
- CASE_TYPE(math, OP_NEGATE, PACKED_INT_ARRAY)
- CASE_TYPE(math, OP_NEGATE, PACKED_REAL_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_INT32_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_INT64_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_FLOAT32_ARRAY)
+ CASE_TYPE(math, OP_NEGATE, PACKED_FLOAT64_ARRAY)
CASE_TYPE(math, OP_NEGATE, PACKED_STRING_ARRAY)
CASE_TYPE(math, OP_NEGATE, PACKED_VECTOR2_ARRAY)
CASE_TYPE(math, OP_NEGATE, PACKED_VECTOR3_ARRAY)
@@ -1201,7 +1229,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MODULE, NIL)
CASE_TYPE(math, OP_MODULE, BOOL)
- CASE_TYPE(math, OP_MODULE, REAL)
+ CASE_TYPE(math, OP_MODULE, FLOAT)
CASE_TYPE(math, OP_MODULE, VECTOR2)
CASE_TYPE(math, OP_MODULE, VECTOR2I)
CASE_TYPE(math, OP_MODULE, RECT2)
@@ -1225,8 +1253,10 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MODULE, DICTIONARY)
CASE_TYPE(math, OP_MODULE, ARRAY)
CASE_TYPE(math, OP_MODULE, PACKED_BYTE_ARRAY)
- CASE_TYPE(math, OP_MODULE, PACKED_INT_ARRAY)
- CASE_TYPE(math, OP_MODULE, PACKED_REAL_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_INT32_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_INT64_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_FLOAT32_ARRAY)
+ CASE_TYPE(math, OP_MODULE, PACKED_FLOAT64_ARRAY)
CASE_TYPE(math, OP_MODULE, PACKED_STRING_ARRAY)
CASE_TYPE(math, OP_MODULE, PACKED_VECTOR2_ARRAY)
CASE_TYPE(math, OP_MODULE, PACKED_VECTOR3_ARRAY)
@@ -1363,13 +1393,13 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->y = p_value._data._int;
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Vector2 *v = reinterpret_cast<Vector2 *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
- v->x = p_value._data._real;
+ v->x = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->y) {
- v->y = p_value._data._real;
+ v->y = p_value._data._float;
valid = true;
}
}
@@ -1385,13 +1415,13 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->y = p_value._data._int;
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Vector2i *v = reinterpret_cast<Vector2i *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
- v->x = p_value._data._real;
+ v->x = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->y) {
- v->y = p_value._data._real;
+ v->y = p_value._data._float;
valid = true;
}
}
@@ -1462,16 +1492,16 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->z = p_value._data._int;
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
- v->x = p_value._data._real;
+ v->x = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->y) {
- v->y = p_value._data._real;
+ v->y = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->z) {
- v->z = p_value._data._real;
+ v->z = p_value._data._float;
valid = true;
}
}
@@ -1491,16 +1521,16 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->z = p_value._data._int;
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
- v->x = p_value._data._real;
+ v->x = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->y) {
- v->y = p_value._data._real;
+ v->y = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->z) {
- v->z = p_value._data._real;
+ v->z = p_value._data._float;
valid = true;
}
}
@@ -1523,19 +1553,19 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->d = p_value._data._int;
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Plane *v = reinterpret_cast<Plane *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
- v->normal.x = p_value._data._real;
+ v->normal.x = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->y) {
- v->normal.y = p_value._data._real;
+ v->normal.y = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->z) {
- v->normal.z = p_value._data._real;
+ v->normal.z = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->d) {
- v->d = p_value._data._real;
+ v->d = p_value._data._float;
valid = true;
}
@@ -1565,24 +1595,24 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->w = p_value._data._int;
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Quat *v = reinterpret_cast<Quat *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
- v->x = p_value._data._real;
+ v->x = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->y) {
- v->y = p_value._data._real;
+ v->y = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->z) {
- v->z = p_value._data._real;
+ v->z = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->w) {
- v->w = p_value._data._real;
+ v->w = p_value._data._float;
valid = true;
}
}
- } break; // 10
+ } break;
case AABB: {
if (p_value.type == Variant::VECTOR3) {
@@ -1666,40 +1696,40 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
v->set_hsv(v->get_h(), v->get_v(), p_value._data._int, v->a);
valid = true;
}
- } else if (p_value.type == Variant::REAL) {
+ } else if (p_value.type == Variant::FLOAT) {
Color *v = reinterpret_cast<Color *>(_data._mem);
if (p_index == CoreStringNames::singleton->r) {
- v->r = p_value._data._real;
+ v->r = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->g) {
- v->g = p_value._data._real;
+ v->g = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->b) {
- v->b = p_value._data._real;
+ v->b = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->a) {
- v->a = p_value._data._real;
+ v->a = p_value._data._float;
valid = true;
} else if (p_index == CoreStringNames::singleton->r8) {
- v->r = p_value._data._real / 255.0;
+ v->r = p_value._data._float / 255.0;
valid = true;
} else if (p_index == CoreStringNames::singleton->g8) {
- v->g = p_value._data._real / 255.0;
+ v->g = p_value._data._float / 255.0;
valid = true;
} else if (p_index == CoreStringNames::singleton->b8) {
- v->b = p_value._data._real / 255.0;
+ v->b = p_value._data._float / 255.0;
valid = true;
} else if (p_index == CoreStringNames::singleton->a8) {
- v->a = p_value._data._real / 255.0;
+ v->a = p_value._data._float / 255.0;
valid = true;
} else if (p_index == CoreStringNames::singleton->h) {
- v->set_hsv(p_value._data._real, v->get_s(), v->get_v(), v->a);
+ v->set_hsv(p_value._data._float, v->get_s(), v->get_v(), v->a);
valid = true;
} else if (p_index == CoreStringNames::singleton->s) {
- v->set_hsv(v->get_h(), p_value._data._real, v->get_v(), v->a);
+ v->set_hsv(v->get_h(), p_value._data._float, v->get_v(), v->a);
valid = true;
} else if (p_index == CoreStringNames::singleton->v) {
- v->set_hsv(v->get_h(), v->get_s(), p_value._data._real, v->a);
+ v->set_hsv(v->get_h(), v->get_s(), p_value._data._float, v->a);
valid = true;
}
}
@@ -1840,7 +1870,7 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
return v->w;
}
- } break; // 10
+ } break;
case AABB: {
const ::AABB *v = _data._aabb;
@@ -1934,28 +1964,55 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
return Variant();
}
-#define DEFAULT_OP_ARRAY_CMD(m_name, m_type, skip_test, cmd) \
- case m_name: { \
- skip_test; \
- \
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) { \
- int index = p_index; \
- m_type *arr = reinterpret_cast<m_type *>(_data._mem); \
- \
- if (index < 0) \
- index += arr->size(); \
- if (index >= 0 && index < arr->size()) { \
- valid = true; \
- cmd; \
- } \
- } \
+#define DEFAULT_OP_ARRAY_CMD(m_name, m_type, skip_test, cmd) \
+ case m_name: { \
+ skip_test; \
+ \
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \
+ int index = p_index; \
+ m_type *arr = reinterpret_cast<m_type *>(_data._mem); \
+ \
+ if (index < 0) \
+ index += arr->size(); \
+ if (index >= 0 && index < arr->size()) { \
+ valid = true; \
+ cmd; \
+ } \
+ } \
} break;
-#define DEFAULT_OP_DVECTOR_SET(m_name, dv_type, skip_cond) \
- DEFAULT_OP_ARRAY_CMD(m_name, Vector<dv_type>, if (skip_cond) return;, arr->set(index, p_value); return )
+#define DEFAULT_OP_DVECTOR_SET(m_name, m_type, skip_cond) \
+ case m_name: { \
+ if (skip_cond) return; \
+ \
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \
+ int index = p_index; \
+ Vector<m_type> *arr = PackedArrayRef<m_type>::get_array_ptr(_data.packed_array); \
+ \
+ if (index < 0) \
+ index += arr->size(); \
+ if (index >= 0 && index < arr->size()) { \
+ valid = true; \
+ arr->set(index, p_value); \
+ } \
+ } \
+ } break;
-#define DEFAULT_OP_DVECTOR_GET(m_name, dv_type) \
- DEFAULT_OP_ARRAY_CMD(m_name, const Vector<dv_type>, ;, return arr->get(index))
+#define DEFAULT_OP_DVECTOR_GET(m_name, m_type) \
+ case m_name: { \
+ \
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \
+ int index = p_index; \
+ const Vector<m_type> *arr = &PackedArrayRef<m_type>::get_array(_data.packed_array); \
+ \
+ if (index < 0) \
+ index += arr->size(); \
+ if (index >= 0 && index < arr->size()) { \
+ valid = true; \
+ return arr->get(index); \
+ } \
+ } \
+ } break;
void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) {
@@ -1974,12 +2031,12 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
case INT: {
return;
} break;
- case REAL: {
+ case FLOAT: {
return;
} break;
case STRING: {
- if (p_index.type != Variant::INT && p_index.type != Variant::REAL)
+ if (p_index.type != Variant::INT && p_index.type != Variant::FLOAT)
return;
int idx = p_index;
@@ -1991,7 +2048,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
String chr;
- if (p_value.type == Variant::INT || p_value.type == Variant::REAL) {
+ if (p_value.type == Variant::INT || p_value.type == Variant::FLOAT) {
chr = String::chr(p_value);
} else if (p_value.type == Variant::STRING) {
@@ -2008,10 +2065,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR2: {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
@@ -2040,13 +2097,13 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
}
- } break; // 5
+ } break;
case VECTOR2I: {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
@@ -2075,7 +2132,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
}
- } break; // 5
+ } break;
case RECT2: {
if (p_value.type != Variant::VECTOR2)
@@ -2131,7 +2188,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
if (p_value.type != Variant::VECTOR2)
return;
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
int index = p_index;
@@ -2167,10 +2224,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR3: {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
if (idx < 0)
@@ -2205,10 +2262,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR3I: {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
if (idx < 0)
@@ -2248,21 +2305,21 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Plane *v = reinterpret_cast<Plane *>(_data._mem);
if (*str == "x") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
valid = true;
v->normal.x = p_value;
return;
} else if (*str == "y") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
valid = true;
v->normal.y = p_value;
return;
} else if (*str == "z") {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
valid = true;
@@ -2285,7 +2342,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case QUAT: {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
if (p_index.get_type() == Variant::STRING) {
@@ -2311,7 +2368,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
}
- } break; // 10
+ } break;
case AABB: {
if (p_value.type != Variant::VECTOR3)
@@ -2342,7 +2399,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
if (p_value.type != Variant::VECTOR3)
return;
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
int index = p_index;
@@ -2378,7 +2435,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case TRANSFORM: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
if (p_value.type != Variant::VECTOR3)
return;
@@ -2421,7 +2478,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case COLOR: {
- if (p_value.type != Variant::INT && p_value.type != Variant::REAL)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
return;
if (p_index.get_type() == Variant::STRING) {
@@ -2487,9 +2544,9 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case STRING_NAME: {
- } break; // 15
+ } break;
case NODE_PATH: {
- } break; // 15
+ } break;
case _RID: {
} break;
case OBJECT: {
@@ -2523,12 +2580,14 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
valid = true; //always valid, i guess? should this really be ok?
return;
} break;
- DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return ) // 20
- DEFAULT_OP_DVECTOR_SET(PACKED_BYTE_ARRAY, uint8_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
- DEFAULT_OP_DVECTOR_SET(PACKED_INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT)
- DEFAULT_OP_DVECTOR_SET(PACKED_REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index] = p_value; return )
+ DEFAULT_OP_DVECTOR_SET(PACKED_BYTE_ARRAY, uint8_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_INT32_ARRAY, int32_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_INT64_ARRAY, int64_t, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_FLOAT32_ARRAY, float, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(PACKED_FLOAT64_ARRAY, double, p_value.type != Variant::FLOAT && p_value.type != Variant::INT)
DEFAULT_OP_DVECTOR_SET(PACKED_STRING_ARRAY, String, p_value.type != Variant::STRING)
- DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2) // 25
+ DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2)
DEFAULT_OP_DVECTOR_SET(PACKED_VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3)
DEFAULT_OP_DVECTOR_SET(PACKED_COLOR_ARRAY, Color, p_value.type != Variant::COLOR)
default:
@@ -2554,12 +2613,12 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
case INT: {
return Variant();
} break;
- case REAL: {
+ case FLOAT: {
return Variant();
} break;
case STRING: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//string index
int idx = p_index;
@@ -2576,7 +2635,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case VECTOR2: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
if (idx < 0)
@@ -2601,10 +2660,10 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
}
- } break; // 5
+ } break;
case VECTOR2I: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
if (idx < 0)
@@ -2629,7 +2688,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
}
- } break; // 5
+ } break;
case RECT2: {
if (p_index.get_type() == Variant::STRING) {
@@ -2670,7 +2729,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case VECTOR3: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
if (idx < 0)
@@ -2701,7 +2760,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case VECTOR3I: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
if (idx < 0)
@@ -2732,7 +2791,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case TRANSFORM2D: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
int index = p_index;
@@ -2808,7 +2867,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
}
- } break; // 10
+ } break;
case AABB: {
if (p_index.get_type() == Variant::STRING) {
@@ -2830,7 +2889,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case BASIS: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
int index = p_index;
if (index < 0)
@@ -2861,7 +2920,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case TRANSFORM: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
int index = p_index;
if (index < 0)
@@ -2941,9 +3000,9 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case STRING_NAME: {
- } break; // 15
+ } break;
case NODE_PATH: {
- } break; // 15
+ } break;
case _RID: {
} break;
case OBJECT: {
@@ -2975,12 +3034,14 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
return *res;
}
} break;
- DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) // 20
+ DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index])
DEFAULT_OP_DVECTOR_GET(PACKED_BYTE_ARRAY, uint8_t)
- DEFAULT_OP_DVECTOR_GET(PACKED_INT_ARRAY, int)
- DEFAULT_OP_DVECTOR_GET(PACKED_REAL_ARRAY, real_t)
+ DEFAULT_OP_DVECTOR_GET(PACKED_INT32_ARRAY, int32_t)
+ DEFAULT_OP_DVECTOR_GET(PACKED_INT64_ARRAY, int64_t)
+ DEFAULT_OP_DVECTOR_GET(PACKED_FLOAT32_ARRAY, float)
+ DEFAULT_OP_DVECTOR_GET(PACKED_FLOAT64_ARRAY, double)
DEFAULT_OP_DVECTOR_GET(PACKED_STRING_ARRAY, String)
- DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR2_ARRAY, Vector2) // 25
+ DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR2_ARRAY, Vector2)
DEFAULT_OP_DVECTOR_GET(PACKED_VECTOR3_ARRAY, Vector3)
DEFAULT_OP_DVECTOR_GET(PACKED_COLOR_ARRAY, Color)
default:
@@ -3042,7 +3103,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
return dic->has(p_index);
- } break; // 20
+ } break;
case ARRAY: {
const Array *arr = reinterpret_cast<const Array *>(_data._mem);
@@ -3059,10 +3120,10 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_BYTE_ARRAY: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
int index = p_index;
- const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
const uint8_t *r = arr->ptr();
@@ -3076,14 +3137,49 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break;
- case PACKED_INT_ARRAY: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ case PACKED_INT32_ARRAY: {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
- int index = p_index;
- const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
+ int32_t index = p_index;
+ const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
+ int32_t l = arr->size();
+ if (l) {
+ const int32_t *r = arr->ptr();
+ for (int32_t i = 0; i < l; i++) {
+ if (r[i] == index)
+ return true;
+ }
+ }
+
+ return false;
+ }
+ } break;
+ case PACKED_INT64_ARRAY: {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
+
+ int64_t index = p_index;
+ const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
+ int64_t l = arr->size();
+ if (l) {
+ const int64_t *r = arr->ptr();
+ for (int64_t i = 0; i < l; i++) {
+ if (r[i] == index)
+ return true;
+ }
+ }
+
+ return false;
+ }
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
+
+ real_t index = p_index;
+ const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
- const int *r = arr->ptr();
+ const float *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -3092,16 +3188,17 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
return false;
}
+
} break;
- case PACKED_REAL_ARRAY: {
+ case PACKED_FLOAT64_ARRAY: {
- if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::REAL) {
+ if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
real_t index = p_index;
- const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
+ const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
- const real_t *r = arr->ptr();
+ const double *r = arr->ptr();
for (int i = 0; i < l; i++) {
if (r[i] == index)
return true;
@@ -3116,7 +3213,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (p_index.get_type() == Variant::STRING) {
String index = p_index;
- const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
+ const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
@@ -3135,7 +3232,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (p_index.get_type() == Variant::VECTOR2) {
Vector2 index = p_index;
- const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
@@ -3154,7 +3251,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (p_index.get_type() == Variant::VECTOR3) {
Vector3 index = p_index;
- const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
@@ -3174,7 +3271,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (p_index.get_type() == Variant::COLOR) {
Color index = p_index;
- const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
+ const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
@@ -3202,16 +3299,16 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
switch (type) {
case VECTOR2: {
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
- } break; // 5
+ } break;
case VECTOR2I: {
p_list->push_back(PropertyInfo(Variant::INT, "x"));
p_list->push_back(PropertyInfo(Variant::INT, "y"));
- } break; // 5
+ } break;
case RECT2: {
p_list->push_back(PropertyInfo(Variant::VECTOR2, "position"));
@@ -3228,9 +3325,9 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} break;
case VECTOR3: {
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::REAL, "z"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "z"));
} break;
case VECTOR3I: {
@@ -3250,20 +3347,20 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
case PLANE: {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "normal"));
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::REAL, "z"));
- p_list->push_back(PropertyInfo(Variant::REAL, "d"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "z"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "d"));
} break;
case QUAT: {
- p_list->push_back(PropertyInfo(Variant::REAL, "x"));
- p_list->push_back(PropertyInfo(Variant::REAL, "y"));
- p_list->push_back(PropertyInfo(Variant::REAL, "z"));
- p_list->push_back(PropertyInfo(Variant::REAL, "w"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "z"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "w"));
- } break; // 10
+ } break;
case AABB: {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "size"));
@@ -3283,13 +3380,13 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} break;
case COLOR: {
- p_list->push_back(PropertyInfo(Variant::REAL, "r"));
- p_list->push_back(PropertyInfo(Variant::REAL, "g"));
- p_list->push_back(PropertyInfo(Variant::REAL, "b"));
- p_list->push_back(PropertyInfo(Variant::REAL, "a"));
- p_list->push_back(PropertyInfo(Variant::REAL, "h"));
- p_list->push_back(PropertyInfo(Variant::REAL, "s"));
- p_list->push_back(PropertyInfo(Variant::REAL, "v"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "r"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "g"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "b"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "a"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "h"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "s"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, "v"));
p_list->push_back(PropertyInfo(Variant::INT, "r8"));
p_list->push_back(PropertyInfo(Variant::INT, "g8"));
p_list->push_back(PropertyInfo(Variant::INT, "b8"));
@@ -3297,9 +3394,9 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} break;
case STRING_NAME: {
- } break; // 15
+ } break;
case NODE_PATH: {
- } break; // 15
+ } break;
case _RID: {
} break;
case OBJECT: {
@@ -3330,12 +3427,14 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
}
}
} break;
- case ARRAY: // 20
+ case ARRAY:
case PACKED_BYTE_ARRAY:
- case PACKED_INT_ARRAY:
- case PACKED_REAL_ARRAY:
+ case PACKED_INT32_ARRAY:
+ case PACKED_INT64_ARRAY:
+ case PACKED_FLOAT32_ARRAY:
+ case PACKED_FLOAT64_ARRAY:
case PACKED_STRING_ARRAY:
- case PACKED_VECTOR2_ARRAY: // 25
+ case PACKED_VECTOR2_ARRAY:
case PACKED_VECTOR3_ARRAY:
case PACKED_COLOR_ARRAY: {
@@ -3354,9 +3453,9 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
r_iter = 0;
return _data._int > 0;
} break;
- case REAL: {
+ case FLOAT: {
r_iter = 0;
- return _data._real > 0.0;
+ return _data._float > 0.0;
} break;
case VECTOR2: {
int64_t from = reinterpret_cast<const Vector2 *>(_data._mem)->x;
@@ -3442,23 +3541,39 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
return true;
} break;
case PACKED_BYTE_ARRAY: {
- const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case PACKED_INT_ARRAY: {
- const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
+ case PACKED_INT32_ARRAY: {
+ const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
return true;
} break;
- case PACKED_REAL_ARRAY: {
- const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
+ case PACKED_INT64_ARRAY: {
+ const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
+ if (arr->size() == 0)
+ return false;
+ r_iter = 0;
+ return true;
+
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+ const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
+ if (arr->size() == 0)
+ return false;
+ r_iter = 0;
+ return true;
+
+ } break;
+ case PACKED_FLOAT64_ARRAY: {
+ const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
@@ -3466,7 +3581,7 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
} break;
case PACKED_STRING_ARRAY: {
- const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
+ const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
@@ -3474,7 +3589,7 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
} break;
case PACKED_VECTOR2_ARRAY: {
- const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
@@ -3482,7 +3597,7 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
} break;
case PACKED_VECTOR3_ARRAY: {
- const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
@@ -3490,7 +3605,7 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
} break;
case PACKED_COLOR_ARRAY: {
- const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
+ const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
if (arr->size() == 0)
return false;
r_iter = 0;
@@ -3516,10 +3631,10 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
r_iter = idx;
return true;
} break;
- case REAL: {
+ case FLOAT: {
int64_t idx = r_iter;
idx++;
- if (idx >= _data._real)
+ if (idx >= _data._float)
return false;
r_iter = idx;
return true;
@@ -3617,7 +3732,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
case PACKED_BYTE_ARRAY: {
- const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3626,8 +3741,28 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
- case PACKED_INT_ARRAY: {
- const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
+ case PACKED_INT32_ARRAY: {
+ const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
+ int32_t idx = r_iter;
+ idx++;
+ if (idx >= arr->size())
+ return false;
+ r_iter = idx;
+ return true;
+
+ } break;
+ case PACKED_INT64_ARRAY: {
+ const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
+ int64_t idx = r_iter;
+ idx++;
+ if (idx >= arr->size())
+ return false;
+ r_iter = idx;
+ return true;
+
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+ const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3636,8 +3771,8 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
return true;
} break;
- case PACKED_REAL_ARRAY: {
- const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
+ case PACKED_FLOAT64_ARRAY: {
+ const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3647,7 +3782,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
} break;
case PACKED_STRING_ARRAY: {
- const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
+ const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3657,7 +3792,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
} break;
case PACKED_VECTOR2_ARRAY: {
- const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3667,7 +3802,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
} break;
case PACKED_VECTOR3_ARRAY: {
- const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3677,7 +3812,7 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
} break;
case PACKED_COLOR_ARRAY: {
- const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
+ const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
if (idx >= arr->size())
@@ -3701,7 +3836,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return r_iter;
} break;
- case REAL: {
+ case FLOAT: {
return r_iter;
} break;
@@ -3764,7 +3899,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return arr->get(idx);
} break;
case PACKED_BYTE_ARRAY: {
- const Vector<uint8_t> *arr = reinterpret_cast<const Vector<uint8_t> *>(_data._mem);
+ const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3774,8 +3909,30 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case PACKED_INT_ARRAY: {
- const Vector<int> *arr = reinterpret_cast<const Vector<int> *>(_data._mem);
+ case PACKED_INT32_ARRAY: {
+ const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
+ int32_t idx = r_iter;
+#ifdef DEBUG_ENABLED
+ if (idx < 0 || idx >= arr->size()) {
+ r_valid = false;
+ return Variant();
+ }
+#endif
+ return arr->get(idx);
+ } break;
+ case PACKED_INT64_ARRAY: {
+ const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
+ int64_t idx = r_iter;
+#ifdef DEBUG_ENABLED
+ if (idx < 0 || idx >= arr->size()) {
+ r_valid = false;
+ return Variant();
+ }
+#endif
+ return arr->get(idx);
+ } break;
+ case PACKED_FLOAT32_ARRAY: {
+ const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3785,8 +3942,8 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
#endif
return arr->get(idx);
} break;
- case PACKED_REAL_ARRAY: {
- const Vector<real_t> *arr = reinterpret_cast<const Vector<real_t> *>(_data._mem);
+ case PACKED_FLOAT64_ARRAY: {
+ const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3797,7 +3954,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return arr->get(idx);
} break;
case PACKED_STRING_ARRAY: {
- const Vector<String> *arr = reinterpret_cast<const Vector<String> *>(_data._mem);
+ const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3809,7 +3966,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
} break;
case PACKED_VECTOR2_ARRAY: {
- const Vector<Vector2> *arr = reinterpret_cast<const Vector<Vector2> *>(_data._mem);
+ const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3821,7 +3978,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
} break;
case PACKED_VECTOR3_ARRAY: {
- const Vector<Vector3> *arr = reinterpret_cast<const Vector<Vector3> *>(_data._mem);
+ const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3833,7 +3990,7 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
} break;
case PACKED_COLOR_ARRAY: {
- const Vector<Color> *arr = reinterpret_cast<const Vector<Color> *>(_data._mem);
+ const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
if (idx < 0 || idx >= arr->size()) {
@@ -3896,9 +4053,9 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst)
r_dst = int(va + vb * c + 0.5);
}
return;
- case REAL: {
- double ra = a._data._real;
- double rb = b._data._real;
+ case FLOAT: {
+ double ra = a._data._float;
+ double rb = b._data._float;
r_dst = ra + rb * c;
}
return;
@@ -4015,9 +4172,9 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = int(va + (vb - va) * c);
}
return;
- case REAL: {
- real_t va = a._data._real;
- real_t vb = b._data._real;
+ case FLOAT: {
+ real_t va = a._data._float;
+ real_t vb = b._data._float;
r_dst = va + (vb - va) * c;
}
return;
@@ -4166,21 +4323,73 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = a;
}
return;
- case PACKED_INT_ARRAY: {
- const Vector<int> *arr_a = reinterpret_cast<const Vector<int> *>(a._data._mem);
- const Vector<int> *arr_b = reinterpret_cast<const Vector<int> *>(b._data._mem);
+ case PACKED_INT32_ARRAY: {
+ const Vector<int32_t> *arr_a = &PackedArrayRef<int32_t>::get_array(a._data.packed_array);
+ const Vector<int32_t> *arr_b = &PackedArrayRef<int32_t>::get_array(b._data.packed_array);
+ int32_t sz = arr_a->size();
+ if (sz == 0 || arr_b->size() != sz) {
+
+ r_dst = a;
+ } else {
+
+ Vector<int32_t> v;
+ v.resize(sz);
+ {
+ int32_t *vw = v.ptrw();
+ const int32_t *ar = arr_a->ptr();
+ const int32_t *br = arr_b->ptr();
+
+ Variant va;
+ for (int32_t i = 0; i < sz; i++) {
+ Variant::interpolate(ar[i], br[i], c, va);
+ vw[i] = va;
+ }
+ }
+ r_dst = v;
+ }
+ }
+ return;
+ case PACKED_INT64_ARRAY: {
+ const Vector<int64_t> *arr_a = &PackedArrayRef<int64_t>::get_array(a._data.packed_array);
+ const Vector<int64_t> *arr_b = &PackedArrayRef<int64_t>::get_array(b._data.packed_array);
+ int64_t sz = arr_a->size();
+ if (sz == 0 || arr_b->size() != sz) {
+
+ r_dst = a;
+ } else {
+
+ Vector<int64_t> v;
+ v.resize(sz);
+ {
+ int64_t *vw = v.ptrw();
+ const int64_t *ar = arr_a->ptr();
+ const int64_t *br = arr_b->ptr();
+
+ Variant va;
+ for (int64_t i = 0; i < sz; i++) {
+ Variant::interpolate(ar[i], br[i], c, va);
+ vw[i] = va;
+ }
+ }
+ r_dst = v;
+ }
+ }
+ return;
+ case PACKED_FLOAT32_ARRAY: {
+ const Vector<float> *arr_a = &PackedArrayRef<float>::get_array(a._data.packed_array);
+ const Vector<float> *arr_b = &PackedArrayRef<float>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- Vector<int> v;
+ Vector<float> v;
v.resize(sz);
{
- int *vw = v.ptrw();
- const int *ar = arr_a->ptr();
- const int *br = arr_b->ptr();
+ float *vw = v.ptrw();
+ const float *ar = arr_a->ptr();
+ const float *br = arr_b->ptr();
Variant va;
for (int i = 0; i < sz; i++) {
@@ -4192,21 +4401,21 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
}
return;
- case PACKED_REAL_ARRAY: {
- const Vector<real_t> *arr_a = reinterpret_cast<const Vector<real_t> *>(a._data._mem);
- const Vector<real_t> *arr_b = reinterpret_cast<const Vector<real_t> *>(b._data._mem);
+ case PACKED_FLOAT64_ARRAY: {
+ const Vector<double> *arr_a = &PackedArrayRef<double>::get_array(a._data.packed_array);
+ const Vector<double> *arr_b = &PackedArrayRef<double>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
r_dst = a;
} else {
- Vector<real_t> v;
+ Vector<double> v;
v.resize(sz);
{
- real_t *vw = v.ptrw();
- const real_t *ar = arr_a->ptr();
- const real_t *br = arr_b->ptr();
+ double *vw = v.ptrw();
+ const double *ar = arr_a->ptr();
+ const double *br = arr_b->ptr();
Variant va;
for (int i = 0; i < sz; i++) {
@@ -4223,8 +4432,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
return;
case PACKED_VECTOR2_ARRAY: {
- const Vector<Vector2> *arr_a = reinterpret_cast<const Vector<Vector2> *>(a._data._mem);
- const Vector<Vector2> *arr_b = reinterpret_cast<const Vector<Vector2> *>(b._data._mem);
+ const Vector<Vector2> *arr_a = &PackedArrayRef<Vector2>::get_array(a._data.packed_array);
+ const Vector<Vector2> *arr_b = &PackedArrayRef<Vector2>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
@@ -4248,8 +4457,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
return;
case PACKED_VECTOR3_ARRAY: {
- const Vector<Vector3> *arr_a = reinterpret_cast<const Vector<Vector3> *>(a._data._mem);
- const Vector<Vector3> *arr_b = reinterpret_cast<const Vector<Vector3> *>(b._data._mem);
+ const Vector<Vector3> *arr_a = &PackedArrayRef<Vector3>::get_array(a._data.packed_array);
+ const Vector<Vector3> *arr_b = &PackedArrayRef<Vector3>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
@@ -4272,8 +4481,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
return;
case PACKED_COLOR_ARRAY: {
- const Vector<Color> *arr_a = reinterpret_cast<const Vector<Color> *>(a._data._mem);
- const Vector<Color> *arr_b = reinterpret_cast<const Vector<Color> *>(b._data._mem);
+ const Vector<Color> *arr_a = &PackedArrayRef<Color>::get_array(a._data.packed_array);
+ const Vector<Color> *arr_b = &PackedArrayRef<Color>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 44bf90674b..12fd9976bd 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -941,20 +941,20 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") {
+ } else if (id == "PackedInt32Array" || id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") {
- Vector<int> args;
- Error err = _parse_construct<int>(p_stream, args, line, r_err_str);
+ Vector<int32_t> args;
+ Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
if (err)
return err;
- Vector<int> arr;
+ Vector<int32_t> arr;
{
- int len = args.size();
+ int32_t len = args.size();
arr.resize(len);
- int *w = arr.ptrw();
- for (int i = 0; i < len; i++) {
- w[i] = int(args[i]);
+ int32_t *w = arr.ptrw();
+ for (int32_t i = 0; i < len; i++) {
+ w[i] = int32_t(args[i]);
}
}
@@ -962,7 +962,28 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return OK;
- } else if (id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") {
+ } else if (id == "PackedInt64Array") {
+
+ Vector<int64_t> args;
+ Error err = _parse_construct<int64_t>(p_stream, args, line, r_err_str);
+ if (err)
+ return err;
+
+ Vector<int64_t> arr;
+ {
+ int64_t len = args.size();
+ arr.resize(len);
+ int64_t *w = arr.ptrw();
+ for (int64_t i = 0; i < len; i++) {
+ w[i] = int64_t(args[i]);
+ }
+ }
+
+ value = arr;
+
+ return OK;
+
+ } else if (id == "PackedFloat32Array" || id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
@@ -982,6 +1003,26 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = arr;
return OK;
+ } else if (id == "PackedFloat64Array") {
+
+ Vector<double> args;
+ Error err = _parse_construct<double>(p_stream, args, line, r_err_str);
+ if (err)
+ return err;
+
+ Vector<double> arr;
+ {
+ int len = args.size();
+ arr.resize(len);
+ double *w = arr.ptrw();
+ for (int i = 0; i < len; i++) {
+ w[i] = args[i];
+ }
+ }
+
+ value = arr;
+
+ return OK;
} else if (id == "PackedStringArray" || id == "PoolStringArray" || id == "StringArray") {
get_token(p_stream, token, line, r_err_str);
@@ -1110,6 +1151,10 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = token.value;
return OK;
+ } else if (token.type == TK_STRING_NAME) {
+
+ value = token.value;
+ return OK;
} else if (token.type == TK_COLOR) {
value = token.value;
@@ -1451,7 +1496,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, itos(p_variant.operator int64_t()));
} break;
- case Variant::REAL: {
+ case Variant::FLOAT: {
String s = rtosfix(p_variant.operator real_t());
if (s.find(".") == -1 && s.find("e") == -1)
@@ -1711,14 +1756,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::PACKED_INT_ARRAY: {
+ case Variant::PACKED_INT32_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedIntArray( ");
- Vector<int> data = p_variant;
- int len = data.size();
- const int *ptr = data.ptr();
+ p_store_string_func(p_store_string_ud, "PackedInt32Array( ");
+ Vector<int32_t> data = p_variant;
+ int32_t len = data.size();
+ const int32_t *ptr = data.ptr();
- for (int i = 0; i < len; i++) {
+ for (int32_t i = 0; i < len; i++) {
if (i > 0)
p_store_string_func(p_store_string_ud, ", ");
@@ -1729,12 +1774,47 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, " )");
} break;
- case Variant::PACKED_REAL_ARRAY: {
+ case Variant::PACKED_INT64_ARRAY: {
+
+ p_store_string_func(p_store_string_ud, "PackedInt64Array( ");
+ Vector<int64_t> data = p_variant;
+ int64_t len = data.size();
+ const int64_t *ptr = data.ptr();
+
+ for (int64_t i = 0; i < len; i++) {
+
+ if (i > 0)
+ p_store_string_func(p_store_string_ud, ", ");
+
+ p_store_string_func(p_store_string_ud, itos(ptr[i]));
+ }
+
+ p_store_string_func(p_store_string_ud, " )");
+
+ } break;
+ case Variant::PACKED_FLOAT32_ARRAY: {
+
+ p_store_string_func(p_store_string_ud, "PackedFloat32Array( ");
+ Vector<float> data = p_variant;
+ int len = data.size();
+ const float *ptr = data.ptr();
+
+ for (int i = 0; i < len; i++) {
+
+ if (i > 0)
+ p_store_string_func(p_store_string_ud, ", ");
+ p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
+ }
+
+ p_store_string_func(p_store_string_ud, " )");
+
+ } break;
+ case Variant::PACKED_FLOAT64_ARRAY: {
- p_store_string_func(p_store_string_ud, "PackedRealArray( ");
- Vector<real_t> data = p_variant;
+ p_store_string_func(p_store_string_ud, "PackedFloat64Array( ");
+ Vector<double> data = p_variant;
int len = data.size();
- const real_t *ptr = data.ptr();
+ const double *ptr = data.ptr();
for (int i = 0; i < len; i++) {