You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix cyclic references in GDScript 2.0
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "gdscript.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
class GDScriptAnalyzer;
|
||||
class GDScriptParser;
|
||||
@@ -56,6 +57,7 @@ private:
|
||||
Status status = EMPTY;
|
||||
Error result = OK;
|
||||
String path;
|
||||
bool cleared = false;
|
||||
|
||||
friend class GDScriptCache;
|
||||
|
||||
@@ -64,6 +66,7 @@ public:
|
||||
Status get_status() const;
|
||||
GDScriptParser *get_parser() const;
|
||||
Error raise_status(Status p_new_status);
|
||||
void clear();
|
||||
|
||||
GDScriptParserRef() {}
|
||||
~GDScriptParserRef();
|
||||
@@ -72,19 +75,25 @@ public:
|
||||
class GDScriptCache {
|
||||
// String key is full path.
|
||||
HashMap<String, GDScriptParserRef *> parser_map;
|
||||
HashMap<String, GDScript *> shallow_gdscript_cache;
|
||||
HashMap<String, GDScript *> full_gdscript_cache;
|
||||
HashMap<String, Ref<GDScript>> shallow_gdscript_cache;
|
||||
HashMap<String, Ref<GDScript>> full_gdscript_cache;
|
||||
HashMap<String, HashSet<String>> dependencies;
|
||||
HashMap<String, Ref<PackedScene>> packed_scene_cache;
|
||||
HashMap<String, HashSet<String>> packed_scene_dependencies;
|
||||
|
||||
friend class GDScript;
|
||||
friend class GDScriptParserRef;
|
||||
friend class GDScriptInstance;
|
||||
|
||||
static GDScriptCache *singleton;
|
||||
|
||||
Mutex lock;
|
||||
static void remove_script(const String &p_path);
|
||||
bool destructing = false;
|
||||
|
||||
Mutex mutex;
|
||||
|
||||
public:
|
||||
static void move_script(const String &p_from, const String &p_to);
|
||||
static void remove_script(const String &p_path);
|
||||
static Ref<GDScriptParserRef> get_parser(const String &p_path, GDScriptParserRef::Status status, Error &r_error, const String &p_owner = String());
|
||||
static String get_source_code(const String &p_path);
|
||||
static Ref<GDScript> get_shallow_script(const String &p_path, Error &r_error, const String &p_owner = String());
|
||||
@@ -92,6 +101,16 @@ public:
|
||||
static Ref<GDScript> get_cached_script(const String &p_path);
|
||||
static Error finish_compiling(const String &p_owner);
|
||||
|
||||
static Ref<PackedScene> get_packed_scene(const String &p_path, Error &r_error, const String &p_owner = "");
|
||||
static void clear_unreferenced_packed_scenes();
|
||||
|
||||
static bool is_destructing() {
|
||||
if (singleton == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return singleton->destructing;
|
||||
};
|
||||
|
||||
GDScriptCache();
|
||||
~GDScriptCache();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user