mirror of
https://github.com/godotengine/godot.git
synced 2025-10-30 13:11:13 +00:00
Remove underscore hacks
Way less cruft. :) Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
This commit is contained in:
parent
81f7d1890b
commit
5161c97c9c
12 changed files with 38 additions and 132 deletions
|
|
@ -94,43 +94,8 @@ Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) {
|
|||
return Variant::VARIANT_MAX;
|
||||
}
|
||||
|
||||
// TODO: Move this to a central location (maybe core?).
|
||||
static HashMap<StringName, StringName> underscore_map;
|
||||
static const char *underscore_classes[] = {
|
||||
"ClassDB",
|
||||
"Directory",
|
||||
"Engine",
|
||||
"File",
|
||||
"Geometry",
|
||||
"GodotSharp",
|
||||
"JSON",
|
||||
"Marshalls",
|
||||
"Mutex",
|
||||
"OS",
|
||||
"ResourceLoader",
|
||||
"ResourceSaver",
|
||||
"Semaphore",
|
||||
"Thread",
|
||||
"VisualScriptEditor",
|
||||
nullptr,
|
||||
};
|
||||
StringName GDScriptParser::get_real_class_name(const StringName &p_source) {
|
||||
if (underscore_map.is_empty()) {
|
||||
const char **class_name = underscore_classes;
|
||||
while (*class_name != nullptr) {
|
||||
underscore_map[*class_name] = String("_") + *class_name;
|
||||
class_name++;
|
||||
}
|
||||
}
|
||||
if (underscore_map.has(p_source)) {
|
||||
return underscore_map[p_source];
|
||||
}
|
||||
return p_source;
|
||||
}
|
||||
|
||||
void GDScriptParser::cleanup() {
|
||||
builtin_types.clear();
|
||||
underscore_map.clear();
|
||||
}
|
||||
|
||||
void GDScriptParser::get_annotation_list(List<MethodInfo> *r_annotations) const {
|
||||
|
|
@ -3363,10 +3328,10 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
|
|||
variable->export_info.hint_string = Variant::get_type_name(export_type.builtin_type);
|
||||
break;
|
||||
case GDScriptParser::DataType::NATIVE:
|
||||
if (ClassDB::is_parent_class(get_real_class_name(export_type.native_type), "Resource")) {
|
||||
if (ClassDB::is_parent_class(export_type.native_type, "Resource")) {
|
||||
variable->export_info.type = Variant::OBJECT;
|
||||
variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
|
||||
variable->export_info.hint_string = get_real_class_name(export_type.native_type);
|
||||
variable->export_info.hint_string = export_type.native_type;
|
||||
} else {
|
||||
push_error(R"(Export type can only be built-in, a resource, or an enum.)", variable);
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue