| 5211 | } |
| 5212 | |
| 5213 | String GDScriptParser::DataType::to_string() const { |
| 5214 | switch (kind) { |
| 5215 | case VARIANT: |
| 5216 | return "Variant"; |
| 5217 | case BUILTIN: |
| 5218 | if (builtin_type == Variant::NIL) { |
| 5219 | return "null"; |
| 5220 | } |
| 5221 | if (builtin_type == Variant::ARRAY && has_container_element_type(0)) { |
| 5222 | return vformat("Array[%s]", get_container_element_type(0).to_string()); |
| 5223 | } |
| 5224 | if (builtin_type == Variant::DICTIONARY && has_container_element_types()) { |
| 5225 | return vformat("Dictionary[%s, %s]", get_container_element_type_or_variant(0).to_string(), get_container_element_type_or_variant(1).to_string()); |
| 5226 | } |
| 5227 | return Variant::get_type_name(builtin_type); |
| 5228 | case NATIVE: |
| 5229 | if (is_meta_type) { |
| 5230 | return GDScriptNativeClass::get_class_static(); |
| 5231 | } |
| 5232 | return native_type.operator String(); |
| 5233 | case CLASS: |
| 5234 | if (class_type->identifier != nullptr) { |
| 5235 | return class_type->identifier->name.operator String(); |
| 5236 | } |
| 5237 | return class_type->fqcn; |
| 5238 | case SCRIPT: { |
| 5239 | if (is_meta_type) { |
| 5240 | return script_type.is_valid() ? script_type->get_class_name().operator String() : ""; |
| 5241 | } |
| 5242 | String name = script_type.is_valid() ? script_type->get_name() : ""; |
| 5243 | if (!name.is_empty()) { |
| 5244 | return name; |
| 5245 | } |
| 5246 | name = script_path; |
| 5247 | if (!name.is_empty()) { |
| 5248 | return name; |
| 5249 | } |
| 5250 | return native_type.operator String(); |
| 5251 | } |
| 5252 | case ENUM: { |
| 5253 | // native_type contains either the native class defining the enum |
| 5254 | // or the fully qualified class name of the script defining the enum |
| 5255 | return String(native_type).get_file(); // Remove path, keep filename |
| 5256 | } |
| 5257 | case RESOLVING: |
| 5258 | case UNRESOLVED: |
| 5259 | return "<unresolved type>"; |
| 5260 | } |
| 5261 | |
| 5262 | ERR_FAIL_V_MSG("<unresolved type>", "Kind set outside the enum range."); |
| 5263 | } |
| 5264 | |
| 5265 | PropertyInfo GDScriptParser::DataType::to_property_info(const String &p_name) const { |
| 5266 | PropertyInfo result; |
no test coverage detected