Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDExtension: Implement GDExtensionLoader concept #91166

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
357 changes: 32 additions & 325 deletions core/extension/gdextension.cpp

Large diffs are not rendered by default.

23 changes: 7 additions & 16 deletions core/extension/gdextension.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -124,11 +120,12 @@ class GDExtension : public Resource {
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,
Expand All @@ -146,17 +143,11 @@ class GDExtension : public Resource {
#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);
Expand Down
Loading
Loading