Move singleton StringName definitions to header

This commit is contained in:
kobewi 2024-12-03 21:34:53 +01:00
parent 1f47e4c4e3
commit d3c9bee653
6 changed files with 126 additions and 404 deletions

View file

@ -1,75 +0,0 @@
/**************************************************************************/
/* core_string_names.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#include "core_string_names.h"
CoreStringNames *CoreStringNames::singleton = nullptr;
CoreStringNames::CoreStringNames() :
free_(StaticCString::create("free")),
changed(StaticCString::create("changed")),
script(StaticCString::create("script")),
script_changed(StaticCString::create("script_changed")),
_iter_init(StaticCString::create("_iter_init")),
_iter_next(StaticCString::create("_iter_next")),
_iter_get(StaticCString::create("_iter_get")),
get_rid(StaticCString::create("get_rid")),
_to_string(StaticCString::create("_to_string")),
_custom_features(StaticCString::create("_custom_features")),
x(StaticCString::create("x")),
y(StaticCString::create("y")),
z(StaticCString::create("z")),
w(StaticCString::create("w")),
r(StaticCString::create("r")),
g(StaticCString::create("g")),
b(StaticCString::create("b")),
a(StaticCString::create("a")),
position(StaticCString::create("position")),
size(StaticCString::create("size")),
end(StaticCString::create("end")),
basis(StaticCString::create("basis")),
origin(StaticCString::create("origin")),
normal(StaticCString::create("normal")),
d(StaticCString::create("d")),
h(StaticCString::create("h")),
s(StaticCString::create("s")),
v(StaticCString::create("v")),
r8(StaticCString::create("r8")),
g8(StaticCString::create("g8")),
b8(StaticCString::create("b8")),
a8(StaticCString::create("a8")),
call(StaticCString::create("call")),
call_deferred(StaticCString::create("call_deferred")),
bind(StaticCString::create("bind")),
notification(StaticCString::create("notification")),
property_list_changed(StaticCString::create("property_list_changed")) {
}

View file

@ -34,61 +34,56 @@
#include "core/string/string_name.h" #include "core/string/string_name.h"
class CoreStringNames { class CoreStringNames {
friend void register_core_types(); inline static CoreStringNames *singleton = nullptr;
friend void unregister_core_types();
public:
static void create() { singleton = memnew(CoreStringNames); } static void create() { singleton = memnew(CoreStringNames); }
static void free() { static void free() {
memdelete(singleton); memdelete(singleton);
singleton = nullptr; singleton = nullptr;
} }
CoreStringNames();
public:
_FORCE_INLINE_ static CoreStringNames *get_singleton() { return singleton; } _FORCE_INLINE_ static CoreStringNames *get_singleton() { return singleton; }
static CoreStringNames *singleton; 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 free_; // "free", conflict with C++ keyword. const StringName x = StaticCString::create("x");
StringName changed; const StringName y = StaticCString::create("y");
StringName script; const StringName z = StaticCString::create("z");
StringName script_changed; const StringName w = StaticCString::create("w");
StringName _iter_init; const StringName r = StaticCString::create("r");
StringName _iter_next; const StringName g = StaticCString::create("g");
StringName _iter_get; const StringName b = StaticCString::create("b");
StringName get_rid; const StringName a = StaticCString::create("a");
StringName _to_string; const StringName position = StaticCString::create("position");
StringName _custom_features; 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 x; const StringName call = StaticCString::create("call");
StringName y; const StringName call_deferred = StaticCString::create("call_deferred");
StringName z; const StringName bind = StaticCString::create("bind");
StringName w; const StringName notification = StaticCString::create("notification");
StringName r; const StringName property_list_changed = StaticCString::create("property_list_changed");
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;
StringName call;
StringName call_deferred;
StringName bind;
StringName notification;
StringName property_list_changed;
}; };
#define CoreStringName(m_name) CoreStringNames::get_singleton()->m_name #define CoreStringName(m_name) CoreStringNames::get_singleton()->m_name

View file

@ -1,40 +0,0 @@
/**************************************************************************/
/* editor_string_names.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#include "editor_string_names.h"
EditorStringNames *EditorStringNames::singleton = nullptr;
EditorStringNames::EditorStringNames() {
Editor = StaticCString::create("Editor");
EditorFonts = StaticCString::create("EditorFonts");
EditorIcons = StaticCString::create("EditorIcons");
EditorStyles = StaticCString::create("EditorStyles");
}

View file

@ -34,9 +34,7 @@
#include "core/string/string_name.h" #include "core/string/string_name.h"
class EditorStringNames { class EditorStringNames {
static EditorStringNames *singleton; inline static EditorStringNames *singleton = nullptr;
EditorStringNames();
public: public:
static void create() { singleton = memnew(EditorStringNames); } static void create() { singleton = memnew(EditorStringNames); }
@ -47,10 +45,10 @@ public:
_FORCE_INLINE_ static EditorStringNames *get_singleton() { return singleton; } _FORCE_INLINE_ static EditorStringNames *get_singleton() { return singleton; }
StringName Editor; const StringName Editor = StaticCString::create("Editor");
StringName EditorFonts; const StringName EditorFonts = StaticCString::create("EditorFonts");
StringName EditorIcons; const StringName EditorIcons = StaticCString::create("EditorIcons");
StringName EditorStyles; const StringName EditorStyles = StaticCString::create("EditorStyles");
}; };
#define EditorStringName(m_name) EditorStringNames::get_singleton()->m_name #define EditorStringName(m_name) EditorStringNames::get_singleton()->m_name

View file

@ -1,148 +0,0 @@
/**************************************************************************/
/* scene_string_names.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#include "scene_string_names.h"
SceneStringNames *SceneStringNames::singleton = nullptr;
SceneStringNames::SceneStringNames() {
resized = StaticCString::create("resized");
draw = StaticCString::create("draw");
hidden = StaticCString::create("hidden");
visibility_changed = StaticCString::create("visibility_changed");
input_event = StaticCString::create("input_event");
shader = StaticCString::create("shader");
tree_entered = StaticCString::create("tree_entered");
tree_exiting = StaticCString::create("tree_exiting");
tree_exited = StaticCString::create("tree_exited");
ready = StaticCString::create("ready");
item_rect_changed = StaticCString::create("item_rect_changed");
size_flags_changed = StaticCString::create("size_flags_changed");
minimum_size_changed = StaticCString::create("minimum_size_changed");
sleeping_state_changed = StaticCString::create("sleeping_state_changed");
finished = StaticCString::create("finished");
animation_finished = StaticCString::create("animation_finished");
animation_changed = StaticCString::create("animation_changed");
animation_started = StaticCString::create("animation_started");
RESET = StaticCString::create("RESET");
pose_updated = StaticCString::create("pose_updated");
skeleton_updated = StaticCString::create("skeleton_updated");
bone_enabled_changed = StaticCString::create("bone_enabled_changed");
show_rest_only_changed = StaticCString::create("show_rest_only_changed");
mouse_entered = StaticCString::create("mouse_entered");
mouse_exited = StaticCString::create("mouse_exited");
mouse_shape_entered = StaticCString::create("mouse_shape_entered");
mouse_shape_exited = StaticCString::create("mouse_shape_exited");
focus_entered = StaticCString::create("focus_entered");
focus_exited = StaticCString::create("focus_exited");
pre_sort_children = StaticCString::create("pre_sort_children");
sort_children = StaticCString::create("sort_children");
body_shape_entered = StaticCString::create("body_shape_entered");
body_entered = StaticCString::create("body_entered");
body_shape_exited = StaticCString::create("body_shape_exited");
body_exited = StaticCString::create("body_exited");
area_shape_entered = StaticCString::create("area_shape_entered");
area_shape_exited = StaticCString::create("area_shape_exited");
update = StaticCString::create("update");
updated = StaticCString::create("updated");
_ready = StaticCString::create("_ready");
screen_entered = StaticCString::create("screen_entered");
screen_exited = StaticCString::create("screen_exited");
gui_input = StaticCString::create("gui_input");
_spatial_editor_group = StaticCString::create("_spatial_editor_group");
_request_gizmo = StaticCString::create("_request_gizmo");
offset = StaticCString::create("offset");
rotation_mode = StaticCString::create("rotation_mode");
rotate = StaticCString::create("rotate");
h_offset = StaticCString::create("h_offset");
v_offset = StaticCString::create("v_offset");
area_entered = StaticCString::create("area_entered");
area_exited = StaticCString::create("area_exited");
line_separation = StaticCString::create("line_separation");
font = StaticCString::create("font");
font_size = StaticCString::create("font_size");
font_color = StaticCString::create("font_color");
frame_changed = StaticCString::create("frame_changed");
texture_changed = StaticCString::create("texture_changed");
autoplay = StaticCString::create("autoplay");
blend_times = StaticCString::create("blend_times");
speed = StaticCString::create("speed");
node_configuration_warning_changed = StaticCString::create("node_configuration_warning_changed");
output = StaticCString::create("output");
path_pp = NodePath("..");
// Audio bus name.
Master = StaticCString::create("Master");
default_ = StaticCString::create("default");
window_input = StaticCString::create("window_input");
theme_changed = StaticCString::create("theme_changed");
shader_overrides_group = StaticCString::create("_shader_overrides_group_");
shader_overrides_group_active = StaticCString::create("_shader_overrides_group_active_");
_custom_type_script = StaticCString::create("_custom_type_script");
pressed = StaticCString::create("pressed");
id_pressed = StaticCString::create("id_pressed");
toggled = StaticCString::create("toggled");
panel = StaticCString::create("panel");
item_selected = StaticCString::create("item_selected");
confirmed = StaticCString::create("confirmed");
text_changed = StaticCString::create("text_changed");
text_submitted = StaticCString::create("text_submitted");
value_changed = StaticCString::create("value_changed");
}

View file

@ -35,129 +35,121 @@
#include "core/string/string_name.h" #include "core/string/string_name.h"
class SceneStringNames { class SceneStringNames {
friend void register_scene_types(); inline static SceneStringNames *singleton = nullptr;
friend void unregister_scene_types();
static SceneStringNames *singleton;
public:
static void create() { singleton = memnew(SceneStringNames); } static void create() { singleton = memnew(SceneStringNames); }
static void free() { static void free() {
memdelete(singleton); memdelete(singleton);
singleton = nullptr; singleton = nullptr;
} }
SceneStringNames();
public:
_FORCE_INLINE_ static SceneStringNames *get_singleton() { return singleton; } _FORCE_INLINE_ static SceneStringNames *get_singleton() { return singleton; }
StringName resized; const StringName resized = StaticCString::create("resized");
StringName draw; const StringName draw = StaticCString::create("draw");
StringName hidden; const StringName hidden = StaticCString::create("hidden");
StringName visibility_changed; const StringName visibility_changed = StaticCString::create("visibility_changed");
StringName input_event;
StringName gui_input;
StringName item_rect_changed;
StringName shader;
StringName tree_entered;
StringName tree_exiting;
StringName tree_exited;
StringName ready;
StringName size_flags_changed;
StringName minimum_size_changed;
StringName sleeping_state_changed;
StringName update;
StringName updated;
StringName line_separation; const StringName input_event = StaticCString::create("input_event");
StringName font; const StringName gui_input = StaticCString::create("gui_input");
StringName font_size; const StringName window_input = StaticCString::create("window_input");
StringName font_color;
StringName mouse_entered; const StringName tree_entered = StaticCString::create("tree_entered");
StringName mouse_exited; const StringName tree_exiting = StaticCString::create("tree_exiting");
StringName mouse_shape_entered; const StringName tree_exited = StaticCString::create("tree_exited");
StringName mouse_shape_exited; const StringName ready = StaticCString::create("ready");
StringName focus_entered; const StringName _ready = StaticCString::create("_ready");
StringName focus_exited;
StringName pre_sort_children; const StringName item_rect_changed = StaticCString::create("item_rect_changed");
StringName sort_children; const StringName size_flags_changed = StaticCString::create("size_flags_changed");
const StringName minimum_size_changed = StaticCString::create("minimum_size_changed");
const StringName sleeping_state_changed = StaticCString::create("sleeping_state_changed");
const StringName node_configuration_warning_changed = StaticCString::create("node_configuration_warning_changed");
const StringName update = StaticCString::create("update");
const StringName updated = StaticCString::create("updated");
StringName finished; const StringName line_separation = StaticCString::create("line_separation");
StringName animation_finished; const StringName font = StaticCString::create("font");
StringName animation_changed; const StringName font_size = StaticCString::create("font_size");
StringName animation_started; const StringName font_color = StaticCString::create("font_color");
StringName RESET;
StringName pose_updated; const StringName mouse_entered = StaticCString::create("mouse_entered");
StringName skeleton_updated; const StringName mouse_exited = StaticCString::create("mouse_exited");
StringName bone_enabled_changed; const StringName mouse_shape_entered = StaticCString::create("mouse_shape_entered");
StringName show_rest_only_changed; const StringName mouse_shape_exited = StaticCString::create("mouse_shape_exited");
const StringName focus_entered = StaticCString::create("focus_entered");
const StringName focus_exited = StaticCString::create("focus_exited");
StringName body_shape_entered; const StringName pre_sort_children = StaticCString::create("pre_sort_children");
StringName body_entered; const StringName sort_children = StaticCString::create("sort_children");
StringName body_shape_exited;
StringName body_exited;
StringName area_shape_entered; const StringName finished = StaticCString::create("finished");
StringName area_shape_exited; const StringName animation_finished = StaticCString::create("animation_finished");
const StringName animation_changed = StaticCString::create("animation_changed");
const StringName animation_started = StaticCString::create("animation_started");
const StringName RESET = StaticCString::create("RESET");
StringName _ready; const StringName pose_updated = StaticCString::create("pose_updated");
const StringName skeleton_updated = StaticCString::create("skeleton_updated");
const StringName bone_enabled_changed = StaticCString::create("bone_enabled_changed");
const StringName show_rest_only_changed = StaticCString::create("show_rest_only_changed");
StringName screen_entered; const StringName body_shape_entered = StaticCString::create("body_shape_entered");
StringName screen_exited; const StringName body_entered = StaticCString::create("body_entered");
const StringName body_shape_exited = StaticCString::create("body_shape_exited");
const StringName body_exited = StaticCString::create("body_exited");
StringName _spatial_editor_group; const StringName area_shape_entered = StaticCString::create("area_shape_entered");
StringName _request_gizmo; const StringName area_shape_exited = StaticCString::create("area_shape_exited");
StringName offset; const StringName screen_entered = StaticCString::create("screen_entered");
StringName rotation_mode; const StringName screen_exited = StaticCString::create("screen_exited");
StringName rotate;
StringName v_offset;
StringName h_offset;
StringName area_entered; const StringName _spatial_editor_group = StaticCString::create("_spatial_editor_group");
StringName area_exited; const StringName _request_gizmo = StaticCString::create("_request_gizmo");
StringName frame_changed; const StringName offset = StaticCString::create("offset");
StringName texture_changed; const StringName rotation_mode = StaticCString::create("rotation_mode");
const StringName rotate = StaticCString::create("rotate");
const StringName h_offset = StaticCString::create("h_offset");
const StringName v_offset = StaticCString::create("v_offset");
StringName autoplay; const StringName area_entered = StaticCString::create("area_entered");
StringName blend_times; const StringName area_exited = StaticCString::create("area_exited");
StringName speed;
NodePath path_pp; const StringName frame_changed = StaticCString::create("frame_changed");
const StringName texture_changed = StaticCString::create("texture_changed");
StringName default_; // "default", conflict with C++ keyword. const StringName autoplay = StaticCString::create("autoplay");
const StringName blend_times = StaticCString::create("blend_times");
const StringName speed = StaticCString::create("speed");
StringName node_configuration_warning_changed; const NodePath path_pp = NodePath("..");
StringName output; const StringName default_ = StaticCString::create("default"); // default would conflict with C++ keyword.
const StringName output = StaticCString::create("output");
StringName Master; const StringName Master = StaticCString::create("Master"); // Audio bus name.
StringName window_input; const StringName theme_changed = StaticCString::create("theme_changed");
const StringName shader = StaticCString::create("shader");
const StringName shader_overrides_group = StaticCString::create("_shader_overrides_group_");
const StringName shader_overrides_group_active = StaticCString::create("_shader_overrides_group_active_");
StringName theme_changed; const StringName _custom_type_script = StaticCString::create("_custom_type_script");
StringName shader_overrides_group;
StringName shader_overrides_group_active;
StringName _custom_type_script; const StringName pressed = StaticCString::create("pressed");
const StringName id_pressed = StaticCString::create("id_pressed");
const StringName toggled = StaticCString::create("toggled");
StringName pressed; const StringName panel = StaticCString::create("panel");
StringName id_pressed; const StringName item_selected = StaticCString::create("item_selected");
StringName toggled; const StringName confirmed = StaticCString::create("confirmed");
StringName panel; const StringName text_changed = StaticCString::create("text_changed");
const StringName text_submitted = StaticCString::create("text_submitted");
StringName item_selected; const StringName value_changed = StaticCString::create("value_changed");
StringName confirmed;
StringName text_changed;
StringName text_submitted;
StringName value_changed;
}; };
#define SceneStringName(m_name) SceneStringNames::get_singleton()->m_name #define SceneStringName(m_name) SceneStringNames::get_singleton()->m_name