| 326 | } |
| 327 | |
| 328 | String replace_variant_constants(const String &p_string) { |
| 329 | String new_string = p_string; |
| 330 | Ref<RegEx> re = memnew(RegEx()); |
| 331 | re->compile("\\b([A-Za-z_][A-Za-z0-9_]+)\\.([A-Za-z_][A-Za-z0-9_]+)\\b"); |
| 332 | Ref<RegExMatch> match = re->search(new_string); |
| 333 | while (match.is_valid()) { |
| 334 | auto start = match->get_start(0); |
| 335 | auto end = match->get_end(0); |
| 336 | String type_name = match->get_string(1); |
| 337 | Variant::Type type = string_to_variant_type(type_name); |
| 338 | if (type == Variant::VARIANT_MAX) { |
| 339 | match = re->search(new_string, end); |
| 340 | continue; |
| 341 | } |
| 342 | String constant_name = match->get_string(2); |
| 343 | if (!Variant::has_constant(type, constant_name)) { |
| 344 | match = re->search(new_string, end); |
| 345 | continue; |
| 346 | } |
| 347 | Variant constant = Variant::get_constant_value(type, constant_name); |
| 348 | if (constant == Variant()) { |
| 349 | match = re->search(new_string, end); |
| 350 | continue; |
| 351 | } |
| 352 | String old_string = new_string; |
| 353 | new_string = new_string.substr(0, start) + constant.get_construct_string() + new_string.substr(end); |
| 354 | if (new_string == old_string) { |
| 355 | match = re->search(new_string, end); |
| 356 | continue; |
| 357 | } |
| 358 | match = re->search(new_string); |
| 359 | } |
| 360 | return new_string; |
| 361 | } |
| 362 | |
| 363 | bool parse_expression(const String &p_expression, Variant &r_value) { |
| 364 | Ref<Expression> expr = Ref<Expression>(memnew(Expression())); |
no test coverage detected