diff options
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r-- | modules/mono/mono_gd/gd_mono_class.cpp | 28 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_class.h | 6 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.cpp | 2 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.h | 1 |
4 files changed, 37 insertions, 0 deletions
diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index b826352f02..66339d7ae6 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -404,6 +404,33 @@ const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() { return properties_list; } +const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { + if (delegates_fetched) + return delegates_list; + + void *iter = NULL; + MonoClass *raw_class = NULL; + while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != NULL) { + if (mono_class_is_delegate(raw_class)) { + StringName name = mono_class_get_name(raw_class); + + Map<StringName, GDMonoClass *>::Element *match = delegates.find(name); + + if (match) { + delegates_list.push_back(match->get()); + } else { + GDMonoClass *delegate = memnew(GDMonoClass(mono_class_get_namespace(raw_class), mono_class_get_name(raw_class), raw_class, assembly)); + delegates.insert(name, delegate); + delegates_list.push_back(delegate); + } + } + } + + delegates_fetched = true; + + return delegates_list; +} + GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name, MonoClass *p_class, GDMonoAssembly *p_assembly) { namespace_name = p_namespace; @@ -417,6 +444,7 @@ GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name methods_fetched = false; fields_fetched = false; properties_fetched = false; + delegates_fetched = false; } GDMonoClass::~GDMonoClass() { diff --git a/modules/mono/mono_gd/gd_mono_class.h b/modules/mono/mono_gd/gd_mono_class.h index afccf2fc63..417c138594 100644 --- a/modules/mono/mono_gd/gd_mono_class.h +++ b/modules/mono/mono_gd/gd_mono_class.h @@ -90,6 +90,10 @@ class GDMonoClass { Map<StringName, GDMonoProperty *> properties; Vector<GDMonoProperty *> properties_list; + bool delegates_fetched; + Map<StringName, GDMonoClass *> delegates; + Vector<GDMonoClass *> delegates_list; + friend class GDMonoAssembly; GDMonoClass(const StringName &p_namespace, const StringName &p_name, MonoClass *p_class, GDMonoAssembly *p_assembly); @@ -133,6 +137,8 @@ public: GDMonoProperty *get_property(const StringName &p_name); const Vector<GDMonoProperty *> &get_all_properties(); + const Vector<GDMonoClass *> &get_all_delegates(); + ~GDMonoClass(); }; diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index a2f0819a72..42e307cf08 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -114,6 +114,7 @@ void MonoCache::clear_members() { class_ExportAttribute = NULL; field_ExportAttribute_hint = NULL; field_ExportAttribute_hintString = NULL; + class_SignalAttribute = NULL; class_ToolAttribute = NULL; class_RemoteAttribute = NULL; class_SyncAttribute = NULL; @@ -201,6 +202,7 @@ void update_godot_api_cache() { CACHE_CLASS_AND_CHECK(ExportAttribute, GODOT_API_CLASS(ExportAttribute)); CACHE_FIELD_AND_CHECK(ExportAttribute, hint, CACHED_CLASS(ExportAttribute)->get_field("hint")); CACHE_FIELD_AND_CHECK(ExportAttribute, hintString, CACHED_CLASS(ExportAttribute)->get_field("hintString")); + CACHE_CLASS_AND_CHECK(SignalAttribute, GODOT_API_CLASS(SignalAttribute)); CACHE_CLASS_AND_CHECK(ToolAttribute, GODOT_API_CLASS(ToolAttribute)); CACHE_CLASS_AND_CHECK(RemoteAttribute, GODOT_API_CLASS(RemoteAttribute)); CACHE_CLASS_AND_CHECK(SyncAttribute, GODOT_API_CLASS(SyncAttribute)); diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index 259da46c31..1a34180d15 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -108,6 +108,7 @@ struct MonoCache { GDMonoClass *class_ExportAttribute; GDMonoField *field_ExportAttribute_hint; GDMonoField *field_ExportAttribute_hintString; + GDMonoClass *class_SignalAttribute; GDMonoClass *class_ToolAttribute; GDMonoClass *class_RemoteAttribute; GDMonoClass *class_SyncAttribute; |