1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

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.
This commit is contained in:
Ignacio Etcheverry
2017-10-17 14:02:19 +02:00
parent 1b2e09355e
commit 6e6b455d1f
9 changed files with 94 additions and 25 deletions

View File

@@ -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;