mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix usage of Enum as constant
This commit is contained in:
parent
7e1bd3f95a
commit
b6aa4840d8
5 changed files with 62 additions and 18 deletions
|
@ -2453,26 +2453,20 @@ Error GDScriptCompiler::_populate_class_members(GDScript *p_script, const GDScri
|
|||
|
||||
case GDScriptParser::ClassNode::Member::ENUM: {
|
||||
const GDScriptParser::EnumNode *enum_n = member.m_enum;
|
||||
StringName name = enum_n->identifier->name;
|
||||
|
||||
// TODO: Make enums not be just a dictionary?
|
||||
Dictionary new_enum;
|
||||
for (int j = 0; j < enum_n->values.size(); j++) {
|
||||
// Needs to be string because Variant::get will convert to String.
|
||||
new_enum[String(enum_n->values[j].identifier->name)] = enum_n->values[j].value;
|
||||
}
|
||||
|
||||
p_script->constants.insert(enum_n->identifier->name, new_enum);
|
||||
p_script->constants.insert(name, enum_n->dictionary);
|
||||
#ifdef TOOLS_ENABLED
|
||||
p_script->member_lines[enum_n->identifier->name] = enum_n->start_line;
|
||||
p_script->doc_enums[enum_n->identifier->name] = DocData::EnumDoc();
|
||||
p_script->doc_enums[enum_n->identifier->name].name = enum_n->identifier->name;
|
||||
p_script->doc_enums[enum_n->identifier->name].description = enum_n->doc_description;
|
||||
p_script->member_lines[name] = enum_n->start_line;
|
||||
p_script->doc_enums[name] = DocData::EnumDoc();
|
||||
p_script->doc_enums[name].name = name;
|
||||
p_script->doc_enums[name].description = enum_n->doc_description;
|
||||
for (int j = 0; j < enum_n->values.size(); j++) {
|
||||
DocData::ConstantDoc const_doc;
|
||||
const_doc.name = enum_n->values[j].identifier->name;
|
||||
const_doc.value = Variant(enum_n->values[j].value).operator String();
|
||||
const_doc.description = enum_n->values[j].doc_description;
|
||||
p_script->doc_enums[enum_n->identifier->name].values.push_back(const_doc);
|
||||
p_script->doc_enums[name].values.push_back(const_doc);
|
||||
}
|
||||
#endif
|
||||
} break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue