diff options
author | David Snopek <dsnopek@gmail.com> | 2023-05-11 16:46:53 -0500 |
---|---|---|
committer | David Snopek <dsnopek@gmail.com> | 2023-05-25 09:14:29 -0500 |
commit | 300716321072c719dc5c3f8a19126fe753747a60 (patch) | |
tree | 1c10336faff8a53cc872e01f335a05157db2e878 /core/extension/gdextension_interface.cpp | |
parent | 809a98216267f3066b9fec2f02b2042bdc9d3e0d (diff) | |
download | redot-engine-300716321072c719dc5c3f8a19126fe753747a60.tar.gz |
Allow GDExtensions to add editor plugins
Diffstat (limited to 'core/extension/gdextension_interface.cpp')
-rw-r--r-- | core/extension/gdextension_interface.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/extension/gdextension_interface.cpp b/core/extension/gdextension_interface.cpp index c661bfa8c7..159c2e87df 100644 --- a/core/extension/gdextension_interface.cpp +++ b/core/extension/gdextension_interface.cpp @@ -1058,6 +1058,20 @@ static void *gdextension_classdb_get_class_tag(GDExtensionConstStringNamePtr p_c return class_info ? class_info->class_ptr : nullptr; } +static void gdextension_editor_add_plugin(GDExtensionConstStringNamePtr p_classname) { +#ifdef TOOLS_ENABLED + const StringName classname = *reinterpret_cast<const StringName *>(p_classname); + GDExtensionEditorPlugins::add_extension_class(classname); +#endif +} + +static void gdextension_editor_remove_plugin(GDExtensionConstStringNamePtr p_classname) { +#ifdef TOOLS_ENABLED + const StringName classname = *reinterpret_cast<const StringName *>(p_classname); + GDExtensionEditorPlugins::remove_extension_class(classname); +#endif +} + #define REGISTER_INTERFACE_FUNC(m_name) GDExtension::register_interface_function(#m_name, (GDExtensionInterfaceFunctionPtr)&gdextension_##m_name) void gdextension_setup_interface() { @@ -1185,6 +1199,8 @@ void gdextension_setup_interface() { REGISTER_INTERFACE_FUNC(classdb_construct_object); REGISTER_INTERFACE_FUNC(classdb_get_method_bind); REGISTER_INTERFACE_FUNC(classdb_get_class_tag); + REGISTER_INTERFACE_FUNC(editor_add_plugin); + REGISTER_INTERFACE_FUNC(editor_remove_plugin); } #undef REGISTER_INTERFACE_FUNCTION |