summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEmmanuel Leblond <emmanuel.leblond@gmail.com>2022-10-22 13:46:59 +0200
committerEmmanuel Leblond <emmanuel.leblond@gmail.com>2022-11-08 21:44:30 +0100
commit0e81f89dd3ea7418573075a716dcdd94b73e8621 (patch)
treed4cc7538914beaf7fd2bc8bcba99e756b4c5aa2c /include
parent73ad6717e907ab24a5c5550f518eda53092c4495 (diff)
downloadredot-cpp-0e81f89dd3ea7418573075a716dcdd94b73e8621.tar.gz
Uses `StringName` in GDExtension perf critical instance creation & method/properties setter/getter
Diffstat (limited to 'include')
-rw-r--r--include/godot_cpp/classes/wrapped.hpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp
index ce1bc51..128e091 100644
--- a/include/godot_cpp/classes/wrapped.hpp
+++ b/include/godot_cpp/classes/wrapped.hpp
@@ -49,7 +49,7 @@ class Wrapped {
friend void postinitialize_handler(Wrapped *);
protected:
- virtual const char *_get_extension_class() const; // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
+ virtual const StringName *_get_extension_class() const; // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
virtual const GDNativeInstanceBindingCallbacks *_get_bindings_callbacks() const = 0;
void _notification(int p_what){};
@@ -74,12 +74,13 @@ protected:
void _postinitialize();
- Wrapped(const char *p_godot_class);
+ Wrapped(const StringName p_godot_class);
Wrapped(GodotObject *p_godot_object);
public:
- static const char *get_class_static() {
- return "Wrapped";
+ static StringName get_class_static() {
+ static StringName string_name = StringName("Wrapped");
+ return string_name;
}
uint64_t get_instance_id() const {
@@ -105,8 +106,9 @@ private:
friend class ::godot::ClassDB; \
\
protected: \
- virtual const char *_get_extension_class() const override { \
- return get_class_static(); \
+ virtual const StringName *_get_extension_class() const override { \
+ static StringName string_name = get_class_static(); \
+ return &string_name; \
} \
\
virtual const GDNativeInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
@@ -164,11 +166,12 @@ public:
initialized = true; \
} \
\
- static const char *get_class_static() { \
- return #m_class; \
+ static StringName get_class_static() { \
+ static StringName string_name = StringName(#m_class); \
+ return string_name; \
} \
\
- static const char *get_parent_class_static() { \
+ static StringName *get_parent_class_static() { \
return m_inherits::get_class_static(); \
} \
\
@@ -357,11 +360,12 @@ protected:
public: \
static void initialize_class() {} \
\
- static const char *get_class_static() { \
- return #m_class; \
+ static StringName get_class_static() { \
+ static StringName string_name = StringName(#m_class); \
+ return string_name; \
} \
\
- static const char *get_parent_class_static() { \
+ static StringName get_parent_class_static() { \
return m_inherits::get_class_static(); \
} \
\