summaryrefslogtreecommitdiff
path: root/modules/mono/mono_gd
diff options
context:
space:
mode:
authorIgnacio Etcheverry <neikeq@users.noreply.github.com>2018-09-27 00:38:39 +0200
committerGitHub <noreply@github.com>2018-09-27 00:38:39 +0200
commit2e877031369c35c918c014a7ae3688b6f555e5bd (patch)
treec3dda8c3b7fc74e5a33eef982de88f74313c843b /modules/mono/mono_gd
parenta2b6be23ada5e7dc6f5815236d7d2b3bb41ab2db (diff)
parent50fd5ef3b5ceb53bd2201441b16b377b2e51c536 (diff)
Merge pull request #22460 from neikeq/issue-22403
Mono: Fix not creating generic Array or Dictionary where expected
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp106
-rw-r--r--modules/mono/mono_gd/gd_mono_header.h11
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h6
3 files changed, 73 insertions, 50 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 2fed6064b7..9311aa3930 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -259,14 +259,15 @@ void GDMono::initialize() {
// The following assemblies are not required at initialization
#ifdef MONO_GLUE_ENABLED
if (_load_api_assemblies()) {
- if (!core_api_assembly_out_of_sync && !editor_api_assembly_out_of_sync && GDMonoUtils::mono_cache.godot_api_cache_updated) {
- // Everything is fine with the api assemblies, load the project assembly
- _load_project_assembly();
- } else {
+ // Everything is fine with the api assemblies, load the project assembly
+ _load_project_assembly();
+ } else {
+ if ((core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)) ||
+ (editor_api_assembly && editor_api_assembly_out_of_sync)) {
#ifdef TOOLS_ENABLED
// The assembly was successfully loaded, but the full api could not be cached.
- // This is most likely an outdated assembly loaded because of an invalid version in the metadata,
- // so we invalidate the version in the metadata and unload the script domain.
+ // This is most likely an outdated assembly loaded because of an invalid version in the
+ // metadata, so we invalidate the version in the metadata and unload the script domain.
if (core_api_assembly_out_of_sync) {
ERR_PRINT("The loaded Core API assembly is out of sync");
@@ -290,12 +291,12 @@ void GDMono::initialize() {
#else
ERR_PRINT("The loaded API assembly is invalid");
CRASH_NOW();
-#endif
+#endif // TOOLS_ENABLED
}
}
#else
print_verbose("Mono: Glue disabled, ignoring script assemblies.");
-#endif
+#endif // MONO_GLUE_ENABLED
print_verbose("Mono: INITIALIZED");
}
@@ -448,8 +449,10 @@ bool GDMono::_load_core_api_assembly() {
return true;
#ifdef TOOLS_ENABLED
- if (metadata_is_api_assembly_invalidated(APIAssembly::API_CORE))
+ if (metadata_is_api_assembly_invalidated(APIAssembly::API_CORE)) {
+ print_verbose("Mono: Skipping loading of Core API assembly because it was invalidated");
return false;
+ }
#endif
bool success = load_assembly(API_ASSEMBLY_NAME, &core_api_assembly);
@@ -460,8 +463,12 @@ bool GDMono::_load_core_api_assembly() {
core_api_assembly_out_of_sync = GodotSharpBindings::get_core_api_hash() != api_assembly_ver.godot_api_hash ||
GodotSharpBindings::get_bindings_version() != api_assembly_ver.bindings_version ||
CS_GLUE_VERSION != api_assembly_ver.cs_glue_version;
-#endif
+ if (!core_api_assembly_out_of_sync) {
+ GDMonoUtils::update_godot_api_cache();
+ }
+#else
GDMonoUtils::update_godot_api_cache();
+#endif
}
return success;
@@ -474,8 +481,10 @@ bool GDMono::_load_editor_api_assembly() {
return true;
#ifdef TOOLS_ENABLED
- if (metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR))
+ if (metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR)) {
+ print_verbose("Mono: Skipping loading of Editor API assembly because it was invalidated");
return false;
+ }
#endif
bool success = load_assembly(EDITOR_API_ASSEMBLY_NAME, &editor_api_assembly);
@@ -533,16 +542,22 @@ bool GDMono::_load_api_assemblies() {
if (OS::get_singleton()->is_stdout_verbose())
print_error("Mono: Failed to load Core API assembly");
return false;
- } else {
+ }
+
+ if (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)
+ return false;
+
#ifdef TOOLS_ENABLED
- if (!_load_editor_api_assembly()) {
- if (OS::get_singleton()->is_stdout_verbose())
- print_error("Mono: Failed to load Editor API assembly");
- return false;
- }
-#endif
+ if (!_load_editor_api_assembly()) {
+ if (OS::get_singleton()->is_stdout_verbose())
+ print_error("Mono: Failed to load Editor API assembly");
+ return false;
}
+ if (editor_api_assembly_out_of_sync)
+ return false;
+#endif
+
return true;
}
@@ -708,43 +723,42 @@ Error GDMono::reload_scripts_domain() {
#ifdef MONO_GLUE_ENABLED
if (!_load_api_assemblies()) {
- return ERR_CANT_OPEN;
- }
+ if ((core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)) ||
+ (editor_api_assembly && editor_api_assembly_out_of_sync)) {
+ // The assembly was successfully loaded, but the full api could not be cached.
+ // This is most likely an outdated assembly loaded because of an invalid version in the
+ // metadata, so we invalidate the version in the metadata and unload the script domain.
- if (!core_api_assembly_out_of_sync && !editor_api_assembly_out_of_sync && GDMonoUtils::mono_cache.godot_api_cache_updated) {
- // Everything is fine with the api assemblies, load the project assembly
- _load_project_assembly();
- } else {
- // The assembly was successfully loaded, but the full api could not be cached.
- // This is most likely an outdated assembly loaded because of an invalid version in the metadata,
- // so we invalidate the version in the metadata and unload the script domain.
-
- if (core_api_assembly_out_of_sync) {
- ERR_PRINT("The loaded Core API assembly is out of sync");
- metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
- } else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
- ERR_PRINT("The loaded Core API assembly is in sync, but the cache update failed");
- metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
- }
+ if (core_api_assembly_out_of_sync) {
+ ERR_PRINT("The loaded Core API assembly is out of sync");
+ metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
+ } else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
+ ERR_PRINT("The loaded Core API assembly is in sync, but the cache update failed");
+ metadata_set_api_assembly_invalidated(APIAssembly::API_CORE, true);
+ }
- if (editor_api_assembly_out_of_sync) {
- ERR_PRINT("The loaded Editor API assembly is out of sync");
- metadata_set_api_assembly_invalidated(APIAssembly::API_EDITOR, true);
- }
+ if (editor_api_assembly_out_of_sync) {
+ ERR_PRINT("The loaded Editor API assembly is out of sync");
+ metadata_set_api_assembly_invalidated(APIAssembly::API_EDITOR, true);
+ }
- Error err = _unload_scripts_domain();
- if (err != OK) {
- WARN_PRINT("Mono: Failed to unload scripts domain");
- }
+ Error err = _unload_scripts_domain();
+ if (err != OK) {
+ WARN_PRINT("Mono: Failed to unload scripts domain");
+ }
- return ERR_CANT_RESOLVE;
+ return ERR_CANT_RESOLVE;
+ } else {
+ return ERR_CANT_OPEN;
+ }
}
- if (!_load_project_assembly())
+ if (!_load_project_assembly()) {
return ERR_CANT_OPEN;
+ }
#else
print_verbose("Mono: Glue disabled, ignoring script assemblies.");
-#endif
+#endif // MONO_GLUE_ENABLED
return OK;
}
diff --git a/modules/mono/mono_gd/gd_mono_header.h b/modules/mono/mono_gd/gd_mono_header.h
index 2fe05006f1..4f2efc7b92 100644
--- a/modules/mono/mono_gd/gd_mono_header.h
+++ b/modules/mono/mono_gd/gd_mono_header.h
@@ -44,9 +44,14 @@ struct ManagedType {
int type_encoding;
GDMonoClass *type_class;
- ManagedType() {
- type_encoding = 0;
- type_class = NULL;
+ ManagedType() :
+ type_encoding(0),
+ type_class(NULL) {
+ }
+
+ ManagedType(int p_type_encoding, GDMonoClass *p_type_class) :
+ type_encoding(p_type_encoding),
+ type_class(p_type_class) {
}
};
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index 1ad0a4a6ea..cc0ab5fa05 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -97,10 +97,14 @@ _FORCE_INLINE_ MonoString *mono_string_from_godot(const String &p_string) {
MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_type);
MonoObject *variant_to_mono_object(const Variant *p_var);
-_FORCE_INLINE_ MonoObject *variant_to_mono_object(Variant p_var) {
+_FORCE_INLINE_ MonoObject *variant_to_mono_object(const Variant &p_var) {
return variant_to_mono_object(&p_var);
}
+_FORCE_INLINE_ MonoObject *variant_to_mono_object(const Variant &p_var, const ManagedType &p_type) {
+ return variant_to_mono_object(&p_var, p_type);
+}
+
Variant mono_object_to_variant(MonoObject *p_obj);
// Array