diff options
| author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2017-10-17 14:02:19 +0200 |
|---|---|---|
| committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2017-10-17 14:42:13 +0200 |
| commit | 6e6b455d1fe791894e1a6bd66e1f5f8471c02abc (patch) | |
| tree | 43863242fc7677aed0684dda7b06ddb9551b3806 /modules/mono/mono_gd/gd_mono_class.cpp | |
| parent | 1b2e09355e890ae32fe172aad19dcda137ed636f (diff) | |
| download | redot-engine-6e6b455d1fe791894e1a6bd66e1f5f8471c02abc.tar.gz | |
Export attribute fixes and improvements
- Allow non-public fields to be exported as well (to avoid confusion).
- Set PROPERTY_HINT_RESOURCE_TYPE for resource derived fields.
- Support enums and automatically fill PROPERTY_HINT_ENUM's hint_string for enum fields.
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 0134ace5d7..77ba0ee90e 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; |
