diff --git a/core/core_bind.cpp b/core/core_bind.cpp index acd589783ec..342e003acd2 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -49,7 +49,7 @@ namespace core_bind { ResourceLoader *ResourceLoader::singleton = nullptr; Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, CacheMode p_cache_mode) { - return ::ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads, ResourceFormatLoader::CacheMode(p_cache_mode)); + return ::ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads, p_cache_mode); } ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, Array r_progress) { @@ -60,7 +60,7 @@ ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const r_progress.resize(1); r_progress[0] = progress; } - return (ThreadLoadStatus)tls; + return tls; } Ref ResourceLoader::load_threaded_get(const String &p_path) { @@ -71,7 +71,7 @@ Ref ResourceLoader::load_threaded_get(const String &p_path) { Ref ResourceLoader::load(const String &p_path, const String &p_type_hint, CacheMode p_cache_mode) { Error err = OK; - Ref ret = ::ResourceLoader::load(p_path, p_type_hint, ResourceFormatLoader::CacheMode(p_cache_mode), &err); + Ref ret = ::ResourceLoader::load(p_path, p_type_hint, p_cache_mode, &err); ERR_FAIL_COND_V_MSG(err != OK, ret, vformat("Error loading resource: '%s'.", p_path)); return ret; @@ -315,15 +315,15 @@ PackedByteArray OS::read_buffer_from_stdin(int64_t p_buffer_size) { } OS::StdHandleType OS::get_stdin_type() const { - return (OS::StdHandleType)::OS::get_singleton()->get_stdin_type(); + return ::OS::get_singleton()->get_stdin_type(); } OS::StdHandleType OS::get_stdout_type() const { - return (OS::StdHandleType)::OS::get_singleton()->get_stdout_type(); + return ::OS::get_singleton()->get_stdout_type(); } OS::StdHandleType OS::get_stderr_type() const { - return (OS::StdHandleType)::OS::get_singleton()->get_stderr_type(); + return ::OS::get_singleton()->get_stderr_type(); } int OS::execute(const String &p_path, const Vector &p_arguments, Array r_output, bool p_read_stderr, bool p_open_console) { @@ -593,7 +593,7 @@ bool OS::is_debug_build() const { } String OS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const { - return ::OS::get_singleton()->get_system_dir(::OS::SystemDir(p_dir), p_shared_storage); + return ::OS::get_singleton()->get_system_dir(p_dir, p_shared_storage); } String OS::get_keycode_string(Key p_code) const { @@ -917,7 +917,7 @@ TypedArray Geometry2D::intersect_polyline_with_polygon(const } TypedArray Geometry2D::offset_polygon(const Vector &p_polygon, real_t p_delta, PolyJoinType p_join_type) { - Vector> polys = ::Geometry2D::offset_polygon(p_polygon, p_delta, ::Geometry2D::PolyJoinType(p_join_type)); + Vector> polys = ::Geometry2D::offset_polygon(p_polygon, p_delta, p_join_type); TypedArray ret; @@ -928,7 +928,7 @@ TypedArray Geometry2D::offset_polygon(const Vector } TypedArray Geometry2D::offset_polyline(const Vector &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) { - Vector> polys = ::Geometry2D::offset_polyline(p_polygon, p_delta, ::Geometry2D::PolyJoinType(p_join_type), ::Geometry2D::PolyEndType(p_end_type)); + Vector> polys = ::Geometry2D::offset_polyline(p_polygon, p_delta, p_join_type, p_end_type); TypedArray ret; @@ -1373,7 +1373,7 @@ Error Thread::start(const Callable &p_callable, Priority p_priority) { Ref *ud = memnew(Ref(this)); ::Thread::Settings s; - s.priority = (::Thread::Priority)p_priority; + s.priority = p_priority; thread.start(_start_func, ud, s); return OK; @@ -1482,8 +1482,7 @@ Variant ClassDB::instantiate(const StringName &p_class) const { } ClassDB::APIType ClassDB::class_get_api_type(const StringName &p_class) const { - ::ClassDB::APIType api_type = ::ClassDB::get_api_type(p_class); - return (APIType)api_type; + return ::ClassDB::get_api_type(p_class); } bool ClassDB::class_has_signal(const StringName &p_class, const StringName &p_signal) const { diff --git a/core/core_bind.h b/core/core_bind.h index b96dc56b0dc..a97651ac469 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -34,6 +34,7 @@ #include "core/debugger/engine_profiler.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/math/geometry_2d.h" #include "core/os/semaphore.h" #include "core/os/thread.h" #include "core/templates/safe_refcount.h" @@ -52,20 +53,10 @@ class ResourceLoader : public Object { static ResourceLoader *singleton; public: - enum ThreadLoadStatus { - THREAD_LOAD_INVALID_RESOURCE, - THREAD_LOAD_IN_PROGRESS, - THREAD_LOAD_FAILED, - THREAD_LOAD_LOADED - }; - - enum CacheMode { - CACHE_MODE_IGNORE, - CACHE_MODE_REUSE, - CACHE_MODE_REPLACE, - CACHE_MODE_IGNORE_DEEP, - CACHE_MODE_REPLACE_DEEP, - }; + using enum ::ResourceLoader::ThreadLoadStatus; + using ThreadLoadStatus = ::ResourceLoader::ThreadLoadStatus; + using enum ResourceFormatLoader::CacheMode; + using CacheMode = ResourceFormatLoader::CacheMode; static ResourceLoader *get_singleton() { return singleton; } @@ -97,16 +88,8 @@ class ResourceSaver : public Object { static ResourceSaver *singleton; public: - enum SaverFlags { - FLAG_NONE = 0, - FLAG_RELATIVE_PATHS = 1, - FLAG_BUNDLE_RESOURCES = 2, - FLAG_CHANGE_PATH = 4, - FLAG_OMIT_EDITOR_PROPERTIES = 8, - FLAG_SAVE_BIG_ENDIAN = 16, - FLAG_COMPRESS = 32, - FLAG_REPLACE_SUBRESOURCE_PATHS = 64, - }; + using enum ::ResourceSaver::SaverFlags; + using SaverFlags = ::ResourceSaver::SaverFlags; static ResourceSaver *get_singleton() { return singleton; } @@ -144,17 +127,14 @@ class OS : public Object { RENDERING_DRIVER_METAL, }; + using enum ::OS::SystemDir; + using SystemDir = ::OS::SystemDir; + using enum ::OS::StdHandleType; + using StdHandleType = ::OS::StdHandleType; + PackedByteArray get_entropy(int p_bytes); String get_system_ca_certificates(); - enum StdHandleType { - STD_HANDLE_INVALID, - STD_HANDLE_CONSOLE, - STD_HANDLE_FILE, - STD_HANDLE_PIPE, - STD_HANDLE_UNKNOWN, - }; - virtual PackedStringArray get_connected_midi_inputs(); virtual void open_midi_inputs(); virtual void close_midi_inputs(); @@ -243,17 +223,6 @@ class OS : public Object { int get_processor_count() const; String get_processor_name() const; - enum SystemDir { - SYSTEM_DIR_DESKTOP, - SYSTEM_DIR_DCIM, - SYSTEM_DIR_DOCUMENTS, - SYSTEM_DIR_DOWNLOADS, - SYSTEM_DIR_MOVIES, - SYSTEM_DIR_MUSIC, - SYSTEM_DIR_PICTURES, - SYSTEM_DIR_RINGTONES, - }; - String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const; Error move_to_trash(const String &p_path) const; @@ -289,6 +258,13 @@ class Geometry2D : public Object { static void _bind_methods(); public: + using enum ::Geometry2D::PolyBooleanOperation; + using PolyBooleanOperation = ::Geometry2D::PolyBooleanOperation; + using enum ::Geometry2D::PolyJoinType; + using PolyJoinType = ::Geometry2D::PolyJoinType; + using enum ::Geometry2D::PolyEndType; + using PolyEndType = ::Geometry2D::PolyEndType; + static Geometry2D *get_singleton(); Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b); Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b); @@ -307,12 +283,6 @@ class Geometry2D : public Object { Vector convex_hull(const Vector &p_points); TypedArray decompose_polygon_in_convex(const Vector &p_polygon); - enum PolyBooleanOperation { - OPERATION_UNION, - OPERATION_DIFFERENCE, - OPERATION_INTERSECTION, - OPERATION_XOR - }; // 2D polygon boolean operations. TypedArray merge_polygons(const Vector &p_polygon_a, const Vector &p_polygon_b); // Union (add). TypedArray clip_polygons(const Vector &p_polygon_a, const Vector &p_polygon_b); // Difference (subtract). @@ -324,18 +294,6 @@ class Geometry2D : public Object { TypedArray intersect_polyline_with_polygon(const Vector &p_polyline, const Vector &p_polygon); // Chop. // 2D offset polygons/polylines. - enum PolyJoinType { - JOIN_SQUARE, - JOIN_ROUND, - JOIN_MITER - }; - enum PolyEndType { - END_POLYGON, - END_JOINED, - END_BUTT, - END_SQUARE, - END_ROUND - }; TypedArray offset_polygon(const Vector &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE); TypedArray offset_polyline(const Vector &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE); @@ -442,12 +400,8 @@ class Thread : public RefCounted { static void _start_func(void *ud); public: - enum Priority { - PRIORITY_LOW, - PRIORITY_NORMAL, - PRIORITY_HIGH, - PRIORITY_MAX - }; + using enum ::Thread::Priority; + using Priority = ::Thread::Priority; Error start(const Callable &p_callable, Priority p_priority = PRIORITY_NORMAL); String get_id() const; @@ -467,13 +421,8 @@ class ClassDB : public Object { static void _bind_methods(); public: - enum APIType { - API_CORE, - API_EDITOR, - API_EXTENSION, - API_EDITOR_EXTENSION, - API_NONE, - }; + using enum ::ClassDB::APIType; + using APIType = ::ClassDB::APIType; PackedStringArray get_class_list() const; PackedStringArray get_inheriters_from_class(const StringName &p_class) const; diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 56052b6a6fc..32e3c2db083 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -95,8 +95,6 @@ class ResourceFormatLoader : public RefCounted { virtual ~ResourceFormatLoader() {} }; -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); diff --git a/core/os/thread.h b/core/os/thread.h index 472998673a3..2db711f5ea3 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -76,7 +76,8 @@ class Thread { enum Priority { PRIORITY_LOW, PRIORITY_NORMAL, - PRIORITY_HIGH + PRIORITY_HIGH, + PRIORITY_MAX, }; struct Settings { @@ -166,7 +167,8 @@ class Thread { enum Priority { PRIORITY_LOW, PRIORITY_NORMAL, - PRIORITY_HIGH + PRIORITY_HIGH, + PRIORITY_MAX, }; struct Settings {