Skip to content

Commit

Permalink
Style: Integrate modernize-use-using
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Feb 2, 2025
1 parent 9d88842 commit ccbd304
Show file tree
Hide file tree
Showing 179 changed files with 441 additions and 444 deletions.
2 changes: 1 addition & 1 deletion core/config/project_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ProjectSettings : public Object {
bool is_changed = false;

public:
typedef HashMap<String, Variant> CustomMap;
using CustomMap = HashMap<String, Variant>;
static const String PROJECT_DATA_DIR_NAME_SUFFIX;

// Properties that are not for built in values begin from this value, so builtin ones are displayed first.
Expand Down
10 changes: 5 additions & 5 deletions core/debugger/engine_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class ScriptDebugger;

class EngineDebugger {
public:
typedef void (*ProfilingToggle)(void *p_user, bool p_enable, const Array &p_opts);
typedef void (*ProfilingTick)(void *p_user, double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time);
typedef void (*ProfilingAdd)(void *p_user, const Array &p_arr);
using ProfilingToggle = void (*)(void *p_user, bool p_enable, const Array &p_opts);
using ProfilingTick = void (*)(void *p_user, double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time);
using ProfilingAdd = void (*)(void *p_user, const Array &p_arr);

typedef Error (*CaptureFunc)(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured);
using CaptureFunc = Error (*)(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured);

typedef RemoteDebuggerPeer *(*CreatePeerFunc)(const String &p_uri);
using CreatePeerFunc = RemoteDebuggerPeer *(*)(const String &p_uri);

class Profiler {
friend class EngineDebugger;
Expand Down
2 changes: 1 addition & 1 deletion core/debugger/remote_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RemoteDebugger : public EngineDebugger {
};

private:
typedef DebuggerMarshalls::OutputError ErrorMessage;
using ErrorMessage = DebuggerMarshalls::OutputError;

class PerformanceProfiler;

Expand Down
2 changes: 1 addition & 1 deletion core/debugger/script_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "core/templates/vector.h"

class ScriptDebugger {
typedef ScriptLanguage::StackInfo StackInfo;
using StackInfo = ScriptLanguage::StackInfo;

bool skip_breakpoints = false;

Expand Down
2 changes: 1 addition & 1 deletion core/error/error_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum ErrorHandlerType {

// Pointer to the error handler printing function. Reassign to any function to have errors printed.
// Parameters: userdata, function, file, line, error, explanation, type.
typedef void (*ErrorHandlerFunc)(void *, const char *, const char *, int p_line, const char *, const char *, bool p_editor_notify, ErrorHandlerType p_type);
using ErrorHandlerFunc = void (*)(void *p_user_data, const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, bool p_editor_notify, ErrorHandlerType p_type);

struct ErrorHandlerList {
ErrorHandlerFunc errfunc = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion core/extension/gdextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
extern void gdextension_setup_interface();
extern GDExtensionInterfaceFunctionPtr gdextension_get_proc_address(const char *p_name);

typedef GDExtensionBool (*GDExtensionLegacyInitializationFunction)(void *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
using GDExtensionLegacyInitializationFunction = GDExtensionBool (*)(void *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);

String GDExtension::get_extension_list_config_file() {
return ProjectSettings::get_singleton()->get_project_data_path().path_join("extension_list.cfg");
Expand Down
6 changes: 3 additions & 3 deletions core/extension/gdextension.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class GDExtensionEditorPlugins {

// Since this in core, we can't directly reference EditorNode, so it will
// set these function pointers in its constructor.
typedef void (*EditorPluginRegisterFunc)(const StringName &p_class_name);
using EditorPluginRegisterFunc = void (*)(const StringName &p_class_name);
static EditorPluginRegisterFunc editor_node_add_plugin;
static EditorPluginRegisterFunc editor_node_remove_plugin;

Expand All @@ -214,10 +214,10 @@ class GDExtensionEditorHelp {
// new documentation data. Note though that, differently from EditorHelp, this
// is initialized even _before_ it gets instantiated, as we need to rely on
// this method while initializing the engine.
typedef void (*EditorHelpLoadXmlBufferFunc)(const uint8_t *p_buffer, int p_size);
using EditorHelpLoadXmlBufferFunc = void (*)(const uint8_t *p_buffer, int p_size);
static EditorHelpLoadXmlBufferFunc editor_help_load_xml_buffer;

typedef void (*EditorHelpRemoveClassFunc)(const String &p_class);
using EditorHelpRemoveClassFunc = void (*)(const String &p_class);
static EditorHelpRemoveClassFunc editor_help_remove_class;

public:
Expand Down
4 changes: 2 additions & 2 deletions core/extension/gdextension_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef uint16_t char16_t;
#endif

#ifdef __cplusplus
extern "C" {
extern "C" { // NOLINTBEGIN(modernize-use-using)
#endif

/* VARIANT TYPES */
Expand Down Expand Up @@ -3079,7 +3079,7 @@ typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars)(const char *
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen)(const char *p_data, GDExtensionInt p_size);

#ifdef __cplusplus
}
} // NOLINTEND(modernize-use-using)
#endif

#endif // GDEXTENSION_INTERFACE_H
2 changes: 1 addition & 1 deletion core/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Input : public Object {
JOYPADS_MAX = 16,
};

typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event);
using EventDispatchFunc = void (*)(const Ref<InputEvent> &p_event);

private:
BitField<MouseButtonMask> mouse_button_mask;
Expand Down
2 changes: 1 addition & 1 deletion core/io/dir_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DirAccess : public RefCounted {
ACCESS_MAX
};

typedef Ref<DirAccess> (*CreateFunc)();
using CreateFunc = Ref<DirAccess> (*)();

private:
AccessType _access_type = ACCESS_FILESYSTEM;
Expand Down
4 changes: 2 additions & 2 deletions core/io/file_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class FileAccess : public RefCounted {
COMPRESSION_BROTLI = Compression::MODE_BROTLI,
};

typedef void (*FileCloseFailNotify)(const String &);
using FileCloseFailNotify = void (*)(const String &p_path);

typedef Ref<FileAccess> (*CreateFunc)();
using CreateFunc = Ref<FileAccess> (*)();
bool big_endian = false;
bool real_is_double = false;

Expand Down
20 changes: 10 additions & 10 deletions core/io/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ class Image;

// Function pointer prototypes.

typedef Error (*SavePNGFunc)(const String &p_path, const Ref<Image> &p_img);
typedef Vector<uint8_t> (*SavePNGBufferFunc)(const Ref<Image> &p_img);
using SavePNGFunc = Error (*)(const String &p_path, const Ref<Image> &p_img);
using SavePNGBufferFunc = Vector<uint8_t> (*)(const Ref<Image> &p_img);

typedef Error (*SaveJPGFunc)(const String &p_path, const Ref<Image> &p_img, float p_quality);
typedef Vector<uint8_t> (*SaveJPGBufferFunc)(const Ref<Image> &p_img, float p_quality);
using SaveJPGFunc = Error (*)(const String &p_path, const Ref<Image> &p_img, float p_quality);
using SaveJPGBufferFunc = Vector<uint8_t> (*)(const Ref<Image> &p_img, float p_quality);

typedef Ref<Image> (*ImageMemLoadFunc)(const uint8_t *p_png, int p_size);
typedef Ref<Image> (*ScalableImageMemLoadFunc)(const uint8_t *p_data, int p_size, float p_scale);
using ImageMemLoadFunc = Ref<Image> (*)(const uint8_t *p_png, int p_size);
using ScalableImageMemLoadFunc = Ref<Image> (*)(const uint8_t *p_data, int p_size, float p_scale);

typedef Error (*SaveWebPFunc)(const String &p_path, const Ref<Image> &p_img, const bool p_lossy, const float p_quality);
typedef Vector<uint8_t> (*SaveWebPBufferFunc)(const Ref<Image> &p_img, const bool p_lossy, const float p_quality);
using SaveWebPFunc = Error (*)(const String &p_path, const Ref<Image> &p_img, const bool p_lossy, const float p_quality);
using SaveWebPBufferFunc = Vector<uint8_t> (*)(const Ref<Image> &p_img, const bool p_lossy, const float p_quality);

typedef Error (*SaveEXRFunc)(const String &p_path, const Ref<Image> &p_img, bool p_grayscale);
typedef Vector<uint8_t> (*SaveEXRBufferFunc)(const Ref<Image> &p_img, bool p_grayscale);
using SaveEXRFunc = Error (*)(const String &p_path, const Ref<Image> &p_img, bool p_grayscale);
using SaveEXRBufferFunc = Vector<uint8_t> (*)(const Ref<Image> &p_img, bool p_grayscale);

class Image : public Resource {
GDCLASS(Image, Resource);
Expand Down
2 changes: 1 addition & 1 deletion core/io/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class IP : public Object {
RESOLVER_INVALID_ID = -1
};

typedef int ResolverID;
using ResolverID = int;

private:
_IP_ResolverPrivate *resolver = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions core/io/marshalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

// uintr_t is only for pairing with real_t, and we only need it in here.
#ifdef REAL_T_IS_DOUBLE
typedef uint64_t uintr_t;
using uintr_t = uint64_t;
#else
typedef uint32_t uintr_t;
using uintr_t = uint32_t;
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
class ResourceImporter;
class ResourceFormatImporter;

typedef Ref<Resource> (*ResourceFormatImporterLoadOnStartup)(ResourceFormatImporter *p_importer, const String &p_path, Error *r_error, bool p_use_sub_threads, float *r_progress, ResourceFormatLoader::CacheMode p_cache_mode);
using ResourceFormatImporterLoadOnStartup = Ref<Resource> (*)(ResourceFormatImporter *p_importer, const String &p_path, Error *r_error, bool p_use_sub_threads, float *r_progress, ResourceFormatLoader::CacheMode p_cache_mode);

class ResourceFormatImporter : public ResourceFormatLoader {
struct PathAndType {
Expand Down
8 changes: 4 additions & 4 deletions core/io/resource_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ class ResourceFormatLoader : public RefCounted {

VARIANT_ENUM_CAST(ResourceFormatLoader::CacheMode)

typedef void (*ResourceLoadErrorNotify)(const String &p_text);
typedef void (*DependencyErrorNotify)(const String &p_loading, const String &p_which, const String &p_type);
using ResourceLoadErrorNotify = void (*)(const String &p_text);
using DependencyErrorNotify = void (*)(const String &p_loading, const String &p_which, const String &p_type);

typedef Error (*ResourceLoaderImport)(const String &p_path);
typedef void (*ResourceLoadedCallback)(Ref<Resource> p_resource, const String &p_path);
using ResourceLoaderImport = Error (*)(const String &p_path);
using ResourceLoadedCallback = void (*)(Ref<Resource> p_resource, const String &p_path);

class ResourceLoader {
friend class LoadToken;
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_saver.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class ResourceFormatSaver : public RefCounted {
virtual ~ResourceFormatSaver() {}
};

typedef void (*ResourceSavedCallback)(Ref<Resource> p_resource, const String &p_path);
typedef ResourceUID::ID (*ResourceSaverGetResourceIDForPath)(const String &p_path, bool p_generate);
using ResourceSavedCallback = void (*)(Ref<Resource> p_resource, const String &p_path);
using ResourceSaverGetResourceIDForPath = ResourceUID::ID (*)(const String &p_path, bool p_generate);

class ResourceSaver {
enum {
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_uid.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FileAccess;
class ResourceUID : public Object {
GDCLASS(ResourceUID, Object)
public:
typedef int64_t ID;
using ID = int64_t;
constexpr const static ID INVALID_ID = -1;

static String get_cache_file();
Expand Down
6 changes: 3 additions & 3 deletions core/math/bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class BVH_Manager {
public:
// note we are using uint32_t instead of BVHHandle, losing type safety, but this
// is for compatibility with octree
typedef void *(*PairCallback)(void *, uint32_t, T *, int, uint32_t, T *, int);
typedef void (*UnpairCallback)(void *, uint32_t, T *, int, uint32_t, T *, int, void *);
typedef void *(*CheckPairCallback)(void *, uint32_t, T *, int, uint32_t, T *, int, void *);
using PairCallback = void *(*)(void *, uint32_t, T *, int, uint32_t, T *, int);
using UnpairCallback = void (*)(void *, uint32_t, T *, int, uint32_t, T *, int, void *);
using CheckPairCallback = void *(*)(void *, uint32_t, T *, int, uint32_t, T *, int, void *);

// allow locally toggling thread safety if the template has been compiled with BVH_THREAD_SAFE
void params_set_thread_safe(bool p_enable) {
Expand Down
2 changes: 1 addition & 1 deletion core/math/disjoint_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DisjointSet {
int rank = 0;
};

typedef HashMap<T, Element *, H, C> MapT;
using MapT = HashMap<T, Element *, H, C>;

MapT elements;

Expand Down
4 changes: 2 additions & 2 deletions core/math/math_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ enum class EulerOrder {
* presence or absence of the REAL_T_IS_DOUBLE define.
*/
#ifdef REAL_T_IS_DOUBLE
typedef double real_t;
using real_t = double;
#else
typedef float real_t;
using real_t = float;
#endif

#endif // MATH_DEFS_H
4 changes: 2 additions & 2 deletions core/math/vector2.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ _FORCE_INLINE_ Vector2 operator*(int64_t p_scalar, const Vector2 &p_vec) {
return p_vec * p_scalar;
}

typedef Vector2 Size2;
typedef Vector2 Point2;
using Size2 = Vector2;
using Point2 = Vector2;

#endif // VECTOR2_H
4 changes: 2 additions & 2 deletions core/math/vector2i.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ _FORCE_INLINE_ Vector2i operator*(double p_scalar, const Vector2i &p_vector) {
return p_vector * p_scalar;
}

typedef Vector2i Size2i;
typedef Vector2i Point2i;
using Size2i = Vector2i;
using Point2i = Vector2i;

#endif // VECTOR2I_H
12 changes: 6 additions & 6 deletions core/object/callable_method_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
const char *p_func_text,
#endif
void (T::*p_method)(P...)) {
typedef CallableCustomMethodPointer<T, void, P...> CCMP; // Messes with memnew otherwise.
using CCMP = CallableCustomMethodPointer<T, void, P...>; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
Expand All @@ -137,7 +137,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
const char *p_func_text,
#endif
R (T::*p_method)(P...)) {
typedef CallableCustomMethodPointer<T, R, P...> CCMP; // Messes with memnew otherwise.
using CCMP = CallableCustomMethodPointer<T, R, P...>; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
Expand Down Expand Up @@ -193,7 +193,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
const char *p_func_text,
#endif
void (T::*p_method)(P...) const) {
typedef CallableCustomMethodPointerC<T, void, P...> CCMP; // Messes with memnew otherwise.
using CCMP = CallableCustomMethodPointerC<T, void, P...>; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
Expand All @@ -207,7 +207,7 @@ Callable create_custom_callable_function_pointer(T *p_instance,
const char *p_func_text,
#endif
R (T::*p_method)(P...) const) {
typedef CallableCustomMethodPointerC<T, R, P...> CCMP; // Messes with memnew otherwise.
using CCMP = CallableCustomMethodPointerC<T, R, P...>; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
Expand Down Expand Up @@ -265,7 +265,7 @@ Callable create_custom_callable_static_function_pointer(
const char *p_func_text,
#endif
void (*p_method)(P...)) {
typedef CallableCustomStaticMethodPointer<void, P...> CCMP; // Messes with memnew otherwise.
using CCMP = CallableCustomStaticMethodPointer<void, P...>; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_method));
#ifdef DEBUG_METHODS_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
Expand All @@ -279,7 +279,7 @@ Callable create_custom_callable_static_function_pointer(
const char *p_func_text,
#endif
R (*p_method)(P...)) {
typedef CallableCustomStaticMethodPointer<R, P...> CCMP; // Messes with memnew otherwise.
using CCMP = CallableCustomStaticMethodPointer<R, P...>; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_method));
#ifdef DEBUG_METHODS_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
Expand Down
2 changes: 1 addition & 1 deletion core/object/message_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CallQueue {

// Needs to be public to be able to define it outside the class.
// Needs to lock because there can be multiple of these allocators in several threads.
typedef PagedAllocator<Page, true> Allocator;
using Allocator = PagedAllocator<Page, true>;

private:
enum {
Expand Down
6 changes: 3 additions & 3 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private:
friend class ::ClassDB; \
\
public: \
typedef m_class self_type; \
using self_type = m_class; \
static constexpr bool _class_is_enabled = !bool(GD_IS_DEFINED(ClassDB_Disable_##m_class)) && m_inherits::_class_is_enabled; \
virtual String get_class() const override { \
if (_get_extension()) { \
Expand Down Expand Up @@ -577,7 +577,7 @@ class ScriptInstance;

class Object {
public:
typedef Object self_type;
using self_type = Object;

enum ConnectFlags {
CONNECT_DEFERRED = 1,
Expand Down Expand Up @@ -1039,7 +1039,7 @@ class ObjectDB {
static void setup();

public:
typedef void (*DebugFunc)(Object *p_obj);
using DebugFunc = void (*)(Object *p_obj);

_ALWAYS_INLINE_ static Object *get_instance(ObjectID p_instance_id) {
uint64_t id = p_instance_id;
Expand Down
4 changes: 2 additions & 2 deletions core/object/ref_counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ struct PtrToArg<Ref<T>> {
return Ref<T>(*reinterpret_cast<T *const *>(p_ptr));
}

typedef Ref<T> EncodeT;
using EncodeT = Ref<T>;

_FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) {
// p_ptr points to an EncodeT object which is a Ref<T> object.
Expand All @@ -235,7 +235,7 @@ struct PtrToArg<Ref<T>> {

template <typename T>
struct PtrToArg<const Ref<T> &> {
typedef Ref<T> EncodeT;
using EncodeT = Ref<T>;

_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
if (p_ptr == nullptr) {
Expand Down
Loading

0 comments on commit ccbd304

Please sign in to comment.