Skip to content

Commit e61ef9e

Browse files
committed
Get rid of the _godotcpp_initialize() helper
1 parent 415d46d commit e61ef9e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

binding_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
20622062
result = []
20632063

20642064
class_name = class_api["name"]
2065+
inherits = class_api["inherits"] if "inherits" in class_api else "Wrapped"
20652066
snake_class_name = camel_to_snake(class_name)
20662067
is_singleton = class_name in singletons
20672068

@@ -2113,7 +2114,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
21132114
result.append("}")
21142115
result.append("")
21152116

2116-
result.append(f"void {class_name}::_godotcpp_initialize() {{")
2117+
result.append(f"{class_name}::{class_name}(GodotObject *p_godot_object) : {inherits}(p_godot_object) {{")
21172118
result.append("\tif (singleton == nullptr) {")
21182119
result.append("\t\tsingleton = this;")
21192120
result.append(f"\t\tClassDB::_register_engine_singleton({class_name}::get_class_static(), singleton);")
@@ -2129,7 +2130,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
21292130
result.append("}")
21302131
result.append("")
21312132
else:
2132-
result.append(f"void {class_name}::_godotcpp_initialize() {{")
2133+
result.append(f"{class_name}::{class_name}(GodotObject *p_godot_object) : {inherits}(p_godot_object) {{")
21332134
result.append("}")
21342135
result.append("")
21352136

include/godot_cpp/classes/wrapped.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,9 @@ private:
414414
friend class ::godot::ClassDB; \
415415
friend class ::godot::Wrapped; \
416416
\
417-
void _godotcpp_initialize(); \
418-
\
419417
protected: \
420418
m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
421-
m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
419+
m_class(GodotObject *p_godot_object); \
422420
\
423421
static void _bind_methods() {} \
424422
\
@@ -483,7 +481,6 @@ public:
483481
static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \
484482
/* Do not call memnew here, we don't want the post-initializer to be called */ \
485483
m_class *obj = new ("", "") m_class((GodotObject *)p_instance); \
486-
obj->_godotcpp_initialize(); \
487484
return obj; \
488485
} \
489486
static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \

0 commit comments

Comments
 (0)