Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Core: Replace `GetSimpleTypeT` with `std::decay_t`

Thaddeus Crewsdd5cd44b0ba5
diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h
index 6a8fef6e422..44a6d4bdf4f 100644
--- a/core/templates/command_queue_mt.h
+++ b/core/templates/command_queue_mt.h
@@ -34,7 +34,6 @@
#include "core/os/condition_variable.h"
#include "core/os/mutex.h"
#include "core/templates/local_vector.h"
-#include "core/templates/simple_type.h"
#include "core/templates/tuple.h"
#include "core/typedefs.h"
@@ -54,7 +53,7 @@ class CommandQueueMT {
struct Command : public CommandBase {
T *instance;
M method;
- Tuple<GetSimpleTypeT<Args>...> args;
+ Tuple<std::decay_t<Args>...> args;
template <typename... FwdArgs>
_FORCE_INLINE_ Command(T *p_instance, M p_method, FwdArgs &&...p_args) :
@@ -82,9 +81,9 @@ class CommandQueueMT {
T *instance;
M method;
R *ret;
- Tuple<GetSimpleTypeT<Args>...> args;
+ Tuple<std::decay_t<Args>...> args;
- _FORCE_INLINE_ CommandRet(T *p_instance, M p_method, R *p_ret, GetSimpleTypeT<Args>... p_args) :
+ _FORCE_INLINE_ CommandRet(T *p_instance, M p_method, R *p_ret, std::decay_t<Args>... p_args) :
CommandBase(true), instance(p_instance), method(p_method), ret(p_ret), args{ p_args... } {}
void call() override {
diff --git a/core/templates/simple_type.h b/core/templates/simple_type.h
deleted file mode 100644
index 1468885ac2b..00000000000
--- a/core/templates/simple_type.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/**************************************************************************/
-/* simple_type.h */
-/**************************************************************************/
-/* 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. */
-/**************************************************************************/
-
-#pragma once
-
-#include <type_traits>
-
-template <typename T>
-using GetSimpleTypeT = typename std::remove_cv_t<std::remove_reference_t<T>>;
diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h
index 85e06a2a995..bd24aaf76cb 100644
--- a/core/variant/binder_common.h
+++ b/core/variant/binder_common.h
@@ -30,7 +30,6 @@
#pragma once
-#include "core/templates/simple_type.h"
#include "core/typedefs.h"
#include "core/variant/method_ptrcall.h"
#include "core/variant/type_info.h"
@@ -117,42 +116,42 @@ void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const void
template <typename T, typename... P, size_t... Is>
void call_with_validated_variant_args_helper(T *p_instance, void (T::*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) {
- (p_instance->*p_method)((VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...);
+ (p_instance->*p_method)((VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...);
}
template <typename T, typename... P, size_t... Is>
void call_with_validated_variant_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const Variant **p_args, IndexSequence<Is...>) {
- (p_instance->*p_method)((VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...);
+ (p_instance->*p_method)((VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...);
}
template <typename T, typename R, typename... P, size_t... Is>
void call_with_validated_variant_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
- VariantInternalAccessor<GetSimpleTypeT<R>>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...));
+ VariantInternalAccessor<std::decay_t<R>>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...));
}
template <typename T, typename R, typename... P, size_t... Is>
void call_with_validated_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
- VariantInternalAccessor<GetSimpleTypeT<R>>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...));
+ VariantInternalAccessor<std::decay_t<R>>::set(r_ret, (p_instance->*p_method)((VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...));
}
template <typename T, typename R, typename... P, size_t... Is>
void call_with_validated_variant_args_static_retc_helper(T *p_instance, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
- VariantInternalAccessor<GetSimpleTypeT<R>>::set(r_ret, p_method(p_instance, (VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...));
+ VariantInternalAccessor<std::decay_t<R>>::set(r_ret, p_method(p_instance, (VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...));
}
template <typename T, typename... P, size_t... Is>
void call_with_validated_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, IndexSequence<Is...>) {
- p_method(p_instance, (VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...);
+ p_method(p_instance, (VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...);
}
template <typename R, typename... P, size_t... Is>
void call_with_validated_variant_args_static_method_ret_helper(R (*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) {
- VariantInternalAccessor<GetSimpleTypeT<R>>::set(r_ret, p_method((VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...));
+ VariantInternalAccessor<std::decay_t<R>>::set(r_ret, p_method((VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...));
}
template <typename... P, size_t... Is>
void call_with_validated_variant_args_static_method_helper(void (*p_method)(P...), const Variant **p_args, IndexSequence<Is...>) {
- p_method((VariantInternalAccessor<GetSimpleTypeT<P>>::get(p_args[Is]))...);
+ p_method((VariantInternalAccessor<std::decay_t<P>>::get(p_args[Is]))...);
}
template <typename T, typename... P>
diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h
index 3aa15e30dc8..d769622e61b 100644
--- a/core/variant/method_ptrcall.h
+++ b/core/variant/method_ptrcall.h
@@ -32,7 +32,6 @@
#include "core/object/object.h"
#include "core/object/object_id.h"
-#include "core/templates/simple_type.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
@@ -142,7 +141,7 @@ template <typename T, typename = void>
struct PtrToArg;
template <typename T>
-struct PtrToArg<T, std::enable_if_t<!std::is_same_v<T, GetSimpleTypeT<T>>>> : PtrToArg<GetSimpleTypeT<T>> {};
+struct PtrToArg<T, std::enable_if_t<!std::is_same_v<T, std::decay_t<T>>>> : PtrToArg<std::decay_t<T>> {};
template <>
struct PtrToArg<bool> : Internal::PtrToArgConvert<bool, uint8_t> {};
diff --git a/core/variant/type_info.h b/core/variant/type_info.h
index f6e65d406c1..18c71431cde 100644
--- a/core/variant/type_info.h
+++ b/core/variant/type_info.h
@@ -31,7 +31,6 @@
#pragma once
#include "core/object/object.h"
-#include "core/templates/simple_type.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
@@ -65,7 +64,7 @@ template <typename T, typename = void>
struct GetTypeInfo;
template <typename T>
-struct GetTypeInfo<T, std::enable_if_t<!std::is_same_v<T, GetSimpleTypeT<T>>>> : GetTypeInfo<GetSimpleTypeT<T>> {};
+struct GetTypeInfo<T, std::enable_if_t<!std::is_same_v<T, std::decay_t<T>>>> : GetTypeInfo<std::decay_t<T>> {};
#define MAKE_TYPE_INFO(m_type, m_var_type) \
template <> \
diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h
index c6b266ab0b2..02a8011f6fe 100644
--- a/core/variant/variant_internal.h
+++ b/core/variant/variant_internal.h
@@ -30,7 +30,6 @@
#pragma once
-#include "core/templates/simple_type.h"
#include "core/variant/type_info.h"
#include "core/variant/variant.h"
#include "core/variant/variant_pools.h"
@@ -577,7 +576,7 @@ template <typename T, typename = void>
struct VariantInternalAccessor;
template <typename T>
-struct VariantInternalAccessor<T, std::enable_if_t<!std::is_same_v<T, GetSimpleTypeT<T>>>> : VariantInternalAccessor<GetSimpleTypeT<T>> {};
+struct VariantInternalAccessor<T, std::enable_if_t<!std::is_same_v<T, std::decay_t<T>>>> : VariantInternalAccessor<std::decay_t<T>> {};
template <typename T>
struct _VariantInternalAccessorLocal {
@@ -971,7 +970,7 @@ struct VariantTypeChanger {
template <typename T>
struct VariantTypeAdjust {
_FORCE_INLINE_ static void adjust(Variant *r_ret) {
- VariantTypeChanger<GetSimpleTypeT<T>>::change(r_ret);
+ VariantTypeChanger<std::decay_t<T>>::change(r_ret);
}
};