Simplify GDVIRTUAL_REQUIRED_CALL calls

This commit is contained in:
kobewi 2022-11-30 16:40:50 +01:00
parent cd491c6e47
commit 9a3960daa5
8 changed files with 124 additions and 233 deletions

View File

@ -148,10 +148,8 @@ bool EditorExportPlugin::_begin_customize_resources(const Ref<EditorExportPlatfo
Ref<Resource> EditorExportPlugin::_customize_resource(const Ref<Resource> &p_resource, const String &p_path) {
Ref<Resource> ret;
if (GDVIRTUAL_REQUIRED_CALL(_customize_resource, p_resource, p_path, ret)) {
return ret;
}
return Ref<Resource>();
GDVIRTUAL_REQUIRED_CALL(_customize_resource, p_resource, p_path, ret);
return ret;
}
bool EditorExportPlugin::_begin_customize_scenes(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features) const {
@ -162,18 +160,14 @@ bool EditorExportPlugin::_begin_customize_scenes(const Ref<EditorExportPlatform>
Node *EditorExportPlugin::_customize_scene(Node *p_root, const String &p_path) {
Node *ret = nullptr;
if (GDVIRTUAL_REQUIRED_CALL(_customize_scene, p_root, p_path, ret)) {
return ret;
}
return nullptr;
GDVIRTUAL_REQUIRED_CALL(_customize_scene, p_root, p_path, ret);
return ret;
}
uint64_t EditorExportPlugin::_get_customization_configuration_hash() const {
uint64_t ret = 0;
if (GDVIRTUAL_REQUIRED_CALL(_get_customization_configuration_hash, ret)) {
return ret;
}
return 0;
GDVIRTUAL_REQUIRED_CALL(_get_customization_configuration_hash, ret);
return ret;
}
void EditorExportPlugin::_end_customize_scenes() {
@ -186,10 +180,8 @@ void EditorExportPlugin::_end_customize_resources() {
String EditorExportPlugin::_get_name() const {
String ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_name, ret)) {
return ret;
}
return "";
GDVIRTUAL_REQUIRED_CALL(_get_name, ret);
return ret;
}
void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) {

View File

@ -92,18 +92,13 @@ void Material::inspect_native_shader_code() {
RID Material::get_shader_rid() const {
RID ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_shader_rid, ret)) {
return ret;
}
return RID();
GDVIRTUAL_REQUIRED_CALL(_get_shader_rid, ret);
return ret;
}
Shader::Mode Material::get_shader_mode() const {
Shader::Mode ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_shader_mode, ret)) {
return ret;
}
return Shader::MODE_MAX;
Shader::Mode ret = Shader::MODE_MAX;
GDVIRTUAL_REQUIRED_CALL(_get_shader_mode, ret);
return ret;
}
bool Material::_can_do_next_pass() const {

View File

@ -40,119 +40,83 @@
Mesh::ConvexDecompositionFunc Mesh::convex_decomposition_function = nullptr;
int Mesh::get_surface_count() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_surface_count, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_surface_count, ret);
return ret;
}
int Mesh::surface_get_array_len(int p_idx) const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_array_len, p_idx, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_surface_get_array_len, p_idx, ret);
return ret;
}
int Mesh::surface_get_array_index_len(int p_idx) const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_array_index_len, p_idx, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_surface_get_array_index_len, p_idx, ret);
return ret;
}
Array Mesh::surface_get_arrays(int p_surface) const {
Array ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_arrays, p_surface, ret)) {
return ret;
}
return Array();
GDVIRTUAL_REQUIRED_CALL(_surface_get_arrays, p_surface, ret);
return ret;
}
TypedArray<Array> Mesh::surface_get_blend_shape_arrays(int p_surface) const {
TypedArray<Array> ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_blend_shape_arrays, p_surface, ret)) {
return ret;
}
return TypedArray<Array>();
GDVIRTUAL_REQUIRED_CALL(_surface_get_blend_shape_arrays, p_surface, ret);
return ret;
}
Dictionary Mesh::surface_get_lods(int p_surface) const {
Dictionary ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_lods, p_surface, ret)) {
return ret;
}
return Dictionary();
GDVIRTUAL_REQUIRED_CALL(_surface_get_lods, p_surface, ret);
return ret;
}
uint32_t Mesh::surface_get_format(int p_idx) const {
uint32_t ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_format, p_idx, ret)) {
return ret;
}
return 0;
uint32_t ret = 0;
GDVIRTUAL_REQUIRED_CALL(_surface_get_format, p_idx, ret);
return ret;
}
Mesh::PrimitiveType Mesh::surface_get_primitive_type(int p_idx) const {
uint32_t ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_primitive_type, p_idx, ret)) {
return (Mesh::PrimitiveType)ret;
}
return PRIMITIVE_MAX;
uint32_t ret = PRIMITIVE_MAX;
GDVIRTUAL_REQUIRED_CALL(_surface_get_primitive_type, p_idx, ret);
return (Mesh::PrimitiveType)ret;
}
void Mesh::surface_set_material(int p_idx, const Ref<Material> &p_material) {
if (GDVIRTUAL_REQUIRED_CALL(_surface_set_material, p_idx, p_material)) {
return;
}
GDVIRTUAL_REQUIRED_CALL(_surface_set_material, p_idx, p_material);
}
Ref<Material> Mesh::surface_get_material(int p_idx) const {
Ref<Material> ret;
if (GDVIRTUAL_REQUIRED_CALL(_surface_get_material, p_idx, ret)) {
return ret;
}
return Ref<Material>();
GDVIRTUAL_REQUIRED_CALL(_surface_get_material, p_idx, ret);
return ret;
}
int Mesh::get_blend_shape_count() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_blend_shape_count, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_blend_shape_count, ret);
return ret;
}
StringName Mesh::get_blend_shape_name(int p_index) const {
StringName ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_blend_shape_name, p_index, ret)) {
return ret;
}
return StringName();
GDVIRTUAL_REQUIRED_CALL(_get_blend_shape_name, p_index, ret);
return ret;
}
void Mesh::set_blend_shape_name(int p_index, const StringName &p_name) {
if (GDVIRTUAL_REQUIRED_CALL(_set_blend_shape_name, p_index, p_name)) {
return;
}
GDVIRTUAL_REQUIRED_CALL(_set_blend_shape_name, p_index, p_name);
}
AABB Mesh::get_aabb() const {
AABB ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_aabb, ret)) {
return ret;
}
return AABB();
GDVIRTUAL_REQUIRED_CALL(_get_aabb, ret);
return ret;
}
Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {

View File

@ -35,11 +35,9 @@
#include <limits.h>
float StyleBox::get_style_margin(Side p_side) const {
float ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_style_margin, p_side, ret)) {
return ret;
}
return 0;
float ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_style_margin, p_side, ret);
return ret;
}
bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
@ -49,9 +47,7 @@ bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
}
void StyleBox::draw(RID p_canvas_item, const Rect2 &p_rect) const {
if (GDVIRTUAL_REQUIRED_CALL(_draw, p_canvas_item, p_rect)) {
return;
}
GDVIRTUAL_REQUIRED_CALL(_draw, p_canvas_item, p_rect);
}
void StyleBox::set_default_margin(Side p_side, float p_value) {

View File

@ -40,19 +40,15 @@
#include "servers/camera/camera_feed.h"
int Texture2D::get_width() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_width, ret);
return ret;
}
int Texture2D::get_height() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_height, ret);
return ret;
}
Size2 Texture2D::get_size() const {
@ -1092,57 +1088,44 @@ TypedArray<Image> Texture3D::_get_datai() const {
}
Image::Format Texture3D::get_format() const {
Image::Format ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_format, ret)) {
return ret;
}
return Image::FORMAT_MAX;
Image::Format ret = Image::FORMAT_MAX;
GDVIRTUAL_REQUIRED_CALL(_get_format, ret);
return ret;
}
int Texture3D::get_width() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_width, ret);
return ret;
}
int Texture3D::get_height() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_height, ret);
return ret;
}
int Texture3D::get_depth() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_depth, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_depth, ret);
return ret;
}
bool Texture3D::has_mipmaps() const {
bool ret;
if (GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret)) {
return ret;
}
return false;
bool ret = false;
GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret);
return ret;
}
Vector<Ref<Image>> Texture3D::get_data() const {
TypedArray<Image> ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_data, ret)) {
Vector<Ref<Image>> data;
data.resize(ret.size());
for (int i = 0; i < data.size(); i++) {
data.write[i] = ret[i];
}
return data;
GDVIRTUAL_REQUIRED_CALL(_get_data, ret);
Vector<Ref<Image>> data;
data.resize(ret.size());
for (int i = 0; i < data.size(); i++) {
data.write[i] = ret[i];
}
return Vector<Ref<Image>>();
return data;
}
void Texture3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_format"), &Texture3D::get_format);
@ -2859,60 +2842,45 @@ AnimatedTexture::~AnimatedTexture() {
///////////////////////////////
Image::Format TextureLayered::get_format() const {
Image::Format ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_format, ret)) {
return ret;
}
return Image::FORMAT_MAX;
Image::Format ret = Image::FORMAT_MAX;
GDVIRTUAL_REQUIRED_CALL(_get_format, ret);
return ret;
}
TextureLayered::LayeredType TextureLayered::get_layered_type() const {
uint32_t ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_layered_type, ret)) {
return (LayeredType)ret;
}
return LAYERED_TYPE_2D_ARRAY;
uint32_t ret = LAYERED_TYPE_2D_ARRAY;
GDVIRTUAL_REQUIRED_CALL(_get_layered_type, ret);
return (LayeredType)ret;
}
int TextureLayered::get_width() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_width, ret);
return ret;
}
int TextureLayered::get_height() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_height, ret);
return ret;
}
int TextureLayered::get_layers() const {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_layers, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_layers, ret);
return ret;
}
bool TextureLayered::has_mipmaps() const {
bool ret;
if (GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret)) {
return ret;
}
return false;
bool ret = false;
GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret);
return ret;
}
Ref<Image> TextureLayered::get_layer_data(int p_layer) const {
Ref<Image> ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_layer_data, p_layer, ret)) {
return ret;
}
return Ref<Image>();
GDVIRTUAL_REQUIRED_CALL(_get_layer_data, p_layer, ret);
return ret;
}
void TextureLayered::_bind_methods() {

View File

@ -31,9 +31,7 @@
#include "audio_effect.h"
void AudioEffectInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
if (GDVIRTUAL_REQUIRED_CALL(_process, p_src_frames, p_dst_frames, p_frame_count)) {
return;
}
GDVIRTUAL_REQUIRED_CALL(_process, p_src_frames, p_dst_frames, p_frame_count);
}
bool AudioEffectInstance::process_silence() const {
bool ret = false;
@ -50,10 +48,8 @@ void AudioEffectInstance::_bind_methods() {
Ref<AudioEffectInstance> AudioEffect::instantiate() {
Ref<AudioEffectInstance> ret;
if (GDVIRTUAL_REQUIRED_CALL(_instantiate, ret)) {
return ret;
}
return Ref<AudioEffectInstance>();
GDVIRTUAL_REQUIRED_CALL(_instantiate, ret);
return ret;
}
void AudioEffect::_bind_methods() {
GDVIRTUAL_BIND(_instantiate);

View File

@ -71,12 +71,9 @@ void AudioStreamPlayback::seek(double p_time) {
}
int AudioStreamPlayback::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_mix, p_buffer, p_rate_scale, p_frames, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_mix, p_buffer, p_rate_scale, p_frames, ret);
return ret;
}
void AudioStreamPlayback::tag_used_streams() {
@ -107,20 +104,14 @@ void AudioStreamPlaybackResampled::begin_resample() {
}
int AudioStreamPlaybackResampled::_mix_internal(AudioFrame *p_buffer, int p_frames) {
int ret;
if (GDVIRTUAL_REQUIRED_CALL(_mix_resampled, p_buffer, p_frames, ret)) {
return ret;
}
return 0;
int ret = 0;
GDVIRTUAL_REQUIRED_CALL(_mix_resampled, p_buffer, p_frames, ret);
return ret;
}
float AudioStreamPlaybackResampled::get_stream_sampling_rate() {
float ret;
if (GDVIRTUAL_REQUIRED_CALL(_get_stream_sampling_rate, ret)) {
return ret;
}
return 0;
float ret = 0;
GDVIRTUAL_REQUIRED_CALL(_get_stream_sampling_rate, ret);
return ret;
}
void AudioStreamPlaybackResampled::_bind_methods() {

View File

@ -52,34 +52,26 @@ MovieWriter *MovieWriter::find_writer_for_file(const String &p_file) {
}
uint32_t MovieWriter::get_audio_mix_rate() const {
uint32_t ret = 0;
if (GDVIRTUAL_REQUIRED_CALL(_get_audio_mix_rate, ret)) {
return ret;
}
return 48000;
uint32_t ret = 48000;
GDVIRTUAL_REQUIRED_CALL(_get_audio_mix_rate, ret);
return ret;
}
AudioServer::SpeakerMode MovieWriter::get_audio_speaker_mode() const {
AudioServer::SpeakerMode ret = AudioServer::SPEAKER_MODE_STEREO;
if (GDVIRTUAL_REQUIRED_CALL(_get_audio_speaker_mode, ret)) {
return ret;
}
return AudioServer::SPEAKER_MODE_STEREO;
GDVIRTUAL_REQUIRED_CALL(_get_audio_speaker_mode, ret);
return ret;
}
Error MovieWriter::write_begin(const Size2i &p_movie_size, uint32_t p_fps, const String &p_base_path) {
Error ret = OK;
if (GDVIRTUAL_REQUIRED_CALL(_write_begin, p_movie_size, p_fps, p_base_path, ret)) {
return ret;
}
return ERR_UNCONFIGURED;
Error ret = ERR_UNCONFIGURED;
GDVIRTUAL_REQUIRED_CALL(_write_begin, p_movie_size, p_fps, p_base_path, ret);
return ret;
}
Error MovieWriter::write_frame(const Ref<Image> &p_image, const int32_t *p_audio_data) {
Error ret = OK;
if (GDVIRTUAL_REQUIRED_CALL(_write_frame, p_image, p_audio_data, ret)) {
return ret;
}
return ERR_UNCONFIGURED;
Error ret = ERR_UNCONFIGURED;
GDVIRTUAL_REQUIRED_CALL(_write_frame, p_image, p_audio_data, ret);
return ret;
}
void MovieWriter::write_end() {
@ -88,18 +80,15 @@ void MovieWriter::write_end() {
bool MovieWriter::handles_file(const String &p_path) const {
bool ret = false;
if (GDVIRTUAL_REQUIRED_CALL(_handles_file, p_path, ret)) {
return ret;
}
return false;
GDVIRTUAL_REQUIRED_CALL(_handles_file, p_path, ret);
return ret;
}
void MovieWriter::get_supported_extensions(List<String> *r_extensions) const {
Vector<String> exts;
if (GDVIRTUAL_REQUIRED_CALL(_get_supported_extensions, exts)) {
for (int i = 0; i < exts.size(); i++) {
r_extensions->push_back(exts[i]);
}
GDVIRTUAL_REQUIRED_CALL(_get_supported_extensions, exts);
for (int i = 0; i < exts.size(); i++) {
r_extensions->push_back(exts[i]);
}
}