Make enum/constant binds 64-bit.
This commit is contained in:
parent
78944fef82
commit
860e24683f
|
@ -2076,9 +2076,9 @@ bool ClassDB::has_integer_constant(const StringName &p_class, const StringName &
|
||||||
return success;
|
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;
|
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);
|
ERR_FAIL_COND_V(!found, 0);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -604,7 +604,7 @@ public:
|
||||||
|
|
||||||
PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
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;
|
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;
|
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;
|
PackedStringArray get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
||||||
|
|
|
@ -42,19 +42,19 @@ struct _CoreConstant {
|
||||||
bool ignore_value_in_docs = false;
|
bool ignore_value_in_docs = false;
|
||||||
#endif
|
#endif
|
||||||
const char *name = nullptr;
|
const char *name = nullptr;
|
||||||
int value = 0;
|
int64_t value = 0;
|
||||||
|
|
||||||
_CoreConstant() {}
|
_CoreConstant() {}
|
||||||
|
|
||||||
#ifdef DEBUG_METHODS_ENABLED
|
#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),
|
enum_name(p_enum_name),
|
||||||
ignore_value_in_docs(p_ignore_value_in_docs),
|
ignore_value_in_docs(p_ignore_value_in_docs),
|
||||||
name(p_name),
|
name(p_name),
|
||||||
value(p_value) {
|
value(p_value) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
_CoreConstant(const char *p_name, int p_value) :
|
_CoreConstant(const char *p_name, int64_t p_value) :
|
||||||
name(p_name),
|
name(p_name),
|
||||||
value(p_value) {
|
value(p_value) {
|
||||||
}
|
}
|
||||||
|
@ -73,13 +73,13 @@ static Vector<_CoreConstant> _global_constants;
|
||||||
|
|
||||||
// This just binds enum classes as if they were regular enum 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) \
|
#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) \
|
#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) \
|
#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) \
|
#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));
|
_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.
|
// This just binds enum classes as if they were regular enum constants.
|
||||||
#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
|
#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) \
|
#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) \
|
#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) \
|
#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
|
||||||
_global_constants.push_back(_CoreConstant(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;
|
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;
|
return _global_constants[p_idx].value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
static StringName get_global_constant_enum(int p_idx);
|
static StringName get_global_constant_enum(int p_idx);
|
||||||
static bool get_ignore_value_in_docs(int p_idx);
|
static bool get_ignore_value_in_docs(int p_idx);
|
||||||
static const char *get_global_constant_name(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
|
#endif // GLOBAL_CONSTANTS_H
|
||||||
|
|
|
@ -334,14 +334,14 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
|
||||||
{
|
{
|
||||||
// Global enums and constants.
|
// Global enums and constants.
|
||||||
Array 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++) {
|
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 enum_name = CoreConstants::get_global_constant_enum(i);
|
||||||
String name = CoreConstants::get_global_constant_name(i);
|
String name = CoreConstants::get_global_constant_name(i);
|
||||||
if (!enum_name.is_empty()) {
|
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 {
|
} else {
|
||||||
Dictionary d;
|
Dictionary d;
|
||||||
d["name"] = name;
|
d["name"] = name;
|
||||||
|
@ -353,11 +353,11 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
|
||||||
api_dump["global_constants"] = constants;
|
api_dump["global_constants"] = constants;
|
||||||
|
|
||||||
Array enums;
|
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;
|
Dictionary d1;
|
||||||
d1["name"] = E.key;
|
d1["name"] = E.key;
|
||||||
Array values;
|
Array values;
|
||||||
for (const Pair<String, int> &F : E.value) {
|
for (const Pair<String, int64_t> &F : E.value) {
|
||||||
Dictionary d2;
|
Dictionary d2;
|
||||||
d2["name"] = F.first;
|
d2["name"] = F.first;
|
||||||
d2["value"] = F.second;
|
d2["value"] = F.second;
|
||||||
|
|
|
@ -228,7 +228,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||||
|
|
||||||
List<StringName> snames;
|
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);
|
snames.push_back(F.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_n
|
||||||
return nullptr;
|
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;
|
OBJTYPE_WLOCK;
|
||||||
|
|
||||||
ClassInfo *type = classes.getptr(p_class);
|
ClassInfo *type = classes.getptr(p_class);
|
||||||
|
@ -583,7 +583,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
|
||||||
}
|
}
|
||||||
#else
|
#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);
|
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;
|
OBJTYPE_RLOCK;
|
||||||
|
|
||||||
ClassInfo *type = classes.getptr(p_class);
|
ClassInfo *type = classes.getptr(p_class);
|
||||||
|
|
||||||
while (type) {
|
while (type) {
|
||||||
int *constant = type->constant_map.getptr(p_name);
|
int64_t *constant = type->constant_map.getptr(p_name);
|
||||||
if (constant) {
|
if (constant) {
|
||||||
if (p_success) {
|
if (p_success) {
|
||||||
*p_success = true;
|
*p_success = true;
|
||||||
|
@ -1066,7 +1066,7 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
|
||||||
return true;
|
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) {
|
if (c) {
|
||||||
r_value = *c;
|
r_value = *c;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -103,7 +103,7 @@ public:
|
||||||
ObjectNativeExtension *native_extension = nullptr;
|
ObjectNativeExtension *native_extension = nullptr;
|
||||||
|
|
||||||
HashMap<StringName, MethodBind *> method_map;
|
HashMap<StringName, MethodBind *> method_map;
|
||||||
HashMap<StringName, int> constant_map;
|
HashMap<StringName, int64_t> constant_map;
|
||||||
HashMap<StringName, List<StringName>> enum_map;
|
HashMap<StringName, List<StringName>> enum_map;
|
||||||
HashMap<StringName, MethodInfo> signal_map;
|
HashMap<StringName, MethodInfo> signal_map;
|
||||||
List<PropertyInfo> property_list;
|
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 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 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 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 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);
|
static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false);
|
||||||
|
|
|
@ -919,7 +919,7 @@ struct _VariantCall {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ConstantData {
|
struct ConstantData {
|
||||||
HashMap<StringName, int> value;
|
HashMap<StringName, int64_t> value;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
List<StringName> value_ordered;
|
List<StringName> value_ordered;
|
||||||
#endif
|
#endif
|
||||||
|
@ -931,7 +931,7 @@ struct _VariantCall {
|
||||||
|
|
||||||
static ConstantData *constant_data;
|
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;
|
constant_data[p_type].value[p_constant_name] = p_constant_value;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
constant_data[p_type].value_ordered.push_back(p_constant_name);
|
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()) {
|
for (const List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) {
|
||||||
p_constants->push_back(E->get());
|
p_constants->push_back(E->get());
|
||||||
#else
|
#else
|
||||||
for (const KeyValue<StringName, int> &E : cd.value) {
|
for (const KeyValue<StringName, int64_t> &E : cd.value) {
|
||||||
p_constants->push_back(E.key);
|
p_constants->push_back(E.key);
|
||||||
#endif
|
#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);
|
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
|
||||||
_VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
|
_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) {
|
if (!E) {
|
||||||
HashMap<StringName, Variant>::Iterator F = cd.variant_value.find(p_value);
|
HashMap<StringName, Variant>::Iterator F = cd.variant_value.find(p_value);
|
||||||
if (F) {
|
if (F) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) {
|
||||||
|
|
||||||
bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
|
bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
bool ok;
|
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) {
|
if (ok) {
|
||||||
r_ret = v;
|
r_ret = v;
|
||||||
|
|
|
@ -2900,7 +2900,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool valid = false;
|
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) {
|
if (valid) {
|
||||||
p_identifier->is_constant = true;
|
p_identifier->is_constant = true;
|
||||||
p_identifier->reduced_value = int_constant;
|
p_identifier->reduced_value = int_constant;
|
||||||
|
|
|
@ -312,7 +312,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||||
// Class C++ integer constant.
|
// Class C++ integer constant.
|
||||||
if (nc) {
|
if (nc) {
|
||||||
bool success = false;
|
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) {
|
if (success) {
|
||||||
return codegen.add_constant(constant);
|
return codegen.add_constant(constant);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
|
||||||
|
|
||||||
List<StringName> snames;
|
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);
|
snames.push_back(F.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(iconstant.proxy_name);
|
||||||
p_output.append(" = ");
|
p_output.append(" = ");
|
||||||
p_output.append(itos(iconstant.value));
|
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("\n" INDENT1 "public enum ");
|
||||||
p_output.append(enum_proxy_name);
|
p_output.append(enum_proxy_name);
|
||||||
|
p_output.append(" : long");
|
||||||
p_output.append("\n" INDENT1 OPEN_BLOCK);
|
p_output.append("\n" INDENT1 OPEN_BLOCK);
|
||||||
|
|
||||||
const ConstantInterface &last = ienum.constants.back()->get();
|
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(iconstant.proxy_name);
|
||||||
output.append(" = ");
|
output.append(" = ");
|
||||||
output.append(itos(iconstant.value));
|
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(MEMBER_BEGIN "public enum ");
|
||||||
output.append(ienum.cname.operator String());
|
output.append(ienum.cname.operator String());
|
||||||
|
output.append(" : long");
|
||||||
output.append(MEMBER_BEGIN OPEN_BLOCK);
|
output.append(MEMBER_BEGIN OPEN_BLOCK);
|
||||||
|
|
||||||
const ConstantInterface &last = ienum.constants.back()->get();
|
const ConstantInterface &last = ienum.constants.back()->get();
|
||||||
|
@ -3088,7 +3090,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
|
||||||
const List<StringName> &enum_constants = E.value;
|
const List<StringName> &enum_constants = E.value;
|
||||||
for (const StringName &constant_cname : enum_constants) {
|
for (const StringName &constant_cname : enum_constants) {
|
||||||
String constant_name = constant_cname.operator String();
|
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);
|
ERR_FAIL_NULL_V(value, false);
|
||||||
constants.erase(constant_name);
|
constants.erase(constant_name);
|
||||||
|
|
||||||
|
@ -3123,7 +3125,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const String &constant_name : constants) {
|
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);
|
ERR_FAIL_NULL_V(value, false);
|
||||||
|
|
||||||
ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value);
|
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);
|
StringName enum_name = CoreConstants::get_global_constant_enum(i);
|
||||||
|
|
||||||
ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), constant_value);
|
ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), constant_value);
|
||||||
|
|
|
@ -45,12 +45,12 @@ class BindingsGenerator {
|
||||||
struct ConstantInterface {
|
struct ConstantInterface {
|
||||||
String name;
|
String name;
|
||||||
String proxy_name;
|
String proxy_name;
|
||||||
int value = 0;
|
int64_t value = 0;
|
||||||
const DocData::ConstantDoc *const_doc;
|
const DocData::ConstantDoc *const_doc;
|
||||||
|
|
||||||
ConstantInterface() {}
|
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;
|
name = p_name;
|
||||||
proxy_name = p_proxy_name;
|
proxy_name = p_proxy_name;
|
||||||
value = p_value;
|
value = p_value;
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct TypeReference {
|
||||||
|
|
||||||
struct ConstantData {
|
struct ConstantData {
|
||||||
String name;
|
String name;
|
||||||
int value = 0;
|
int64_t value = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EnumData {
|
struct EnumData {
|
||||||
|
@ -743,7 +743,7 @@ void add_exposed_classes(Context &r_context) {
|
||||||
TEST_FAIL_COND(String(constant_name).find("::") != -1,
|
TEST_FAIL_COND(String(constant_name).find("::") != -1,
|
||||||
"Enum constant contains '::', check bindings to remove the scope: '",
|
"Enum constant contains '::', check bindings to remove the scope: '",
|
||||||
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
|
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: '",
|
TEST_FAIL_COND(!value, "Missing enum constant value: '",
|
||||||
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
|
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
|
||||||
constants.erase(constant_name);
|
constants.erase(constant_name);
|
||||||
|
@ -765,7 +765,7 @@ void add_exposed_classes(Context &r_context) {
|
||||||
TEST_FAIL_COND(constant_name.find("::") != -1,
|
TEST_FAIL_COND(constant_name.find("::") != -1,
|
||||||
"Constant contains '::', check bindings to remove the scope: '",
|
"Constant contains '::', check bindings to remove the scope: '",
|
||||||
String(class_name), ".", constant_name, "'.");
|
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), "'.");
|
TEST_FAIL_COND(!value, "Missing constant value: '", String(class_name), ".", String(constant_name), "'.");
|
||||||
|
|
||||||
ConstantData constant;
|
ConstantData constant;
|
||||||
|
|
Loading…
Reference in New Issue