feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CONDITION_VARIABLE_H
#define CONDITION_VARIABLE_H
#pragma once
#include "core/os/mutex.h"
#include "core/os/safe_binary_mutex.h"
@ -85,5 +84,3 @@ public:
};
#endif // THREADS_ENABLED
#endif // CONDITION_VARIABLE_H

View file

@ -387,6 +387,10 @@ String keycode_get_string(Key p_code) {
}
p_code &= KeyModifierMask::CODE_MASK;
if ((char32_t)p_code == 0) {
// The key was just a modifier without any code.
return codestr;
}
const _KeyCodeText *kct = &_keycodes[0];
@ -406,7 +410,7 @@ String keycode_get_string(Key p_code) {
Key find_keycode(const String &p_codestr) {
Key keycode = Key::NONE;
Vector<String> code_parts = p_codestr.split("+");
if (code_parts.size() < 1) {
if (code_parts.is_empty()) {
return keycode;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef KEYBOARD_H
#define KEYBOARD_H
#pragma once
#include "core/string/ustring.h"
@ -347,5 +346,3 @@ const char *keycode_get_name_by_index(int p_index);
char32_t fix_unicode(char32_t p_char);
Key fix_keycode(char32_t p_char, Key p_key);
Key fix_key_label(char32_t p_char, Key p_key);
#endif // KEYBOARD_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MAIN_LOOP_H
#define MAIN_LOOP_H
#pragma once
#include "core/input/input_event.h"
#include "core/object/gdvirtual.gen.inc"
@ -71,5 +70,3 @@ public:
MainLoop() {}
virtual ~MainLoop() {}
};
#endif // MAIN_LOOP_H

View file

@ -28,14 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MEMORY_H
#define MEMORY_H
#pragma once
#include "core/error/error_macros.h"
#include "core/templates/safe_refcount.h"
#include <stddef.h>
#include <new>
#include <cstring>
#include <new> // IWYU pragma: keep // `new` operators.
#include <type_traits>
class Memory {
@ -196,6 +195,22 @@ T *memnew_arr_template(size_t p_elements) {
return (T *)mem;
}
// Fast alternative to a loop constructor pattern.
template <bool p_ensure_zero = false, typename T>
_FORCE_INLINE_ void memnew_arr_placement(T *p_start, size_t p_num) {
if constexpr (std::is_trivially_constructible_v<T> && !p_ensure_zero) {
// Don't need to do anything :)
} else if constexpr (is_zero_constructible_v<T>) {
// Can optimize with memset.
memset(static_cast<void *>(p_start), 0, p_num * sizeof(T));
} else {
// Need to use a for loop.
for (size_t i = 0; i < p_num; i++) {
memnew_placement(p_start + i, T);
}
}
}
/**
* Wonders of having own array functions, you can actually check the length of
* an allocated-with memnew_arr() array
@ -244,5 +259,3 @@ public:
_FORCE_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); }
_FORCE_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); }
};
#endif // MEMORY_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MIDI_DRIVER_H
#define MIDI_DRIVER_H
#pragma once
#include "core/typedefs.h"
#include "core/variant/variant.h"
@ -110,5 +109,3 @@ public:
PackedStringArray get_connected_inputs() const;
};
#endif // MIDI_DRIVER_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MUTEX_H
#define MUTEX_H
#pragma once
#include "core/typedefs.h"
@ -127,5 +126,3 @@ using Mutex = MutexImpl;
using BinaryMutex = MutexImpl;
#endif // THREADS_ENABLED
#endif // MUTEX_H

View file

@ -199,6 +199,14 @@ void OS::set_stderr_enabled(bool p_enabled) {
_stderr_enabled = p_enabled;
}
String OS::multibyte_to_string(const String &p_encoding, const PackedByteArray &p_array) const {
return String();
}
PackedByteArray OS::string_to_multibyte(const String &p_encoding, const String &p_string) const {
return PackedByteArray();
}
int OS::get_exit_code() const {
return _exit_code;
}
@ -214,7 +222,7 @@ String OS::get_locale() const {
// Non-virtual helper to extract the 2 or 3-letter language code from
// `get_locale()` in a way that's consistent for all platforms.
String OS::get_locale_language() const {
return get_locale().left(3).replace("_", "");
return get_locale().left(3).remove_char('_');
}
// Embedded PCK offset.
@ -246,7 +254,7 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const
if (p_allow_paths) {
// Dir separators are allowed, but disallow ".." to avoid going up the filesystem
invalid_chars.push_back("..");
safe_dir_name = safe_dir_name.replace("\\", "/").strip_edges();
safe_dir_name = safe_dir_name.replace_char('\\', '/').replace("//", "/").strip_edges();
} else {
invalid_chars.push_back("/");
invalid_chars.push_back("\\");
@ -274,7 +282,7 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const
// Get properly capitalized engine name for system paths
String OS::get_godot_dir_name() const {
// Default to lowercase, so only override when different case is needed
return String(VERSION_SHORT_NAME).to_lower();
return String(GODOT_VERSION_SHORT_NAME).to_lower();
}
// OS equivalent of XDG_DATA_HOME

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef OS_H
#define OS_H
#pragma once
#include "core/config/engine.h"
#include "core/io/logger.h"
@ -266,6 +265,9 @@ public:
virtual void set_crash_handler_silent() { _silent_crash_handler = true; }
virtual bool is_crash_handler_silent() { return _silent_crash_handler; }
virtual String multibyte_to_string(const String &p_encoding, const PackedByteArray &p_array) const;
virtual PackedByteArray string_to_multibyte(const String &p_encoding, const String &p_string) const;
virtual void disable_crash_handler() {}
virtual bool is_disable_crash_handler() const { return false; }
virtual void initialize_debugging() {}
@ -362,12 +364,10 @@ public:
// This is invoked by the GDExtensionManager after loading GDExtensions specified by the project.
virtual void load_platform_gdextensions() const {}
// Windows only. Tests OpenGL context and Rendering Device simultaneous creation. This function is expected to crash on some NVIDIA drivers.
virtual bool _test_create_rendering_device_and_gl() const { return true; }
virtual bool _test_create_rendering_device() const { return true; }
// Tests OpenGL context and Rendering Device simultaneous creation. This function is expected to crash on some NVIDIA drivers.
virtual bool _test_create_rendering_device_and_gl(const String &p_display_driver) const { return true; }
virtual bool _test_create_rendering_device(const String &p_display_driver) const { return true; }
OS();
virtual ~OS();
};
#endif // OS_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RW_LOCK_H
#define RW_LOCK_H
#pragma once
#include "core/typedefs.h"
@ -102,5 +101,3 @@ public:
lock.write_unlock();
}
};
#endif // RW_LOCK_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SAFE_BINARY_MUTEX_H
#define SAFE_BINARY_MUTEX_H
#pragma once
#include "core/error/error_macros.h"
#include "core/os/mutex.h"
@ -37,10 +36,7 @@
#ifdef THREADS_ENABLED
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-var-template"
#endif
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wundefined-var-template")
// A very special kind of mutex, used in scenarios where these
// requirements hold at the same time:
@ -120,9 +116,7 @@ public:
// TODO: Implement a `try_temp_relock` if needed (will also need a dummy method below).
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
GODOT_CLANG_WARNING_POP
#else // No threads.
@ -149,5 +143,3 @@ public:
};
#endif // THREADS_ENABLED
#endif // SAFE_BINARY_MUTEX_H

View file

@ -28,15 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#pragma once
#include <cstdint>
#include "core/typedefs.h"
#ifdef THREADS_ENABLED
#include "core/error/error_list.h"
#include "core/typedefs.h"
#ifdef DEBUG_ENABLED
#include "core/error/error_macros.h"
#endif
@ -148,5 +145,3 @@ public:
};
#endif // THREADS_ENABLED
#endif // SEMAPHORE_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SHARED_OBJECT_H
#define SHARED_OBJECT_H
#pragma once
#include "core/string/ustring.h"
#include "core/templates/vector.h"
@ -47,5 +46,3 @@ struct SharedObject {
SharedObject() {}
};
#endif // SHARED_OBJECT_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPIN_LOCK_H
#define SPIN_LOCK_H
#pragma once
#include "core/os/thread.h"
#include "core/typedefs.h"
@ -127,5 +126,3 @@ public:
};
#endif // THREADS_ENABLED
#endif // SPIN_LOCK_H

View file

@ -28,6 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#pragma once
#include "platform_config.h"
// Define PLATFORM_THREAD_OVERRIDE in your platform's `platform_config.h`
@ -40,9 +42,6 @@
#else
#ifndef THREAD_H
#define THREAD_H
#include "core/typedefs.h"
#ifdef THREADS_ENABLED
@ -93,14 +92,9 @@ public:
};
#if defined(__cpp_lib_hardware_interference_size) && !defined(ANDROID_ENABLED) // This would be OK with NDK >= 26.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winterference-size"
#endif
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Winterference-size")
static constexpr size_t CACHE_LINE_BYTES = std::hardware_destructive_interference_size;
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
GODOT_GCC_WARNING_POP
#else
// At a negligible memory cost, we use a conservatively high value.
static constexpr size_t CACHE_LINE_BYTES = 128;
@ -125,6 +119,8 @@ private:
public:
static void _set_platform_functions(const PlatformFunctions &p_functions);
_FORCE_INLINE_ static void yield() { std::this_thread::yield(); }
_FORCE_INLINE_ ID get_id() const { return id; }
// get the ID of the caller thread
_FORCE_INLINE_ static ID get_caller_id() {
@ -208,6 +204,4 @@ public:
#endif // THREADS_ENABLED
#endif // THREAD_H
#endif // PLATFORM_THREAD_OVERRIDE

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef THREAD_SAFE_H
#define THREAD_SAFE_H
#pragma once
#include "core/os/mutex.h" // IWYU pragma: keep // Used in macro.
@ -40,5 +39,3 @@
bool is_current_thread_safe_for_nodes();
void set_current_thread_safe_for_nodes(bool p_safe);
#endif // THREAD_SAFE_H

View file

@ -233,15 +233,8 @@ Dictionary Time::get_time_dict_from_unix_time(int64_t p_unix_time_val) const {
String Time::get_datetime_string_from_unix_time(int64_t p_unix_time_val, bool p_use_space) const {
UNIX_TIME_TO_HMS
UNIX_TIME_TO_YMD
// vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
String timestamp = vformat("%04d-%02d-%02d", year, (uint8_t)month, day);
if (p_use_space) {
timestamp = vformat("%s %02d:%02d:%02d", timestamp, hour, minute, second);
} else {
timestamp = vformat("%sT%02d:%02d:%02d", timestamp, hour, minute, second);
}
return timestamp;
const String format_string = p_use_space ? "%04d-%02d-%02d %02d:%02d:%02d" : "%04d-%02d-%02dT%02d:%02d:%02d";
return vformat(format_string, year, (uint8_t)month, day, hour, minute, second);
}
String Time::get_date_string_from_unix_time(int64_t p_unix_time_val) const {
@ -277,14 +270,8 @@ String Time::get_datetime_string_from_datetime_dict(const Dictionary &p_datetime
ERR_FAIL_COND_V_MSG(p_datetime.is_empty(), "", "Invalid datetime Dictionary: Dictionary is empty.");
EXTRACT_FROM_DICTIONARY
VALIDATE_YMDHMS("")
// vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
String timestamp = vformat("%04d-%02d-%02d", year, (uint8_t)month, day);
if (p_use_space) {
timestamp = vformat("%s %02d:%02d:%02d", timestamp, hour, minute, second);
} else {
timestamp = vformat("%sT%02d:%02d:%02d", timestamp, hour, minute, second);
}
return timestamp;
const String format_string = p_use_space ? "%04d-%02d-%02d %02d:%02d:%02d" : "%04d-%02d-%02dT%02d:%02d:%02d";
return vformat(format_string, year, (uint8_t)month, day, hour, minute, second);
}
int64_t Time::get_unix_time_from_datetime_dict(const Dictionary &p_datetime) const {
@ -352,15 +339,8 @@ Dictionary Time::get_time_dict_from_system(bool p_utc) const {
String Time::get_datetime_string_from_system(bool p_utc, bool p_use_space) const {
OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
// vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
String timestamp = vformat("%04d-%02d-%02d", dt.year, (uint8_t)dt.month, dt.day);
if (p_use_space) {
timestamp = vformat("%s %02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second);
} else {
timestamp = vformat("%sT%02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second);
}
return timestamp;
const String format_string = p_use_space ? "%04d-%02d-%02d %02d:%02d:%02d" : "%04d-%02d-%02dT%02d:%02d:%02d";
return vformat(format_string, dt.year, (uint8_t)dt.month, dt.day, dt.hour, dt.minute, dt.second);
}
String Time::get_date_string_from_system(bool p_utc) const {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef TIME_H
#define TIME_H
#pragma once
#include "core/object/class_db.h"
#include "time_enums.h"
@ -83,5 +82,3 @@ public:
VARIANT_ENUM_CAST(Month);
VARIANT_ENUM_CAST(Weekday);
#endif // TIME_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef TIME_ENUMS_H
#define TIME_ENUMS_H
#pragma once
#include <cstdint>
@ -59,5 +58,3 @@ enum Weekday : uint8_t {
WEEKDAY_FRIDAY,
WEEKDAY_SATURDAY,
};
#endif // TIME_ENUMS_H