Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change AudioStreamPlayer autoplay and GLTFBufferView getters to be const #86907

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions misc/extension_api_validation/4.2-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ Validate extension JSON: Error: Field 'classes/GPUParticles3D/properties/process
Validate extension JSON: Error: Field 'classes/Sky/properties/sky_material': type changed value in new API, from "ShaderMaterial,PanoramaSkyMaterial,ProceduralSkyMaterial,PhysicalSkyMaterial" to "PanoramaSkyMaterial,ProceduralSkyMaterial,PhysicalSkyMaterial,ShaderMaterial".

Property hints reordered to improve editor usability. The types allowed are still the same as before. No adjustments should be necessary.


GH-86907
--------

Validate extension JSON: Error: Field 'classes/AudioStreamPlayer/methods/is_autoplay_enabled': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/AudioStreamPlayer2D/methods/is_autoplay_enabled': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/AudioStreamPlayer3D/methods/is_autoplay_enabled': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/get_buffer': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/get_byte_length': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/get_byte_offset': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/get_byte_stride': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/get_indices': is_const changed value in new API, from false to true.

Change AudioStreamPlayer* is_autoplay_enabled and GLTFBufferView getters to be const.
61 changes: 61 additions & 0 deletions modules/gltf/structures/gltf_buffer_view.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**************************************************************************/
/* gltf_buffer_view.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

GLTFBufferIndex GLTFBufferView::_get_buffer_bind_compat_86907() {
return get_buffer();
}

int GLTFBufferView::_get_byte_offset_bind_compat_86907() {
return get_byte_offset();
}

int GLTFBufferView::_get_byte_length_bind_compat_86907() {
return get_byte_length();
}

int GLTFBufferView::_get_byte_stride_bind_compat_86907() {
return get_byte_stride();
}

bool GLTFBufferView::_get_indices_bind_compat_86907() {
return get_indices();
}

void GLTFBufferView::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("get_buffer"), &GLTFBufferView::_get_buffer_bind_compat_86907);
ClassDB::bind_compatibility_method(D_METHOD("get_byte_offset"), &GLTFBufferView::_get_byte_offset_bind_compat_86907);
ClassDB::bind_compatibility_method(D_METHOD("get_byte_length"), &GLTFBufferView::_get_byte_length_bind_compat_86907);
ClassDB::bind_compatibility_method(D_METHOD("get_byte_stride"), &GLTFBufferView::_get_byte_stride_bind_compat_86907);
ClassDB::bind_compatibility_method(D_METHOD("get_indices"), &GLTFBufferView::_get_indices_bind_compat_86907);
}

#endif // DISABLE_DEPRECATED
11 changes: 6 additions & 5 deletions modules/gltf/structures/gltf_buffer_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "gltf_buffer_view.h"
#include "gltf_buffer_view.compat.inc"

#include "../gltf_state.h"

Expand All @@ -53,39 +54,39 @@ void GLTFBufferView::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indices"), "set_indices", "get_indices"); // bool
}

GLTFBufferIndex GLTFBufferView::get_buffer() {
GLTFBufferIndex GLTFBufferView::get_buffer() const {
return buffer;
}

void GLTFBufferView::set_buffer(GLTFBufferIndex p_buffer) {
buffer = p_buffer;
}

int GLTFBufferView::get_byte_offset() {
int GLTFBufferView::get_byte_offset() const {
return byte_offset;
}

void GLTFBufferView::set_byte_offset(int p_byte_offset) {
byte_offset = p_byte_offset;
}

int GLTFBufferView::get_byte_length() {
int GLTFBufferView::get_byte_length() const {
return byte_length;
}

void GLTFBufferView::set_byte_length(int p_byte_length) {
byte_length = p_byte_length;
}

int GLTFBufferView::get_byte_stride() {
int GLTFBufferView::get_byte_stride() const {
return byte_stride;
}

void GLTFBufferView::set_byte_stride(int p_byte_stride) {
byte_stride = p_byte_stride;
}

bool GLTFBufferView::get_indices() {
bool GLTFBufferView::get_indices() const {
return indices;
}

Expand Down
19 changes: 14 additions & 5 deletions modules/gltf/structures/gltf_buffer_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,29 @@ class GLTFBufferView : public Resource {
protected:
static void _bind_methods();

#ifndef DISABLE_DEPRECATED
GLTFBufferIndex _get_buffer_bind_compat_86907();
int _get_byte_offset_bind_compat_86907();
int _get_byte_length_bind_compat_86907();
int _get_byte_stride_bind_compat_86907();
bool _get_indices_bind_compat_86907();
static void _bind_compatibility_methods();
#endif // DISABLE_DEPRECATED

public:
GLTFBufferIndex get_buffer();
GLTFBufferIndex get_buffer() const;
void set_buffer(GLTFBufferIndex p_buffer);

int get_byte_offset();
int get_byte_offset() const;
void set_byte_offset(int p_byte_offset);

int get_byte_length();
int get_byte_length() const;
void set_byte_length(int p_byte_length);

int get_byte_stride();
int get_byte_stride() const;
void set_byte_stride(int p_byte_stride);

bool get_indices();
bool get_indices() const;
void set_indices(bool p_indices);

Vector<uint8_t> load_buffer_view_data(const Ref<GLTFState> p_state) const;
Expand Down
41 changes: 41 additions & 0 deletions scene/2d/audio_stream_player_2d.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**************************************************************************/
/* audio_stream_player_2d.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

bool AudioStreamPlayer2D::_is_autoplay_enabled_bind_compat_86907() {
return is_autoplay_enabled();
}

void AudioStreamPlayer2D::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("is_autoplay_enabled"), &AudioStreamPlayer2D::_is_autoplay_enabled_bind_compat_86907);
}

#endif // DISABLE_DEPRECATED
3 changes: 2 additions & 1 deletion scene/2d/audio_stream_player_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "audio_stream_player_2d.h"
#include "audio_stream_player_2d.compat.inc"

#include "core/config/project_settings.h"
#include "scene/2d/area_2d.h"
Expand Down Expand Up @@ -251,7 +252,7 @@ void AudioStreamPlayer2D::set_autoplay(bool p_enable) {
internal->autoplay = p_enable;
}

bool AudioStreamPlayer2D::is_autoplay_enabled() {
bool AudioStreamPlayer2D::is_autoplay_enabled() const {
return internal->autoplay;
}

Expand Down
7 changes: 6 additions & 1 deletion scene/2d/audio_stream_player_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class AudioStreamPlayer2D : public Node2D {
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;

#ifndef DISABLE_DEPRECATED
bool _is_autoplay_enabled_bind_compat_86907();
static void _bind_compatibility_methods();
#endif // DISABLE_DEPRECATED

public:
void set_stream(Ref<AudioStream> p_stream);
Ref<AudioStream> get_stream() const;
Expand All @@ -109,7 +114,7 @@ class AudioStreamPlayer2D : public Node2D {
StringName get_bus() const;

void set_autoplay(bool p_enable);
bool is_autoplay_enabled();
bool is_autoplay_enabled() const;

void set_max_distance(float p_pixels);
float get_max_distance() const;
Expand Down
41 changes: 41 additions & 0 deletions scene/3d/audio_stream_player_3d.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**************************************************************************/
/* audio_stream_player_3d.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

bool AudioStreamPlayer3D::_is_autoplay_enabled_bind_compat_86907() {
return is_autoplay_enabled();
}

void AudioStreamPlayer3D::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("is_autoplay_enabled"), &AudioStreamPlayer3D::_is_autoplay_enabled_bind_compat_86907);
}

#endif // DISABLE_DEPRECATED
3 changes: 2 additions & 1 deletion scene/3d/audio_stream_player_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "audio_stream_player_3d.h"
#include "audio_stream_player_3d.compat.inc"

#include "core/config/project_settings.h"
#include "scene/3d/area_3d.h"
Expand Down Expand Up @@ -571,7 +572,7 @@ void AudioStreamPlayer3D::set_autoplay(bool p_enable) {
internal->autoplay = p_enable;
}

bool AudioStreamPlayer3D::is_autoplay_enabled() {
bool AudioStreamPlayer3D::is_autoplay_enabled() const {
return internal->autoplay;
}

Expand Down
7 changes: 6 additions & 1 deletion scene/3d/audio_stream_player_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ class AudioStreamPlayer3D : public Node3D {
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;

#ifndef DISABLE_DEPRECATED
bool _is_autoplay_enabled_bind_compat_86907();
static void _bind_compatibility_methods();
#endif // DISABLE_DEPRECATED

public:
void set_stream(Ref<AudioStream> p_stream);
Ref<AudioStream> get_stream() const;
Expand Down Expand Up @@ -150,7 +155,7 @@ class AudioStreamPlayer3D : public Node3D {
int get_max_polyphony() const;

void set_autoplay(bool p_enable);
bool is_autoplay_enabled();
bool is_autoplay_enabled() const;

void set_max_distance(float p_metres);
float get_max_distance() const;
Expand Down
41 changes: 41 additions & 0 deletions scene/audio/audio_stream_player.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**************************************************************************/
/* audio_stream_player.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

bool AudioStreamPlayer::_is_autoplay_enabled_bind_compat_86907() {
return is_autoplay_enabled();
}

void AudioStreamPlayer::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("is_autoplay_enabled"), &AudioStreamPlayer::_is_autoplay_enabled_bind_compat_86907);
}

#endif // DISABLE_DEPRECATED
3 changes: 2 additions & 1 deletion scene/audio/audio_stream_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "audio_stream_player.h"
#include "audio_stream_player.compat.inc"

#include "scene/audio/audio_stream_player_internal.h"
#include "servers/audio/audio_stream.h"
Expand Down Expand Up @@ -126,7 +127,7 @@ void AudioStreamPlayer::set_autoplay(bool p_enable) {
internal->autoplay = p_enable;
}

bool AudioStreamPlayer::is_autoplay_enabled() {
bool AudioStreamPlayer::is_autoplay_enabled() const {
return internal->autoplay;
}

Expand Down
Loading
Loading