diff options
| author | Ignacio Etcheverry | 2017-10-17 14:02:19 +0200 |
|---|---|---|
| committer | Ignacio Etcheverry | 2017-10-17 14:42:13 +0200 |
| commit | 6e6b455d1fe791894e1a6bd66e1f5f8471c02abc (patch) | |
| tree | 43863242fc7677aed0684dda7b06ddb9551b3806 /modules/mono/mono_gd/gd_mono_class.cpp | |
| parent | 1b2e09355e890ae32fe172aad19dcda137ed636f (diff) | |
| download | godot-6e6b455d1fe791894e1a6bd66e1f5f8471c02abc.tar.gz godot-6e6b455d1fe791894e1a6bd66e1f5f8471c02abc.tar.zst godot-6e6b455d1fe791894e1a6bd66e1f5f8471c02abc.zip | |
Diffstat (limited to 'modules/mono/mono_gd/gd_mono_class.cpp')
| -rw-r--r-- | modules/mono/mono_gd/gd_mono_class.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index 0134ace5d..77ba0ee90 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -43,6 +43,14 @@ bool GDMonoClass::is_assignable_from(GDMonoClass *p_from) const { return mono_class_is_assignable_from(mono_class, p_from->mono_class); } +String GDMonoClass::get_full_name() const { + + String res = namespace_name; + if (res.length()) + res += "."; + return res + class_name; +} + GDMonoClass *GDMonoClass::get_parent_class() { if (assembly) { @@ -56,6 +64,30 @@ GDMonoClass *GDMonoClass::get_parent_class() { return NULL; } +#ifdef TOOLS_ENABLED +Vector<MonoClassField *> GDMonoClass::get_enum_fields() { + + bool class_is_enum = mono_class_is_enum(mono_class); + ERR_FAIL_COND_V(!class_is_enum, Vector<MonoClassField *>()); + + Vector<MonoClassField *> enum_fields; + + void *iter = NULL; + MonoClassField *raw_field = NULL; + while ((raw_field = mono_class_get_fields(get_raw(), &iter)) != NULL) { + uint32_t field_flags = mono_field_get_flags(raw_field); + + // Enums have an instance field named value__ which holds the value of the enum. + // Enum constants are static, so we will use this to ignore the value__ field. + if (field_flags & MONO_FIELD_ATTR_PUBLIC && field_flags & MONO_FIELD_ATTR_STATIC) { + enum_fields.push_back(raw_field); + } + } + + return enum_fields; +} +#endif + bool GDMonoClass::has_method(const StringName &p_name) { return get_method(p_name) != NULL; |
