diff options
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 92 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.h | 6 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_assembly.cpp | 46 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_cache.cpp | 164 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_class.cpp | 78 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_field.cpp | 10 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_internals.cpp | 4 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_log.cpp | 8 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_marshal.cpp | 42 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_marshal.h | 4 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_method.cpp | 30 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_method.h | 6 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_method_thunk.h | 50 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_property.cpp | 32 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_property.h | 6 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.cpp | 104 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.h | 8 | ||||
-rw-r--r-- | modules/mono/mono_gd/managed_type.h | 2 | ||||
-rwxr-xr-x | modules/mono/mono_gd/support/android_support.cpp | 60 |
19 files changed, 376 insertions, 376 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 3390aaae88..306a1997ab 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -76,7 +76,7 @@ // This has turn into a gigantic mess. There's too much going on here. Too much #ifdef as well. // It's just painful to read... It needs to be re-structured. Please, clean this up, future me. -GDMono *GDMono::singleton = NULL; +GDMono *GDMono::singleton = nullptr; namespace { @@ -332,8 +332,8 @@ void GDMono::initialize() { determine_mono_dirs(assembly_rootdir, config_dir); // Leak if we call mono_set_dirs more than once - mono_set_dirs(assembly_rootdir.length() ? assembly_rootdir.utf8().get_data() : NULL, - config_dir.length() ? config_dir.utf8().get_data() : NULL); + mono_set_dirs(assembly_rootdir.length() ? assembly_rootdir.utf8().get_data() : nullptr, + config_dir.length() ? config_dir.utf8().get_data() : nullptr); add_mono_shared_libs_dir_to_path(); #endif @@ -341,7 +341,7 @@ void GDMono::initialize() { #ifdef ANDROID_ENABLED mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data()); #else - mono_config_parse(NULL); + mono_config_parse(nullptr); #endif #if defined(ANDROID_ENABLED) @@ -356,7 +356,7 @@ void GDMono::initialize() { gd_mono_profiler_init(); #endif - mono_install_unhandled_exception_hook(&unhandled_exception_hook, NULL); + mono_install_unhandled_exception_hook(&unhandled_exception_hook, nullptr); #ifndef TOOLS_ENABLED // Exported games that don't use C# must still work. They likely don't ship with mscorlib. @@ -375,7 +375,7 @@ void GDMono::initialize() { #endif // NOTE: Internal calls must be registered after the Mono runtime initialization. - // Otherwise registration fails with the error: 'assertion 'hash != NULL' failed'. + // Otherwise registration fails with the error: 'assertion 'hash != nullptr' failed'. root_domain = gd_initialize_mono_runtime(); ERR_FAIL_NULL_MSG(root_domain, "Mono: Failed to initialize runtime."); @@ -523,7 +523,7 @@ GDMonoAssembly *GDMono::get_loaded_assembly(const String &p_name) { MonoDomain *domain = mono_domain_get(); uint32_t domain_id = domain ? mono_domain_get_id(domain) : 0; GDMonoAssembly **result = assemblies[domain_id].getptr(p_name); - return result ? *result : NULL; + return result ? *result : nullptr; } bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly) { @@ -545,7 +545,7 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo print_verbose("Mono: Loading assembly " + p_name + (p_refonly ? " (refonly)" : "") + "..."); MonoImageOpenStatus status = MONO_IMAGE_OK; - MonoAssembly *assembly = mono_assembly_load_full(p_aname, NULL, &status, p_refonly); + MonoAssembly *assembly = mono_assembly_load_full(p_aname, nullptr, &status, p_refonly); if (!assembly) return false; @@ -556,7 +556,7 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo GDMonoAssembly **stored_assembly = assemblies[domain_id].getptr(p_name); - ERR_FAIL_COND_V(stored_assembly == NULL, false); + ERR_FAIL_COND_V(stored_assembly == nullptr, false); ERR_FAIL_COND_V((*stored_assembly)->get_assembly() != assembly, false); *r_assembly = *stored_assembly; @@ -596,15 +596,15 @@ ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMo if (nativecalls_klass) { GDMonoField *api_hash_field = nativecalls_klass->get_field("godot_api_hash"); if (api_hash_field) - api_assembly_version.godot_api_hash = GDMonoMarshal::unbox<uint64_t>(api_hash_field->get_value(NULL)); + api_assembly_version.godot_api_hash = GDMonoMarshal::unbox<uint64_t>(api_hash_field->get_value(nullptr)); GDMonoField *binds_ver_field = nativecalls_klass->get_field("bindings_version"); if (binds_ver_field) - api_assembly_version.bindings_version = GDMonoMarshal::unbox<uint32_t>(binds_ver_field->get_value(NULL)); + api_assembly_version.bindings_version = GDMonoMarshal::unbox<uint32_t>(binds_ver_field->get_value(nullptr)); GDMonoField *cs_glue_ver_field = nativecalls_klass->get_field("cs_glue_version"); if (cs_glue_ver_field) - api_assembly_version.cs_glue_version = GDMonoMarshal::unbox<uint32_t>(cs_glue_ver_field->get_value(NULL)); + api_assembly_version.cs_glue_version = GDMonoMarshal::unbox<uint32_t>(cs_glue_ver_field->get_value(nullptr)); } return api_assembly_version; @@ -735,7 +735,7 @@ bool GDMono::_temp_domain_load_are_assemblies_out_of_sync(const String &p_config GDMono::LoadedApiAssembly temp_editor_api_assembly; if (!_try_load_api_assemblies(temp_core_api_assembly, temp_editor_api_assembly, - p_config, /* refonly: */ true, /* loaded_callback: */ NULL)) { + p_config, /* refonly: */ true, /* loaded_callback: */ nullptr)) { return temp_core_api_assembly.out_of_sync || temp_editor_api_assembly.out_of_sync; } @@ -1002,8 +1002,8 @@ void GDMono::_install_trace_listener() { GDMonoClass *debug_utils = get_core_api_assembly()->get_class(BINDINGS_NAMESPACE, "DebuggingUtils"); GDMonoMethod *install_func = debug_utils->get_method("InstallTraceListener"); - MonoException *exc = NULL; - install_func->invoke_raw(NULL, NULL, &exc); + MonoException *exc = nullptr; + install_func->invoke_raw(nullptr, nullptr, &exc); if (exc) { GDMonoUtils::debug_print_unhandled_exception(exc); ERR_PRINT("Failed to install 'System.Diagnostics.Trace' listener."); @@ -1014,7 +1014,7 @@ void GDMono::_install_trace_listener() { #ifndef GD_MONO_SINGLE_APPDOMAIN Error GDMono::_load_scripts_domain() { - ERR_FAIL_COND_V(scripts_domain != NULL, ERR_BUG); + ERR_FAIL_COND_V(scripts_domain != nullptr, ERR_BUG); print_verbose("Mono: Loading scripts domain..."); @@ -1050,23 +1050,23 @@ Error GDMono::_unload_scripts_domain() { _domain_assemblies_cleanup(mono_domain_get_id(scripts_domain)); - core_api_assembly.assembly = NULL; + core_api_assembly.assembly = nullptr; #ifdef TOOLS_ENABLED - editor_api_assembly.assembly = NULL; + editor_api_assembly.assembly = nullptr; #endif - project_assembly = NULL; + project_assembly = nullptr; #ifdef TOOLS_ENABLED - tools_assembly = NULL; - tools_project_editor_assembly = NULL; + tools_assembly = nullptr; + tools_project_editor_assembly = nullptr; #endif MonoDomain *domain = scripts_domain; - scripts_domain = NULL; + scripts_domain = nullptr; print_verbose("Mono: Unloading scripts domain..."); - MonoException *exc = NULL; + MonoException *exc = nullptr; mono_domain_try_unload(domain, (MonoObject **)&exc); if (exc) { @@ -1119,7 +1119,7 @@ Error GDMono::reload_scripts_domain() { #ifndef GD_MONO_SINGLE_APPDOMAIN Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { - CRASH_COND(p_domain == NULL); + CRASH_COND(p_domain == nullptr); CRASH_COND(p_domain == GDMono::get_singleton()->get_scripts_domain()); // Should use _unload_scripts_domain() instead String domain_name = mono_domain_get_friendly_name(p_domain); @@ -1137,7 +1137,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { _domain_assemblies_cleanup(mono_domain_get_id(p_domain)); - MonoException *exc = NULL; + MonoException *exc = nullptr; mono_domain_try_unload(p_domain, (MonoObject **)&exc); if (exc) { @@ -1160,7 +1160,7 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { uint32_t domain_id = mono_domain_get_id(mono_domain_get()); HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id]; - const String *k = NULL; + const String *k = nullptr; while ((k = domain_assemblies.next(k))) { GDMonoAssembly *assembly = domain_assemblies.get(*k); if (assembly->get_image() == image) { @@ -1171,7 +1171,7 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { } } - return NULL; + return nullptr; } GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName &p_name) { @@ -1183,7 +1183,7 @@ GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName & uint32_t domain_id = mono_domain_get_id(mono_domain_get()); HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id]; - const String *k = NULL; + const String *k = nullptr; while ((k = domain_assemblies.next(k))) { GDMonoAssembly *assembly = domain_assemblies.get(*k); klass = assembly->get_class(p_namespace, p_name); @@ -1191,14 +1191,14 @@ GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName & return klass; } - return NULL; + return nullptr; } void GDMono::_domain_assemblies_cleanup(uint32_t p_domain_id) { HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[p_domain_id]; - const String *k = NULL; + const String *k = nullptr; while ((k = domain_assemblies.next(k))) { memdelete(domain_assemblies.get(*k)); } @@ -1232,14 +1232,14 @@ GDMono::GDMono() { runtime_initialized = false; finalizing_scripts_domain = false; - root_domain = NULL; - scripts_domain = NULL; + root_domain = nullptr; + scripts_domain = nullptr; - corlib_assembly = NULL; - project_assembly = NULL; + corlib_assembly = nullptr; + project_assembly = nullptr; #ifdef TOOLS_ENABLED - tools_assembly = NULL; - tools_project_editor_assembly = NULL; + tools_assembly = nullptr; + tools_project_editor_assembly = nullptr; #endif api_core_hash = 0; @@ -1282,21 +1282,21 @@ GDMono::~GDMono() { _domain_assemblies_cleanup(mono_domain_get_id(root_domain)); - core_api_assembly.assembly = NULL; + core_api_assembly.assembly = nullptr; - project_assembly = NULL; + project_assembly = nullptr; - root_domain = NULL; - scripts_domain = NULL; + root_domain = nullptr; + scripts_domain = nullptr; // Leave the rest to 'mono_jit_cleanup' #endif - const uint32_t *k = NULL; + const uint32_t *k = nullptr; while ((k = assemblies.next(k))) { HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies.get(*k); - const String *kk = NULL; + const String *kk = nullptr; while ((kk = domain_assemblies.next(kk))) { memdelete(domain_assemblies.get(*kk)); } @@ -1319,10 +1319,10 @@ GDMono::~GDMono() { if (gdmono_log) memdelete(gdmono_log); - singleton = NULL; + singleton = nullptr; } -_GodotSharp *_GodotSharp::singleton = NULL; +_GodotSharp *_GodotSharp::singleton = nullptr; void _GodotSharp::attach_thread() { @@ -1350,7 +1350,7 @@ int32_t _GodotSharp::get_scripts_domain_id() { bool _GodotSharp::is_scripts_domain_loaded() { - return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != NULL; + return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != nullptr; } bool _GodotSharp::_is_domain_finalizing_for_unload(int32_t p_domain_id) { @@ -1415,5 +1415,5 @@ _GodotSharp::_GodotSharp() { _GodotSharp::~_GodotSharp() { - singleton = NULL; + singleton = nullptr; } diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h index f7c2426734..4898833e8e 100644 --- a/modules/mono/mono_gd/gd_mono.h +++ b/modules/mono/mono_gd/gd_mono.h @@ -91,7 +91,7 @@ public: bool out_of_sync; LoadedApiAssembly() : - assembly(NULL), + assembly(nullptr), out_of_sync(false) { } }; @@ -200,7 +200,7 @@ public: #ifdef TOOLS_ENABLED bool copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const String &p_config); - String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = NULL, const bool *p_editor_api_out_of_sync = NULL); + String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = nullptr, const bool *p_editor_api_out_of_sync = nullptr); #endif static GDMono *get_singleton() { return singleton; } @@ -265,7 +265,7 @@ public: this->prev_domain = prev_domain; mono_domain_set(p_domain, false); } else { - this->prev_domain = NULL; + this->prev_domain = nullptr; } } diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index a6a44fe8eb..8439769d84 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -144,7 +144,7 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d if (loaded_asm) return loaded_asm->get_assembly(); - return NULL; + return nullptr; } MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, void *user_data, bool refonly) { @@ -157,7 +157,7 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, vo MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) { - MonoAssembly *res = NULL; + MonoAssembly *res = nullptr; String path; bool has_extension = p_name.ends_with(".dll") || p_name.ends_with(".exe"); @@ -169,27 +169,27 @@ MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const path = search_dir.plus_file(p_name); if (FileAccess::exists(path)) { res = _real_load_assembly_from(path, p_refonly); - if (res != NULL) + if (res != nullptr) return res; } } else { path = search_dir.plus_file(p_name + ".dll"); if (FileAccess::exists(path)) { res = _real_load_assembly_from(path, p_refonly); - if (res != NULL) + if (res != nullptr) return res; } path = search_dir.plus_file(p_name + ".exe"); if (FileAccess::exists(path)) { res = _real_load_assembly_from(path, p_refonly); - if (res != NULL) + if (res != nullptr) return res; } } } - return NULL; + return nullptr; } String GDMonoAssembly::find_assembly(const String &p_name) { @@ -223,17 +223,17 @@ void GDMonoAssembly::initialize() { fill_search_dirs(search_dirs); - mono_install_assembly_search_hook(&assembly_search_hook, NULL); - mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, NULL); - mono_install_assembly_preload_hook(&assembly_preload_hook, NULL); - mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, NULL); - mono_install_assembly_load_hook(&assembly_load_hook, NULL); + mono_install_assembly_search_hook(&assembly_search_hook, nullptr); + mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, nullptr); + mono_install_assembly_preload_hook(&assembly_preload_hook, nullptr); + mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, nullptr); + mono_install_assembly_load_hook(&assembly_load_hook, nullptr); } MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, bool p_refonly) { Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); - ERR_FAIL_COND_V_MSG(data.empty(), NULL, "Could read the assembly in the specified location"); + ERR_FAIL_COND_V_MSG(data.empty(), nullptr, "Could read the assembly in the specified location"); String image_filename; @@ -255,7 +255,7 @@ MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, boo true, &status, p_refonly, image_filename.utf8()); - ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !image, NULL, "Failed to open assembly image from the loaded data"); + ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !image, nullptr, "Failed to open assembly image from the loaded data"); #ifdef DEBUG_ENABLED Vector<uint8_t> pdb_data; @@ -281,7 +281,7 @@ no_pdb: MonoAssembly *assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, p_refonly); - ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !assembly, NULL, "Failed to load assembly for image"); + ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !assembly, nullptr, "Failed to load assembly for image"); // Decrement refcount which was previously incremented by mono_image_open_from_data_with_name mono_image_close(image); @@ -300,8 +300,8 @@ void GDMonoAssembly::unload() { cached_classes.clear(); cached_raw.clear(); - assembly = NULL; - image = NULL; + assembly = nullptr; + image = nullptr; } String GDMonoAssembly::get_path() const { @@ -310,7 +310,7 @@ String GDMonoAssembly::get_path() const { GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) { - ERR_FAIL_NULL_V(image, NULL); + ERR_FAIL_NULL_V(image, nullptr); ClassKey key(p_namespace, p_name); @@ -322,7 +322,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri MonoClass *mono_class = mono_class_from_name(image, String(p_namespace).utf8(), String(p_name).utf8()); if (!mono_class) - return NULL; + return nullptr; GDMonoClass *wrapped_class = memnew(GDMonoClass(p_namespace, p_name, mono_class, this)); @@ -334,7 +334,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { - ERR_FAIL_NULL_V(image, NULL); + ERR_FAIL_NULL_V(image, nullptr); Map<MonoClass *, GDMonoClass *>::Element *match = cached_raw.find(p_mono_class); @@ -354,7 +354,7 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) { - GDMonoClass *match = NULL; + GDMonoClass *match = nullptr; if (gdobject_class_cache_updated) { Map<StringName, GDMonoClass *>::Element *result = gdobject_class_cache.find(p_class); @@ -386,7 +386,7 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) GDMonoClass *current_nested = nested_classes.front()->get(); nested_classes.pop_back(); - void *iter = NULL; + void *iter = nullptr; while (true) { MonoClass *raw_nested = mono_class_get_nested_types(current_nested->get_mono_ptr(), &iter); @@ -425,11 +425,11 @@ GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_ if (!assembly) { assembly = _real_load_assembly_from(p_path, p_refonly); - ERR_FAIL_NULL_V(assembly, NULL); + ERR_FAIL_NULL_V(assembly, nullptr); } GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name); - ERR_FAIL_NULL_V_MSG(loaded_asm, NULL, "Loaded assembly missing from table. Did we not receive the load hook?"); + ERR_FAIL_NULL_V_MSG(loaded_asm, nullptr, "Loaded assembly missing from table. Did we not receive the load hook?"); return loaded_asm; } diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp index e493098211..40cc41122b 100644 --- a/modules/mono/mono_gd/gd_mono_cache.cpp +++ b/modules/mono/mono_gd/gd_mono_cache.cpp @@ -40,11 +40,11 @@ namespace GDMonoCache { CachedData cached_data; -#define CACHE_AND_CHECK(m_var, m_val) \ - { \ - CRASH_COND(m_var != NULL); \ - m_var = m_val; \ - ERR_FAIL_COND_MSG(m_var == NULL, "Mono Cache: Member " #m_var " is null."); \ +#define CACHE_AND_CHECK(m_var, m_val) \ + { \ + CRASH_COND(m_var != nullptr); \ + m_var = m_val; \ + ERR_FAIL_COND_MSG(m_var == nullptr, "Mono Cache: Member " #m_var " is null."); \ } #define CACHE_CLASS_AND_CHECK(m_class, m_val) CACHE_AND_CHECK(cached_data.class_##m_class, m_val) @@ -54,12 +54,12 @@ CachedData cached_data; #define CACHE_METHOD_AND_CHECK(m_class, m_method, m_val) CACHE_AND_CHECK(cached_data.method_##m_class##_##m_method, m_val) #define CACHE_PROPERTY_AND_CHECK(m_class, m_property, m_val) CACHE_AND_CHECK(cached_data.property_##m_class##_##m_property, m_val) -#define CACHE_METHOD_THUNK_AND_CHECK_IMPL(m_var, m_val) \ - { \ - CRASH_COND(!m_var.is_null()); \ - ERR_FAIL_COND_MSG(m_val == NULL, "Mono Cache: Method for member " #m_var " is null."); \ - m_var.set_from_method(m_val); \ - ERR_FAIL_COND_MSG(m_var.is_null(), "Mono Cache: Member " #m_var " is null."); \ +#define CACHE_METHOD_THUNK_AND_CHECK_IMPL(m_var, m_val) \ + { \ + CRASH_COND(!m_var.is_null()); \ + ERR_FAIL_COND_MSG(m_val == nullptr, "Mono Cache: Method for member " #m_var " is null."); \ + m_var.set_from_method(m_val); \ + ERR_FAIL_COND_MSG(m_var.is_null(), "Mono Cache: Member " #m_var " is null."); \ } #define CACHE_METHOD_THUNK_AND_CHECK(m_class, m_method, m_val) CACHE_METHOD_THUNK_AND_CHECK_IMPL(cached_data.methodthunk_##m_class##_##m_method, m_val) @@ -68,93 +68,93 @@ void CachedData::clear_corlib_cache() { corlib_cache_updated = false; - class_MonoObject = NULL; - class_bool = NULL; - class_int8_t = NULL; - class_int16_t = NULL; - class_int32_t = NULL; - class_int64_t = NULL; - class_uint8_t = NULL; - class_uint16_t = NULL; - class_uint32_t = NULL; - class_uint64_t = NULL; - class_float = NULL; - class_double = NULL; - class_String = NULL; - class_IntPtr = NULL; - - class_System_Collections_IEnumerable = NULL; - class_System_Collections_IDictionary = NULL; + class_MonoObject = nullptr; + class_bool = nullptr; + class_int8_t = nullptr; + class_int16_t = nullptr; + class_int32_t = nullptr; + class_int64_t = nullptr; + class_uint8_t = nullptr; + class_uint16_t = nullptr; + class_uint32_t = nullptr; + class_uint64_t = nullptr; + class_float = nullptr; + class_double = nullptr; + class_String = nullptr; + class_IntPtr = nullptr; + + class_System_Collections_IEnumerable = nullptr; + class_System_Collections_IDictionary = nullptr; #ifdef DEBUG_ENABLED - class_System_Diagnostics_StackTrace = NULL; + class_System_Diagnostics_StackTrace = nullptr; methodthunk_System_Diagnostics_StackTrace_GetFrames.nullify(); - method_System_Diagnostics_StackTrace_ctor_bool = NULL; - method_System_Diagnostics_StackTrace_ctor_Exception_bool = NULL; + method_System_Diagnostics_StackTrace_ctor_bool = nullptr; + method_System_Diagnostics_StackTrace_ctor_Exception_bool = nullptr; #endif - class_KeyNotFoundException = NULL; + class_KeyNotFoundException = nullptr; } void CachedData::clear_godot_api_cache() { godot_api_cache_updated = false; - rawclass_Dictionary = NULL; - - class_Vector2 = NULL; - class_Vector2i = NULL; - class_Rect2 = NULL; - class_Rect2i = NULL; - class_Transform2D = NULL; - class_Vector3 = NULL; - class_Vector3i = NULL; - class_Basis = NULL; - class_Quat = NULL; - class_Transform = NULL; - class_AABB = NULL; - class_Color = NULL; - class_Plane = NULL; - class_StringName = NULL; - class_NodePath = NULL; - class_RID = NULL; - class_GodotObject = NULL; - class_GodotResource = NULL; - class_Node = NULL; - class_Control = NULL; - class_Node3D = NULL; - class_WeakRef = NULL; - class_Callable = NULL; - class_SignalInfo = NULL; - class_Array = NULL; - class_Dictionary = NULL; - class_MarshalUtils = NULL; - class_ISerializationListener = NULL; + rawclass_Dictionary = nullptr; + + class_Vector2 = nullptr; + class_Vector2i = nullptr; + class_Rect2 = nullptr; + class_Rect2i = nullptr; + class_Transform2D = nullptr; + class_Vector3 = nullptr; + class_Vector3i = nullptr; + class_Basis = nullptr; + class_Quat = nullptr; + class_Transform = nullptr; + class_AABB = nullptr; + class_Color = nullptr; + class_Plane = nullptr; + class_StringName = nullptr; + class_NodePath = nullptr; + class_RID = nullptr; + class_GodotObject = nullptr; + class_GodotResource = nullptr; + class_Node = nullptr; + class_Control = nullptr; + class_Node3D = nullptr; + class_WeakRef = nullptr; + class_Callable = nullptr; + class_SignalInfo = nullptr; + class_Array = nullptr; + class_Dictionary = nullptr; + class_MarshalUtils = nullptr; + class_ISerializationListener = nullptr; #ifdef DEBUG_ENABLED - class_DebuggingUtils = NULL; + class_DebuggingUtils = nullptr; methodthunk_DebuggingUtils_GetStackFrameInfo.nullify(); #endif - class_ExportAttribute = NULL; - field_ExportAttribute_hint = NULL; - field_ExportAttribute_hintString = NULL; - class_SignalAttribute = NULL; - class_ToolAttribute = NULL; - class_RemoteAttribute = NULL; - class_MasterAttribute = NULL; - class_PuppetAttribute = NULL; - class_RemoteSyncAttribute = NULL; - class_MasterSyncAttribute = NULL; - class_PuppetSyncAttribute = NULL; - class_GodotMethodAttribute = NULL; - field_GodotMethodAttribute_methodName = NULL; - - field_GodotObject_ptr = NULL; - field_StringName_ptr = NULL; - field_NodePath_ptr = NULL; - field_Image_ptr = NULL; - field_RID_ptr = NULL; + class_ExportAttribute = nullptr; + field_ExportAttribute_hint = nullptr; + field_ExportAttribute_hintString = nullptr; + class_SignalAttribute = nullptr; + class_ToolAttribute = nullptr; + class_RemoteAttribute = nullptr; + class_MasterAttribute = nullptr; + class_PuppetAttribute = nullptr; + class_RemoteSyncAttribute = nullptr; + class_MasterSyncAttribute = nullptr; + class_PuppetSyncAttribute = nullptr; + class_GodotMethodAttribute = nullptr; + field_GodotMethodAttribute_methodName = nullptr; + + field_GodotObject_ptr = nullptr; + field_StringName_ptr = nullptr; + field_NodePath_ptr = nullptr; + field_Image_ptr = nullptr; + field_RID_ptr = nullptr; methodthunk_GodotObject_Dispose.nullify(); methodthunk_Array_GetPtr.nullify(); diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index 648f5f6c6b..ede4203e35 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -40,7 +40,7 @@ String GDMonoClass::get_full_name(MonoClass *p_mono_class) { // mono_type_get_full_name is not exposed to embedders, but this seems to do the job MonoReflectionType *type_obj = mono_type_get_object(mono_domain_get(), get_mono_type(p_mono_class)); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoString *str = GDMonoUtils::object_to_string((MonoObject *)type_obj, &exc); UNHANDLED_EXCEPTION(exc); @@ -76,12 +76,12 @@ bool GDMonoClass::is_assignable_from(GDMonoClass *p_from) const { GDMonoClass *GDMonoClass::get_parent_class() { MonoClass *parent_mono_class = mono_class_get_parent(mono_class); - return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : NULL; + return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : nullptr; } GDMonoClass *GDMonoClass::get_nesting_class() { MonoClass *nesting_type = mono_class_get_nesting_type(mono_class); - return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : NULL; + return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : nullptr; } #ifdef TOOLS_ENABLED @@ -92,9 +92,9 @@ Vector<MonoClassField *> GDMonoClass::get_enum_fields() { Vector<MonoClassField *> enum_fields; - void *iter = NULL; - MonoClassField *raw_field = NULL; - while ((raw_field = mono_class_get_fields(get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoClassField *raw_field = nullptr; + while ((raw_field = mono_class_get_fields(get_mono_ptr(), &iter)) != nullptr) { uint32_t field_flags = mono_field_get_flags(raw_field); // Enums have an instance field named value__ which holds the value of the enum. @@ -126,21 +126,21 @@ bool GDMonoClass::has_attribute(GDMonoClass *p_attr_class) { MonoObject *GDMonoClass::get_attribute(GDMonoClass *p_attr_class) { #ifdef DEBUG_ENABLED - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); #endif if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoClass::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_class(get_mono_ptr()); attrs_fetched = true; @@ -153,9 +153,9 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base if (methods_fetched) return; - void *iter = NULL; - MonoMethod *raw_method = NULL; - while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoMethod *raw_method = nullptr; + while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { StringName name = mono_method_get_name(raw_method); // get_method implicitly fetches methods and adds them to this->methods @@ -198,7 +198,7 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base } #endif - uint32_t flags = mono_method_get_flags(method->mono_method, NULL); + uint32_t flags = mono_method_get_flags(method->mono_method, nullptr); if (!(flags & MONO_METHOD_ATTR_VIRTUAL)) continue; @@ -242,21 +242,21 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base GDMonoMethod *GDMonoClass::get_fetched_method_unknown_params(const StringName &p_name) { - ERR_FAIL_COND_V(!methods_fetched, NULL); + ERR_FAIL_COND_V(!methods_fetched, nullptr); - const MethodKey *k = NULL; + const MethodKey *k = nullptr; while ((k = methods.next(k))) { if (k->name == p_name) return methods.get(*k); } - return NULL; + return nullptr; } bool GDMonoClass::has_fetched_method_unknown_params(const StringName &p_name) { - return get_fetched_method_unknown_params(p_name) != NULL; + return get_fetched_method_unknown_params(p_name) != nullptr; } bool GDMonoClass::implements_interface(GDMonoClass *p_interface) { @@ -274,7 +274,7 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou return *match; if (methods_fetched) - return NULL; + return nullptr; MonoMethod *raw_method = mono_class_get_method_from_name(mono_class, String(p_name).utf8().get_data(), p_params_count); @@ -285,7 +285,7 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou return method; } - return NULL; + return nullptr; } GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) { @@ -307,7 +307,7 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName &p_name, int p_params_count) { - ERR_FAIL_NULL_V(p_raw_method, NULL); + ERR_FAIL_NULL_V(p_raw_method, nullptr); MethodKey key = MethodKey(p_name, p_params_count); @@ -328,7 +328,7 @@ GDMonoMethod *GDMonoClass::get_method_with_desc(const String &p_description, boo MonoMethod *method = mono_method_desc_search_in_class(desc, mono_class); mono_method_desc_free(desc); - ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, NULL); + ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, nullptr); return get_method(method); } @@ -341,7 +341,7 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) { return result->value(); if (fields_fetched) - return NULL; + return nullptr; MonoClassField *raw_field = mono_class_get_field_from_name(mono_class, String(p_name).utf8().get_data()); @@ -352,7 +352,7 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) { return field; } - return NULL; + return nullptr; } const Vector<GDMonoField *> &GDMonoClass::get_all_fields() { @@ -360,9 +360,9 @@ const Vector<GDMonoField *> &GDMonoClass::get_all_fields() { if (fields_fetched) return fields_list; - void *iter = NULL; - MonoClassField *raw_field = NULL; - while ((raw_field = mono_class_get_fields(mono_class, &iter)) != NULL) { + void *iter = nullptr; + MonoClassField *raw_field = nullptr; + while ((raw_field = mono_class_get_fields(mono_class, &iter)) != nullptr) { StringName name = mono_field_get_name(raw_field); Map<StringName, GDMonoField *>::Element *match = fields.find(name); @@ -389,7 +389,7 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) { return result->value(); if (properties_fetched) - return NULL; + return nullptr; MonoProperty *raw_property = mono_class_get_property_from_name(mono_class, String(p_name).utf8().get_data()); @@ -400,7 +400,7 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) { return property; } - return NULL; + return nullptr; } const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() { @@ -408,9 +408,9 @@ const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() { if (properties_fetched) return properties_list; - void *iter = NULL; - MonoProperty *raw_property = NULL; - while ((raw_property = mono_class_get_properties(mono_class, &iter)) != NULL) { + void *iter = nullptr; + MonoProperty *raw_property = nullptr; + while ((raw_property = mono_class_get_properties(mono_class, &iter)) != nullptr) { StringName name = mono_property_get_name(raw_property); Map<StringName, GDMonoProperty *>::Element *match = properties.find(name); @@ -433,9 +433,9 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { if (delegates_fetched) return delegates_list; - void *iter = NULL; - MonoClass *raw_class = NULL; - while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != NULL) { + void *iter = nullptr; + MonoClass *raw_class = nullptr; + while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != nullptr) { if (mono_class_is_delegate(raw_class)) { StringName name = mono_class_get_name(raw_class); @@ -459,9 +459,9 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { const Vector<GDMonoMethod *> &GDMonoClass::get_all_methods() { if (!method_list_fetched) { - void *iter = NULL; - MonoMethod *raw_method = NULL; - while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoMethod *raw_method = nullptr; + while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { method_list.push_back(memnew(GDMonoMethod(mono_method_get_name(raw_method), raw_method))); } @@ -479,7 +479,7 @@ GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name assembly = p_assembly; attrs_fetched = false; - attributes = NULL; + attributes = nullptr; methods_fetched = false; method_list_fetched = false; @@ -512,7 +512,7 @@ GDMonoClass::~GDMonoClass() { Vector<GDMonoMethod *> deleted_methods; deleted_methods.resize(methods.size()); - const MethodKey *k = NULL; + const MethodKey *k = nullptr; while ((k = methods.next(k))) { GDMonoMethod *method = methods.get(*k); diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index 11942c47d9..3f4e5fe5ac 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -116,7 +116,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_ case MONO_TYPE_STRING: { if (p_value.get_type() == Variant::NIL) { // Otherwise, Variant -> String would return the string "Null" - MonoString *mono_string = NULL; + MonoString *mono_string = nullptr; mono_field_set_value(p_object, mono_field, mono_string); } else { MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value); @@ -623,19 +623,19 @@ bool GDMonoField::has_attribute(GDMonoClass *p_attr_class) { } MonoObject *GDMonoField::get_attribute(GDMonoClass *p_attr_class) { - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoField::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_field(owner->get_mono_ptr(), mono_field); attrs_fetched = true; } @@ -671,7 +671,7 @@ GDMonoField::GDMonoField(MonoClassField *p_mono_field, GDMonoClass *p_owner) { type.type_class = GDMono::get_singleton()->get_class(field_type_class); attrs_fetched = false; - attributes = NULL; + attributes = nullptr; } GDMonoField::~GDMonoField() { diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 53e642f317..1898785699 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -61,7 +61,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { GDMonoClass *native = GDMonoUtils::get_class_native_base(klass); - CRASH_COND(native == NULL); + CRASH_COND(native == nullptr); if (native == klass) { // If it's just a wrapper Godot class and not a custom inheriting class, then attach a @@ -119,7 +119,7 @@ void unhandled_exception(MonoException *p_exc) { if (GDMono::get_singleton()->get_unhandled_exception_policy() == GDMono::POLICY_TERMINATE_APP) { // Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders - GDMono::unhandled_exception_hook((MonoObject *)p_exc, NULL); + GDMono::unhandled_exception_hook((MonoObject *)p_exc, nullptr); GD_UNREACHABLE(); } else { #ifdef DEBUG_ENABLED diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index 4189934570..ca16c2b76a 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -46,13 +46,13 @@ static CharString get_default_log_level() { #endif } -GDMonoLog *GDMonoLog::singleton = NULL; +GDMonoLog *GDMonoLog::singleton = nullptr; #ifdef GD_MONO_LOG_ENABLED static int get_log_level_id(const char *p_log_level) { - const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", NULL }; + const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", nullptr }; int i = 0; while (valid_log_levels[i]) { @@ -191,7 +191,7 @@ GDMonoLog::GDMonoLog() { GDMonoLog::~GDMonoLog() { - singleton = NULL; + singleton = nullptr; if (log_file) { log_file->close(); @@ -213,7 +213,7 @@ GDMonoLog::GDMonoLog() { GDMonoLog::~GDMonoLog() { - singleton = NULL; + singleton = nullptr; } #endif // !defined(JAVASCRIPT_ENABLED) diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 0de5352752..1878038f44 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -410,7 +410,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty case MONO_TYPE_STRING: { if (p_var->get_type() == Variant::NIL) - return NULL; // Otherwise, Variant -> String would return the string "Null" + return nullptr; // Otherwise, Variant -> String would return the string "Null" return (MonoObject *)mono_string_from_godot(p_var->operator String()); } break; @@ -537,7 +537,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty return BOX_ENUM(enum_baseclass, val); } default: { - ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed enum value of unmarshallable base type."); + ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to a managed enum value of unmarshallable base type."); } } } @@ -577,7 +577,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty if (array_type->eklass == CACHED_CLASS_RAW(Color)) return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray()); - ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed array of unmarshallable element type."); + ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to a managed array of unmarshallable element type."); } break; case MONO_TYPE_CLASS: { @@ -749,7 +749,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty case Variant::PACKED_COLOR_ARRAY: return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray()); default: - return NULL; + return nullptr; } break; case MONO_TYPE_GENERICINST: { @@ -792,8 +792,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty } break; } - ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to an unmarshallable managed type. Name: '" + - p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + "."); + ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to an unmarshallable managed type. Name: '" + + p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + "."); } Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type, bool p_fail_with_err = true) { @@ -831,7 +831,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type return unbox<double>(p_obj); case MONO_TYPE_STRING: { - if (p_obj == NULL) + if (p_obj == nullptr) return Variant(); // NIL return mono_string_to_godot_not_null((MonoString *)p_obj); } break; @@ -935,7 +935,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type // GodotObject if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) { Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj)); - if (ptr != NULL) { + if (ptr != nullptr) { Reference *ref = Object::cast_to<Reference>(ptr); return ref ? Variant(Ref<Reference>(ref)) : Variant(ptr); } @@ -958,14 +958,14 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type } if (CACHED_CLASS(Array) == type_class) { - MonoException *exc = NULL; + MonoException *exc = nullptr; Array *ptr = CACHED_METHOD_THUNK(Array, GetPtr).invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return ptr ? Variant(*ptr) : Variant(); } if (CACHED_CLASS(Dictionary) == type_class) { - MonoException *exc = NULL; + MonoException *exc = nullptr; Dictionary *ptr = CACHED_METHOD_THUNK(Dictionary, GetPtr).invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return ptr ? Variant(*ptr) : Variant(); @@ -996,14 +996,14 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), p_type.type_class->get_mono_type()); if (GDMonoUtils::Marshal::type_is_generic_dictionary(reftype)) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = p_type.type_class->get_method("GetPtr")->invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return *unbox<Dictionary *>(ret); } if (GDMonoUtils::Marshal::type_is_generic_array(reftype)) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = p_type.type_class->get_method("GetPtr")->invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return *unbox<Array *>(ret); @@ -1064,9 +1064,9 @@ String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) { ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj)); Variant var = GDMonoMarshal::mono_object_to_variant_no_err(p_obj, type); - if (var.get_type() == Variant::NIL && p_obj != NULL) { + if (var.get_type() == Variant::NIL && p_obj != nullptr) { // Cannot convert MonoObject* to Variant; fallback to 'ToString()'. - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoString *mono_str = GDMonoUtils::object_to_string(p_obj, &exc); if (exc) { @@ -1393,7 +1393,7 @@ Callable managed_to_callable(const M_Callable &p_managed_callable) { } else { Object *target = p_managed_callable.target ? unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) : - NULL; + nullptr; StringName *method_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name)); StringName method = method_ptr ? *method_ptr : StringName(); return Callable(target, method); @@ -1408,7 +1408,7 @@ M_Callable callable_to_managed(const Callable &p_callable) { if (compare_equal_func == ManagedCallable::compare_equal_func_ptr) { ManagedCallable *managed_callable = static_cast<ManagedCallable *>(custom); return { - NULL, NULL, + nullptr, nullptr, managed_callable->get_delegate() }; } else if (compare_equal_func == SignalAwaiterCallable::compare_equal_func_ptr) { @@ -1416,30 +1416,30 @@ M_Callable callable_to_managed(const Callable &p_callable) { return { GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(signal_awaiter_callable->get_object())), GDMonoUtils::create_managed_from(signal_awaiter_callable->get_signal()), - NULL + nullptr }; } else if (compare_equal_func == EventSignalCallable::compare_equal_func_ptr) { EventSignalCallable *event_signal_callable = static_cast<EventSignalCallable *>(custom); return { GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(event_signal_callable->get_object())), GDMonoUtils::create_managed_from(event_signal_callable->get_signal()), - NULL + nullptr }; } // Some other CallableCustom. We only support ManagedCallable. - return { NULL, NULL, NULL }; + return { nullptr, nullptr, nullptr }; } else { MonoObject *target_managed = GDMonoUtils::unmanaged_get_managed(p_callable.get_object()); MonoObject *method_string_name_managed = GDMonoUtils::create_managed_from(p_callable.get_method()); - return { target_managed, method_string_name_managed, NULL }; + return { target_managed, method_string_name_managed, nullptr }; } } Signal managed_to_signal_info(const M_SignalInfo &p_managed_signal) { Object *owner = p_managed_signal.owner ? unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) : - NULL; + nullptr; StringName *name_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name)); StringName name = name_ptr ? *name_ptr : StringName(); return Signal(owner, name); diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index 7d09f46b00..8b405291a7 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -63,7 +63,7 @@ T *unbox_addr(MonoObject *p_obj) { #define BOX_PTR(x) mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(IntPtr), x) #define BOX_ENUM(m_enum_class, x) mono_value_box(mono_domain_get(), m_enum_class, &x) -Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_variant = NULL); +Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_variant = nullptr); bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_elem_type); bool try_get_dictionary_key_value_types(const ManagedType &p_dictionary_type, ManagedType &r_key_type, ManagedType &r_value_type); @@ -81,7 +81,7 @@ _FORCE_INLINE_ String mono_string_to_godot_not_null(MonoString *p_mono_string) { } _FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) { - if (p_mono_string == NULL) + if (p_mono_string == nullptr) return String(); return mono_string_to_godot_not_null(p_mono_string); diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp index e6a1ec2697..c8cc5247c6 100644 --- a/modules/mono/mono_gd/gd_mono_method.cpp +++ b/modules/mono/mono_gd/gd_mono_method.cpp @@ -58,9 +58,9 @@ void GDMonoMethod::_update_signature(MonoMethodSignature *p_method_sig) { } } - void *iter = NULL; + void *iter = nullptr; MonoType *param_raw_type; - while ((param_raw_type = mono_signature_get_params(p_method_sig, &iter)) != NULL) { + while ((param_raw_type = mono_signature_get_params(p_method_sig, &iter)) != nullptr) { ManagedType param_type; param_type.type_encoding = mono_type_get_type(param_raw_type); @@ -81,11 +81,11 @@ GDMonoClass *GDMonoMethod::get_enclosing_class() const { } bool GDMonoMethod::is_static() { - return mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_STATIC; + return mono_method_get_flags(mono_method, nullptr) & MONO_METHOD_ATTR_STATIC; } IMonoClassMember::Visibility GDMonoMethod::get_visibility() { - switch (mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) { + switch (mono_method_get_flags(mono_method, nullptr) & MONO_METHOD_ATTR_ACCESS_MASK) { case MONO_METHOD_ATTR_PRIVATE: return IMonoClassMember::PRIVATE; case MONO_METHOD_ATTR_FAM_AND_ASSEM: @@ -102,7 +102,7 @@ IMonoClassMember::Visibility GDMonoMethod::get_visibility() { } MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc) const { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret; if (params_count > 0) { @@ -115,11 +115,11 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, ret = GDMonoUtils::runtime_invoke_array(mono_method, p_object, params, &exc); } else { - ret = GDMonoUtils::runtime_invoke(mono_method, p_object, NULL, &exc); + ret = GDMonoUtils::runtime_invoke(mono_method, p_object, nullptr, &exc); } if (exc) { - ret = NULL; + ret = nullptr; if (r_exc) { *r_exc = exc; } else { @@ -131,16 +131,16 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, } MonoObject *GDMonoMethod::invoke(MonoObject *p_object, MonoException **r_exc) const { - ERR_FAIL_COND_V(get_parameters_count() > 0, NULL); - return invoke_raw(p_object, NULL, r_exc); + ERR_FAIL_COND_V(get_parameters_count() > 0, nullptr); + return invoke_raw(p_object, nullptr, r_exc); } MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc) const { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = GDMonoUtils::runtime_invoke(mono_method, p_object, p_params, &exc); if (exc) { - ret = NULL; + ret = nullptr; if (r_exc) { *r_exc = exc; } else { @@ -164,19 +164,19 @@ bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) { } MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) { - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoMethod::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_method(mono_method); attrs_fetched = true; } @@ -281,7 +281,7 @@ GDMonoMethod::GDMonoMethod(StringName p_name, MonoMethod *p_method) { method_info_fetched = false; attrs_fetched = false; - attributes = NULL; + attributes = nullptr; _update_signature(); } diff --git a/modules/mono/mono_gd/gd_mono_method.h b/modules/mono/mono_gd/gd_mono_method.h index d4379f41fe..54b2eba3e8 100644 --- a/modules/mono/mono_gd/gd_mono_method.h +++ b/modules/mono/mono_gd/gd_mono_method.h @@ -76,9 +76,9 @@ public: _FORCE_INLINE_ int get_parameters_count() const { return params_count; } _FORCE_INLINE_ ManagedType get_return_type() const { return return_type; } - MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = NULL) const; - MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = NULL) const; - MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = NULL) const; + MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = nullptr) const; + MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = nullptr) const; + MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr) const; String get_full_name(bool p_signature = false) const; String get_full_name_no_class() const; diff --git a/modules/mono/mono_gd/gd_mono_method_thunk.h b/modules/mono/mono_gd/gd_mono_method_thunk.h index 614ae30947..0e05e974e9 100644 --- a/modules/mono/mono_gd/gd_mono_method_thunk.h +++ b/modules/mono/mono_gd/gd_mono_method_thunk.h @@ -60,16 +60,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method_thunk == NULL; + return mono_method_thunk == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method_thunk = NULL; + mono_method_thunk = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding != MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -82,7 +82,7 @@ public: } GDMonoMethodThunk() : - mono_method_thunk(NULL) { + mono_method_thunk(nullptr) { } explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) { @@ -106,16 +106,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method_thunk == NULL; + return mono_method_thunk == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method_thunk = NULL; + mono_method_thunk = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding == MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -128,12 +128,12 @@ public: } GDMonoMethodThunkR() : - mono_method_thunk(NULL) { + mono_method_thunk(nullptr) { } explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); #endif mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr()); } @@ -146,7 +146,7 @@ struct VariadicInvokeMonoMethodImpl { static void invoke(GDMonoMethod *p_mono_method, P1 p_arg1, ParamTypes... p_args, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[ThunkParamCount] = { p_arg1, p_args... }; - p_mono_method->invoke_raw(NULL, args, r_exc); + p_mono_method->invoke_raw(nullptr, args, r_exc); } else { void *args[ThunkParamCount] = { p_args... }; p_mono_method->invoke_raw((MonoObject *)p_arg1, args, r_exc); @@ -167,7 +167,7 @@ struct VariadicInvokeMonoMethod<0> { #ifdef DEBUG_ENABLED CRASH_COND(!p_mono_method->is_static()); #endif - p_mono_method->invoke_raw(NULL, NULL, r_exc); + p_mono_method->invoke_raw(nullptr, nullptr, r_exc); } }; @@ -176,9 +176,9 @@ struct VariadicInvokeMonoMethod<1, P1> { static void invoke(GDMonoMethod *p_mono_method, P1 p_arg1, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[1] = { p_arg1 }; - p_mono_method->invoke_raw(NULL, args, r_exc); + p_mono_method->invoke_raw(nullptr, args, r_exc); } else { - p_mono_method->invoke_raw((MonoObject *)p_arg1, NULL, r_exc); + p_mono_method->invoke_raw((MonoObject *)p_arg1, nullptr, r_exc); } } }; @@ -203,7 +203,7 @@ struct VariadicInvokeMonoMethodRImpl { static R invoke(GDMonoMethod *p_mono_method, P1 p_arg1, ParamTypes... p_args, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[ThunkParamCount] = { p_arg1, p_args... }; - MonoObject *r = p_mono_method->invoke_raw(NULL, args, r_exc); + MonoObject *r = p_mono_method->invoke_raw(nullptr, args, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } else { void *args[ThunkParamCount] = { p_args... }; @@ -226,7 +226,7 @@ struct VariadicInvokeMonoMethodR<0, R> { #ifdef DEBUG_ENABLED CRASH_COND(!p_mono_method->is_static()); #endif - MonoObject *r = p_mono_method->invoke_raw(NULL, NULL, r_exc); + MonoObject *r = p_mono_method->invoke_raw(nullptr, nullptr, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } }; @@ -236,10 +236,10 @@ struct VariadicInvokeMonoMethodR<1, R, P1> { static R invoke(GDMonoMethod *p_mono_method, P1 p_arg1, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[1] = { p_arg1 }; - MonoObject *r = p_mono_method->invoke_raw(NULL, args, r_exc); + MonoObject *r = p_mono_method->invoke_raw(nullptr, args, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } else { - MonoObject *r = p_mono_method->invoke_raw((MonoObject *)p_arg1, NULL, r_exc); + MonoObject *r = p_mono_method->invoke_raw((MonoObject *)p_arg1, nullptr, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } } @@ -256,16 +256,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method == NULL; + return mono_method == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method = NULL; + mono_method = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding != MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -278,7 +278,7 @@ public: } GDMonoMethodThunk() : - mono_method(NULL) { + mono_method(nullptr) { } explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) { @@ -297,16 +297,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method == NULL; + return mono_method == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method = NULL; + mono_method = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding == MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -319,7 +319,7 @@ public: } GDMonoMethodThunkR() : - mono_method(NULL) { + mono_method(nullptr) { } explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) { diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp index 3b5ce58d80..c3e7598f2d 100644 --- a/modules/mono/mono_gd/gd_mono_property.cpp +++ b/modules/mono/mono_gd/gd_mono_property.cpp @@ -57,7 +57,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own MonoMethodSignature *setter_sig = mono_method_signature(prop_method); - void *iter = NULL; + void *iter = nullptr; MonoType *param_raw_type = mono_signature_get_params(setter_sig, &iter); type.type_encoding = mono_type_get_type(param_raw_type); @@ -66,7 +66,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own } attrs_fetched = false; - attributes = NULL; + attributes = nullptr; } GDMonoProperty::~GDMonoProperty() { @@ -77,17 +77,17 @@ GDMonoProperty::~GDMonoProperty() { bool GDMonoProperty::is_static() { MonoMethod *prop_method = mono_property_get_get_method(mono_property); - if (prop_method == NULL) + if (prop_method == nullptr) prop_method = mono_property_get_set_method(mono_property); - return mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_STATIC; + return mono_method_get_flags(prop_method, nullptr) & MONO_METHOD_ATTR_STATIC; } IMonoClassMember::Visibility GDMonoProperty::get_visibility() { MonoMethod *prop_method = mono_property_get_get_method(mono_property); - if (prop_method == NULL) + if (prop_method == nullptr) prop_method = mono_property_get_set_method(mono_property); - switch (mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) { + switch (mono_method_get_flags(prop_method, nullptr) & MONO_METHOD_ATTR_ACCESS_MASK) { case MONO_METHOD_ATTR_PRIVATE: return IMonoClassMember::PRIVATE; case MONO_METHOD_ATTR_FAM_AND_ASSEM: @@ -116,36 +116,36 @@ bool GDMonoProperty::has_attribute(GDMonoClass *p_attr_class) { } MonoObject *GDMonoProperty::get_attribute(GDMonoClass *p_attr_class) { - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoProperty::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_property(owner->get_mono_ptr(), mono_property); attrs_fetched = true; } bool GDMonoProperty::has_getter() { - return mono_property_get_get_method(mono_property) != NULL; + return mono_property_get_get_method(mono_property) != nullptr; } bool GDMonoProperty::has_setter() { - return mono_property_get_set_method(mono_property) != NULL; + return mono_property_get_set_method(mono_property) != nullptr; } void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc) { MonoMethod *prop_method = mono_property_get_set_method(mono_property); MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), 1); mono_array_setref(params, 0, p_value); - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_invoke_array(prop_method, p_object, params, &exc); if (exc) { if (r_exc) { @@ -157,7 +157,7 @@ void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoEx } void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoException **r_exc) { - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::property_set_value(mono_property, p_object, p_params, &exc); if (exc) { @@ -170,11 +170,11 @@ void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoExcept } MonoObject *GDMonoProperty::get_value(MonoObject *p_object, MonoException **r_exc) { - MonoException *exc = NULL; - MonoObject *ret = GDMonoUtils::property_get_value(mono_property, p_object, NULL, &exc); + MonoException *exc = nullptr; + MonoObject *ret = GDMonoUtils::property_get_value(mono_property, p_object, nullptr, &exc); if (exc) { - ret = NULL; + ret = nullptr; if (r_exc) { *r_exc = exc; } else { diff --git a/modules/mono/mono_gd/gd_mono_property.h b/modules/mono/mono_gd/gd_mono_property.h index 2aec64f565..4653758a86 100644 --- a/modules/mono/mono_gd/gd_mono_property.h +++ b/modules/mono/mono_gd/gd_mono_property.h @@ -65,9 +65,9 @@ public: _FORCE_INLINE_ ManagedType get_type() const { return type; } - void set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc = NULL); - void set_value(MonoObject *p_object, void **p_params, MonoException **r_exc = NULL); - MonoObject *get_value(MonoObject *p_object, MonoException **r_exc = NULL); + void set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc = nullptr); + void set_value(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr); + MonoObject *get_value(MonoObject *p_object, MonoException **r_exc = nullptr); bool get_bool_value(MonoObject *p_object); int get_int_value(MonoObject *p_object); diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 5a2bdffe54..00119ced88 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -57,7 +57,7 @@ namespace GDMonoUtils { MonoObject *unmanaged_get_managed(Object *unmanaged) { if (!unmanaged) - return NULL; + return nullptr; if (unmanaged->get_script_instance()) { CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(unmanaged->get_script_instance()); @@ -71,7 +71,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { void *data = unmanaged->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); - ERR_FAIL_NULL_V(data, NULL); + ERR_FAIL_NULL_V(data, nullptr); CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->value(); @@ -82,7 +82,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { // Already had a binding that needs to be setup CSharpLanguage::get_singleton()->setup_csharp_script_binding(script_binding, unmanaged); - ERR_FAIL_COND_V(!script_binding.inited, NULL); + ERR_FAIL_COND_V(!script_binding.inited, nullptr); } } @@ -99,11 +99,11 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { #ifdef DEBUG_ENABLED CRASH_COND(script_binding.type_name == StringName()); - CRASH_COND(script_binding.wrapper_class == NULL); + CRASH_COND(script_binding.wrapper_class == nullptr); #endif MonoObject *mono_object = GDMonoUtils::create_managed_for_godot_object(script_binding.wrapper_class, script_binding.type_name, unmanaged); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); gchandle = MonoGCHandleData::new_strong_handle(mono_object); @@ -127,7 +127,7 @@ void set_main_thread(MonoThread *p_thread) { } MonoThread *attach_current_thread() { - ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), NULL); + ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), nullptr); MonoDomain *scripts_domain = GDMono::get_singleton()->get_scripts_domain(); #ifndef GD_MONO_SINGLE_APPDOMAIN MonoThread *mono_thread = mono_thread_attach(scripts_domain ? scripts_domain : mono_get_root_domain()); @@ -135,7 +135,7 @@ MonoThread *attach_current_thread() { // The scripts domain is the root domain MonoThread *mono_thread = mono_thread_attach(scripts_domain); #endif - ERR_FAIL_NULL_V(mono_thread, NULL); + ERR_FAIL_NULL_V(mono_thread, nullptr); return mono_thread; } @@ -157,7 +157,7 @@ MonoThread *get_current_thread() { } bool is_thread_attached() { - return mono_domain_get() != NULL; + return mono_domain_get() != nullptr; } uint32_t new_strong_gchandle(MonoObject *p_object) { @@ -179,11 +179,11 @@ void free_gchandle(uint32_t p_gchandle) { void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc) { GDMonoMethod *ctor = p_class->get_method(".ctor", 0); ERR_FAIL_NULL(ctor); - ctor->invoke_raw(p_this_obj, NULL, r_exc); + ctor->invoke_raw(p_this_obj, nullptr, r_exc); } bool mono_delegate_equal(MonoDelegate *p_a, MonoDelegate *p_b) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(Delegate, Equals).invoke((MonoObject *)p_a, (MonoObject *)p_b, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -226,18 +226,18 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class) { if (assembly == GDMono::get_singleton()->get_editor_api_assembly()) return klass; #endif - } while ((klass = klass->get_parent_class()) != NULL); + } while ((klass = klass->get_parent_class()) != nullptr); - return NULL; + return nullptr; } MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object) { bool parent_is_object_class = ClassDB::is_parent_class(p_object->get_class_name(), p_native); - ERR_FAIL_COND_V_MSG(!parent_is_object_class, NULL, + ERR_FAIL_COND_V_MSG(!parent_is_object_class, nullptr, "Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'."); MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, p_object); @@ -249,7 +249,7 @@ MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringNa MonoObject *create_managed_from(const StringName &p_from) { MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(StringName)); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Construct GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(StringName)); @@ -261,7 +261,7 @@ MonoObject *create_managed_from(const StringName &p_from) { MonoObject *create_managed_from(const NodePath &p_from) { MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(NodePath)); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Construct GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(NodePath)); @@ -273,7 +273,7 @@ MonoObject *create_managed_from(const NodePath &p_from) { MonoObject *create_managed_from(const RID &p_from) { MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(RID)); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Construct GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(RID)); @@ -285,15 +285,15 @@ MonoObject *create_managed_from(const RID &p_from) { MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) { MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Search constructor that takes a pointer as parameter MonoMethod *m; - void *iter = NULL; + void *iter = nullptr; while ((m = mono_class_get_methods(p_class->get_mono_ptr(), &iter))) { if (strcmp(mono_method_get_name(m), ".ctor") == 0) { MonoMethodSignature *sig = mono_method_signature(m); - void *front = NULL; + void *front = nullptr; if (mono_signature_get_param_count(sig) == 1 && mono_class_from_mono_type(mono_signature_get_params(sig, &front)) == CACHED_CLASS(IntPtr)->get_mono_ptr()) { break; @@ -301,12 +301,12 @@ MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) { } } - CRASH_COND(m == NULL); + CRASH_COND(m == nullptr); Array *new_array = memnew(Array(p_from)); void *args[1] = { &new_array }; - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_invoke(m, mono_object, args, &exc); UNHANDLED_EXCEPTION(exc); @@ -315,15 +315,15 @@ MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) { MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) { MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Search constructor that takes a pointer as parameter MonoMethod *m; - void *iter = NULL; + void *iter = nullptr; while ((m = mono_class_get_methods(p_class->get_mono_ptr(), &iter))) { if (strcmp(mono_method_get_name(m), ".ctor") == 0) { MonoMethodSignature *sig = mono_method_signature(m); - void *front = NULL; + void *front = nullptr; if (mono_signature_get_param_count(sig) == 1 && mono_class_from_mono_type(mono_signature_get_params(sig, &front)) == CACHED_CLASS(IntPtr)->get_mono_ptr()) { break; @@ -331,12 +331,12 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) } } - CRASH_COND(m == NULL); + CRASH_COND(m == nullptr); Dictionary *new_dict = memnew(Dictionary(p_from)); void *args[1] = { &new_dict }; - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_invoke(m, mono_object, args, &exc); UNHANDLED_EXCEPTION(exc); @@ -346,7 +346,7 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) MonoDomain *create_domain(const String &p_friendly_name) { print_verbose("Mono: Creating domain '" + p_friendly_name + "'..."); - MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), NULL); + MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), nullptr); if (domain) { // Workaround to avoid this exception: @@ -371,7 +371,7 @@ String get_exception_name_and_message(MonoException *p_exc) { res += ": "; MonoProperty *prop = mono_class_get_property_from_name(klass, "Message"); - MonoString *msg = (MonoString *)property_get_value(prop, (MonoObject *)p_exc, NULL, NULL); + MonoString *msg = (MonoString *)property_get_value(prop, (MonoObject *)p_exc, nullptr, nullptr); res += GDMonoMarshal::mono_string_to_godot(msg); return res; @@ -382,7 +382,7 @@ void set_exception_message(MonoException *p_exc, String message) { MonoProperty *prop = mono_class_get_property_from_name(klass, "Message"); MonoString *msg = GDMonoMarshal::mono_string_from_godot(message); void *params[1] = { msg }; - property_set_value(prop, (MonoObject *)p_exc, params, NULL); + property_set_value(prop, (MonoObject *)p_exc, params, nullptr); } void debug_print_unhandled_exception(MonoException *p_exc) { @@ -415,14 +415,14 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { Vector<ScriptLanguage::StackInfo> si; String exc_msg; - while (p_exc != NULL) { + while (p_exc != nullptr) { GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace); MonoObject *stack_trace = mono_object_new(mono_domain_get(), st_klass->get_mono_ptr()); MonoBoolean need_file_info = true; void *ctor_args[2] = { p_exc, &need_file_info }; - MonoException *unexpected_exc = NULL; + MonoException *unexpected_exc = nullptr; CACHED_METHOD(System_Diagnostics_StackTrace, ctor_Exception_bool)->invoke_raw(stack_trace, ctor_args, &unexpected_exc); if (unexpected_exc) { @@ -431,7 +431,7 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { } Vector<ScriptLanguage::StackInfo> _si; - if (stack_trace != NULL) { + if (stack_trace != nullptr) { _si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace); for (int i = _si.size() - 1; i >= 0; i--) si.insert(0, _si[i]); @@ -441,10 +441,10 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { GDMonoClass *exc_class = GDMono::get_singleton()->get_class(mono_get_exception_class()); GDMonoProperty *inner_exc_prop = exc_class->get_property("InnerException"); - CRASH_COND(inner_exc_prop == NULL); + CRASH_COND(inner_exc_prop == nullptr); MonoObject *inner_exc = inner_exc_prop->get_value((MonoObject *)p_exc); - if (inner_exc != NULL) + if (inner_exc != nullptr) si.insert(0, separator); p_exc = (MonoException *)inner_exc; @@ -570,7 +570,7 @@ namespace Marshal { bool type_is_generic_array(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericArray).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -578,27 +578,27 @@ bool type_is_generic_array(MonoReflectionType *p_reftype) { bool type_is_generic_dictionary(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericDictionary).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; } void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype) { - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, ArrayGetElementType).invoke(p_array_reftype, r_elem_reftype, &exc); UNHANDLED_EXCEPTION(exc); } void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) { - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, DictionaryGetKeyValueTypes).invoke(p_dict_reftype, r_key_reftype, r_value_reftype, &exc); UNHANDLED_EXCEPTION(exc); } bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIEnumerableIsAssignableFromType).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -606,7 +606,7 @@ bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype) { bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryIsAssignableFromType).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -614,7 +614,7 @@ bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype) { bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_elem_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIEnumerableIsAssignableFromType_with_info).invoke(p_reftype, r_elem_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -622,7 +622,7 @@ bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype, MonoR bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryIsAssignableFromType_with_info).invoke(p_reftype, r_key_reftype, r_value_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -631,7 +631,7 @@ bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype, MonoR Array enumerable_to_array(MonoObject *p_enumerable) { NO_GLUE_RET(Array()); Array result; - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, EnumerableToArray).invoke(p_enumerable, &result, &exc); UNHANDLED_EXCEPTION(exc); return result; @@ -640,7 +640,7 @@ Array enumerable_to_array(MonoObject *p_enumerable) { Dictionary idictionary_to_dictionary(MonoObject *p_idictionary) { NO_GLUE_RET(Dictionary()); Dictionary result; - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, IDictionaryToDictionary).invoke(p_idictionary, &result, &exc); UNHANDLED_EXCEPTION(exc); return result; @@ -649,23 +649,23 @@ Dictionary idictionary_to_dictionary(MonoObject *p_idictionary) { Dictionary generic_idictionary_to_dictionary(MonoObject *p_generic_idictionary) { NO_GLUE_RET(Dictionary()); Dictionary result; - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryToDictionary).invoke(p_generic_idictionary, &result, &exc); UNHANDLED_EXCEPTION(exc); return result; } GDMonoClass *make_generic_array_type(MonoReflectionType *p_elem_reftype) { - NO_GLUE_RET(NULL); - MonoException *exc = NULL; + NO_GLUE_RET(nullptr); + MonoException *exc = nullptr; MonoReflectionType *reftype = CACHED_METHOD_THUNK(MarshalUtils, MakeGenericArrayType).invoke(p_elem_reftype, &exc); UNHANDLED_EXCEPTION(exc); return GDMono::get_singleton()->get_class(mono_class_from_mono_type(mono_reflection_type_get_type(reftype))); } GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype) { - NO_GLUE_RET(NULL); - MonoException *exc = NULL; + NO_GLUE_RET(nullptr); + MonoException *exc = nullptr; MonoReflectionType *reftype = CACHED_METHOD_THUNK(MarshalUtils, MakeGenericDictionaryType).invoke(p_key_reftype, p_value_reftype, &exc); UNHANDLED_EXCEPTION(exc); return GDMono::get_singleton()->get_class(mono_class_from_mono_type(mono_reflection_type_get_type(reftype))); @@ -674,7 +674,7 @@ GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, Mon } // namespace Marshal ScopeThreadAttach::ScopeThreadAttach() : - mono_thread(NULL) { + mono_thread(nullptr) { if (likely(GDMono::get_singleton()->is_runtime_initialized()) && unlikely(!mono_domain_get())) { mono_thread = GDMonoUtils::attach_current_thread(); } @@ -687,7 +687,7 @@ ScopeThreadAttach::~ScopeThreadAttach() { } StringName get_native_godot_class_name(GDMonoClass *p_class) { - MonoObject *native_name_obj = p_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL); + MonoObject *native_name_obj = p_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(nullptr); StringName *ptr = GDMonoMarshal::unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(native_name_obj)); return ptr ? *ptr : StringName(); } diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index fd02907d87..b850e1be9b 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -41,7 +41,7 @@ #include "core/reference.h" #define UNHANDLED_EXCEPTION(m_exc) \ - if (unlikely(m_exc != NULL)) { \ + if (unlikely(m_exc != nullptr)) { \ GDMonoUtils::debug_unhandled_exception(m_exc); \ GD_UNREACHABLE(); \ } @@ -77,7 +77,7 @@ _FORCE_INLINE_ void hash_combine(uint32_t &p_hash, const uint32_t &p_with_hash) /** * If the object has a csharp script, returns the target of the gchandle stored in the script instance * Otherwise returns a newly constructed MonoObject* which is attached to the object - * Returns NULL on error + * Returns nullptr on error */ MonoObject *unmanaged_get_managed(Object *unmanaged); @@ -89,7 +89,7 @@ MonoThread *get_current_thread(); bool is_thread_attached(); _FORCE_INLINE_ bool is_main_thread() { - return mono_domain_get() != NULL && mono_thread_get_main() == mono_thread_current(); + return mono_domain_get() != nullptr && mono_thread_get_main() == mono_thread_current(); } uint32_t new_strong_gchandle(MonoObject *p_object); @@ -97,7 +97,7 @@ uint32_t new_strong_gchandle_pinned(MonoObject *p_object); uint32_t new_weak_gchandle(MonoObject *p_object); void free_gchandle(uint32_t p_gchandle); -void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc = NULL); +void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc = nullptr); bool mono_delegate_equal(MonoDelegate *p_a, MonoDelegate *p_b); diff --git a/modules/mono/mono_gd/managed_type.h b/modules/mono/mono_gd/managed_type.h index 11b832d0cc..84d1837853 100644 --- a/modules/mono/mono_gd/managed_type.h +++ b/modules/mono/mono_gd/managed_type.h @@ -46,7 +46,7 @@ struct ManagedType { ManagedType() : type_encoding(0), - type_class(NULL) { + type_class(nullptr) { } ManagedType(int p_type_encoding, GDMonoClass *p_type_class) : diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp index 222b50730d..8bcdeec9dd 100755 --- a/modules/mono/mono_gd/support/android_support.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -69,7 +69,7 @@ struct ScopedLocalRef { _FORCE_INLINE_ operator T() const { return local_ref; } _FORCE_INLINE_ operator jvalue() const { return (jvalue)local_ref; } - _FORCE_INLINE_ operator bool() const { return local_ref != NULL; } + _FORCE_INLINE_ operator bool() const { return local_ref != nullptr; } _FORCE_INLINE_ bool operator==(std::nullptr_t) const { return local_ref == nullptr; @@ -124,7 +124,7 @@ String determine_app_native_lib_dir() { String result; - const char *const nativeLibraryDirUtf8 = env->GetStringUTFChars(nativeLibraryDir, NULL); + const char *const nativeLibraryDirUtf8 = env->GetStringUTFChars(nativeLibraryDir, nullptr); if (nativeLibraryDirUtf8) { result.parse_utf8(nativeLibraryDirUtf8); env->ReleaseStringUTFChars(nativeLibraryDir, nativeLibraryDirUtf8); @@ -159,14 +159,14 @@ int gd_mono_convert_dl_flags(int flags) { const char *mono_so_name = GD_MONO_SO_NAME; const char *godot_so_name = "libgodot_android.so"; -void *mono_dl_handle = NULL; -void *godot_dl_handle = NULL; +void *mono_dl_handle = nullptr; +void *godot_dl_handle = nullptr; void *try_dlopen(const String &p_so_path, int p_flags) { if (!FileAccess::exists(p_so_path)) { if (OS::get_singleton()->is_stdout_verbose()) OS::get_singleton()->print("Cannot find shared library: '%s'\n", p_so_path.utf8().get_data()); - return NULL; + return nullptr; } int lflags = gd_mono_convert_dl_flags(p_flags); @@ -176,7 +176,7 @@ void *try_dlopen(const String &p_so_path, int p_flags) { if (!handle) { if (OS::get_singleton()->is_stdout_verbose()) OS::get_singleton()->print("Failed to open shared library: '%s'. Error: '%s'\n", p_so_path.utf8().get_data(), dlerror()); - return NULL; + return nullptr; } if (OS::get_singleton()->is_stdout_verbose()) @@ -186,7 +186,7 @@ void *try_dlopen(const String &p_so_path, int p_flags) { } void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void *p_user_data) { - if (p_name == NULL) { + if (p_name == nullptr) { // __Internal if (!mono_dl_handle) { @@ -211,7 +211,7 @@ void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void return try_dlopen(so_path, p_flags); } - return NULL; + return nullptr; } void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, void *p_user_data) { @@ -232,7 +232,7 @@ void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, vo if (r_err) *r_err = str_format_new("%s\n", dlerror()); - return NULL; + return nullptr; } void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) { @@ -240,9 +240,9 @@ void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) { // Not sure if this ever happens. Does Mono close the handle for the main module? if (p_handle == mono_dl_handle) - mono_dl_handle = NULL; + mono_dl_handle = nullptr; - return NULL; + return nullptr; } int32_t build_version_sdk_int = 0; @@ -267,7 +267,7 @@ int32_t get_build_version_sdk_int() { return build_version_sdk_int; } -jobject certStore = NULL; // KeyStore +jobject certStore = nullptr; // KeyStore MonoBoolean _gd_mono_init_cert_store() { // The JNI code is the equivalent of: @@ -295,7 +295,7 @@ MonoBoolean _gd_mono_init_cert_store() { if (jni_exception_check(env)) return 0; - env->CallVoidMethod(certStoreLocal, load, NULL); + env->CallVoidMethod(certStoreLocal, load, nullptr); if (jni_exception_check(env)) return 0; @@ -319,7 +319,7 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { if (!mono_error_ok(&mono_error)) { ERR_PRINT(String() + "Failed to convert MonoString* to UTF-8: '" + mono_error_get_message(&mono_error) + "'."); mono_error_cleanup(&mono_error); - return NULL; + return nullptr; } JNIEnv *env = ThreadAndroid::get_env(); @@ -328,20 +328,20 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { mono_free(alias_utf8); ScopedLocalRef<jclass> keyStoreClass(env, env->FindClass("java/security/KeyStore")); - ERR_FAIL_NULL_V(keyStoreClass, NULL); + ERR_FAIL_NULL_V(keyStoreClass, nullptr); ScopedLocalRef<jclass> certificateClass(env, env->FindClass("java/security/cert/Certificate")); - ERR_FAIL_NULL_V(certificateClass, NULL); + ERR_FAIL_NULL_V(certificateClass, nullptr); jmethodID getCertificate = env->GetMethodID(keyStoreClass, "getCertificate", "(Ljava/lang/String;)Ljava/security/cert/Certificate;"); - ERR_FAIL_NULL_V(getCertificate, NULL); + ERR_FAIL_NULL_V(getCertificate, nullptr); jmethodID getEncoded = env->GetMethodID(certificateClass, "getEncoded", "()[B"); - ERR_FAIL_NULL_V(getEncoded, NULL); + ERR_FAIL_NULL_V(getEncoded, nullptr); ScopedLocalRef<jobject> certificate(env, env->CallObjectMethod(certStore, getCertificate, js_alias.get())); if (!certificate) - return NULL; + return nullptr; ScopedLocalRef<jbyteArray> encoded(env, (jbyteArray)env->CallObjectMethod(certificate, getEncoded)); jsize encodedLength = env->GetArrayLength(encoded); @@ -363,7 +363,7 @@ void initialize() { // We need to set this environment variable to make the monodroid BCL use btls instead of legacy as the default provider OS::get_singleton()->set_environment("XA_TLS_PROVIDER", "btls"); - mono_dl_fallback_register(gd_mono_android_dlopen, gd_mono_android_dlsym, gd_mono_android_dlclose, NULL); + mono_dl_fallback_register(gd_mono_android_dlopen, gd_mono_android_dlsym, gd_mono_android_dlclose, nullptr); String app_native_lib_dir = get_app_native_lib_dir(); String so_path = path::join(app_native_lib_dir, godot_so_name); @@ -375,16 +375,16 @@ void cleanup() { // This is called after shutting down the Mono runtime if (mono_dl_handle) - gd_mono_android_dlclose(mono_dl_handle, NULL); + gd_mono_android_dlclose(mono_dl_handle, nullptr); if (godot_dl_handle) - gd_mono_android_dlclose(godot_dl_handle, NULL); + gd_mono_android_dlclose(godot_dl_handle, nullptr); JNIEnv *env = ThreadAndroid::get_env(); if (certStore) { env->DeleteGlobalRef(certStore); - certStore = NULL; + certStore = nullptr; } } @@ -421,7 +421,7 @@ GD_PINVOKE_EXPORT int32_t monodroid_get_system_property(const char *p_name, char memcpy(*r_value, prop_value_str, len); (*r_value)[len] = '\0'; } else { - *r_value = NULL; + *r_value = nullptr; } } @@ -608,7 +608,7 @@ GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array) if (!r_dns_servers_array) return -1; - *r_dns_servers_array = NULL; + *r_dns_servers_array = nullptr; char *dns_servers[dns_servers_len]; int dns_servers_count = 0; @@ -652,23 +652,23 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() { JNIEnv *env = ThreadAndroid::get_env(); ScopedLocalRef<jclass> timeZoneClass(env, env->FindClass("java/util/TimeZone")); - ERR_FAIL_NULL_V(timeZoneClass, NULL); + ERR_FAIL_NULL_V(timeZoneClass, nullptr); jmethodID getDefault = env->GetStaticMethodID(timeZoneClass, "getDefault", "()Ljava/util/TimeZone;"); - ERR_FAIL_NULL_V(getDefault, NULL); + ERR_FAIL_NULL_V(getDefault, nullptr); jmethodID getID = env->GetMethodID(timeZoneClass, "getID", "()Ljava/lang/String;"); - ERR_FAIL_NULL_V(getID, NULL); + ERR_FAIL_NULL_V(getID, nullptr); ScopedLocalRef<jobject> defaultTimeZone(env, env->CallStaticObjectMethod(timeZoneClass, getDefault)); if (!defaultTimeZone) - return NULL; + return nullptr; ScopedLocalRef<jstring> defaultTimeZoneID(env, (jstring)env->CallObjectMethod(defaultTimeZone, getID)); if (!defaultTimeZoneID) - return NULL; + return nullptr; const char *default_time_zone_id = env->GetStringUTFChars(defaultTimeZoneID, 0); |