Skip to content

Commit

Permalink
Merge pull request #80168 from akien-mga/extension-compat
Browse files Browse the repository at this point in the history
Fix or workaround recent extension API compatibility issues
  • Loading branch information
akien-mga committed Aug 3, 2023
2 parents 0606ba7 + 858e874 commit 4c70849
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 14 deletions.
70 changes: 62 additions & 8 deletions misc/extension_api_validation/4.0-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -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()".
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
2 changes: 1 addition & 1 deletion misc/scripts/clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions scene/2d/tile_map.compat.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* object.compat.inc */
/* tile_map.compat.inc */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -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();
}
Expand Down
41 changes: 41 additions & 0 deletions scene/gui/code_edit.compat.inc
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions scene/gui/code_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "code_edit.h"
#include "code_edit.compat.inc"

#include "core/os/keyboard.h"
#include "core/string/string_builder.h"
Expand Down
5 changes: 5 additions & 0 deletions scene/gui/code_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
41 changes: 41 additions & 0 deletions servers/rendering/rendering_device.compat.inc
Original file line number Diff line number Diff line change
@@ -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<uint8_t> &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
1 change: 1 addition & 0 deletions servers/rendering/rendering_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "rendering_device.h"
#include "rendering_device.compat.inc"

#include "rendering_device_binds.h"

Expand Down
5 changes: 5 additions & 0 deletions servers/rendering/rendering_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> &p_shader_binary);
static void _bind_compatibility_methods();
#endif

Capabilities device_capabilities;

public:
Expand Down

0 comments on commit 4c70849

Please sign in to comment.