Skip to content

Commit

Permalink
Merge pull request #893 from Spartan322/merge/a372214
Browse files Browse the repository at this point in the history
  • Loading branch information
Spartan322 authored Dec 11, 2024
2 parents 5c03d04 + 14bb361 commit 6f0eb78
Show file tree
Hide file tree
Showing 284 changed files with 6,565 additions and 3,897 deletions.
5 changes: 5 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ Comment: Noto Sans font
Copyright: 2012, Google Inc.
License: OFL-1.1

Files: ./thirdparty/fonts/Vazirmatn*.woff2
Comment: Vazirmatn font
Copyright: 2015, The Vazirmatn Project Authors.
License: OFL-1.1

Files: ./thirdparty/freetype/
Comment: The FreeType Project
Copyright: 1996-2023, David Turner, Robert Wilhelm, and Werner Lemberg.
Expand Down
3 changes: 3 additions & 0 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ String Engine::get_architecture_name() const {
return "ppc";
#endif

#elif defined(__loongarch64)
return "loongarch64";

#elif defined(__wasm__)
#if defined(__wasm64__)
return "wasm64";
Expand Down
83 changes: 39 additions & 44 deletions core/core_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,61 +36,56 @@
#include "core/string/string_name.h"

class CoreStringNames {
friend void register_core_types();
friend void unregister_core_types();
inline static CoreStringNames *singleton = nullptr;

public:
static void create() { singleton = memnew(CoreStringNames); }
static void free() {
memdelete(singleton);
singleton = nullptr;
}

CoreStringNames();

public:
_FORCE_INLINE_ static CoreStringNames *get_singleton() { return singleton; }

static CoreStringNames *singleton;

StringName free_; // "free", conflict with C++ keyword.
StringName changed;
StringName script;
StringName script_changed;
StringName _iter_init;
StringName _iter_next;
StringName _iter_get;
StringName get_rid;
StringName _to_string;
StringName _custom_features;
const StringName free_ = StaticCString::create("free"); // free would conflict with C++ keyword.
const StringName changed = StaticCString::create("changed");
const StringName script = StaticCString::create("script");
const StringName script_changed = StaticCString::create("script_changed");
const StringName _iter_init = StaticCString::create("_iter_init");
const StringName _iter_next = StaticCString::create("_iter_next");
const StringName _iter_get = StaticCString::create("_iter_get");
const StringName get_rid = StaticCString::create("get_rid");
const StringName _to_string = StaticCString::create("_to_string");
const StringName _custom_features = StaticCString::create("_custom_features");

StringName x;
StringName y;
StringName z;
StringName w;
StringName r;
StringName g;
StringName b;
StringName a;
StringName position;
StringName size;
StringName end;
StringName basis;
StringName origin;
StringName normal;
StringName d;
StringName h;
StringName s;
StringName v;
StringName r8;
StringName g8;
StringName b8;
StringName a8;
const StringName x = StaticCString::create("x");
const StringName y = StaticCString::create("y");
const StringName z = StaticCString::create("z");
const StringName w = StaticCString::create("w");
const StringName r = StaticCString::create("r");
const StringName g = StaticCString::create("g");
const StringName b = StaticCString::create("b");
const StringName a = StaticCString::create("a");
const StringName position = StaticCString::create("position");
const StringName size = StaticCString::create("size");
const StringName end = StaticCString::create("end");
const StringName basis = StaticCString::create("basis");
const StringName origin = StaticCString::create("origin");
const StringName normal = StaticCString::create("normal");
const StringName d = StaticCString::create("d");
const StringName h = StaticCString::create("h");
const StringName s = StaticCString::create("s");
const StringName v = StaticCString::create("v");
const StringName r8 = StaticCString::create("r8");
const StringName g8 = StaticCString::create("g8");
const StringName b8 = StaticCString::create("b8");
const StringName a8 = StaticCString::create("a8");

StringName call;
StringName call_deferred;
StringName bind;
StringName notification;
StringName property_list_changed;
const StringName call = StaticCString::create("call");
const StringName call_deferred = StaticCString::create("call_deferred");
const StringName bind = StaticCString::create("bind");
const StringName notification = StaticCString::create("notification");
const StringName property_list_changed = StaticCString::create("property_list_changed");
};

#define CoreStringName(m_name) CoreStringNames::get_singleton()->m_name
Expand Down
2 changes: 1 addition & 1 deletion core/debugger/remote_debugger_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ RemoteDebuggerPeer *RemoteDebuggerPeerTCP::create(const String &p_uri) {
String debug_host = p_uri.replace("tcp://", "");
uint16_t debug_port = 6007;

if (debug_host.contains(":")) {
if (debug_host.contains_char(':')) {
int sep_pos = debug_host.rfind_char(':');
debug_port = debug_host.substr(sep_pos + 1).to_int();
debug_host = debug_host.substr(0, sep_pos);
Expand Down
2 changes: 1 addition & 1 deletion core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
if (F.name.begins_with("_")) {
continue; //hidden property
}
if (F.name.contains("/")) {
if (F.name.contains_char('/')) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
continue;
}
Expand Down
12 changes: 12 additions & 0 deletions core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
mb->set_factor(factor);
mb->set_button_index(button_index);

mb->merge_meta_from(this);

return mb;
}

Expand Down Expand Up @@ -976,6 +978,8 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
mm->set_velocity(p_xform.basis_xform(get_velocity()));
mm->set_screen_velocity(get_screen_velocity());

mm->merge_meta_from(this);

return mm;
}

Expand Down Expand Up @@ -1368,6 +1372,8 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co
st->set_canceled(canceled);
st->set_double_tap(double_tap);

st->merge_meta_from(this);

return st;
}

Expand Down Expand Up @@ -1496,6 +1502,8 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
sd->set_velocity(p_xform.basis_xform(velocity));
sd->set_screen_velocity(get_screen_velocity());

sd->merge_meta_from(this);

return sd;
}

Expand Down Expand Up @@ -1707,6 +1715,8 @@ Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform,
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
ev->set_factor(get_factor());

ev->merge_meta_from(this);

return ev;
}

Expand Down Expand Up @@ -1747,6 +1757,8 @@ Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, con
ev->set_position(p_xform.xform(get_position() + p_local_ofs));
ev->set_delta(get_delta());

ev->merge_meta_from(this);

return ev;
}

Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ bool FileAccess::store_csv_line(const Vector<String> &p_values, const String &p_
for (int i = 0; i < size; ++i) {
String value = p_values[i];

if (value.contains("\"") || value.contains(p_delim) || value.contains("\n")) {
if (value.contains_char('"') || value.contains(p_delim) || value.contains_char('\n')) {
value = "\"" + value.replace("\"", "\"\"") + "\"";
}
if (i < size - 1) {
Expand Down
4 changes: 2 additions & 2 deletions core/io/file_access_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void PackedData::add_path(const String &p_pkg_path, const String &p_path, uint64
// Search for directory.
PackedDir *cd = root;

if (simplified_path.contains("/")) { // In a subdirectory.
if (simplified_path.contains_char('/')) { // In a subdirectory.
Vector<String> ds = simplified_path.get_base_dir().split("/");

for (int j = 0; j < ds.size(); j++) {
Expand Down Expand Up @@ -106,7 +106,7 @@ void PackedData::remove_path(const String &p_path) {
// Search for directory.
PackedDir *cd = root;

if (simplified_path.contains("/")) { // In a subdirectory.
if (simplified_path.contains_char('/')) { // In a subdirectory.
Vector<String> ds = simplified_path.get_base_dir().split("/");

for (int j = 0; j < ds.size(); j++) {
Expand Down
2 changes: 1 addition & 1 deletion core/io/ip_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ IPAddress::IPAddress(const String &p_string) {
// Wildcard (not a valid IP)
wildcard = true;

} else if (p_string.contains(":")) {
} else if (p_string.contains_char(':')) {
// IPv6
_parse_ipv6(p_string);
valid = true;
Expand Down
2 changes: 1 addition & 1 deletion core/object/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName

String enum_name = p_enum;
if (!enum_name.is_empty()) {
if (enum_name.contains(".")) {
if (enum_name.contains_char('.')) {
enum_name = enum_name.get_slicec('.', 1);
}

Expand Down
4 changes: 4 additions & 0 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ bool OS::has_feature(const String &p_feature) {
if (p_feature == "wasm") {
return true;
}
#elif defined(__loongarch64)
if (p_feature == "loongarch64") {
return true;
}
#endif

#if defined(IOS_SIMULATOR)
Expand Down
33 changes: 27 additions & 6 deletions core/os/spin_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@
#ifndef SPIN_LOCK_H
#define SPIN_LOCK_H

#include "core/os/thread.h"
#include "core/typedefs.h"

#ifdef THREADS_ENABLED

// Note the implementations below avoid false sharing by ensuring their
// sizes match the assumed cache line. We can't use align attributes
// because these objects may end up unaligned in semi-tightly packed arrays.

#ifdef _MSC_VER
#include <intrin.h>
#endif
Expand All @@ -44,7 +51,10 @@
#include <os/lock.h>

class SpinLock {
mutable os_unfair_lock _lock = OS_UNFAIR_LOCK_INIT;
union {
mutable os_unfair_lock _lock = OS_UNFAIR_LOCK_INIT;
char aligner[Thread::CACHE_LINE_BYTES];
};

public:
_ALWAYS_INLINE_ void lock() const {
Expand All @@ -56,9 +66,7 @@ class SpinLock {
}
};

#else

#include "core/os/thread.h"
#else // __APPLE__

#include <atomic>

Expand Down Expand Up @@ -86,8 +94,11 @@ _ALWAYS_INLINE_ static void _cpu_pause() {

static_assert(std::atomic_bool::is_always_lock_free);

class alignas(Thread::CACHE_LINE_BYTES) SpinLock {
mutable std::atomic<bool> locked = ATOMIC_VAR_INIT(false);
class SpinLock {
union {
mutable std::atomic<bool> locked = ATOMIC_VAR_INIT(false);
char aligner[Thread::CACHE_LINE_BYTES];
};

public:
_ALWAYS_INLINE_ void lock() const {
Expand All @@ -109,4 +120,14 @@ class alignas(Thread::CACHE_LINE_BYTES) SpinLock {

#endif // __APPLE__

#else // THREADS_ENABLED

class SpinLock {
public:
void lock() const {}
void unlock() const {}
};

#endif // THREADS_ENABLED

#endif // SPIN_LOCK_H
Loading

0 comments on commit 6f0eb78

Please sign in to comment.