diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 0b900f55ddf..9f6e65a3c29 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -174,7 +174,7 @@ Ref ResourceFormatLoader::load(const String &p_path, const String &p_o } } - ERR_FAIL_V_MSG(Ref(), vformat("Failed to load resource '%s'. ResourceFormatLoader::load was not implemented for this resource type.", p_path)); + return Ref(); } void ResourceFormatLoader::get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index d2873863501..1aa33fe3adb 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -70,7 +70,7 @@ protected: GDVIRTUAL2RC(Error, _rename_dependencies, String, Dictionary) GDVIRTUAL1RC(bool, _exists, String) - GDVIRTUAL4RC(Variant, _load, String, String, bool, int) + GDVIRTUAL4RC_REQUIRED(Variant, _load, String, String, bool, int) public: virtual Ref load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); diff --git a/doc/classes/AudioStream.xml b/doc/classes/AudioStream.xml index 2d40cfa9ab5..9a4c2b2af51 100644 --- a/doc/classes/AudioStream.xml +++ b/doc/classes/AudioStream.xml @@ -64,7 +64,7 @@ Override this method to return [code]true[/code] if this stream has a loop. - + Override this method to customize the returned value of [method instantiate_playback]. Should return a new [AudioStreamPlayback] created when the stream is played (such as by an [AudioStreamPlayer]). diff --git a/doc/classes/AudioStreamPlayback.xml b/doc/classes/AudioStreamPlayback.xml index 4550b1841fa..24fdaa3bd34 100644 --- a/doc/classes/AudioStreamPlayback.xml +++ b/doc/classes/AudioStreamPlayback.xml @@ -23,13 +23,13 @@ Return the current value of a playback parameter by name (see [method AudioStream._get_parameter_list]). - + Overridable method. Should return the current progress along the audio stream, in seconds. - + Overridable method. Should return [code]true[/code] if this playback is active and playing its audio stream. @@ -60,14 +60,14 @@ Set the current value of a playback parameter by name (see [method AudioStream._get_parameter_list]). - + Override this method to customize what happens when the playback starts at the given position, such as by calling [method AudioStreamPlayer.play]. - + Override this method to customize what happens when the playback is stopped, such as by calling [method AudioStreamPlayer.stop]. diff --git a/doc/classes/EditorResourcePreviewGenerator.xml b/doc/classes/EditorResourcePreviewGenerator.xml index 89bfe836d76..6c37520e344 100644 --- a/doc/classes/EditorResourcePreviewGenerator.xml +++ b/doc/classes/EditorResourcePreviewGenerator.xml @@ -16,7 +16,7 @@ By default, it returns [code]false[/code]. - + @@ -47,7 +47,7 @@ By default, it returns [code]false[/code]. - + diff --git a/doc/classes/EditorSceneFormatImporter.xml b/doc/classes/EditorSceneFormatImporter.xml index 3440fdc140a..e89d4571934 100644 --- a/doc/classes/EditorSceneFormatImporter.xml +++ b/doc/classes/EditorSceneFormatImporter.xml @@ -10,7 +10,7 @@ - + Return supported file extensions for this scene importer. @@ -34,7 +34,7 @@ Should return [code]true[/code] to show the given option, [code]false[/code] to hide the given option, or [code]null[/code] to ignore. - + diff --git a/doc/classes/ResourceFormatLoader.xml b/doc/classes/ResourceFormatLoader.xml index 9dba7440e5d..c6a4d24f82a 100644 --- a/doc/classes/ResourceFormatLoader.xml +++ b/doc/classes/ResourceFormatLoader.xml @@ -80,7 +80,7 @@ [b]Note:[/b] Custom resource types defined by scripts aren't known by the [ClassDB], so you might just handle [code]"Resource"[/code] for them. - + diff --git a/doc/classes/VideoStream.xml b/doc/classes/VideoStream.xml index 271330a5986..c7974dc24e9 100644 --- a/doc/classes/VideoStream.xml +++ b/doc/classes/VideoStream.xml @@ -11,7 +11,7 @@ $DOCS_URL/tutorials/io/runtime_file_loading_and_saving.html - + Called when the video starts playing, to initialize and return a subclass of [VideoStreamPlayback]. diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 64e870ca17c..b0d139fccde 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -59,14 +59,10 @@ void EditorSceneFormatImporter::get_extensions(List *r_extensions) const { Vector arr; - if (GDVIRTUAL_CALL(_get_extensions, arr)) { - for (int i = 0; i < arr.size(); i++) { - r_extensions->push_back(arr[i]); - } - return; + GDVIRTUAL_CALL(_get_extensions, arr); + for (int i = 0; i < arr.size(); i++) { + r_extensions->push_back(arr[i]); } - - ERR_FAIL(); } Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap &p_options, List *r_missing_deps, Error *r_err) { @@ -75,11 +71,8 @@ Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_f options_dict[elem.key] = elem.value; } Object *ret = nullptr; - if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, options_dict, ret)) { - return Object::cast_to(ret); - } - - ERR_FAIL_V(nullptr); + GDVIRTUAL_CALL(_import_scene, p_path, p_flags, options_dict, ret); + return Object::cast_to(ret); } void EditorSceneFormatImporter::add_import_option(const String &p_name, const Variant &p_default_value) { diff --git a/editor/import/3d/resource_importer_scene.h b/editor/import/3d/resource_importer_scene.h index 071d294b0e3..4077b74a24b 100644 --- a/editor/import/3d/resource_importer_scene.h +++ b/editor/import/3d/resource_importer_scene.h @@ -57,8 +57,8 @@ protected: Node *import_scene_wrapper(const String &p_path, uint32_t p_flags, const Dictionary &p_options); Ref import_animation_wrapper(const String &p_path, uint32_t p_flags, const Dictionary &p_options); - GDVIRTUAL0RC(Vector, _get_extensions) - GDVIRTUAL3R(Object *, _import_scene, String, uint32_t, Dictionary) + GDVIRTUAL0RC_REQUIRED(Vector, _get_extensions) + GDVIRTUAL3R_REQUIRED(Object *, _import_scene, String, uint32_t, Dictionary) GDVIRTUAL1(_get_import_options, String) GDVIRTUAL3RC(Variant, _get_option_visibility, String, bool, String) diff --git a/editor/inspector/editor_resource_preview.cpp b/editor/inspector/editor_resource_preview.cpp index 68ec8b3b872..e7fc677212a 100644 --- a/editor/inspector/editor_resource_preview.cpp +++ b/editor/inspector/editor_resource_preview.cpp @@ -46,18 +46,14 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const { bool success = false; - if (GDVIRTUAL_CALL(_handles, p_type, success)) { - return success; - } - ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::_handles needs to be overridden."); + GDVIRTUAL_CALL(_handles, p_type, success); + return success; } Ref EditorResourcePreviewGenerator::generate(const Ref &p_from, const Size2 &p_size, Dictionary &p_metadata) const { Ref preview; - if (GDVIRTUAL_CALL(_generate, p_from, p_size, p_metadata, preview)) { - return preview; - } - ERR_FAIL_V_MSG(Ref(), "EditorResourcePreviewGenerator::_generate needs to be overridden."); + GDVIRTUAL_CALL(_generate, p_from, p_size, p_metadata, preview); + return preview; } Ref EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const { diff --git a/editor/inspector/editor_resource_preview.h b/editor/inspector/editor_resource_preview.h index 5b25b5c6113..899986bdb97 100644 --- a/editor/inspector/editor_resource_preview.h +++ b/editor/inspector/editor_resource_preview.h @@ -44,8 +44,8 @@ class EditorResourcePreviewGenerator : public RefCounted { protected: static void _bind_methods(); - GDVIRTUAL1RC(bool, _handles, String) - GDVIRTUAL3RC(Ref, _generate, Ref, Vector2i, Dictionary) + GDVIRTUAL1RC_REQUIRED(bool, _handles, String) + GDVIRTUAL3RC_REQUIRED(Ref, _generate, Ref, Vector2i, Dictionary) GDVIRTUAL3RC(Ref, _generate_from_path, String, Vector2i, Dictionary) GDVIRTUAL0RC(bool, _generate_small_preview_automatically) GDVIRTUAL0RC(bool, _can_generate_small_preview) diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index 79aff4bed71..d08cc69509a 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -94,7 +94,7 @@ class VideoStream : public Resource { protected: static void _bind_methods(); - GDVIRTUAL0R(Ref, _instantiate_playback); + GDVIRTUAL0R_REQUIRED(Ref, _instantiate_playback); String file; int audio_track = 0; diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 440acb72e57..bf328689be2 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -33,23 +33,15 @@ #include "core/config/project_settings.h" void AudioStreamPlayback::start(double p_from_pos) { - if (GDVIRTUAL_CALL(_start, p_from_pos)) { - return; - } - ERR_FAIL_MSG("AudioStreamPlayback::start unimplemented!"); + GDVIRTUAL_CALL(_start, p_from_pos); } void AudioStreamPlayback::stop() { - if (GDVIRTUAL_CALL(_stop)) { - return; - } - ERR_FAIL_MSG("AudioStreamPlayback::stop unimplemented!"); + GDVIRTUAL_CALL(_stop); } bool AudioStreamPlayback::is_playing() const { - bool ret; - if (GDVIRTUAL_CALL(_is_playing, ret)) { - return ret; - } - ERR_FAIL_V_MSG(false, "AudioStreamPlayback::is_playing unimplemented!"); + bool ret = false; + GDVIRTUAL_CALL(_is_playing, ret); + return ret; } int AudioStreamPlayback::get_loop_count() const { @@ -59,11 +51,9 @@ int AudioStreamPlayback::get_loop_count() const { } double AudioStreamPlayback::get_playback_position() const { - double ret; - if (GDVIRTUAL_CALL(_get_playback_position, ret)) { - return ret; - } - ERR_FAIL_V_MSG(0, "AudioStreamPlayback::get_playback_position unimplemented!"); + double ret = 0.0; + GDVIRTUAL_CALL(_get_playback_position, ret); + return ret; } void AudioStreamPlayback::seek(double p_time) { GDVIRTUAL_CALL(_seek, p_time); @@ -250,10 +240,8 @@ int AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale, Ref AudioStream::instantiate_playback() { Ref ret; - if (GDVIRTUAL_CALL(_instantiate_playback, ret)) { - return ret; - } - ERR_FAIL_V_MSG(Ref(), "Method must be implemented!"); + GDVIRTUAL_CALL(_instantiate_playback, ret); + return ret; } String AudioStream::get_stream_name() const { String ret; diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 57f78dd32bc..aa7edbb0da4 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -81,11 +81,11 @@ class AudioStreamPlayback : public RefCounted { protected: static void _bind_methods(); PackedVector2Array _mix_audio_bind(float p_rate_scale, int p_frames); - GDVIRTUAL1(_start, double) - GDVIRTUAL0(_stop) - GDVIRTUAL0RC(bool, _is_playing) + GDVIRTUAL1_REQUIRED(_start, double) + GDVIRTUAL0_REQUIRED(_stop) + GDVIRTUAL0RC_REQUIRED(bool, _is_playing) GDVIRTUAL0RC(int, _get_loop_count) - GDVIRTUAL0RC(double, _get_playback_position) + GDVIRTUAL0RC_REQUIRED(double, _get_playback_position) GDVIRTUAL1(_seek, double) GDVIRTUAL3R_REQUIRED(int, _mix, GDExtensionPtr, float, int) GDVIRTUAL0(_tag_used_streams) @@ -170,7 +170,7 @@ class AudioStream : public Resource { protected: static void _bind_methods(); - GDVIRTUAL0RC(Ref, _instantiate_playback) + GDVIRTUAL0RC_REQUIRED(Ref, _instantiate_playback) GDVIRTUAL0RC(String, _get_stream_name) GDVIRTUAL0RC(double, _get_length) GDVIRTUAL0RC(bool, _is_monophonic)