Skip to content

Commit

Permalink
Merge pull request #68402 from Chaosus/gds_fix_enums
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga committed Nov 8, 2022
2 parents 40ed34f + f11b66b commit a499f7b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions modules/gdscript/gdscript_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,9 +2432,8 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
// TODO: Make enums not be just a dictionary?
Dictionary new_enum;
for (int j = 0; j < enum_n->values.size(); j++) {
int value = enum_n->values[j].value;
// Needs to be string because Variant::get will convert to String.
new_enum[String(enum_n->values[j].identifier->name)] = value;
new_enum[String(enum_n->values[j].identifier->name)] = enum_n->values[j].value;
}

p_script->constants.insert(enum_n->identifier->name, new_enum);
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node

String enum_hint_string;
bool first = true;
for (const KeyValue<StringName, int> &E : export_type.enum_values) {
for (const KeyValue<StringName, int64_t> &E : export_type.enum_values) {
if (!first) {
enum_hint_string += ",";
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class GDScriptParser {
ClassNode *class_type = nullptr;

MethodInfo method_info; // For callable/signals.
HashMap<StringName, int> enum_values; // For enums.
HashMap<StringName, int64_t> enum_values; // For enums.

_FORCE_INLINE_ bool is_set() const { return kind != UNRESOLVED; }
_FORCE_INLINE_ bool has_no_type() const { return type_source == UNDETECTED; }
Expand Down

0 comments on commit a499f7b

Please sign in to comment.