GDExtension: Implement GDExtensionLoader concept
- Implements the concept of GDExtension loaders that can be used to customize how GDExtensions are loaded and initialized. - Moves the parsing of `.gdextension` config files to the new `GDExtensionLibraryLoader`. - `GDExtensionManager` is now meant to be the main way to load/unload extensions and can optionally take a `GDExtensionLoader`. - `EditorFileSystem` avoids unloading extensions if the file still exists, this should prevent unloading extensions that are outside the user project.
This commit is contained in:
@ -31,13 +31,11 @@
|
||||
#ifndef GDEXTENSION_H
|
||||
#define GDEXTENSION_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "core/extension/gdextension_interface.h"
|
||||
#include "core/extension/gdextension_loader.h"
|
||||
#include "core/io/config_file.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/os/shared_object.h"
|
||||
|
||||
class GDExtensionMethodBind;
|
||||
|
||||
@ -46,8 +44,8 @@ class GDExtension : public Resource {
|
||||
|
||||
friend class GDExtensionManager;
|
||||
|
||||
void *library = nullptr; // pointer if valid,
|
||||
String library_path;
|
||||
Ref<GDExtensionLoader> loader;
|
||||
|
||||
bool reloadable = false;
|
||||
|
||||
struct Extension {
|
||||
@ -96,8 +94,6 @@ class GDExtension : public Resource {
|
||||
int32_t level_initialized = -1;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
uint64_t resource_last_modified_time = 0;
|
||||
uint64_t library_last_modified_time = 0;
|
||||
bool is_reloading = false;
|
||||
Vector<GDExtensionMethodBind *> invalid_methods;
|
||||
Vector<ObjectID> instance_bindings;
|
||||
@ -124,11 +120,12 @@ public:
|
||||
virtual bool editor_can_reload_from_file() override { return false; } // Reloading is handled in a special way.
|
||||
|
||||
static String get_extension_list_config_file();
|
||||
static String find_extension_library(const String &p_path, Ref<ConfigFile> p_config, std::function<bool(String)> p_has_feature, PackedStringArray *r_tags = nullptr);
|
||||
static Vector<SharedObject> find_extension_dependencies(const String &p_path, Ref<ConfigFile> p_config, std::function<bool(String)> p_has_feature);
|
||||
|
||||
Error open_library(const String &p_path, const String &p_entry_symbol, Vector<SharedObject> *p_dependencies = nullptr);
|
||||
const Ref<GDExtensionLoader> get_loader() const { return loader; }
|
||||
|
||||
Error open_library(const String &p_path, const Ref<GDExtensionLoader> &p_loader);
|
||||
void close_library();
|
||||
bool is_library_open() const;
|
||||
|
||||
enum InitializationLevel {
|
||||
INITIALIZATION_LEVEL_CORE = GDEXTENSION_INITIALIZATION_CORE,
|
||||
@ -146,17 +143,11 @@ protected:
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool is_library_open() const;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
bool is_reloadable() const { return reloadable; }
|
||||
void set_reloadable(bool p_reloadable) { reloadable = p_reloadable; }
|
||||
|
||||
bool has_library_changed() const;
|
||||
void update_last_modified_time(uint64_t p_resource_last_modified_time, uint64_t p_library_last_modified_time) {
|
||||
resource_last_modified_time = p_resource_last_modified_time;
|
||||
library_last_modified_time = p_library_last_modified_time;
|
||||
}
|
||||
|
||||
void track_instance_binding(Object *p_object);
|
||||
void untrack_instance_binding(Object *p_object);
|
||||
|
||||
Reference in New Issue
Block a user