Mono: Fix hot-reloading of nested classes

This commit is contained in:
Ignacio Etcheverry 2020-05-09 17:11:35 +02:00
parent 825a89d0da
commit e0a001549e
3 changed files with 21 additions and 6 deletions

View file

@ -850,7 +850,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
to_reload.push_back(script);
if (script->get_path().empty()) {
script->tied_class_name_for_reload = script->script_class->get_name();
script->tied_class_name_for_reload = script->script_class->get_name_for_lookup();
script->tied_class_namespace_for_reload = script->script_class->get_namespace();
}

View file

@ -79,12 +79,26 @@ bool GDMonoClass::is_assignable_from(GDMonoClass *p_from) const {
return mono_class_is_assignable_from(mono_class, p_from->mono_class);
}
GDMonoClass *GDMonoClass::get_parent_class() {
StringName GDMonoClass::get_namespace() const {
GDMonoClass *nesting_class = get_nesting_class();
if (!nesting_class)
return namespace_name;
return nesting_class->get_namespace();
}
String GDMonoClass::get_name_for_lookup() const {
GDMonoClass *nesting_class = get_nesting_class();
if (!nesting_class)
return class_name;
return nesting_class->get_name_for_lookup() + "/" + class_name;
}
GDMonoClass *GDMonoClass::get_parent_class() const {
MonoClass *parent_mono_class = mono_class_get_parent(mono_class);
return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : nullptr;
}
GDMonoClass *GDMonoClass::get_nesting_class() {
GDMonoClass *GDMonoClass::get_nesting_class() const {
MonoClass *nesting_type = mono_class_get_nesting_type(mono_class);
return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : nullptr;
}

View file

@ -113,14 +113,15 @@ public:
bool is_assignable_from(GDMonoClass *p_from) const;
_FORCE_INLINE_ StringName get_namespace() const { return namespace_name; }
StringName get_namespace() const;
_FORCE_INLINE_ StringName get_name() const { return class_name; }
String get_name_for_lookup() const;
_FORCE_INLINE_ MonoClass *get_mono_ptr() const { return mono_class; }
_FORCE_INLINE_ const GDMonoAssembly *get_assembly() const { return assembly; }
GDMonoClass *get_parent_class();
GDMonoClass *get_nesting_class();
GDMonoClass *get_parent_class() const;
GDMonoClass *get_nesting_class() const;
#ifdef TOOLS_ENABLED
Vector<MonoClassField *> get_enum_fields();