-
-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for new NOTIFICATION_POSTINITIALIZE handling #1568
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,9 +116,13 @@ class ClassDB { | |
static void _register_class(bool p_virtual = false, bool p_exposed = true, bool p_runtime = false); | ||
|
||
template <typename T> | ||
static GDExtensionObjectPtr _create_instance_func(void *data) { | ||
static GDExtensionObjectPtr _create_instance_func(void *data, GDExtensionBool p_notify_postinitialize) { | ||
if constexpr (!std::is_abstract_v<T>) { | ||
T *new_object = memnew(T); | ||
Wrapped::_set_construct_info<T>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By replacing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR shouldn't change anything about how developers use godot-cpp, this should be a purely internal change within godot-cpp. If you look a couple lines down, it will call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh that makes sense. Thanks for explaining! |
||
T *new_object = new ("", "") T; | ||
if (p_notify_postinitialize) { | ||
new_object->_postinitialize(); | ||
} | ||
return new_object->_owner; | ||
} else { | ||
return nullptr; | ||
|
@@ -241,7 +245,7 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { | |
class_register_order.push_back(cl.name); | ||
|
||
// Register this class with Godot | ||
GDExtensionClassCreationInfo3 class_info = { | ||
GDExtensionClassCreationInfo4 class_info = { | ||
p_virtual, // GDExtensionBool is_virtual; | ||
is_abstract, // GDExtensionBool is_abstract; | ||
p_exposed, // GDExtensionBool is_exposed; | ||
|
@@ -263,11 +267,10 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { | |
&ClassDB::get_virtual_func, // GDExtensionClassGetVirtual get_virtual_func; | ||
nullptr, // GDExtensionClassGetVirtualCallData get_virtual_call_data_func; | ||
nullptr, // GDExtensionClassCallVirtualWithData call_virtual_func; | ||
nullptr, // GDExtensionClassGetRID get_rid; | ||
(void *)&T::get_class_static(), // void *class_userdata; | ||
}; | ||
|
||
internal::gdextension_interface_classdb_register_extension_class3(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info); | ||
internal::gdextension_interface_classdb_register_extension_class4(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info); | ||
|
||
// call bind_methods etc. to register all members of the class | ||
T::initialize_class(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt anyone will see a deprecation comment. Is there a reason we are avoiding
[[deprecated("Use GDExtensionClassCreationInfo4 instead.")]]
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is using a restricted subset of C: we want it to be possible to compile it with a C or C++ compiler, but it isn't meant to be "real code" because some bindings parse it, rather than compile it.
[[deprecated ...]]
is a C++ thing, but even if it was C, I think we probably wouldn't use it anyway because it could create problems for bindings that manually parse the header.FYI, I'd love to replace this with a JSON or XML definition that we generate the C code from, rather than the header being the definitive source.