summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-05-09 12:47:10 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-06-17 16:36:26 +0300
commit860e24683fd4ee627a3a950418dbd2b4cc6fe78b (patch)
tree58e7033f2942ae3e7bb328b3a0961837447726ce /core
parent78944fef820b7df87ca73d89169e68639ceef8e9 (diff)
Make enum/constant binds 64-bit.
Diffstat (limited to 'core')
-rw-r--r--core/core_bind.cpp4
-rw-r--r--core/core_bind.h2
-rw-r--r--core/core_constants.cpp20
-rw-r--r--core/core_constants.h2
-rw-r--r--core/extension/extension_api_dump.cpp10
-rw-r--r--core/object/class_db.cpp12
-rw-r--r--core/object/class_db.h6
-rw-r--r--core/variant/variant_call.cpp8
8 files changed, 32 insertions, 32 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 194c7fdefd..8fafc459e3 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -2076,9 +2076,9 @@ bool ClassDB::has_integer_constant(const StringName &p_class, const StringName &
return success;
}
-int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name) const {
+int64_t ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name) const {
bool found;
- int c = ::ClassDB::get_integer_constant(p_class, p_name, &found);
+ int64_t c = ::ClassDB::get_integer_constant(p_class, p_name, &found);
ERR_FAIL_COND_V(!found, 0);
return c;
}
diff --git a/core/core_bind.h b/core/core_bind.h
index e4d15d5c9d..c2098b1b59 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -604,7 +604,7 @@ public:
PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
- int get_integer_constant(const StringName &p_class, const StringName &p_name) const;
+ int64_t get_integer_constant(const StringName &p_class, const StringName &p_name) const;
bool has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
PackedStringArray get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
diff --git a/core/core_constants.cpp b/core/core_constants.cpp
index eb5a8226d7..4e0845e625 100644
--- a/core/core_constants.cpp
+++ b/core/core_constants.cpp
@@ -42,19 +42,19 @@ struct _CoreConstant {
bool ignore_value_in_docs = false;
#endif
const char *name = nullptr;
- int value = 0;
+ int64_t value = 0;
_CoreConstant() {}
#ifdef DEBUG_METHODS_ENABLED
- _CoreConstant(const StringName &p_enum_name, const char *p_name, int p_value, bool p_ignore_value_in_docs = false) :
+ _CoreConstant(const StringName &p_enum_name, const char *p_name, int64_t p_value, bool p_ignore_value_in_docs = false) :
enum_name(p_enum_name),
ignore_value_in_docs(p_ignore_value_in_docs),
name(p_name),
value(p_value) {
}
#else
- _CoreConstant(const char *p_name, int p_value) :
+ _CoreConstant(const char *p_name, int64_t p_value) :
name(p_name),
value(p_value) {
}
@@ -73,13 +73,13 @@ static Vector<_CoreConstant> _global_constants;
// This just binds enum classes as if they were regular enum constants.
#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int)m_enum::m_member));
+ _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int64_t)m_enum::m_member));
#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_name), #m_name, (int)m_enum::m_member));
+ _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_name), #m_name, (int64_t)m_enum::m_member));
#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int)m_enum::m_member, true));
+ _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int64_t)m_enum::m_member, true));
#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
_global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_constant, #m_constant), m_custom_name, m_constant));
@@ -103,13 +103,13 @@ static Vector<_CoreConstant> _global_constants;
// This just binds enum classes as if they were regular enum constants.
#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int)m_enum::m_member));
+ _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int64_t)m_enum::m_member));
#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \
- _global_constants.push_back(_CoreConstant(#m_name, (int)m_enum::m_member));
+ _global_constants.push_back(_CoreConstant(#m_name, (int64_t)m_enum::m_member));
#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int)m_enum::m_member));
+ _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int64_t)m_enum::m_member));
#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
_global_constants.push_back(_CoreConstant(m_custom_name, m_constant));
@@ -772,6 +772,6 @@ const char *CoreConstants::get_global_constant_name(int p_idx) {
return _global_constants[p_idx].name;
}
-int CoreConstants::get_global_constant_value(int p_idx) {
+int64_t CoreConstants::get_global_constant_value(int p_idx) {
return _global_constants[p_idx].value;
}
diff --git a/core/core_constants.h b/core/core_constants.h
index 9302c23959..d5b3b156b2 100644
--- a/core/core_constants.h
+++ b/core/core_constants.h
@@ -39,7 +39,7 @@ public:
static StringName get_global_constant_enum(int p_idx);
static bool get_ignore_value_in_docs(int p_idx);
static const char *get_global_constant_name(int p_idx);
- static int get_global_constant_value(int p_idx);
+ static int64_t get_global_constant_value(int p_idx);
};
#endif // GLOBAL_CONSTANTS_H
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index 9e8addf8aa..edd48cf9cd 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -334,14 +334,14 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
{
// Global enums and constants.
Array constants;
- HashMap<String, List<Pair<String, int>>> enum_list;
+ HashMap<String, List<Pair<String, int64_t>>> enum_list;
for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
- int value = CoreConstants::get_global_constant_value(i);
+ int64_t value = CoreConstants::get_global_constant_value(i);
String enum_name = CoreConstants::get_global_constant_enum(i);
String name = CoreConstants::get_global_constant_name(i);
if (!enum_name.is_empty()) {
- enum_list[enum_name].push_back(Pair<String, int>(name, value));
+ enum_list[enum_name].push_back(Pair<String, int64_t>(name, value));
} else {
Dictionary d;
d["name"] = name;
@@ -353,11 +353,11 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
api_dump["global_constants"] = constants;
Array enums;
- for (const KeyValue<String, List<Pair<String, int>>> &E : enum_list) {
+ for (const KeyValue<String, List<Pair<String, int64_t>>> &E : enum_list) {
Dictionary d1;
d1["name"] = E.key;
Array values;
- for (const Pair<String, int> &F : E.value) {
+ for (const Pair<String, int64_t> &F : E.value) {
Dictionary d2;
d2["name"] = F.first;
d2["value"] = F.second;
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index f61bd24efd..533cb6e789 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -228,7 +228,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
List<StringName> snames;
- for (const KeyValue<StringName, int> &F : t->constant_map) {
+ for (const KeyValue<StringName, int64_t> &F : t->constant_map) {
snames.push_back(F.key);
}
@@ -536,7 +536,7 @@ MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_n
return nullptr;
}
-void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant) {
+void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int64_t p_constant) {
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
@@ -583,7 +583,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
}
#else
- for (const KeyValue<StringName, int> &E : type->constant_map) {
+ for (const KeyValue<StringName, int64_t> &E : type->constant_map) {
p_constants->push_back(E.key);
}
@@ -596,13 +596,13 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
}
}
-int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success) {
+int64_t ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success) {
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
- int *constant = type->constant_map.getptr(p_name);
+ int64_t *constant = type->constant_map.getptr(p_name);
if (constant) {
if (p_success) {
*p_success = true;
@@ -1066,7 +1066,7 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
return true;
}
- const int *c = check->constant_map.getptr(p_property); //constants count
+ const int64_t *c = check->constant_map.getptr(p_property); //constants count
if (c) {
r_value = *c;
return true;
diff --git a/core/object/class_db.h b/core/object/class_db.h
index 2448a86e33..f2f73dc674 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -103,7 +103,7 @@ public:
ObjectNativeExtension *native_extension = nullptr;
HashMap<StringName, MethodBind *> method_map;
- HashMap<StringName, int> constant_map;
+ HashMap<StringName, int64_t> constant_map;
HashMap<StringName, List<StringName>> enum_map;
HashMap<StringName, MethodInfo> signal_map;
List<PropertyInfo> property_list;
@@ -325,9 +325,9 @@ public:
static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual = true, const Vector<String> &p_arg_names = Vector<String>(), bool p_object_core = false);
static void get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false);
- static void bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant);
+ static void bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int64_t p_constant);
static void get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance = false);
- static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = nullptr);
+ static int64_t get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = nullptr);
static bool has_integer_constant(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false);
static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false);
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index b335f2fcf4..6e8dc64811 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -919,7 +919,7 @@ struct _VariantCall {
}
struct ConstantData {
- HashMap<StringName, int> value;
+ HashMap<StringName, int64_t> value;
#ifdef DEBUG_ENABLED
List<StringName> value_ordered;
#endif
@@ -931,7 +931,7 @@ struct _VariantCall {
static ConstantData *constant_data;
- static void add_constant(int p_type, StringName p_constant_name, int p_constant_value) {
+ static void add_constant(int p_type, StringName p_constant_name, int64_t p_constant_value) {
constant_data[p_type].value[p_constant_name] = p_constant_value;
#ifdef DEBUG_ENABLED
constant_data[p_type].value_ordered.push_back(p_constant_name);
@@ -1245,7 +1245,7 @@ void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_c
for (const List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) {
p_constants->push_back(E->get());
#else
- for (const KeyValue<StringName, int> &E : cd.value) {
+ for (const KeyValue<StringName, int64_t> &E : cd.value) {
p_constants->push_back(E.key);
#endif
}
@@ -1281,7 +1281,7 @@ Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_va
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
_VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
- HashMap<StringName, int>::Iterator E = cd.value.find(p_value);
+ HashMap<StringName, int64_t>::Iterator E = cd.value.find(p_value);
if (!E) {
HashMap<StringName, Variant>::Iterator F = cd.variant_value.find(p_value);
if (F) {