| 413 | } |
| 414 | |
| 415 | ScriptInstance *GDScript::instance_create(Object *p_this) { |
| 416 | ERR_FAIL_COND_V_MSG(!valid, nullptr, "Script is invalid!"); |
| 417 | |
| 418 | GDScript *top = this; |
| 419 | while (top->_base) { |
| 420 | top = top->_base; |
| 421 | } |
| 422 | |
| 423 | if (top->native.is_valid()) { |
| 424 | if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) { |
| 425 | if (EngineDebugger::is_active()) { |
| 426 | GDScriptLanguage::get_singleton()->debug_break_parse(_get_debug_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be assigned to an object of type: '" + p_this->get_class() + "'"); |
| 427 | } |
| 428 | ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be assigned to an object of type '" + p_this->get_class() + "'" + "."); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | Callable::CallError unchecked_error; |
| 433 | return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error); |
| 434 | } |
| 435 | |
| 436 | PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) { |
| 437 | #ifdef TOOLS_ENABLED |
no test coverage detected