summaryrefslogtreecommitdiff
path: root/modules/mono/csharp_script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r--modules/mono/csharp_script.cpp89
1 files changed, 48 insertions, 41 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 990a95821e..8fd3626a20 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2035,6 +2035,52 @@ void CSharpScript::_update_exports_values(HashMap<StringName, Variant> &values,
}
#endif
+void GD_CLR_STDCALL CSharpScript::_add_property_info_list_callback(CSharpScript *p_script, const String *p_current_class_name, void *p_props, int32_t p_count) {
+ GDMonoCache::godotsharp_property_info *props = (GDMonoCache::godotsharp_property_info *)p_props;
+
+#ifdef TOOLS_ENABLED
+ p_script->exported_members_cache.push_back(PropertyInfo(
+ Variant::NIL, *p_current_class_name, PROPERTY_HINT_NONE,
+ p_script->get_path(), PROPERTY_USAGE_CATEGORY));
+#endif
+
+ for (int i = 0; i < p_count; i++) {
+ const GDMonoCache::godotsharp_property_info &prop = props[i];
+
+ StringName name = *reinterpret_cast<const StringName *>(&prop.name);
+ String hint_string = *reinterpret_cast<const String *>(&prop.hint_string);
+
+ PropertyInfo pinfo(prop.type, name, prop.hint, hint_string, prop.usage);
+
+ p_script->member_info[name] = pinfo;
+
+ if (prop.exported) {
+#ifdef TOOLS_ENABLED
+ p_script->exported_members_cache.push_back(pinfo);
+#endif
+
+#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
+ p_script->exported_members_names.insert(name);
+#endif
+ }
+ }
+}
+
+#ifdef TOOLS_ENABLED
+void GD_CLR_STDCALL CSharpScript::_add_property_default_values_callback(CSharpScript *p_script, void *p_def_vals, int32_t p_count) {
+ GDMonoCache::godotsharp_property_def_val_pair *def_vals = (GDMonoCache::godotsharp_property_def_val_pair *)p_def_vals;
+
+ for (int i = 0; i < p_count; i++) {
+ const GDMonoCache::godotsharp_property_def_val_pair &def_val_pair = def_vals[i];
+
+ StringName name = *reinterpret_cast<const StringName *>(&def_val_pair.name);
+ Variant value = *reinterpret_cast<const Variant *>(&def_val_pair.value);
+
+ p_script->exported_members_defval_cache[name] = value;
+ }
+}
+#endif
+
bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_update) {
#ifdef TOOLS_ENABLED
bool is_editor = Engine::get_singleton()->is_editor_hint();
@@ -2066,49 +2112,10 @@ bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_upda
#endif
if (GDMonoCache::godot_api_cache_updated) {
- GDMonoCache::managed_callbacks.ScriptManagerBridge_GetPropertyInfoList(this,
- [](CSharpScript *p_script, const String *p_current_class_name, GDMonoCache::godotsharp_property_info *p_props, int32_t p_count) {
-#ifdef TOOLS_ENABLED
- p_script->exported_members_cache.push_back(PropertyInfo(
- Variant::NIL, *p_current_class_name, PROPERTY_HINT_NONE,
- p_script->get_path(), PROPERTY_USAGE_CATEGORY));
-#endif
-
- for (int i = 0; i < p_count; i++) {
- const GDMonoCache::godotsharp_property_info &prop = p_props[i];
-
- StringName name = *reinterpret_cast<const StringName *>(&prop.name);
- String hint_string = *reinterpret_cast<const String *>(&prop.hint_string);
-
- PropertyInfo pinfo(prop.type, name, prop.hint, hint_string, prop.usage);
-
- p_script->member_info[name] = pinfo;
-
- if (prop.exported) {
+ GDMonoCache::managed_callbacks.ScriptManagerBridge_GetPropertyInfoList(this, &_add_property_info_list_callback);
#ifdef TOOLS_ENABLED
- p_script->exported_members_cache.push_back(pinfo);
-#endif
-
-#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
- p_script->exported_members_names.insert(name);
-#endif
- }
- }
- });
-
-#ifdef TOOLS_ENABLED
- GDMonoCache::managed_callbacks.ScriptManagerBridge_GetPropertyDefaultValues(this,
- [](CSharpScript *p_script, GDMonoCache::godotsharp_property_def_val_pair *p_def_vals, int32_t p_count) {
- for (int i = 0; i < p_count; i++) {
- const GDMonoCache::godotsharp_property_def_val_pair &def_val_pair = p_def_vals[i];
-
- StringName name = *reinterpret_cast<const StringName *>(&def_val_pair.name);
- Variant value = *reinterpret_cast<const Variant *>(&def_val_pair.value);
-
- p_script->exported_members_defval_cache[name] = value;
- }
- });
+ GDMonoCache::managed_callbacks.ScriptManagerBridge_GetPropertyDefaultValues(this, &_add_property_default_values_callback);
#endif
}
}