diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-04-02 14:52:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 14:52:36 +0200 |
commit | 058a0afdeca83145d58a95c426dd01216c397ea9 (patch) | |
tree | be0cd59e5a90926e9d653fed9f3b1b77e735ca2f /modules/mono | |
parent | 5f11e1557156617366d2c316a97716172103980d (diff) | |
parent | 95a1400a2ac9de1a29fa305f45b928ce8e3044bd (diff) |
Merge pull request #37338 from lupoDharkael/nullprt
Replace NULL with nullptr
Diffstat (limited to 'modules/mono')
40 files changed, 566 insertions, 566 deletions
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index b04e53bd81..384685d04b 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -42,7 +42,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> names; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = ClassDB::classes.next(k))) { @@ -67,7 +67,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->method_map.next(k))) { @@ -132,7 +132,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->constant_map.next(k))) { @@ -160,7 +160,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->signal_map.next(k))) { @@ -196,7 +196,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->property_setget.next(k))) { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index a007491142..0b5d3c8dbc 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -158,7 +158,7 @@ void CSharpLanguage::finish() { if (gdmono) { memdelete(gdmono); - gdmono = NULL; + gdmono = nullptr; } // Clear here, after finalizing all domains to make sure there is nothing else referencing the elements. @@ -614,7 +614,7 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::stack_trace_get_info(MonoObjec GD_MONO_SCOPE_THREAD_ATTACH; - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoArray *frames = CACHED_METHOD_THUNK(System_Diagnostics_StackTrace, GetFrames).invoke(p_stack_trace, &exc); @@ -679,14 +679,14 @@ void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) { void CSharpLanguage::frame() { - if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != NULL) { + if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != nullptr) { const Ref<MonoGCHandleRef> &task_scheduler_handle = GDMonoCache::cached_data.task_scheduler_handle; if (task_scheduler_handle.is_valid()) { MonoObject *task_scheduler = task_scheduler_handle->get_target(); if (task_scheduler) { - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(GodotTaskScheduler, Activate).invoke(task_scheduler, &exc); if (exc) { @@ -813,7 +813,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { Array serialized_data; MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TrySerializeDelegate).invoke(delegate, managed_serialized_data, &exc); if (exc) { @@ -946,7 +946,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // Restore Variant properties state, it will be kept by the placeholder until the next script reloading for (List<Pair<StringName, Variant>>::Element *G = scr->pending_reload_state[obj_id].properties.front(); G; G = G->next()) { - placeholder->property_set_fallback(G->get().first, G->get().second, NULL); + placeholder->property_set_fallback(G->get().first, G->get().second, nullptr); } scr->pending_reload_state.erase(obj_id); @@ -980,12 +980,12 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { GDMonoAssembly *project_assembly = gdmono->get_project_assembly(); // Search in project and tools assemblies first as those are the most likely to have the class - GDMonoClass *script_class = (project_assembly ? project_assembly->get_class(class_namespace, class_name) : NULL); + GDMonoClass *script_class = (project_assembly ? project_assembly->get_class(class_namespace, class_name) : nullptr); #ifdef TOOLS_ENABLED if (!script_class) { GDMonoAssembly *tools_assembly = gdmono->get_tools_assembly(); - script_class = (tools_assembly ? tools_assembly->get_class(class_namespace, class_name) : NULL); + script_class = (tools_assembly ? tools_assembly->get_class(class_namespace, class_name) : nullptr); } #endif @@ -1056,7 +1056,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { continue; } #else - CRASH_COND(si != NULL); + CRASH_COND(si != nullptr); #endif // Re-create script instance obj->set_script(script); // will create the script instance as well @@ -1105,9 +1105,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { const CSharpScript::EventSignal &event_signal = match->value(); MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoDelegate *delegate = NULL; + MonoDelegate *delegate = nullptr; - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TryDeserializeDelegate).invoke(managed_serialized_data, &delegate, &exc); if (exc) { @@ -1116,7 +1116,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } if (success) { - ERR_CONTINUE(delegate == NULL); + ERR_CONTINUE(delegate == nullptr); event_signal.field->set_value(csi->get_mono_object(), (MonoObject *)delegate); } else if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Failed to deserialize event signal delegate\n"); @@ -1141,9 +1141,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { const Array &serialized_data = elem->value(); MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoDelegate *delegate = NULL; + MonoDelegate *delegate = nullptr; - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TryDeserializeDelegate).invoke(managed_serialized_data, &delegate, &exc); if (exc) { @@ -1152,7 +1152,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } if (success) { - ERR_CONTINUE(delegate == NULL); + ERR_CONTINUE(delegate == nullptr); managed_callable->set_delegate(delegate); } else if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Failed to deserialize delegate\n"); @@ -1292,7 +1292,7 @@ void CSharpLanguage::_on_scripts_domain_unloaded() { for (SelfList<ManagedCallable> *elem = ManagedCallable::instances.first(); elem; elem = elem->next()) { ManagedCallable *managed_callable = elem->self(); managed_callable->delegate_handle.release(); - managed_callable->delegate_invoke = NULL; + managed_callable->delegate_invoke = nullptr; } } @@ -1307,17 +1307,17 @@ void CSharpLanguage::_editor_init_callback() { // Initialize GodotSharpEditor GDMonoClass *editor_klass = GDMono::get_singleton()->get_tools_assembly()->get_class("GodotTools", "GodotSharpEditor"); - CRASH_COND(editor_klass == NULL); + CRASH_COND(editor_klass == nullptr); MonoObject *mono_object = mono_object_new(mono_domain_get(), editor_klass->get_mono_ptr()); - CRASH_COND(mono_object == NULL); + CRASH_COND(mono_object == nullptr); - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_object_init(mono_object, editor_klass, &exc); UNHANDLED_EXCEPTION(exc); EditorPlugin *godotsharp_editor = Object::cast_to<EditorPlugin>(GDMonoMarshal::mono_object_to_variant(mono_object)); - CRASH_COND(godotsharp_editor == NULL); + CRASH_COND(godotsharp_editor == nullptr); // Enable it as a plugin EditorNode::add_editor_plugin(godotsharp_editor); @@ -1354,7 +1354,7 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, MonoGCH // already released and could have been replaced) or if we can't get its target MonoObject* // (which doesn't necessarily mean it was released, and we want it released in order to // avoid locking other threads unnecessarily). - if (target == p_expected_obj || target == NULL) { + if (target == p_expected_obj || target == nullptr) { p_gchandle.release(); } } @@ -1380,7 +1380,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b // I don't trust you if (p_object->get_script_instance()) { CSharpInstance *csharp_instance = CAST_CSHARP_INSTANCE(p_object->get_script_instance()); - CRASH_COND(csharp_instance != NULL && !csharp_instance->is_destructing_script_instance()); + CRASH_COND(csharp_instance != nullptr && !csharp_instance->is_destructing_script_instance()); } #endif @@ -1434,7 +1434,7 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) { CSharpScriptBinding script_binding; if (!setup_csharp_script_binding(script_binding, p_object)) - return NULL; + return nullptr; return (void *)insert_script_binding(p_object, script_binding); } @@ -1446,7 +1446,7 @@ Map<Object *, CSharpScriptBinding>::Element *CSharpLanguage::insert_script_bindi void CSharpLanguage::free_instance_binding_data(void *p_data) { - if (GDMono::get_singleton() == NULL) { + if (GDMono::get_singleton() == nullptr) { #ifdef DEBUG_ENABLED CRASH_COND(!script_bindings.empty()); #endif @@ -1471,7 +1471,7 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) { // This is done to avoid trying to dispose the native instance from Dispose(bool). MonoObject *mono_object = script_binding.gchandle.get_target(); if (mono_object) { - CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, NULL); + CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, nullptr); } script_binding.gchandle.release(); } @@ -1563,7 +1563,7 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS Reference *ref = Object::cast_to<Reference>(p_owner); - instance->base_ref = ref != NULL; + instance->base_ref = ref != nullptr; instance->owner = p_owner; instance->gchandle = p_gchandle; @@ -1577,7 +1577,7 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS MonoObject *CSharpInstance::get_mono_object() const { - ERR_FAIL_COND_V(gchandle.is_released(), NULL); + ERR_FAIL_COND_V(gchandle.is_released(), nullptr); return gchandle.get_target(); } @@ -1662,7 +1662,7 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const { GDMonoProperty *property = top->get_property(p_name); if (property) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *value = property->get_value(mono_object, &exc); if (exc) { r_ret = Variant(); @@ -1743,7 +1743,7 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, Array serialized_data; MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TrySerializeDelegate).invoke(delegate_field_value, managed_serialized_data, &exc); if (exc) { @@ -1910,7 +1910,7 @@ bool CSharpInstance::_reference_owner_unsafe() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); CRASH_COND(unsafe_referenced); // already referenced #endif @@ -1932,7 +1932,7 @@ bool CSharpInstance::_unreference_owner_unsafe() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); #endif if (!unsafe_referenced) @@ -1953,13 +1953,13 @@ bool CSharpInstance::_unreference_owner_unsafe() { MonoObject *CSharpInstance::_internal_new_managed() { // Search the constructor first, to fail with an error if it's not found before allocating anything else. GDMonoMethod *ctor = script->script_class->get_method(CACHED_STRING_NAME(dotctor), 0); - ERR_FAIL_NULL_V_MSG(ctor, NULL, + ERR_FAIL_NULL_V_MSG(ctor, nullptr, "Cannot create script instance because the class does not define a parameterless constructor: '" + script->get_path() + "'."); CSharpLanguage::get_singleton()->release_script_gchandle(gchandle); - ERR_FAIL_NULL_V(owner, NULL); - ERR_FAIL_COND_V(script.is_null(), NULL); + ERR_FAIL_NULL_V(owner, nullptr); + ERR_FAIL_COND_V(script.is_null(), nullptr); MonoObject *mono_object = mono_object_new(mono_domain_get(), script->script_class->get_mono_ptr()); @@ -1971,9 +1971,9 @@ MonoObject *CSharpInstance::_internal_new_managed() { // Not ok for the owner to die here. If there is a situation where this can happen, it will be considered a bug. CRASH_COND(die == true); - owner = NULL; + owner = nullptr; - ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object."); + ERR_FAIL_V_MSG(nullptr, "Failed to allocate memory for the object."); } // Tie managed to unmanaged @@ -1985,7 +1985,7 @@ MonoObject *CSharpInstance::_internal_new_managed() { CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, owner); // Construct - ctor->invoke_raw(mono_object, NULL); + ctor->invoke_raw(mono_object, nullptr); return mono_object; } @@ -2066,7 +2066,7 @@ void CSharpInstance::refcount_incremented() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); #endif Reference *ref_owner = Object::cast_to<Reference>(owner); @@ -2089,7 +2089,7 @@ bool CSharpInstance::refcount_decremented() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); #endif Reference *ref_owner = Object::cast_to<Reference>(owner); @@ -2181,7 +2181,7 @@ void CSharpInstance::notification(int p_notification) { MonoObject *mono_object = get_mono_object(); ERR_FAIL_NULL(mono_object); - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(mono_object, &exc); if (exc) { @@ -2226,13 +2226,13 @@ String CSharpInstance::to_string(bool *r_valid) { MonoObject *mono_object = get_mono_object(); - if (mono_object == NULL) { + if (mono_object == nullptr) { if (r_valid) *r_valid = false; return String(); } - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoString *result = GDMonoUtils::object_to_string(mono_object, &exc); if (exc) { @@ -2242,7 +2242,7 @@ String CSharpInstance::to_string(bool *r_valid) { return String(); } - if (result == NULL) { + if (result == nullptr) { if (r_valid) *r_valid = false; return String(); @@ -2276,13 +2276,13 @@ CSharpInstance::~CSharpInstance() { // This destructor is not called from the owners destructor. // This could be being called from the owner's set_script_instance method, // meaning this script is being replaced with another one. If this is the case, - // we must call Dispose here, because Dispose calls owner->set_script_instance(NULL) + // we must call Dispose here, because Dispose calls owner->set_script_instance(nullptr) // and that would mess up with the new script instance if called later. MonoObject *mono_object = gchandle.get_target(); if (mono_object) { - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(mono_object, &exc); if (exc) { @@ -2312,7 +2312,7 @@ CSharpInstance::~CSharpInstance() { CRASH_COND(die == true); // `owner_keep_alive` holds a reference, so it can't die void *data = owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); - CRASH_COND(data == NULL); + CRASH_COND(data == nullptr); CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get(); @@ -2455,11 +2455,11 @@ bool CSharpScript::_update_exports() { GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), 0); - ERR_FAIL_NULL_V_MSG(ctor, NULL, + ERR_FAIL_NULL_V_MSG(ctor, false, "Cannot construct temporary MonoObject because the class does not define a parameterless constructor: '" + get_path() + "'."); - MonoException *ctor_exc = NULL; - ctor->invoke(tmp_object, NULL, &ctor_exc); + MonoException *ctor_exc = nullptr; + ctor->invoke(tmp_object, nullptr, &ctor_exc); Object *tmp_native = GDMonoMarshal::unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(tmp_object)); @@ -2467,7 +2467,7 @@ bool CSharpScript::_update_exports() { // TODO: Should we free 'tmp_native' if the exception was thrown after its creation? GDMonoUtils::free_gchandle(tmp_pinned_gchandle); - tmp_object = NULL; + tmp_object = nullptr; ERR_PRINT("Exception thrown from constructor of temporary MonoObject:"); GDMonoUtils::debug_print_unhandled_exception(ctor_exc); @@ -2514,7 +2514,7 @@ bool CSharpScript::_update_exports() { exported_members_cache.push_front(prop_info); if (tmp_object) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = property->get_value(tmp_object, &exc); if (exc) { exported_members_defval_cache[member_name] = Variant(); @@ -2533,11 +2533,11 @@ bool CSharpScript::_update_exports() { } // Need to check this here, before disposal - bool base_ref = Object::cast_to<Reference>(tmp_native) != NULL; + bool base_ref = Object::cast_to<Reference>(tmp_native) != nullptr; // Dispose the temporary managed instance - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(tmp_object, &exc); if (exc) { @@ -2546,7 +2546,7 @@ bool CSharpScript::_update_exports() { } GDMonoUtils::free_gchandle(tmp_pinned_gchandle); - tmp_object = NULL; + tmp_object = nullptr; if (tmp_native && !base_ref) { Node *node = Object::cast_to<Node>(tmp_native); @@ -2609,9 +2609,9 @@ void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_nati List<StringName> found_event_signals; - void *iter = NULL; - MonoEvent *raw_event = NULL; - while ((raw_event = mono_class_get_events(top->get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoEvent *raw_event = nullptr; + while ((raw_event = mono_class_get_events(top->get_mono_ptr(), &iter)) != nullptr) { MonoCustomAttrInfo *event_attrs = mono_custom_attrs_from_event(top->get_mono_ptr(), raw_event); if (event_attrs) { if (mono_custom_attrs_has_attr(event_attrs, CACHED_CLASS(SignalAttribute)->get_mono_ptr())) { @@ -2811,7 +2811,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage // Instead of using mono_field_get_value_object, we can do this without boxing. Check the // internal mono functions: ves_icall_System_Enum_GetEnumValuesAndNames and the get_enum_field. - MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, NULL); + MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, nullptr); ERR_FAIL_NULL_V_MSG(val_obj, -1, "Failed to get '" + enum_field_name + "' constant enum value."); @@ -2835,7 +2835,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage } } else if (p_variant_type == Variant::OBJECT && CACHED_CLASS(GodotResource)->is_assignable_from(p_type.type_class)) { GDMonoClass *field_native_class = GDMonoUtils::get_class_native_base(p_type.type_class); - CRASH_COND(field_native_class == NULL); + CRASH_COND(field_native_class == nullptr); r_hint = PROPERTY_HINT_RESOURCE_TYPE; r_hint_string = String(NATIVE_GDMONOCLASS_NAME(field_native_class)); @@ -2877,14 +2877,14 @@ void CSharpScript::_clear() { tool = false; valid = false; - base = NULL; - native = NULL; - script_class = NULL; + base = nullptr; + native = nullptr; + script_class = nullptr; } Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (unlikely(GDMono::get_singleton() == NULL)) { + if (unlikely(GDMono::get_singleton() == nullptr)) { // Probably not the best error but eh. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; return Variant(); @@ -2898,7 +2898,7 @@ Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, i GDMonoMethod *method = top->get_method(p_method, p_argcount); if (method && method->is_static()) { - MonoObject *result = method->invoke(NULL, p_args); + MonoObject *result = method->invoke(nullptr, p_args); if (result) { return GDMonoMarshal::mono_object_to_variant(result); @@ -2960,7 +2960,7 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class, GD // This method should not fail, only assertions allowed - CRASH_COND(p_class == NULL); + CRASH_COND(p_class == nullptr); // TODO OPTIMIZE: Cache the 'CSharpScript' associated with this 'p_class' instead of allocating a new one every time Ref<CSharpScript> script = memnew(CSharpScript); @@ -2974,13 +2974,13 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon // This method should not fail, only assertions allowed - CRASH_COND(p_class == NULL); + CRASH_COND(p_class == nullptr); p_script->name = p_class->get_name(); p_script->script_class = p_class; p_script->native = p_native; - CRASH_COND(p_script->native == NULL); + CRASH_COND(p_script->native == nullptr); GDMonoClass *base = p_script->script_class->get_parent_class(); @@ -3046,12 +3046,12 @@ bool CSharpScript::can_instance() const { // For tool scripts, this will never fire if the class is not found. That's because we // don't know if it's a tool script if we can't find the class to access the attributes. if (extra_cond && !script_class) { - if (GDMono::get_singleton()->get_project_assembly() == NULL) { + if (GDMono::get_singleton()->get_project_assembly() == nullptr) { // The project assembly is not loaded - ERR_FAIL_V_MSG(NULL, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'."); + ERR_FAIL_V_MSG(false, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'."); } else { // The project assembly is loaded, but the class could not found - ERR_FAIL_V_MSG(NULL, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'."); + ERR_FAIL_V_MSG(false, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'."); } } @@ -3074,13 +3074,13 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg // Search the constructor first, to fail with an error if it's not found before allocating anything else. GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), p_argcount); - if (ctor == NULL) { - ERR_FAIL_COND_V_MSG(p_argcount == 0, NULL, + if (ctor == nullptr) { + ERR_FAIL_COND_V_MSG(p_argcount == 0, nullptr, "Cannot create script instance. The class '" + script_class->get_full_name() + "' does not define a parameterless constructor." + (get_path().empty() ? String() : " Path: '" + get_path() + "'.")); - ERR_FAIL_V_MSG(NULL, "Constructor not found."); + ERR_FAIL_V_MSG(nullptr, "Constructor not found."); } Ref<Reference> ref; @@ -3092,13 +3092,13 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg // If the object had a script instance binding, dispose it before adding the CSharpInstance if (p_owner->has_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index())) { void *data = p_owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); - CRASH_COND(data == NULL); + CRASH_COND(data == nullptr); CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get(); if (script_binding.inited && !script_binding.gchandle.is_released()) { MonoObject *mono_object = script_binding.gchandle.get_target(); if (mono_object) { - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(mono_object, &exc); if (exc) { @@ -3123,15 +3123,15 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg if (!mono_object) { // Important to clear this before destroying the script instance here instance->script = Ref<CSharpScript>(); - instance->owner = NULL; + instance->owner = nullptr; bool die = instance->_unreference_owner_unsafe(); // Not ok for the owner to die here. If there is a situation where this can happen, it will be considered a bug. CRASH_COND(die == true); - p_owner->set_script_instance(NULL); + p_owner->set_script_instance(nullptr); r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object."); + ERR_FAIL_V_MSG(nullptr, "Failed to allocate memory for the object."); } // Tie managed to unmanaged @@ -3177,7 +3177,7 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal ref = REF(r); } - CSharpInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); + CSharpInstance *instance = _create_instance(p_args, p_argcount, owner, r != nullptr, r_error); if (!instance) { if (ref.is_null()) { memdelete(owner); //no owner, sorry @@ -3206,15 +3206,15 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { "Script inherits from native type '" + String(native_name) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"); } - ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + String(native_name) + - "', so it can't be instanced in object of type: '" + p_this->get_class() + "'."); + ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(native_name) + + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'."); } } GD_MONO_SCOPE_THREAD_ATTACH; Callable::CallError unchecked_error; - return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error); + return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error); } PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) { @@ -3225,7 +3225,7 @@ PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_t _update_exports(); return si; #else - return NULL; + return nullptr; #endif } @@ -3333,7 +3333,7 @@ Error CSharpScript::reload(bool p_keep_state) { script_class = project_assembly->get_object_derived_class(name); } - valid = script_class != NULL; + valid = script_class != nullptr; if (script_class) { #ifdef DEBUG_ENABLED @@ -3355,7 +3355,7 @@ Error CSharpScript::reload(bool p_keep_state) { native = GDMonoUtils::get_class_native_base(script_class); - CRASH_COND(native == NULL); + CRASH_COND(native == nullptr); GDMonoClass *base_class = script_class->get_parent_class(); @@ -3767,7 +3767,7 @@ void ResourceFormatSaverCSharpScript::get_recognized_extensions(const RES &p_res bool ResourceFormatSaverCSharpScript::recognize(const RES &p_resource) const { - return Object::cast_to<CSharpScript>(p_resource.ptr()) != NULL; + return Object::cast_to<CSharpScript>(p_resource.ptr()) != nullptr; } CSharpLanguage::StringNameCache::StringNameCache() { diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 53b4aa6c20..29c33b50bb 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -77,8 +77,8 @@ public: }; struct EventSignal { - GDMonoField *field = NULL; - GDMonoMethod *invoke_method = NULL; + GDMonoField *field = nullptr; + GDMonoMethod *invoke_method = nullptr; Vector<SignalParameter> parameters; }; @@ -331,8 +331,8 @@ struct CSharpScriptBinding { CSharpScriptBinding() : inited(false), - wrapper_class(NULL), - owner(NULL) { + wrapper_class(nullptr), + owner(nullptr) { } }; diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 9a5de6db16..6cd10a94f9 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -411,7 +411,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("\"/>"); } else { // Try to find as global enum constant - const EnumInterface *target_ienum = NULL; + const EnumInterface *target_ienum = nullptr; for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { target_ienum = &E->get(); @@ -449,7 +449,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("\"/>"); } else { // Try to find as enum constant in the current class - const EnumInterface *target_ienum = NULL; + const EnumInterface *target_ienum = nullptr; for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) { target_ienum = &E->get(); @@ -782,7 +782,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { const ConstantInterface &iconstant = E->get(); if (iconstant.const_doc && iconstant.const_doc->description.size()) { - String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), NULL); + String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); if (summary_lines.size()) { @@ -843,7 +843,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { const ConstantInterface &iconstant = F->get(); if (iconstant.const_doc && iconstant.const_doc->description.size()) { - String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), NULL); + String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); if (summary_lines.size()) { @@ -1494,7 +1494,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte if (idx_arg.type.cname != name_cache.type_int) { // Assume the index parameter is an enum const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type); - CRASH_COND(idx_arg_type == NULL); + CRASH_COND(idx_arg_type == nullptr); p_output.append("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index)); } else { p_output.append(itos(p_iprop.index)); @@ -1522,7 +1522,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte if (idx_arg.type.cname != name_cache.type_int) { // Assume the index parameter is an enum const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type); - CRASH_COND(idx_arg_type == NULL); + CRASH_COND(idx_arg_type == nullptr); p_output.append("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index) + ", "); } else { p_output.append(itos(p_iprop.index) + ", "); @@ -2121,7 +2121,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte if (return_type->is_object_type) { ptrcall_return_type = return_type->is_reference ? "Ref<Reference>" : return_type->c_type; - initialization = return_type->is_reference ? "" : " = NULL"; + initialization = return_type->is_reference ? "" : " = nullptr"; } else { ptrcall_return_type = return_type->c_type; } @@ -2130,10 +2130,10 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte p_output.append(" " C_LOCAL_RET); p_output.append(initialization + ";\n"); - String fail_ret = return_type->c_type_out.ends_with("*") && !return_type->ret_as_byref_arg ? "NULL" : return_type->c_type_out + "()"; + String fail_ret = return_type->c_type_out.ends_with("*") && !return_type->ret_as_byref_arg ? "nullptr" : return_type->c_type_out + "()"; if (return_type->ret_as_byref_arg) { - p_output.append("\tif (" CS_PARAM_INSTANCE " == NULL) { *arg_ret = "); + p_output.append("\tif (" CS_PARAM_INSTANCE " == nullptr) { *arg_ret = "); p_output.append(fail_ret); p_output.append("; ERR_FAIL_MSG(\"Parameter ' arg_ret ' is null.\"); }\n"); } else { @@ -2198,8 +2198,8 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte } } else { p_output.append("\t" CS_PARAM_METHODBIND "->ptrcall(" CS_PARAM_INSTANCE ", "); - p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ", " : "NULL, "); - p_output.append(!ret_void ? "&" C_LOCAL_RET ");\n" : "NULL);\n"); + p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ", " : "nullptr, "); + p_output.append(!ret_void ? "&" C_LOCAL_RET ");\n" : "nullptr);\n"); } if (!ret_void) { @@ -2241,11 +2241,11 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(con // Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead. const Map<StringName, TypeInterface>::Element *int_match = builtin_types.find(name_cache.type_int); - ERR_FAIL_NULL_V(int_match, NULL); + ERR_FAIL_NULL_V(int_match, nullptr); return &int_match->get(); } - return NULL; + return nullptr; } const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placeholder(const TypeReference &p_typeref) { @@ -2412,7 +2412,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { iprop.proxy_name = iprop.proxy_name.replace("/", "__"); // Some members have a slash... - iprop.prop_doc = NULL; + iprop.prop_doc = nullptr; for (int i = 0; i < itype.class_doc->properties.size(); i++) { const DocData::PropertyDoc &prop_doc = itype.class_doc->properties[i]; @@ -2457,7 +2457,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { PropertyInfo return_info = method_info.return_val; - MethodBind *m = imethod.is_virtual ? NULL : ClassDB::get_method(type_cname, method_info.name); + MethodBind *m = imethod.is_virtual ? nullptr : ClassDB::get_method(type_cname, method_info.name); imethod.is_vararg = m && m->is_vararg(); @@ -2603,7 +2603,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // Populate signals const HashMap<StringName, MethodInfo> &signal_map = class_info->signal_map; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = signal_map.next(k))) { SignalInterface isignal; @@ -2685,7 +2685,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::get_integer_constant_list(type_cname, &constants, true); const HashMap<StringName, List<StringName>> &enum_map = class_info->enum_map; - k = NULL; + k = nullptr; while ((k = enum_map.next(k))) { StringName enum_proxy_cname = *k; @@ -2707,7 +2707,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); - iconstant.const_doc = NULL; + iconstant.const_doc = nullptr; for (int i = 0; i < itype.class_doc->constants.size(); i++) { const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i]; @@ -2742,7 +2742,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); - iconstant.const_doc = NULL; + iconstant.const_doc = nullptr; for (int i = 0; i < itype.class_doc->constants.size(); i++) { const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i]; @@ -3262,7 +3262,7 @@ void BindingsGenerator::_populate_global_constants() { String constant_name = GlobalConstants::get_global_constant_name(i); - const DocData::ConstantDoc *const_doc = NULL; + const DocData::ConstantDoc *const_doc = nullptr; for (int j = 0; j < global_scope_doc.constants.size(); j++) { const DocData::ConstantDoc &curr_const_doc = global_scope_doc.constants[j]; diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index bebe489d02..7c87c688db 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -176,7 +176,7 @@ class BindingsGenerator { is_virtual = false; requires_object_call = false; is_internal = false; - method_doc = NULL; + method_doc = nullptr; is_deprecated = false; } }; @@ -202,7 +202,7 @@ class BindingsGenerator { } SignalInterface() { - method_doc = NULL; + method_doc = nullptr; is_deprecated = false; } }; @@ -376,7 +376,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } const PropertyInterface *find_property_by_name(const StringName &p_cname) const { @@ -385,7 +385,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const { @@ -394,7 +394,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const { @@ -403,7 +403,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } private: @@ -498,7 +498,7 @@ class BindingsGenerator { c_arg_in = "%s"; - class_doc = NULL; + class_doc = nullptr; } }; @@ -622,7 +622,7 @@ class BindingsGenerator { if (it->get().name == p_name) return it; it = it->next(); } - return NULL; + return nullptr; } const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const { @@ -631,7 +631,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } inline String get_unique_sig(const TypeInterface &p_type) { diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp index 872f45ba91..e5c2d023d3 100644 --- a/modules/mono/editor/csharp_project.cpp +++ b/modules/mono/editor/csharp_project.cpp @@ -57,8 +57,8 @@ void add_item(const String &p_project_path, const String &p_item_type, const Str Variant item_type = p_item_type; Variant include = p_include; const Variant *args[3] = { &project_path, &item_type, &include }; - MonoException *exc = NULL; - klass->get_method("AddItemToProjectChecked", 3)->invoke(NULL, args, &exc); + MonoException *exc = nullptr; + klass->get_method("AddItemToProjectChecked", 3)->invoke(nullptr, args, &exc); if (exc) { GDMonoUtils::debug_print_unhandled_exception(exc); diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 31996a03d0..283d4beb8e 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -95,7 +95,7 @@ MonoString *godot_icall_GodotSharpDirs_MonoSolutionsDir() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_mono_solutions_dir()); #else - return NULL; + return nullptr; #endif } @@ -103,7 +103,7 @@ MonoString *godot_icall_GodotSharpDirs_BuildLogsDirs() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_build_logs_dir()); #else - return NULL; + return nullptr; #endif } @@ -111,7 +111,7 @@ MonoString *godot_icall_GodotSharpDirs_ProjectSlnPath() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_project_sln_path()); #else - return NULL; + return nullptr; #endif } @@ -119,7 +119,7 @@ MonoString *godot_icall_GodotSharpDirs_ProjectCsProjPath() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_project_csproj_path()); #else - return NULL; + return nullptr; #endif } @@ -127,7 +127,7 @@ MonoString *godot_icall_GodotSharpDirs_DataEditorToolsDir() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_editor_tools_dir()); #else - return NULL; + return nullptr; #endif } @@ -135,7 +135,7 @@ MonoString *godot_icall_GodotSharpDirs_DataEditorPrebuiltApiDir() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_editor_prebuilt_api_dir()); #else - return NULL; + return nullptr; #endif } @@ -151,7 +151,7 @@ MonoString *godot_icall_GodotSharpDirs_DataMonoBinDir() { #ifdef WINDOWS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_mono_bin_dir()); #else - return NULL; + return nullptr; #endif } @@ -202,7 +202,7 @@ uint32_t godot_icall_BindingsGenerator_CsGlueVersion() { } int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes, MonoString **r_error_str) { - *r_error_str = NULL; + *r_error_str = nullptr; String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath); @@ -335,7 +335,7 @@ MonoString *godot_icall_Internal_MonoWindowsInstallRoot() { String install_root_dir = GDMono::get_singleton()->get_mono_reg_info().install_root_dir; return GDMonoMarshal::mono_string_from_godot(install_root_dir); #else - return NULL; + return nullptr; #endif } diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index 19b3bea5cf..324013e5e2 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -59,7 +59,7 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> if (r_dependencies.has(ref_name)) continue; - GDMonoAssembly *ref_assembly = NULL; + GDMonoAssembly *ref_assembly = nullptr; String path; bool has_extension = ref_name.ends_with(".dll") || ref_name.ends_with(".exe"); @@ -70,21 +70,21 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> path = search_dir.plus_file(ref_name); if (FileAccess::exists(path)) { GDMono::get_singleton()->load_assembly_from(ref_name.get_basename(), path, &ref_assembly, true); - if (ref_assembly != NULL) + if (ref_assembly != nullptr) break; } } else { path = search_dir.plus_file(ref_name + ".dll"); if (FileAccess::exists(path)) { GDMono::get_singleton()->load_assembly_from(ref_name, path, &ref_assembly, true); - if (ref_assembly != NULL) + if (ref_assembly != nullptr) break; } path = search_dir.plus_file(ref_name + ".exe"); if (FileAccess::exists(path)) { GDMono::get_singleton()->load_assembly_from(ref_name, path, &ref_assembly, true); - if (ref_assembly != NULL) + if (ref_assembly != nullptr) break; } } @@ -117,7 +117,7 @@ Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencie String assembly_name = *key; String assembly_path = p_initial_dependencies[*key]; - GDMonoAssembly *assembly = NULL; + GDMonoAssembly *assembly = nullptr; bool load_success = GDMono::get_singleton()->load_assembly_from(assembly_name, assembly_path, &assembly, /* refonly: */ true); ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + assembly_name + "'."); diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 120668d1ef..f370883320 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -51,7 +51,7 @@ Object *godot_icall_Object_Ctor(MonoObject *p_obj) { void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { #ifdef DEBUG_ENABLED - CRASH_COND(p_ptr == NULL); + CRASH_COND(p_ptr == nullptr); #endif if (p_ptr->get_script_instance()) { @@ -59,7 +59,7 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { if (cs_instance) { if (!cs_instance->is_destructing_script_instance()) { cs_instance->mono_object_disposed(p_obj); - p_ptr->set_script_instance(NULL); + p_ptr->set_script_instance(nullptr); } return; } @@ -80,7 +80,7 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolean p_is_finalizer) { #ifdef DEBUG_ENABLED - CRASH_COND(p_ptr == NULL); + CRASH_COND(p_ptr == nullptr); // This is only called with Reference derived classes CRASH_COND(!Object::cast_to<Reference>(p_ptr)); #endif @@ -99,7 +99,7 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea if (delete_owner) { memdelete(ref); } else if (remove_script_instance) { - ref->set_script_instance(NULL); + ref->set_script_instance(nullptr); } } return; @@ -141,7 +141,7 @@ MethodBind *godot_icall_Object_ClassDB_get_method(StringName *p_type, MonoString MonoObject *godot_icall_Object_weakref(Object *p_ptr) { if (!p_ptr) - return NULL; + return nullptr; Ref<WeakRef> wref; Reference *ref = Object::cast_to<Reference>(p_ptr); @@ -149,7 +149,7 @@ MonoObject *godot_icall_Object_weakref(Object *p_ptr) { if (ref) { REF r = ref; if (!r.is_valid()) - return NULL; + return nullptr; wref.instance(); wref->set_ref(r); @@ -230,7 +230,7 @@ MonoBoolean godot_icall_DynamicGodotObject_SetMember(Object *p_ptr, MonoString * MonoString *godot_icall_Object_ToString(Object *p_ptr) { #ifdef DEBUG_ENABLED // Cannot happen in C#; would get an ObjectDisposedException instead. - CRASH_COND(p_ptr == NULL); + CRASH_COND(p_ptr == nullptr); #endif // Can't call 'Object::to_string()' here, as that can end up calling 'ToString' again resulting in an endless circular loop. String result = "[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]"; diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index b7fa7fcab2..4e3dc9c4ea 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -49,7 +49,7 @@ void godot_icall_Array_Dtor(Array *ptr) { MonoObject *godot_icall_Array_At(Array *ptr, int index) { if (index < 0 || index >= ptr->size()) { GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index)); } @@ -57,7 +57,7 @@ MonoObject *godot_icall_Array_At(Array *ptr, int index) { MonoObject *godot_icall_Array_At_Generic(Array *ptr, int index, uint32_t type_encoding, GDMonoClass *type_class) { if (index < 0 || index >= ptr->size()) { GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index), ManagedType(type_encoding, type_class)); } @@ -162,28 +162,28 @@ void godot_icall_Dictionary_Dtor(Dictionary *ptr) { MonoObject *godot_icall_Dictionary_GetValue(Dictionary *ptr, MonoObject *key) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { + if (ret == nullptr) { MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr()); #ifdef DEBUG_ENABLED CRASH_COND(!exc); #endif GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException)); GDMonoUtils::set_pending_exception((MonoException *)exc); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ret); } MonoObject *godot_icall_Dictionary_GetValue_Generic(Dictionary *ptr, MonoObject *key, uint32_t type_encoding, GDMonoClass *type_class) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { + if (ret == nullptr) { MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr()); #ifdef DEBUG_ENABLED CRASH_COND(!exc); #endif GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException)); GDMonoUtils::set_pending_exception((MonoException *)exc); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class)); } @@ -207,7 +207,7 @@ int godot_icall_Dictionary_Count(Dictionary *ptr) { void godot_icall_Dictionary_Add(Dictionary *ptr, MonoObject *key, MonoObject *value) { Variant varKey = GDMonoMarshal::mono_object_to_variant(key); Variant *ret = ptr->getptr(varKey); - if (ret != NULL) { + if (ret != nullptr) { GDMonoUtils::set_pending_exception(mono_get_exception_argument("key", "An element with the same key already exists")); return; } @@ -221,7 +221,7 @@ void godot_icall_Dictionary_Clear(Dictionary *ptr) { MonoBoolean godot_icall_Dictionary_Contains(Dictionary *ptr, MonoObject *key, MonoObject *value) { // no dupes Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - return ret != NULL && *ret == GDMonoMarshal::mono_object_to_variant(value); + return ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value); } MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key) { @@ -241,7 +241,7 @@ MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, Mono // no dupes Variant *ret = ptr->getptr(varKey); - if (ret != NULL && *ret == GDMonoMarshal::mono_object_to_variant(value)) { + if (ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value)) { ptr->erase(varKey); return true; } @@ -251,8 +251,8 @@ MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, Mono MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key, MonoObject **value) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { - *value = NULL; + if (ret == nullptr) { + *value = nullptr; return false; } *value = GDMonoMarshal::variant_to_mono_object(ret); @@ -261,8 +261,8 @@ MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key, MonoBoolean godot_icall_Dictionary_TryGetValue_Generic(Dictionary *ptr, MonoObject *key, MonoObject **value, uint32_t type_encoding, GDMonoClass *type_class) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { - *value = NULL; + if (ret == nullptr) { + *value = nullptr; return false; } *value = GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class)); diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp index 1576d31a3b..2da39a916a 100644 --- a/modules/mono/glue/gd_glue.cpp +++ b/modules/mono/glue/gd_glue.cpp @@ -45,7 +45,7 @@ MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes, MonoBoolean p_allow_objects) { Variant ret; PackedByteArray varr = GDMonoMarshal::mono_array_to_PackedByteArray(p_bytes); - Error err = decode_variant(ret, varr.ptr(), varr.size(), NULL, p_allow_objects); + Error err = decode_variant(ret, varr.ptr(), varr.size(), nullptr, p_allow_objects); if (err != OK) { ret = RTR("Not enough bytes for decoding bytes, or invalid format."); } @@ -57,7 +57,7 @@ MonoObject *godot_icall_GD_convert(MonoObject *p_what, int32_t p_type) { const Variant *args[1] = { &what }; Callable::CallError ce; Variant ret = Variant::construct(Variant::Type(p_type), args, 1, ce); - ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, NULL); + ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr); return GDMonoMarshal::variant_to_mono_object(ret); } @@ -76,7 +76,7 @@ void godot_icall_GD_print(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -98,7 +98,7 @@ void godot_icall_GD_printerr(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -119,7 +119,7 @@ void godot_icall_GD_printraw(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -140,7 +140,7 @@ void godot_icall_GD_prints(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -164,7 +164,7 @@ void godot_icall_GD_printt(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -259,8 +259,8 @@ MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_object PackedByteArray barr; int len; - Error err = encode_variant(var, NULL, len, p_full_objects); - ERR_FAIL_COND_V_MSG(err != OK, NULL, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."); + Error err = encode_variant(var, nullptr, len, p_full_objects); + ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."); barr.resize(len); encode_variant(var, barr.ptrw(), len, p_full_objects); diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h index 8130b0cc39..ee99a300b9 100644 --- a/modules/mono/glue/glue_header.h +++ b/modules/mono/glue/glue_header.h @@ -70,7 +70,7 @@ void godot_register_glue_header_icalls() { #include "../mono_gd/gd_mono_utils.h" #define GODOTSHARP_INSTANCE_OBJECT(m_instance, m_type) \ - static ClassDB::ClassInfo *ci = NULL; \ + static ClassDB::ClassInfo *ci = nullptr; \ if (!ci) { \ ci = ClassDB::classes.getptr(m_type); \ } \ diff --git a/modules/mono/managed_callable.cpp b/modules/mono/managed_callable.cpp index a9cf64d1cc..dfd78a8244 100644 --- a/modules/mono/managed_callable.cpp +++ b/modules/mono/managed_callable.cpp @@ -99,7 +99,7 @@ void ManagedCallable::call(const Variant **p_arguments, int p_argcount, Variant MonoObject *delegate = delegate_handle.get_target(); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = delegate_invoke->invoke(delegate, p_arguments, &exc); if (exc) { @@ -119,7 +119,7 @@ void ManagedCallable::set_delegate(MonoDelegate *p_delegate) { ManagedCallable::ManagedCallable(MonoDelegate *p_delegate) { #ifdef DEBUG_ENABLED - CRASH_COND(p_delegate == NULL); + CRASH_COND(p_delegate == nullptr); #endif set_delegate(p_delegate); diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp index 4b6d7269e9..e362d5affb 100644 --- a/modules/mono/mono_gc_handle.cpp +++ b/modules/mono/mono_gc_handle.cpp @@ -34,7 +34,7 @@ void MonoGCHandleData::release() { #ifdef DEBUG_ENABLED - CRASH_COND(handle && GDMono::get_singleton() == NULL); + CRASH_COND(handle && GDMono::get_singleton() == nullptr); #endif if (handle && GDMono::get_singleton()->is_runtime_initialized()) { diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h index 705b2265ba..fbcb405b0d 100644 --- a/modules/mono/mono_gc_handle.h +++ b/modules/mono/mono_gc_handle.h @@ -53,7 +53,7 @@ struct MonoGCHandleData { _FORCE_INLINE_ bool is_released() const { return !handle; } _FORCE_INLINE_ bool is_weak() const { return type == gdmono::GCHandleType::WEAK_HANDLE; } - _FORCE_INLINE_ MonoObject *get_target() const { return handle ? mono_gchandle_get_target(handle) : NULL; } + _FORCE_INLINE_ MonoObject *get_target() const { return handle ? mono_gchandle_get_target(handle) : nullptr; } void release(); 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); diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index 4823ba3679..94431e7c30 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -34,11 +34,11 @@ #include "csharp_script.h" -CSharpLanguage *script_language_cs = NULL; +CSharpLanguage *script_language_cs = nullptr; Ref<ResourceFormatLoaderCSharpScript> resource_loader_cs; Ref<ResourceFormatSaverCSharpScript> resource_saver_cs; -_GodotSharp *_godotsharp = NULL; +_GodotSharp *_godotsharp = nullptr; void register_mono_types() { ClassDB::register_class<CSharpScript>(); diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp index 25e5a41215..e77a2e98f2 100644 --- a/modules/mono/signal_awaiter_utils.cpp +++ b/modules/mono/signal_awaiter_utils.cpp @@ -121,7 +121,7 @@ void SignalAwaiterCallable::call(const Variant **p_arguments, int p_argcount, Va return; } - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(SignalAwaiter, SignalCallback).invoke(awaiter, signal_args, &exc); if (exc) { @@ -210,7 +210,7 @@ void EventSignalCallable::call(const Variant **p_arguments, int p_argcount, Vari return; } - MonoException *exc = NULL; + MonoException *exc = nullptr; event_signal->invoke_method->invoke(delegate_field_value, p_arguments, &exc); if (exc) { diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index c1cd5f1db4..8f0ad8ba5e 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -73,13 +73,13 @@ LONG _RegKeyQueryString(HKEY hKey, const String &p_value_name, String &r_value) buffer.resize(512); DWORD dwBufferSize = buffer.size(); - LONG res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, NULL, (LPBYTE)buffer.ptr(), &dwBufferSize); + LONG res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize); if (res == ERROR_MORE_DATA) { // dwBufferSize now contains the actual size Vector<WCHAR> buffer; buffer.resize(dwBufferSize); - res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, NULL, (LPBYTE)buffer.ptr(), &dwBufferSize); + res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize); } if (res == ERROR_SUCCESS) { @@ -180,7 +180,7 @@ String find_msbuild_tools_path() { String output; int exit_code; - OS::get_singleton()->execute(vswhere_path, vswhere_args, true, NULL, &output, &exit_code); + OS::get_singleton()->execute(vswhere_path, vswhere_args, true, nullptr, &output, &exit_code); if (exit_code == 0) { Vector<String> lines = output.split("\n"); diff --git a/modules/mono/utils/osx_utils.cpp b/modules/mono/utils/osx_utils.cpp index 432b306414..8fadf3c109 100644 --- a/modules/mono/utils/osx_utils.cpp +++ b/modules/mono/utils/osx_utils.cpp @@ -39,9 +39,9 @@ bool osx_is_app_bundle_installed(const String &p_bundle_id) { - CFURLRef app_url = NULL; - CFStringRef bundle_id = CFStringCreateWithCString(NULL, p_bundle_id.utf8(), kCFStringEncodingUTF8); - OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, NULL, NULL, &app_url); + CFURLRef app_url = nullptr; + CFStringRef bundle_id = CFStringCreateWithCString(nullptr, p_bundle_id.utf8(), kCFStringEncodingUTF8); + OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, nullptr, nullptr, &app_url); CFRelease(bundle_id); if (app_url) diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 545da6c79e..973375a471 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -80,7 +80,7 @@ String find_executable(const String &p_name) { String cwd() { #ifdef WINDOWS_ENABLED - const DWORD expected_size = ::GetCurrentDirectoryW(0, NULL); + const DWORD expected_size = ::GetCurrentDirectoryW(0, nullptr); String buffer; buffer.resize((int)expected_size); @@ -90,7 +90,7 @@ String cwd() { return buffer.simplify_path(); #else char buffer[PATH_MAX]; - if (::getcwd(buffer, sizeof(buffer)) == NULL) + if (::getcwd(buffer, sizeof(buffer)) == nullptr) return "."; String result; @@ -114,12 +114,12 @@ String realpath(const String &p_path) { // Open file without read/write access HANDLE hFile = ::CreateFileW(p_path.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) return p_path; - const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, NULL, 0, FILE_NAME_NORMALIZED); + const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, nullptr, 0, FILE_NAME_NORMALIZED); if (expected_size == 0) { ::CloseHandle(hFile); @@ -133,7 +133,7 @@ String realpath(const String &p_path) { ::CloseHandle(hFile); return buffer.simplify_path(); #elif UNIX_ENABLED - char *resolved_path = ::realpath(p_path.utf8().get_data(), NULL); + char *resolved_path = ::realpath(p_path.utf8().get_data(), nullptr); if (!resolved_path) return p_path; diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index 49c4fb3f73..907811355f 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -212,7 +212,7 @@ String str_format(const char *p_format, ...) { #define gd_vscprintf(m_format, m_args_copy) _vscprintf(m_format, m_args_copy) #else #define gd_vsnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf(m_buffer, m_count, m_format, m_args_copy) -#define gd_vscprintf(m_format, m_args_copy) vsnprintf(NULL, 0, p_format, m_args_copy) +#define gd_vscprintf(m_format, m_args_copy) vsnprintf(nullptr, 0, p_format, m_args_copy) #endif String str_format(const char *p_format, va_list p_list) { |