1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-23 15:16:17 +00:00

Merge pull request #77010 from dsnopek/gdextension-editor-plugins

Allow GDExtensions to add editor plugins
This commit is contained in:
Rémi Verschelde
2023-05-26 11:00:32 +02:00
9 changed files with 143 additions and 0 deletions

View File

@@ -1071,6 +1071,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() {
@@ -1199,6 +1213,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