From 858e8748e817e99509d1a8e03c9ee6b309def81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 2 Aug 2023 14:45:44 +0200 Subject: [PATCH] Fix or workaround recent extension API compatibility issues - Add compatibility methods for `RenderingDevice::shader_create_from_bytecode` and `CodeEdit::get_text_for_symbol_loopup`. - Silence errors which now have compatibility methods. - Acknowledge GraphEdit/GraphNode compat breakage, intended and WIP. --- .../4.0-stable.expected | 70 ++++++++++++++++--- misc/scripts/clang_format.sh | 2 +- scene/2d/tile_map.compat.inc | 6 +- scene/gui/code_edit.compat.inc | 41 +++++++++++ scene/gui/code_edit.cpp | 1 + scene/gui/code_edit.h | 5 ++ servers/rendering/rendering_device.compat.inc | 41 +++++++++++ servers/rendering/rendering_device.cpp | 1 + servers/rendering/rendering_device.h | 5 ++ 9 files changed, 158 insertions(+), 14 deletions(-) create mode 100644 scene/gui/code_edit.compat.inc create mode 100644 servers/rendering/rendering_device.compat.inc diff --git a/misc/extension_api_validation/4.0-stable.expected b/misc/extension_api_validation/4.0-stable.expected index 380c1d519309..9dc852d5b970 100644 --- a/misc/extension_api_validation/4.0-stable.expected +++ b/misc/extension_api_validation/4.0-stable.expected @@ -4,8 +4,21 @@ This file contains the expected output of --validate-extension-api when run agai Only lines that start with "Validate extension JSON:" matter, everything else is considered a comment and ignored. They should instead be used to justify these changes and describe how users should work around these changes. +Add new entries at the end of the file. + ======================================================================================================================== +Misc +---- +Validate extension JSON: API was removed: classes/FramebufferCacheRD +Validate extension JSON: API was removed: classes/UniformSetCacheRD + +FIXME: These aren't written when dumping the interface with a headless build +(since there's no RD backend in use). We need to fix this inconsistency somehow. + + +## Changes between 4.0-stable and 4.1-stable + GH-78517 -------- Validate extension JSON: Error: Field 'classes/DisplayServer/methods/global_menu_add_check_item/arguments/2': default_value changed value in new API, from "" to "Callable()". @@ -36,10 +49,12 @@ Validate extension JSON: Error: Field 'classes/RenderingServer/methods/instances The previous argument was a serialization bug, there's no actual API change. + GH-78237 -------- Validate extension JSON: Error: Field 'classes/WebRTCPeerConnectionExtension/methods/_create_data_channel/return_value': type changed value in new API, from "Object" to "WebRTCDataChannel". + GH-77757 -------- Validate extension JSON: Error: Field 'classes/Viewport/methods/gui_get_focus_owner': is_const changed value in new API, from false to true. @@ -136,13 +151,6 @@ Navigation avoidance was reworked entirely. Migration: TODO -GH-????? --------- -Validate extension JSON: API was removed: classes/FramebufferCacheRD -Validate extension JSON: API was removed: classes/UniformSetCacheRD - -Unsure where these come from; when dumping the interface, these do actually still exist - GH-76176 -------- Validate extension JSON: Error: Hash changed for 'classes/EditorInterface/methods/get_base_control', from 31757941 to A5E188F5. This means that the function has changed and no compatibility function was provided. @@ -260,7 +268,6 @@ Validate extension JSON: Error: Field 'classes/SyntaxHighlighter/methods/get_tex Function was made `const`. No adjustments should be necessary. - GH-75250 & GH-76401 ------------------- Validate extension JSON: Error: Hash changed for 'classes/RichTextLabel/methods/push_paragraph', from 3DD1D1C2 to BFDC71FE. This means that the function has changed and no compatibility function was provided. @@ -359,6 +366,9 @@ Validate extension JSON: Error: Hash changed for 'classes/UndoRedo/methods/creat Added a optional parameters with default values. No adjustments should be necessary. + +## Changes between 4.1-stable and 4.2-stable + GH-79911 -------- Validate extension JSON: Error: Field 'classes/RenderingDevice/enums/BarrierMask/values/BARRIER_MASK_RASTER': value changed value in new API, from 1.0 to 9. @@ -379,3 +389,47 @@ Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/barrier/a Validate extension JSON: Error: Hash changed for 'classes/RenderingDevice/methods/barrier', from 0FE50041 to DD9E8DAB. This means that the function has changed and no compatibility function was provided. Raster barrier was split into vertex and fragment barriers for use in mobile renderer. + + +GH-79308 +-------- +Validate extension JSON: API was removed: classes/GraphEdit/methods/get_scroll_ofs +Validate extension JSON: API was removed: classes/GraphEdit/methods/get_snap +Validate extension JSON: API was removed: classes/GraphEdit/methods/get_zoom_hbox +Validate extension JSON: API was removed: classes/GraphEdit/methods/is_using_snap +Validate extension JSON: API was removed: classes/GraphEdit/methods/set_scroll_ofs +Validate extension JSON: API was removed: classes/GraphEdit/methods/set_snap +Validate extension JSON: API was removed: classes/GraphEdit/methods/set_use_snap +Validate extension JSON: API was removed: classes/GraphEdit/properties/snap_distance +Validate extension JSON: API was removed: classes/GraphEdit/properties/use_snap +Validate extension JSON: API was removed: classes/GraphNode/methods/is_comment +Validate extension JSON: API was removed: classes/GraphNode/methods/set_comment +Validate extension JSON: API was removed: classes/GraphNode/properties/comment +Validate extension JSON: Error: Field 'classes/GraphEdit/properties/scroll_offset': getter changed value in new API, from "get_scroll_ofs" to &"get_scroll_offset". +Validate extension JSON: Error: Field 'classes/GraphEdit/properties/scroll_offset': setter changed value in new API, from "set_scroll_ofs" to &"set_scroll_offset". + +Intentional compatibility breakage during refactoring of API marked as experimental. + +FIXME: Still a WIP, review this list once the work is completed, especially if compatibility +code is added. + + +GH-73196 +-------- +Validate extension JSON: Error: Field 'classes/CodeEdit/methods/get_text_for_symbol_lookup': is_const changed value in new API, from false to true. + +Function was made `const`. No adjustments should be necessary. + + +GH-78328 +-------- +Validate extension JSON: Error: Field 'classes/TileMap/methods/get_used_rect': is_const changed value in new API, from false to true. + +Function was made `const`. No adjustments should be necessary. + + +GH-79606 +-------- +Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/shader_create_from_bytecode/arguments': size changed value in new API, from 1 to 2. + +Added optional argument. Compatibility method registered. diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh index 74a8e1a8a3aa..40d94d42761a 100755 --- a/misc/scripts/clang_format.sh +++ b/misc/scripts/clang_format.sh @@ -21,7 +21,7 @@ fi # Fix copyright headers, but not all files get them. for f in $files; do - if [[ "$f" == *"inc" ]]; then + if [[ "$f" == *"inc" && "$f" != *"compat.inc" ]]; then continue elif [[ "$f" == *"glsl" ]]; then continue diff --git a/scene/2d/tile_map.compat.inc b/scene/2d/tile_map.compat.inc index 49e2bf6f0b7f..c7786eccede7 100644 --- a/scene/2d/tile_map.compat.inc +++ b/scene/2d/tile_map.compat.inc @@ -1,5 +1,5 @@ /**************************************************************************/ -/* object.compat.inc */ +/* tile_map.compat.inc */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,10 +30,6 @@ #ifndef DISABLE_DEPRECATED -#include "core/object/object.h" - -#include "core/object/class_db.h" - Rect2i TileMap::_get_used_rect_bind_compat_78328() { return get_used_rect(); } diff --git a/scene/gui/code_edit.compat.inc b/scene/gui/code_edit.compat.inc new file mode 100644 index 000000000000..9107d6523f95 --- /dev/null +++ b/scene/gui/code_edit.compat.inc @@ -0,0 +1,41 @@ +/**************************************************************************/ +/* code_edit.compat.inc */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef DISABLE_DEPRECATED + +String CodeEdit::_get_text_for_symbol_lookup_bind_compat_73196() { + return get_text_for_symbol_lookup(); +} + +void CodeEdit::_bind_compatibility_methods() { + ClassDB::bind_compatibility_method(D_METHOD("get_text_for_symbol_lookup"), &CodeEdit::_get_text_for_symbol_lookup_bind_compat_73196); +} + +#endif diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index eee59606e399..68241337c9b2 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "code_edit.h" +#include "code_edit.compat.inc" #include "core/os/keyboard.h" #include "core/string/string_builder.h" diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index a3c968da60b7..addbb6e46806 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -287,6 +287,11 @@ class CodeEdit : public TextEdit { void _notification(int p_what); static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + String _get_text_for_symbol_lookup_bind_compat_73196(); + static void _bind_compatibility_methods(); +#endif + virtual void _update_theme_item_cache() override; /* Text manipulation */ diff --git a/servers/rendering/rendering_device.compat.inc b/servers/rendering/rendering_device.compat.inc new file mode 100644 index 000000000000..dc7817e66bdd --- /dev/null +++ b/servers/rendering/rendering_device.compat.inc @@ -0,0 +1,41 @@ +/**************************************************************************/ +/* rendering_device.compat.inc */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef DISABLE_DEPRECATED + +RID RenderingDevice::_shader_create_from_bytecode_bind_compat_79606(const Vector &p_shader_binary) { + return shader_create_from_bytecode(p_shader_binary, RID()); +} + +void RenderingDevice::_bind_compatibility_methods() { + ClassDB::bind_compatibility_method(D_METHOD("shader_create_from_bytecode", "binary_data"), &RenderingDevice::_shader_create_from_bytecode_bind_compat_79606); +} + +#endif diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 1b0a3e9d0fcb..4e1ff07be464 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "rendering_device.h" +#include "rendering_device.compat.inc" #include "rendering_device_binds.h" diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 58da3df57786..30d9b1c7b721 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -141,6 +141,11 @@ class RenderingDevice : public Object { protected: static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + RID _shader_create_from_bytecode_bind_compat_79606(const Vector &p_shader_binary); + static void _bind_compatibility_methods(); +#endif + Capabilities device_capabilities; public: