Skip to content

Commit

Permalink
Move singleton StringName definitions to header
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Dec 3, 2024
1 parent 0f20e67 commit a35d6a1
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 428 deletions.
75 changes: 0 additions & 75 deletions core/core_string_names.cpp

This file was deleted.

83 changes: 39 additions & 44 deletions core/core_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,61 +34,56 @@
#include "core/string/string_name.h"

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

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
40 changes: 0 additions & 40 deletions editor/editor_string_names.cpp

This file was deleted.

12 changes: 5 additions & 7 deletions editor/editor_string_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
#include "core/string/string_name.h"

class EditorStringNames {
static EditorStringNames *singleton;

EditorStringNames();
inline static EditorStringNames *singleton = nullptr;

public:
static void create() { singleton = memnew(EditorStringNames); }
Expand All @@ -47,10 +45,10 @@ class EditorStringNames {

_FORCE_INLINE_ static EditorStringNames *get_singleton() { return singleton; }

StringName Editor;
StringName EditorFonts;
StringName EditorIcons;
StringName EditorStyles;
const StringName Editor = StaticCString::create("Editor");
const StringName EditorFonts = StaticCString::create("EditorFonts");
const StringName EditorIcons = StaticCString::create("EditorIcons");
const StringName EditorStyles = StaticCString::create("EditorStyles");
};

#define EditorStringName(m_name) EditorStringNames::get_singleton()->m_name
Expand Down
148 changes: 0 additions & 148 deletions scene/scene_string_names.cpp

This file was deleted.

Loading

0 comments on commit a35d6a1

Please sign in to comment.