diff options
| author | Jeff Ward <jeff@fuzzybinary.com> | 2023-08-15 20:03:49 -0400 |
|---|---|---|
| committer | Jeff Ward <jeff@fuzzybinary.com> | 2023-09-19 22:33:32 -0400 |
| commit | 60851af4daf2d64631cfa87718da068b2ae47a4f (patch) | |
| tree | 57a4f354475ec8f2f1e1d18130590a57e615e520 /core/extension/gdextension.cpp | |
| parent | 571cd0eb791b37e9a8adda9f909251138170f6b7 (diff) | |
| download | redot-engine-60851af4daf2d64631cfa87718da068b2ae47a4f.tar.gz | |
Add functions for non-ptr style virtual calls in GDExtension
This adds two functions to `GDExtensionClassCreationInfo` that allow for developers to supply a generic virtual call function along with user data to be sent to that call.
If `get_virutal_call_data_func` is not null, extensions call this function to get user data to pass to a supplied `call_virtual_with_data_func`. Both must be provided is one is provided.
If `get_virtual_call_data_func` is null, Godot falls back to the old `get_virtual_func` logic.
Fixes #63275
Co-authored-by: David Snopek <dsnopek@gmail.com>
Diffstat (limited to 'core/extension/gdextension.cpp')
| -rw-r--r-- | core/extension/gdextension.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index 3bc7dde10a..bffa0e251f 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -301,6 +301,8 @@ void GDExtension::_register_extension_class(GDExtensionClassLibraryPtr p_library p_extension_funcs->create_instance_func, // GDExtensionClassCreateInstance create_instance_func; /* this one is mandatory */ p_extension_funcs->free_instance_func, // GDExtensionClassFreeInstance free_instance_func; /* this one is mandatory */ p_extension_funcs->get_virtual_func, // GDExtensionClassGetVirtual get_virtual_func; + nullptr, // GDExtensionClassGetVirtualCallData get_virtual_call_data_func; + nullptr, // GDExtensionClassCallVirtualWithData call_virtual_func; p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid; p_extension_funcs->class_userdata, // void *class_userdata; }; @@ -375,6 +377,8 @@ void GDExtension::_register_extension_class_internal(GDExtensionClassLibraryPtr extension->gdextension.create_instance = p_extension_funcs->create_instance_func; extension->gdextension.free_instance = p_extension_funcs->free_instance_func; extension->gdextension.get_virtual = p_extension_funcs->get_virtual_func; + extension->gdextension.get_virtual_call_data = p_extension_funcs->get_virtual_call_data_func; + extension->gdextension.call_virtual_with_data = p_extension_funcs->call_virtual_with_data_func; extension->gdextension.get_rid = p_extension_funcs->get_rid_func; ClassDB::register_extension_class(&extension->gdextension); |
