| 380 | } |
| 381 | |
| 382 | Error FakeCSharpScript::reload(bool p_keep_state) { |
| 383 | error_message.clear(); |
| 384 | valid = false; |
| 385 | loaded = false; |
| 386 | |
| 387 | if (script_info.is_empty()) { |
| 388 | error_message = "Script info is empty"; |
| 389 | return ERR_INVALID_DATA; |
| 390 | } |
| 391 | |
| 392 | String ns = script_info.get("namespace", ""); |
| 393 | local_name = script_info.get("class_name", ""); |
| 394 | base_classes = script_info.get("base_classes", Vector<String>()); |
| 395 | base_type_paths = script_info.get("base_type_paths", Vector<String>()); |
| 396 | icon_path = script_info.get("icon_path", ""); |
| 397 | globally_available = script_info.get("is_global_class", false); |
| 398 | global_name = globally_available ? local_name : ""; |
| 399 | base_type = base_classes.size() > 0 ? base_classes[0] : "RefCounted"; |
| 400 | tool = script_info.get("is_tool", false); |
| 401 | abstract = script_info.get("is_abstract", false); |
| 402 | TypedArray<Dictionary> script_properties = script_info.get("properties", TypedArray<Dictionary>()); |
| 403 | TypedArray<Dictionary> signals = script_info.get("signals", TypedArray<Dictionary>()); |
| 404 | TypedArray<Dictionary> methods = script_info.get("methods", TypedArray<Dictionary>()); |
| 405 | |
| 406 | members.clear(); |
| 407 | _signals.clear(); |
| 408 | _methods.clear(); |
| 409 | for (int i = 0; i < script_properties.size(); i++) { |
| 410 | Dictionary property = script_properties[i]; |
| 411 | String prop_name = property.get("name", ""); |
| 412 | if (prop_name.is_empty()) { |
| 413 | continue; |
| 414 | } |
| 415 | members.insert(prop_name, dict_to_property_info(property)); |
| 416 | String default_value = property.get("default_value", ""); |
| 417 | if (!default_value.is_empty()) { |
| 418 | // quick hack for Color() with 3 arguments |
| 419 | if (default_value.begins_with("Color(") && default_value.ends_with(")")) { |
| 420 | if (default_value.count(",") == 2) { |
| 421 | default_value = default_value.trim_suffix(")") + ",1.0)"; |
| 422 | } |
| 423 | } |
| 424 | VariantParser::StreamString ss; |
| 425 | ss.s = default_value; |
| 426 | Variant v; |
| 427 | String err_string; |
| 428 | int line = 0; |
| 429 | Error err = VariantParserCompat::parse(&ss, v, err_string, line); |
| 430 | if (err == OK) { |
| 431 | member_default_values.insert(prop_name, v); |
| 432 | } else { |
| 433 | if (parse_expression(default_value, v)) { |
| 434 | member_default_values.insert(prop_name, v); |
| 435 | } else { |
| 436 | default_value = replace_variant_constants(default_value); |
| 437 | if (parse_expression(default_value, v)) { |
| 438 | member_default_values.insert(prop_name, v); |
| 439 | } |
nothing calls this directly
no test coverage detected