diff options
-rw-r--r-- | core/core_bind.cpp | 4 | ||||
-rw-r--r-- | core/core_bind.h | 2 | ||||
-rw-r--r-- | core/core_constants.cpp | 20 | ||||
-rw-r--r-- | core/core_constants.h | 2 | ||||
-rw-r--r-- | core/extension/extension_api_dump.cpp | 10 | ||||
-rw-r--r-- | core/object/class_db.cpp | 12 | ||||
-rw-r--r-- | core/object/class_db.h | 6 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | misc/scripts/codespell.sh | 0 | ||||
-rw-r--r-- | modules/gdscript/gdscript.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 2 | ||||
-rw-r--r-- | modules/mono/class_db_api_json.cpp | 2 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 12 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.h | 4 | ||||
-rw-r--r-- | tests/core/object/test_class_db.h | 6 |
16 files changed, 48 insertions, 46 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) { diff --git a/misc/scripts/codespell.sh b/misc/scripts/codespell.sh index f99c5d22b2..f99c5d22b2 100644..100755 --- a/misc/scripts/codespell.sh +++ b/misc/scripts/codespell.sh diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 64258ee8d3..617db883f8 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -62,7 +62,7 @@ GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) { bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const { bool ok; - int v = ClassDB::get_integer_constant(name, p_name, &ok); + int64_t v = ClassDB::get_integer_constant(name, p_name, &ok); if (ok) { r_ret = v; diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index a070d319f3..42b02ce3b9 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2900,7 +2900,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod return; } bool valid = false; - int int_constant = ClassDB::get_integer_constant(native, name, &valid); + int64_t int_constant = ClassDB::get_integer_constant(native, name, &valid); if (valid) { p_identifier->is_constant = true; p_identifier->reduced_value = int_constant; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index b2cce9d8ee..25454030b1 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -312,7 +312,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code // Class C++ integer constant. if (nc) { bool success = false; - int constant = ClassDB::get_integer_constant(nc->get_name(), identifier, &success); + int64_t constant = ClassDB::get_integer_constant(nc->get_name(), identifier, &success); if (success) { return codegen.add_constant(constant); } diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index 3afde1e8d3..c4547b4323 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -124,7 +124,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::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); } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 960d2fe27c..9d3d481068 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -954,7 +954,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { } } - p_output.append(MEMBER_BEGIN "public const int "); + p_output.append(MEMBER_BEGIN "public const long "); p_output.append(iconstant.proxy_name); p_output.append(" = "); p_output.append(itos(iconstant.value)); @@ -992,6 +992,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append("\n" INDENT1 "public enum "); p_output.append(enum_proxy_name); + p_output.append(" : long"); p_output.append("\n" INDENT1 OPEN_BLOCK); const ConstantInterface &last = ienum.constants.back()->get(); @@ -1417,7 +1418,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str } } - output.append(MEMBER_BEGIN "public const int "); + output.append(MEMBER_BEGIN "public const long "); output.append(iconstant.proxy_name); output.append(" = "); output.append(itos(iconstant.value)); @@ -1435,6 +1436,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(MEMBER_BEGIN "public enum "); output.append(ienum.cname.operator String()); + output.append(" : long"); output.append(MEMBER_BEGIN OPEN_BLOCK); const ConstantInterface &last = ienum.constants.back()->get(); @@ -3088,7 +3090,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { const List<StringName> &enum_constants = E.value; for (const StringName &constant_cname : enum_constants) { String constant_name = constant_cname.operator String(); - int *value = class_info->constant_map.getptr(constant_cname); + int64_t *value = class_info->constant_map.getptr(constant_cname); ERR_FAIL_NULL_V(value, false); constants.erase(constant_name); @@ -3123,7 +3125,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } for (const String &constant_name : constants) { - int *value = class_info->constant_map.getptr(StringName(constant_name)); + int64_t *value = class_info->constant_map.getptr(StringName(constant_name)); ERR_FAIL_NULL_V(value, false); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); @@ -3666,7 +3668,7 @@ void BindingsGenerator::_populate_global_constants() { } } - int constant_value = CoreConstants::get_global_constant_value(i); + int64_t constant_value = CoreConstants::get_global_constant_value(i); StringName enum_name = CoreConstants::get_global_constant_enum(i); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), constant_value); diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index f0ba2b18e4..70c4f12146 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -45,12 +45,12 @@ class BindingsGenerator { struct ConstantInterface { String name; String proxy_name; - int value = 0; + int64_t value = 0; const DocData::ConstantDoc *const_doc; ConstantInterface() {} - ConstantInterface(const String &p_name, const String &p_proxy_name, int p_value) { + ConstantInterface(const String &p_name, const String &p_proxy_name, int64_t p_value) { name = p_name; proxy_name = p_proxy_name; value = p_value; diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index 8aaca69d13..7ea9e16ff1 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -46,7 +46,7 @@ struct TypeReference { struct ConstantData { String name; - int value = 0; + int64_t value = 0; }; struct EnumData { @@ -743,7 +743,7 @@ void add_exposed_classes(Context &r_context) { TEST_FAIL_COND(String(constant_name).find("::") != -1, "Enum constant contains '::', check bindings to remove the scope: '", String(class_name), ".", String(enum_.name), ".", String(constant_name), "'."); - int *value = class_info->constant_map.getptr(constant_name); + int64_t *value = class_info->constant_map.getptr(constant_name); TEST_FAIL_COND(!value, "Missing enum constant value: '", String(class_name), ".", String(enum_.name), ".", String(constant_name), "'."); constants.erase(constant_name); @@ -765,7 +765,7 @@ void add_exposed_classes(Context &r_context) { TEST_FAIL_COND(constant_name.find("::") != -1, "Constant contains '::', check bindings to remove the scope: '", String(class_name), ".", constant_name, "'."); - int *value = class_info->constant_map.getptr(StringName(E)); + int64_t *value = class_info->constant_map.getptr(StringName(E)); TEST_FAIL_COND(!value, "Missing constant value: '", String(class_name), ".", String(constant_name), "'."); ConstantData constant; |