Path: blob/master/core/extension/gdextension_manager.h
9903 views
/**************************************************************************/1/* gdextension_manager.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/extension/gdextension.h"3334class GDExtensionManager : public Object {35GDCLASS(GDExtensionManager, Object);3637int32_t level = -1;38HashMap<String, Ref<GDExtension>> gdextension_map;39HashMap<String, String> gdextension_class_icon_paths;4041bool startup_callback_called = false;42bool shutdown_callback_called = false;4344static void _bind_methods();4546static inline GDExtensionManager *singleton = nullptr;4748public:49enum LoadStatus {50LOAD_STATUS_OK,51LOAD_STATUS_FAILED,52LOAD_STATUS_ALREADY_LOADED,53LOAD_STATUS_NOT_LOADED,54LOAD_STATUS_NEEDS_RESTART,55};5657private:58LoadStatus _load_extension_internal(const Ref<GDExtension> &p_extension, bool p_first_load);59void _finish_load_extension(const Ref<GDExtension> &p_extension);60LoadStatus _unload_extension_internal(const Ref<GDExtension> &p_extension);6162#ifdef TOOLS_ENABLED63static void _reload_all_scripts();64#endif6566public:67LoadStatus load_extension(const String &p_path);68LoadStatus load_extension_with_loader(const String &p_path, const Ref<GDExtensionLoader> &p_loader);69LoadStatus reload_extension(const String &p_path);70LoadStatus unload_extension(const String &p_path);71bool is_extension_loaded(const String &p_path) const;72Vector<String> get_loaded_extensions() const;73Ref<GDExtension> get_extension(const String &p_path);7475bool class_has_icon_path(const String &p_class) const;76String class_get_icon_path(const String &p_class) const;7778void initialize_extensions(GDExtension::InitializationLevel p_level);79void deinitialize_extensions(GDExtension::InitializationLevel p_level);8081#ifdef TOOLS_ENABLED82void track_instance_binding(void *p_token, Object *p_object);83void untrack_instance_binding(void *p_token, Object *p_object);84#endif8586static GDExtensionManager *get_singleton();8788void load_extensions();89void reload_extensions();90bool ensure_extensions_loaded(const HashSet<String> &p_extensions);9192void startup();93void shutdown();94void frame();9596GDExtensionManager();97~GDExtensionManager();98};99100VARIANT_ENUM_CAST(GDExtensionManager::LoadStatus)101102103