@@ -52,6 +52,14 @@ class Wrapped {
52
52
friend class ClassDB ;
53
53
friend void postinitialize_handler (Wrapped *);
54
54
55
+ template <typename T, std::enable_if_t <std::is_base_of<::godot::Wrapped, T>::value, bool >>
56
+ friend _ALWAYS_INLINE_ void _pre_initialize ();
57
+
58
+ thread_local static const StringName *constructing_extension_class_name;
59
+ thread_local static const GDExtensionInstanceBindingCallbacks *constructing_extension_class_binds_callbacks;
60
+
61
+ void _initialize ();
62
+
55
63
protected:
56
64
#ifdef HOT_RELOAD_ENABLED
57
65
struct RecreateInstance {
@@ -62,9 +70,6 @@ class Wrapped {
62
70
inline static RecreateInstance *recreate_instance = nullptr ;
63
71
#endif
64
72
65
- virtual const StringName *_get_extension_class_name () const ; // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
66
- virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks () const = 0;
67
-
68
73
void _notification (int p_what) {}
69
74
bool _set (const StringName &p_name, const Variant &p_property) { return false ; }
70
75
bool _get (const StringName &p_name, Variant &r_property) const { return false ; }
@@ -95,6 +100,8 @@ class Wrapped {
95
100
virtual ~Wrapped () {}
96
101
97
102
public:
103
+ static const StringName *_get_extension_class_name (); // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
104
+
98
105
static StringName &get_class_static () {
99
106
static StringName string_name = StringName (" Wrapped" );
100
107
return string_name;
@@ -108,6 +115,12 @@ class Wrapped {
108
115
GodotObject *_owner = nullptr ;
109
116
};
110
117
118
+ template <typename T, std::enable_if_t <std::is_base_of<::godot::Wrapped, T>::value, bool > = true >
119
+ _ALWAYS_INLINE_ void _pre_initialize () {
120
+ Wrapped::constructing_extension_class_name = T::_get_extension_class_name ();
121
+ Wrapped::constructing_extension_class_binds_callbacks = &T::_gde_binding_callbacks;
122
+ }
123
+
111
124
_FORCE_INLINE_ void snarray_add_str (Vector<StringName> &arr) {
112
125
}
113
126
@@ -162,15 +175,6 @@ private:
162
175
friend class ::godot::ClassDB; \
163
176
\
164
177
protected: \
165
- virtual const ::godot::StringName *_get_extension_class_name () const override { \
166
- static ::godot::StringName string_name = get_class_static (); \
167
- return &string_name; \
168
- } \
169
- \
170
- virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks () const override { \
171
- return &_gde_binding_callbacks; \
172
- } \
173
- \
174
178
static void (*_get_bind_methods ())() { \
175
179
return &m_class::_bind_methods; \
176
180
} \
@@ -213,6 +217,11 @@ protected:
213
217
} \
214
218
\
215
219
public: \
220
+ static const ::godot::StringName *_get_extension_class_name () { \
221
+ static ::godot::StringName string_name = get_class_static (); \
222
+ return &string_name; \
223
+ } \
224
+ \
216
225
typedef m_class self_type; \
217
226
\
218
227
static void initialize_class () { \
@@ -383,10 +392,6 @@ private:
383
392
void operator =(const m_class &p_rval) {} \
384
393
\
385
394
protected: \
386
- virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks () const override { \
387
- return &_gde_binding_callbacks; \
388
- } \
389
- \
390
395
m_class (const char *p_godot_class) : m_inherits(p_godot_class) {} \
391
396
m_class (GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
392
397
\
0 commit comments