Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/variant/container_type_validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ struct ContainerTypeValidate {
}

const StringName &obj_class = object->get_class_name();
if (obj_class != class_name && !ClassDB::is_parent_class(obj_class, class_name)) {
if (obj_class != class_name && !object->is_class(class_name)) {
if (p_output_errors) {
ERR_FAIL_V_MSG(false, vformat("Attempted to %s an object of type '%s' into a %s, which does not inherit from '%s'.", String(p_operation), object->get_class(), where, String(class_name)));
ERR_FAIL_V_MSG(false, vformat("Attempted to %s an object of type '%s' into a %s, which does not inherit from '%s'.", String(p_operation), obj_class, where, String(class_name)));
} else {
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions editor/docks/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
// Prefer nodes that inherit from the current scene root.
Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene();
if (current_edited_scene_root) {
String root_class = current_edited_scene_root->get_class_name();
static Vector<String> preferred_types;
if (preferred_types.is_empty()) {
preferred_types.push_back("Control");
Expand All @@ -660,7 +659,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}

for (int i = 0; i < preferred_types.size(); i++) {
if (ClassDB::is_parent_class(root_class, preferred_types[i])) {
if (current_edited_scene_root->is_class(preferred_types[i])) {
create_dialog->set_preferred_search_result_type(preferred_types[i]);
break;
}
Expand Down
7 changes: 3 additions & 4 deletions editor/inspector/editor_properties_array_dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,14 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
return false;
}

String res_type = res->get_class();
StringName script_class;
if (res->get_script()) {
script_class = EditorNode::get_singleton()->get_object_custom_type_name(res->get_script());
}

for (String at : allowed_type.split(",", false)) {
at = at.strip_edges();
if (ClassDB::is_parent_class(res_type, at) || EditorNode::get_editor_data().script_class_is_parent(script_class, at)) {
if (res->is_class(at) || EditorNode::get_editor_data().script_class_is_parent(script_class, at)) {
return true;
}
}
Expand Down Expand Up @@ -684,7 +683,7 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
ERR_FAIL_NULL_V_MSG(dropped_node, false, "Could not get the dropped node by its path.");

if (allowed_type != "NodePath") {
if (!ClassDB::is_parent_class(dropped_node->get_class_name(), allowed_type) &&
if (!dropped_node->is_class(allowed_type) &&
!EditorNode::get_singleton()->is_object_of_custom_type(dropped_node, allowed_type)) {
// Fail if one of the nodes is not of allowed type.
return false;
Expand All @@ -696,7 +695,7 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
if (!allowed_subtype_array.has(dropped_node->get_class_name())) {
// The dropped node type was not found in the allowed subtype array, we must check if it inherits one of them.
for (const String &ast : allowed_subtype_array) {
if (ClassDB::is_parent_class(dropped_node->get_class_name(), ast) ||
if (dropped_node->is_class(ast) ||
EditorNode::get_singleton()->is_object_of_custom_type(dropped_node, ast)) {
is_drop_allowed = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion editor/script/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ static String _get_dropped_resource_as_member(const Ref<Resource> &p_resource, b
path = ResourceUID::get_singleton()->id_to_text(id);
}
}
const bool is_script = ClassDB::is_parent_class(p_resource->get_class(), "Script");
const bool is_script = p_resource->is_class(SNAME("Script"));

if (!p_create_field) {
return vformat("preload(%s)", _quote_drop_data(path));
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}

if (top->native.is_valid()) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) {
if (!p_this->is_class(top->native->get_name())) {
if (EngineDebugger::is_active()) {
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() + "'");
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool GDScriptDataType::is_type(const Variant &p_variant, bool p_allow_implicit_c
return !was_freed;
}

if (!ClassDB::is_parent_class(obj->get_class_name(), native_type)) {
if (!obj->is_class(native_type)) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_utility_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ struct GDScriptUtilityFunctionsDefinitions {

GDScriptNativeClass *native_type = Object::cast_to<GDScriptNativeClass>(type_object);
if (native_type) {
*r_ret = ClassDB::is_parent_class(value_object->get_class_name(), native_type->get_name());
*r_ret = value_object->is_class(native_type->get_name());
return;
}

Expand Down
8 changes: 4 additions & 4 deletions modules/gdscript/gdscript_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_BREAK;
}

*dst = object && ClassDB::is_parent_class(object->get_class_name(), native_type);
*dst = object && object->is_class(native_type);
ip += 4;
}
DISPATCH_OPCODE;
Expand Down Expand Up @@ -1553,7 +1553,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_BREAK;
}

if (src_obj && !ClassDB::is_parent_class(src_obj->get_class_name(), nc->get_name())) {
if (src_obj && !src_obj->is_class(nc->get_name())) {
err_text = "Trying to assign value of type '" + src_obj->get_class_name() +
"' to a variable of type '" + nc->get_name() + "'.";
OPCODE_BREAK;
Expand Down Expand Up @@ -1674,7 +1674,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
Object *src_obj = src->operator Object *();

if (src_obj && !ClassDB::is_parent_class(src_obj->get_class_name(), nc->get_name())) {
if (src_obj && !src_obj->is_class(nc->get_name())) {
*dst = Variant(); // invalid cast, assign NULL
} else {
*dst = *src;
Expand Down Expand Up @@ -2948,7 +2948,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#else
Object *ret_obj = r->operator Object *();
#endif // DEBUG_ENABLED
if (ret_obj && !ClassDB::is_parent_class(ret_obj->get_class_name(), nc->get_name())) {
if (ret_obj && !ret_obj->is_class(nc->get_name())) {
#ifdef DEBUG_ENABLED
err_text = vformat(R"(Trying to return a value of type "%s" from a function whose return type is "%s".)",
_get_var_type(r), nc->get_name());
Expand Down
6 changes: 3 additions & 3 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
continue;
}

if (!ClassDB::is_parent_class(obj->get_class_name(), native_name)) {
if (!obj->is_class(native_name)) {
// No longer inherits the same compatible type, can't reload
scr->pending_reload_state.erase(obj_id);
continue;
Expand Down Expand Up @@ -1158,7 +1158,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
ERR_FAIL_NULL_V(classinfo, false);
type_name = classinfo->gdtype->get_name();

bool parent_is_object_class = ClassDB::is_parent_class(p_object->get_class_name(), type_name);
bool parent_is_object_class = p_object->is_class(type_name);
ERR_FAIL_COND_V_MSG(!parent_is_object_class, false,
"Type inherits from native type '" + type_name + "', so it can't be instantiated in object of type: '" + p_object->get_class() + "'.");

Expand Down Expand Up @@ -2464,7 +2464,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {

ERR_FAIL_COND_V(native_name == StringName(), nullptr);

if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) {
if (!p_this->is_class(native_name)) {
if (EngineDebugger::is_active()) {
CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0,
"Script inherits from native type '" + String(native_name) +
Expand Down
4 changes: 2 additions & 2 deletions modules/mono/glue/runtime_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ GCHandleIntPtr godotsharp_internal_unmanaged_instance_binding_create_managed(Obj
CRASH_COND(script_binding.type_name == StringName());
#endif

bool parent_is_object_class = ClassDB::is_parent_class(p_unmanaged->get_class_name(), script_binding.type_name);
bool parent_is_object_class = p_unmanaged->is_class(script_binding.type_name);
ERR_FAIL_COND_V_MSG(!parent_is_object_class, { nullptr },
"Type inherits from native type '" + script_binding.type_name + "', so it can't be instantiated in object of type: '" + p_unmanaged->get_class() + "'.");

Expand Down Expand Up @@ -356,7 +356,7 @@ void godotsharp_array_filter_godot_objects_by_native(StringName *p_native_name,
memnew_placement(r_output, Array);

for (int i = 0; i < p_input->size(); ++i) {
if (ClassDB::is_parent_class(((Object *)(*p_input)[i])->get_class(), *p_native_name)) {
if (((Object *)(*p_input)[i])->is_class(*p_native_name)) {
r_output->push_back(p_input[i]);
}
}
Expand Down