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/gdnative | |
parent | 5f11e1557156617366d2c316a97716172103980d (diff) | |
parent | 95a1400a2ac9de1a29fa305f45b928ce8e3044bd (diff) |
Merge pull request #37338 from lupoDharkael/nullprt
Replace NULL with nullptr
Diffstat (limited to 'modules/gdnative')
21 files changed, 160 insertions, 160 deletions
diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp index 6e0358342f..bc39be1813 100644 --- a/modules/gdnative/android/android_gdn.cpp +++ b/modules/gdnative/android/android_gdn.cpp @@ -50,7 +50,7 @@ JNIEnv *GDAPI godot_android_get_env() { #ifdef __ANDROID__ return ThreadAndroid::get_env(); #else - return NULL; + return nullptr; #endif } @@ -59,7 +59,7 @@ jobject GDAPI godot_android_get_activity() { OS_Android *os_android = (OS_Android *)OS::get_singleton(); return os_android->get_godot_java()->get_activity(); #else - return NULL; + return nullptr; #endif } @@ -68,7 +68,7 @@ jobject GDAPI godot_android_get_surface() { OS_Android *os_android = (OS_Android *)OS::get_singleton(); return os_android->get_godot_java()->get_surface(); #else - return NULL; + return nullptr; #endif } diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index faa891e624..f14691027a 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -42,15 +42,15 @@ ARVRInterfaceGDNative::ARVRInterfaceGDNative() { print_verbose("Construct gdnative interface\n"); // we won't have our data pointer until our library gets set - data = NULL; + data = nullptr; - interface = NULL; + interface = nullptr; } ARVRInterfaceGDNative::~ARVRInterfaceGDNative() { print_verbose("Destruct gdnative interface\n"); - if (interface != NULL && is_initialized()) { + if (interface != nullptr && is_initialized()) { uninitialize(); }; @@ -59,10 +59,10 @@ ARVRInterfaceGDNative::~ARVRInterfaceGDNative() { } void ARVRInterfaceGDNative::cleanup() { - if (interface != NULL) { + if (interface != nullptr) { interface->destructor(data); - data = NULL; - interface = NULL; + data = nullptr; + interface = nullptr; } } @@ -81,7 +81,7 @@ void ARVRInterfaceGDNative::set_interface(const godot_arvr_interface_gdnative *p StringName ARVRInterfaceGDNative::get_name() const { - ERR_FAIL_COND_V(interface == NULL, StringName()); + ERR_FAIL_COND_V(interface == nullptr, StringName()); godot_string result = interface->get_name(data); @@ -95,7 +95,7 @@ StringName ARVRInterfaceGDNative::get_name() const { int ARVRInterfaceGDNative::get_capabilities() const { int capabilities; - ERR_FAIL_COND_V(interface == NULL, 0); // 0 = None + ERR_FAIL_COND_V(interface == nullptr, 0); // 0 = None capabilities = interface->get_capabilities(data); @@ -104,21 +104,21 @@ int ARVRInterfaceGDNative::get_capabilities() const { bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->get_anchor_detection_is_enabled(data); } void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_anchor_detection_is_enabled(data, p_enable); } int ARVRInterfaceGDNative::get_camera_feed_id() { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) { return (unsigned int)interface->get_camera_feed_id(data); @@ -130,7 +130,7 @@ int ARVRInterfaceGDNative::get_camera_feed_id() { bool ARVRInterfaceGDNative::is_stereo() { bool stereo; - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); stereo = interface->is_stereo(data); @@ -139,13 +139,13 @@ bool ARVRInterfaceGDNative::is_stereo() { bool ARVRInterfaceGDNative::is_initialized() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_initialized(data); } bool ARVRInterfaceGDNative::initialize() { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); bool initialized = interface->initialize(data); @@ -153,7 +153,7 @@ bool ARVRInterfaceGDNative::initialize() { // if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface ARVRServer *arvr_server = ARVRServer::get_singleton(); - if ((arvr_server != NULL) && (arvr_server->get_primary_interface() == NULL)) { + if ((arvr_server != nullptr) && (arvr_server->get_primary_interface() == nullptr)) { arvr_server->set_primary_interface(this); }; }; @@ -162,10 +162,10 @@ bool ARVRInterfaceGDNative::initialize() { } void ARVRInterfaceGDNative::uninitialize() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); ARVRServer *arvr_server = ARVRServer::get_singleton(); - if (arvr_server != NULL) { + if (arvr_server != nullptr) { // Whatever happens, make sure this is no longer our primary interface arvr_server->clear_primary_interface_if(this); } @@ -175,7 +175,7 @@ void ARVRInterfaceGDNative::uninitialize() { Size2 ARVRInterfaceGDNative::get_render_targetsize() { - ERR_FAIL_COND_V(interface == NULL, Size2()); + ERR_FAIL_COND_V(interface == nullptr, Size2()); godot_vector2 result = interface->get_render_targetsize(data); Vector2 *vec = (Vector2 *)&result; @@ -186,7 +186,7 @@ Size2 ARVRInterfaceGDNative::get_render_targetsize() { Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) { Transform *ret; - ERR_FAIL_COND_V(interface == NULL, Transform()); + ERR_FAIL_COND_V(interface == nullptr, Transform()); godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform); @@ -198,7 +198,7 @@ Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) { CameraMatrix cm; - ERR_FAIL_COND_V(interface == NULL, CameraMatrix()); + ERR_FAIL_COND_V(interface == nullptr, CameraMatrix()); interface->fill_projection_for_eye(data, (godot_real *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far); @@ -207,7 +207,7 @@ CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface::Eyes p_eye) { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) { return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye); @@ -218,19 +218,19 @@ unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface:: void ARVRInterfaceGDNative::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect); } void ARVRInterfaceGDNative::process() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->process(data); } void ARVRInterfaceGDNative::notification(int p_what) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); // this is only available in interfaces that implement 1.1 or later if ((interface->version.major > 1) || ((interface->version.major == 1) && (interface->version.minor > 0))) { @@ -265,7 +265,7 @@ godot_transform GDAPI godot_arvr_get_reference_frame() { Transform *reference_frame_ptr = (Transform *)&reference_frame; ARVRServer *arvr_server = ARVRServer::get_singleton(); - if (arvr_server != NULL) { + if (arvr_server != nullptr) { *reference_frame_ptr = arvr_server->get_reference_frame(); } else { godot_transform_new_identity(&reference_frame); @@ -360,7 +360,7 @@ void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) { ERR_FAIL_NULL(input); ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (remove_tracker != NULL) { + if (remove_tracker != nullptr) { // unset our joystick if applicable int joyid = remove_tracker->get_joy_id(); if (joyid != -1) { @@ -379,7 +379,7 @@ void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_ ERR_FAIL_NULL(arvr_server); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { Transform *transform = (Transform *)p_transform; if (p_tracks_orientation) { tracker->set_orientation(transform->basis); @@ -398,7 +398,7 @@ void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int ERR_FAIL_NULL(input); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { int joyid = tracker->get_joy_id(); if (joyid != -1) { input->joy_button(joyid, p_button, p_is_pressed); @@ -414,7 +414,7 @@ void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p ERR_FAIL_NULL(input); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { int joyid = tracker->get_joy_id(); if (joyid != -1) { InputFilter::JoyAxis jx; @@ -430,7 +430,7 @@ godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id) { ERR_FAIL_NULL_V(arvr_server, 0.0); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { return tracker->get_rumble(); } diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 0457a42f30..d3426044ec 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -248,7 +248,7 @@ void GDNativeLibrary::_bind_methods() { } GDNative::GDNative() { - native_handle = NULL; + native_handle = nullptr; initialized = false; } @@ -338,7 +338,7 @@ bool GDNative::initialize() { if (err || !library_init) { OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = NULL; + native_handle = nullptr; ERR_PRINT("Failed to obtain " + library->get_symbol_prefix() + "gdnative_init symbol"); return false; } @@ -408,7 +408,7 @@ bool GDNative::terminate() { Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate); if (error || !library_terminate) { OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = NULL; + native_handle = nullptr; initialized = false; return true; } @@ -426,7 +426,7 @@ bool GDNative::terminate() { // GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = NULL; + native_handle = nullptr; return true; } @@ -466,7 +466,7 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced p_procedure_name, procedure_handle); - if (err != OK || procedure_handle == NULL) { + if (err != OK || procedure_handle == nullptr) { return Variant(); } @@ -544,11 +544,11 @@ Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_reso } bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const { - return Object::cast_to<GDNativeLibrary>(*p_resource) != NULL; + return Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr; } void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<GDNativeLibrary>(*p_resource) != NULL) { + if (Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr) { p_extensions->push_back("gdnlib"); } } diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index d996b006a5..3175340448 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -95,7 +95,7 @@ godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classnam ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); if (class_info) return (godot_class_constructor)class_info->creation_func; - return NULL; + return nullptr; } godot_dictionary GDAPI godot_get_global_constants() { @@ -173,14 +173,14 @@ godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) { void *godot_get_class_tag(const godot_string_name *p_class) { StringName class_name = *(StringName *)p_class; ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name); - return class_info ? class_info->class_ptr : NULL; + return class_info ? class_info->class_ptr : nullptr; } godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) { - if (!p_object) return NULL; + if (!p_object) return nullptr; Object *o = (Object *)p_object; - return o->is_class_ptr(p_class_tag) ? (godot_object *)o : NULL; + return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr; } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 9b4c3c794e..10ddd79d3a 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -119,7 +119,7 @@ void GDNativeLibraryEditor::_update_tree() { new_arch->set_expand_right(0, true); new_arch->set_metadata(1, E->key()); - platform->set_collapsed(collapsed_items.find(E->get().name) != NULL); + platform->set_collapsed(collapsed_items.find(E->get().name) != nullptr); } filter->set_text(text); } diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h index 341e7f9e2b..406c3ba663 100644 --- a/modules/gdnative/include/pluginscript/godot_pluginscript.h +++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h @@ -60,7 +60,7 @@ typedef struct { //this is used by script languages that keep a reference counter of their own //you can make make Ref<> not die when it reaches zero, so deleting the reference //depends entirely from the script. - // Note: You can set those function pointer to NULL if not needed. + // Note: You can set those function pointer to nullptr if not needed. void (*refcount_incremented)(godot_pluginscript_instance_data *p_data); bool (*refcount_decremented)(godot_pluginscript_instance_data *p_data); // return true if it can die } godot_pluginscript_instance_desc; @@ -119,18 +119,18 @@ typedef struct { const char *name; const char *type; const char *extension; - const char **recognized_extensions; // NULL terminated array + const char **recognized_extensions; // nullptr terminated array godot_pluginscript_language_data *(*init)(); void (*finish)(godot_pluginscript_language_data *p_data); - const char **reserved_words; // NULL terminated array - const char **comment_delimiters; // NULL terminated array - const char **string_delimiters; // NULL terminated array + const char **reserved_words; // nullptr terminated array + const char **comment_delimiters; // nullptr terminated array + const char **string_delimiters; // nullptr terminated array godot_bool has_named_classes; godot_bool supports_builtin_mode; godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name); godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, int *r_line_error, int *r_col_error, godot_string *r_test_error, const godot_string *p_path, godot_packed_string_array *r_functions); - int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be NULL + int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be nullptr godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args); godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint); void (*auto_indent_code)(godot_pluginscript_language_data *p_data, godot_string *p_code, int p_from_line, int p_to_line); diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 11fe746e90..3c0cfd0484 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -46,7 +46,7 @@ static Error save_file(const String &p_path, const List<String> &p_content) { ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); - for (const List<String>::Element *e = p_content.front(); e != NULL; e = e->next()) { + for (const List<String>::Element *e = p_content.front(); e != nullptr; e = e->next()) { file->store_string(e->get()); } @@ -197,7 +197,7 @@ List<ClassAPI> generate_c_api_classes() { api.push_back(global_constants_api); } - for (List<StringName>::Element *e = classes.front(); e != NULL; e = e->next()) { + for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) { StringName class_name = e->get(); ClassAPI class_api; @@ -229,7 +229,7 @@ List<ClassAPI> generate_c_api_classes() { List<String> constant; ClassDB::get_integer_constant_list(class_name, &constant, true); constant.sort_custom<NoCaseComparator>(); - for (List<String>::Element *c = constant.front(); c != NULL; c = c->next()) { + for (List<String>::Element *c = constant.front(); c != nullptr; c = c->next()) { ConstantAPI constant_api; constant_api.constant_name = c->get(); constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get()); @@ -284,7 +284,7 @@ List<ClassAPI> generate_c_api_classes() { ClassDB::get_property_list(class_name, &properties, true); properties.sort_custom<PropertyInfoComparator>(); - for (List<PropertyInfo>::Element *p = properties.front(); p != NULL; p = p->next()) { + for (List<PropertyInfo>::Element *p = properties.front(); p != nullptr; p = p->next()) { PropertyAPI property_api; property_api.name = p->get().name; @@ -312,7 +312,7 @@ List<ClassAPI> generate_c_api_classes() { ClassDB::get_method_list(class_name, &methods, true); methods.sort_custom<MethodInfoComparator>(); - for (List<MethodInfo>::Element *m = methods.front(); m != NULL; m = m->next()) { + for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; m = m->next()) { MethodAPI method_api; MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name); MethodInfo &method_info = m->get(); @@ -392,7 +392,7 @@ List<ClassAPI> generate_c_api_classes() { enum_api.name = E->get(); ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { - int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL); + int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr); enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); } enum_api.values.sort_custom<PairSort<int, String>>(); @@ -417,7 +417,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back("[\n"); - for (const List<ClassAPI>::Element *c = p_api.front(); c != NULL; c = c->next()) { + for (const List<ClassAPI>::Element *c = p_api.front(); c != nullptr; c = c->next()) { ClassAPI api = c->get(); source.push_back("\t{\n"); diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index f953206a34..0502458b4f 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -77,7 +77,7 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char } } else { - desc.base_data = NULL; + desc.base_data = nullptr; desc.base_native_type = p_base; } @@ -111,7 +111,7 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const } } else { - desc.base_data = NULL; + desc.base_data = nullptr; desc.base_native_type = p_base; } @@ -210,11 +210,11 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { Object *instance = (Object *)p_instance; if (!instance) - return NULL; + return nullptr; if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { return ((NativeScriptInstance *)instance->get_script_instance())->userdata; } - return NULL; + return nullptr; } /* @@ -319,18 +319,18 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) const Object *o = (Object *)p_object; if (!o->get_script_instance()) { - return NULL; + return nullptr; } else { NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr()); if (!script) { - return NULL; + return nullptr; } if (script->get_script_desc()) return script->get_script_desc()->type_tag; } - return NULL; + return nullptr; } int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions) { diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 80aebaccd1..bf458c15ee 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -204,7 +204,7 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) { NativeScriptDesc *script_data = get_script_desc(); if (!script_data) { - return NULL; + return nullptr; } NativeScriptInstance *nsi = memnew(NativeScriptInstance); @@ -214,7 +214,7 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) { #ifndef TOOLS_ENABLED if (!ScriptServer::is_scripting_enabled()) { - nsi->userdata = NULL; + nsi->userdata = nullptr; } else { nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data); } @@ -240,7 +240,7 @@ PlaceHolderScriptInstance *NativeScript::placeholder_instance_create(Object *p_t return sins; #else - return NULL; + return nullptr; #endif } @@ -738,7 +738,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal r_error.error = Callable::CallError::CALL_OK; REF ref; - Object *owner = NULL; + Object *owner = nullptr; if (!(script_data->base_native_type == "")) { owner = ClassDB::instance(script_data->base_native_type); @@ -886,7 +886,7 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c E->get().method.method_data, userdata, 0, - NULL); + nullptr); Variant res = *(Variant *)&result; godot_variant_destroy(&result); @@ -1007,7 +1007,7 @@ void NativeScriptInstance::notification(int p_notification) { String NativeScriptInstance::to_string(bool *r_valid) { if (has_method(CoreStringNames::get_singleton()->_to_string)) { Callable::CallError ce; - Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce); + Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) { if (ret.get_type() != Variant::STRING) { if (r_valid) @@ -1026,7 +1026,7 @@ String NativeScriptInstance::to_string(bool *r_valid) { void NativeScriptInstance::refcount_incremented() { Callable::CallError err; - call("_refcount_incremented", NULL, 0, err); + call("_refcount_incremented", nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) { ERR_PRINT("Failed to invoke _refcount_incremented - should not happen"); } @@ -1034,7 +1034,7 @@ void NativeScriptInstance::refcount_incremented() { bool NativeScriptInstance::refcount_decremented() { Callable::CallError err; - Variant ret = call("_refcount_decremented", NULL, 0, err); + Variant ret = call("_refcount_decremented", nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) { ERR_PRINT("Failed to invoke _refcount_decremented - should not happen"); return true; // assume we can destroy the object @@ -1525,14 +1525,14 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) { } void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) { - ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), nullptr); - ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, NULL, "Tried to get binding data for a nativescript binding that does not exist."); + ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, nullptr, "Tried to get binding data for a nativescript binding that does not exist."); Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx); if (!binding_data) - return NULL; // should never happen. + return nullptr; // should never happen. if (binding_data->size() <= p_idx) { // okay, add new elements here. @@ -1541,7 +1541,7 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec binding_data->resize(p_idx + 1); for (int i = old_size; i <= p_idx; i++) { - (*binding_data).write[i] = NULL; + (*binding_data).write[i] = nullptr; } } @@ -1563,7 +1563,7 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { binding_data->resize(binding_functions.size()); for (int i = 0; i < binding_functions.size(); i++) { - (*binding_data).write[i] = NULL; + (*binding_data).write[i] = nullptr; } binding_instances.insert(binding_data); @@ -1652,12 +1652,12 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const { if (!global_type_tags.has(p_idx)) - return NULL; + return nullptr; const HashMap<StringName, const void *> &tags = global_type_tags[p_idx]; if (!tags.has(p_class_name)) - return NULL; + return nullptr; const void *tag = tags.get(p_class_name); @@ -1956,7 +1956,7 @@ Error ResourceFormatSaverNativeScript::save(const String &p_path, const RES &p_r } bool ResourceFormatSaverNativeScript::recognize(const RES &p_resource) const { - return Object::cast_to<NativeScript>(*p_resource) != NULL; + return Object::cast_to<NativeScript>(*p_resource) != nullptr; } void ResourceFormatSaverNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index aba3f6b2d0..75bbb42664 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -95,7 +95,7 @@ struct NativeScriptDesc { base(), base_native_type(), documentation(), - type_tag(NULL) { + type_tag(nullptr) { zeromem(&create_func, sizeof(godot_instance_create_func)); zeromem(&destroy_func, sizeof(godot_instance_destroy_func)); } @@ -341,7 +341,7 @@ public: virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; @@ -389,7 +389,7 @@ public: inline NativeScriptDesc *NativeScript::get_script_desc() const { Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name); - return E ? &E->get() : NULL; + return E ? &E->get() : nullptr; } class NativeReloadNode : public Node { @@ -406,7 +406,7 @@ public: class ResourceFormatLoaderNativeScript : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp index 8c43a79cc5..a95697ea65 100644 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp @@ -31,7 +31,7 @@ #include "multiplayer_peer_gdnative.h" MultiplayerPeerGDNative::MultiplayerPeerGDNative() { - interface = NULL; + interface = nullptr; } MultiplayerPeerGDNative::~MultiplayerPeerGDNative() { @@ -42,73 +42,73 @@ void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multip } Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); } int MultiplayerPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_max_packet_size(interface->data); } int MultiplayerPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_packet_count(interface->data); } /* NetworkedMultiplayerPeer */ void MultiplayerPeerGDNative::set_transfer_mode(TransferMode p_mode) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_transfer_mode(interface->data, (godot_int)p_mode); } NetworkedMultiplayerPeer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const { - ERR_FAIL_COND_V(interface == NULL, TRANSFER_MODE_UNRELIABLE); + ERR_FAIL_COND_V(interface == nullptr, TRANSFER_MODE_UNRELIABLE); return (TransferMode)interface->get_transfer_mode(interface->data); } void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_target_peer(interface->data, p_peer_id); } int MultiplayerPeerGDNative::get_packet_peer() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_packet_peer(interface->data); } bool MultiplayerPeerGDNative::is_server() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_server(interface->data); } void MultiplayerPeerGDNative::poll() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->poll(interface->data); } int MultiplayerPeerGDNative::get_unique_id() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_unique_id(interface->data); } void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_refuse_new_connections(interface->data, p_enable); } bool MultiplayerPeerGDNative::is_refusing_new_connections() const { - ERR_FAIL_COND_V(interface == NULL, true); + ERR_FAIL_COND_V(interface == nullptr, true); return interface->is_refusing_new_connections(interface->data); } NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const { - ERR_FAIL_COND_V(interface == NULL, CONNECTION_DISCONNECTED); + ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED); return (ConnectionStatus)interface->get_connection_status(interface->data); } diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp index 75e1e0b824..28135df3b6 100644 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ b/modules/gdnative/net/packet_peer_gdnative.cpp @@ -31,7 +31,7 @@ #include "packet_peer_gdnative.h" PacketPeerGDNative::PacketPeerGDNative() { - interface = NULL; + interface = nullptr; } PacketPeerGDNative::~PacketPeerGDNative() { @@ -45,22 +45,22 @@ void PacketPeerGDNative::_bind_methods() { } Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); } int PacketPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_max_packet_size(interface->data); } int PacketPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_packet_count(interface->data); } diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp index 22634daf5f..9dcb184115 100644 --- a/modules/gdnative/net/stream_peer_gdnative.cpp +++ b/modules/gdnative/net/stream_peer_gdnative.cpp @@ -31,7 +31,7 @@ #include "stream_peer_gdnative.h" StreamPeerGDNative::StreamPeerGDNative() { - interface = NULL; + interface = nullptr; } StreamPeerGDNative::~StreamPeerGDNative() { @@ -45,27 +45,27 @@ void StreamPeerGDNative::_bind_methods() { } Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->put_data(interface->data, p_data, p_bytes)); } Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent)); } Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->get_data(interface->data, p_buffer, p_bytes)); } Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received)); } int StreamPeerGDNative::get_available_bytes() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_bytes(interface->data); } diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp index 22e8372130..7d17a7d5ab 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.cpp +++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp @@ -156,7 +156,7 @@ bool PluginScriptInstance::init(PluginScript *p_script, Object *p_owner) { _script = Ref<PluginScript>(p_script); _desc = &p_script->_desc->instance_desc; _data = _desc->init(p_script->_data, (godot_object *)p_owner); - ERR_FAIL_COND_V(_data == NULL, false); + ERR_FAIL_COND_V(_data == nullptr, false); p_owner->set_script_instance(this); return true; } diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h index c91ad643a7..6309b6fde3 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.h +++ b/modules/gdnative/pluginscript/pluginscript_instance.h @@ -55,7 +55,7 @@ public: virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; - virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const; + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const; virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName &p_method) const; diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h index 809034744a..dd6758713f 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.h +++ b/modules/gdnative/pluginscript/pluginscript_language.h @@ -74,7 +74,7 @@ public: virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp index 46db20b6c2..3fb22b3f8d 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp @@ -109,5 +109,5 @@ void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_res bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const { - return Object::cast_to<PluginScript>(*p_resource) != NULL; + return Object::cast_to<PluginScript>(*p_resource) != nullptr; } diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h index a039072fdc..c929be53bd 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.h +++ b/modules/gdnative/pluginscript/pluginscript_loader.h @@ -44,7 +44,7 @@ class ResourceFormatLoaderPluginScript : public ResourceFormatLoader { public: ResourceFormatLoaderPluginScript(PluginScriptLanguage *language); - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index b7cbedc51a..a4c84dc0ca 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -69,7 +69,7 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int } else { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; memdelete(instance); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } // Construct @@ -93,7 +93,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal } REF ref; - Object *owner = NULL; + Object *owner = nullptr; if (get_instance_base_type() == "") { owner = memnew(Reference); @@ -175,7 +175,7 @@ void PluginScript::update_exports() { // TODO: rename p_this "p_owner" ? ScriptInstance *PluginScript::instance_create(Object *p_this) { - ASSERT_SCRIPT_VALID_V(NULL); + ASSERT_SCRIPT_VALID_V(nullptr); // TODO check script validity ? if (!_tool && !ScriptServer::is_scripting_enabled()) { #ifdef TOOLS_ENABLED @@ -185,7 +185,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) { update_exports(); return si; #else - return NULL; + return nullptr; #endif } @@ -197,12 +197,12 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) { // if (EngineDebugger::is_active()) { // _language->debug_break_parse(get_path(), 0, msg); // } - ERR_FAIL_V_MSG(NULL, msg); + ERR_FAIL_V_MSG(nullptr, msg); } } Callable::CallError unchecked_error; - return _create_instance(NULL, 0, p_this, unchecked_error); + return _create_instance(nullptr, 0, p_this, unchecked_error); } bool PluginScript::instance_has(const Object *p_this) const { @@ -296,7 +296,7 @@ Error PluginScript::reload(bool p_keep_state) { _tool = manifest.is_tool; Dictionary *members = (Dictionary *)&manifest.member_lines; - for (const Variant *key = members->next(); key != NULL; key = members->next(key)) { + for (const Variant *key = members->next(); key != nullptr; key = members->next(key)) { _member_lines[*key] = (*members)[*key]; } Array *methods = (Array *)&manifest.methods; @@ -366,14 +366,14 @@ Error PluginScript::reload(bool p_keep_state) { void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const { ASSERT_SCRIPT_VALID(); - for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != NULL; e = e->next()) { + for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) { r_methods->push_back(e->get()); } } void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const { ASSERT_SCRIPT_VALID(); - for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != NULL; e = e->next()) { + for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) { r_properties->push_back(e->get()); } } @@ -386,7 +386,7 @@ bool PluginScript::has_method(const StringName &p_method) const { MethodInfo PluginScript::get_method_info(const StringName &p_method) const { ASSERT_SCRIPT_VALID_V(MethodInfo()); const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method); - if (e != NULL) { + if (e != nullptr) { return e->get(); } else { return MethodInfo(); @@ -401,7 +401,7 @@ bool PluginScript::has_property(const StringName &p_method) const { PropertyInfo PluginScript::get_property_info(const StringName &p_property) const { ASSERT_SCRIPT_VALID_V(PropertyInfo()); const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property); - if (e != NULL) { + if (e != nullptr) { return e->get(); } else { return PropertyInfo(); @@ -412,7 +412,7 @@ bool PluginScript::get_property_default_value(const StringName &p_property, Vari ASSERT_SCRIPT_VALID_V(false); #ifdef TOOLS_ENABLED const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property); - if (e != NULL) { + if (e != nullptr) { r_value = e->get(); return true; } else { @@ -462,7 +462,7 @@ bool PluginScript::has_script_signal(const StringName &p_signal) const { void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const { ASSERT_SCRIPT_VALID(); - for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != NULL; e = e->next()) { + for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) { r_signals->push_back(e->get()); } } @@ -543,9 +543,9 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable } PluginScript::PluginScript() : - _data(NULL), - _desc(NULL), - _language(NULL), + _data(nullptr), + _desc(nullptr), + _language(nullptr), _tool(false), _valid(false), _script_list(this) { diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index f6e2bad739..fa9f6be5c1 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -33,7 +33,7 @@ #include "core/project_settings.h" #include "servers/audio_server.h" -VideoDecoderServer *VideoDecoderServer::instance = NULL; +VideoDecoderServer *VideoDecoderServer::instance = nullptr; static VideoDecoderServer decoder_server; @@ -113,7 +113,7 @@ void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interfac // VideoStreamPlaybackGDNative starts here. bool VideoStreamPlaybackGDNative::open_file(const String &p_file) { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); file = FileAccess::open(p_file, FileAccess::READ); bool file_opened = interface->open_file(data_struct, file); @@ -150,7 +150,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) { return; } time += p_delta; - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->update(data_struct, p_delta); // Don't mix if there's no audio (num_channels == 0). @@ -189,7 +189,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) { void VideoStreamPlaybackGDNative::update_texture() { PackedByteArray *pba = (PackedByteArray *)interface->get_videoframe(data_struct); - if (pba == NULL) { + if (pba == nullptr) { playing = false; return; } @@ -205,19 +205,19 @@ VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() : texture(Ref<ImageTexture>(memnew(ImageTexture))), playing(false), paused(false), - mix_udata(NULL), - mix_callback(NULL), + mix_udata(nullptr), + mix_callback(nullptr), num_channels(-1), time(0), seek_backward(false), mix_rate(0), delay_compensation(0), - pcm(NULL), + pcm(nullptr), pcm_write_idx(0), samples_decoded(0), - file(NULL), - interface(NULL), - data_struct(NULL) {} + file(nullptr), + interface(nullptr), + data_struct(nullptr) {} VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() { cleanup(); @@ -228,16 +228,16 @@ void VideoStreamPlaybackGDNative::cleanup() { interface->destructor(data_struct); if (pcm) memfree(pcm); - pcm = NULL; + pcm = nullptr; time = 0; num_channels = -1; - interface = NULL; - data_struct = NULL; + interface = nullptr; + data_struct = nullptr; } void VideoStreamPlaybackGDNative::set_interface(const godot_videodecoder_interface_gdnative *p_interface) { - ERR_FAIL_COND(p_interface == NULL); - if (interface != NULL) { + ERR_FAIL_COND(p_interface == nullptr); + if (interface != nullptr) { cleanup(); } interface = p_interface; @@ -272,7 +272,7 @@ void VideoStreamPlaybackGDNative::stop() { } void VideoStreamPlaybackGDNative::seek(float p_time) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->seek(data_struct, p_time); if (p_time < time) seek_backward = true; @@ -292,13 +292,13 @@ Ref<Texture2D> VideoStreamPlaybackGDNative::get_texture() const { } float VideoStreamPlaybackGDNative::get_length() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_length(data_struct); } float VideoStreamPlaybackGDNative::get_playback_position() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_playback_position(data_struct); } @@ -312,7 +312,7 @@ void VideoStreamPlaybackGDNative::set_loop(bool p_enable) { } void VideoStreamPlaybackGDNative::set_audio_track(int p_idx) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_audio_track(data_struct, p_idx); } @@ -323,13 +323,13 @@ void VideoStreamPlaybackGDNative::set_mix_callback(AudioMixCallback p_callback, } int VideoStreamPlaybackGDNative::get_channels() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return (num_channels > 0) ? num_channels : 0; } int VideoStreamPlaybackGDNative::get_mix_rate() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return mix_rate; } @@ -339,13 +339,13 @@ int VideoStreamPlaybackGDNative::get_mix_rate() const { Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() { Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative); VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower()); - if (decoder == NULL) - return NULL; + if (decoder == nullptr) + return nullptr; pb->set_interface(decoder->interface); pb->set_audio_track(audio_track); if (pb->open_file(file)) return pb; - return NULL; + return nullptr; } void VideoStreamGDNative::set_file(const String &p_file) { diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index 8eef6f9098..fbc0d4016f 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -42,7 +42,7 @@ struct VideoDecoderGDNative { Vector<String> supported_extensions; VideoDecoderGDNative() : - interface(NULL), + interface(nullptr), plugin_name("none") {} VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) : @@ -89,7 +89,7 @@ public: VideoDecoderGDNative *get_decoder(const String &extension) { if (extensions.size() == 0 || !extensions.has(extension)) - return NULL; + return nullptr; return decoders[extensions[extension]]; } @@ -102,7 +102,7 @@ public: memdelete(decoders[i]); } decoders.clear(); - instance = NULL; + instance = nullptr; } }; @@ -199,7 +199,7 @@ public: class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; |