summaryrefslogtreecommitdiff
path: root/modules/gdnative/pluginscript
diff options
context:
space:
mode:
authorMarc Gilleron <marc.gilleron@gmail.com>2018-06-11 02:59:53 +0200
committerMarc Gilleron <marc.gilleron@gmail.com>2018-12-15 05:34:53 +0000
commit065e2670af53ae2f71b78d57f8a217b4539cbbe2 (patch)
treea6b802b74f6f7ebd2018b5a3d35061bdcb91eb9d /modules/gdnative/pluginscript
parentca28c455bfdc8408485c217c17f07011c0b43f64 (diff)
Added basic support for custom resource savers and loaders
Diffstat (limited to 'modules/gdnative/pluginscript')
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp6
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h8
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h6
3 files changed, 12 insertions, 8 deletions
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 2b538c4a36..0cda8859dd 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -417,8 +417,8 @@ void PluginScriptLanguage::unlock() {
PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) :
_desc(*desc) {
- _resource_loader = memnew(ResourceFormatLoaderPluginScript(this));
- _resource_saver = memnew(ResourceFormatSaverPluginScript(this));
+ _resource_loader = Ref<ResourceFormatLoaderPluginScript>(memnew(ResourceFormatLoaderPluginScript(this)));
+ _resource_saver = Ref<ResourceFormatSaverPluginScript>(memnew(ResourceFormatSaverPluginScript(this)));
// TODO: totally remove _lock attribute if NO_THREADS is set
#ifdef NO_THREADS
@@ -429,8 +429,6 @@ PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_des
}
PluginScriptLanguage::~PluginScriptLanguage() {
- memdelete(_resource_loader);
- memdelete(_resource_saver);
#ifndef NO_THREADS
if (_lock) {
memdelete(_lock);
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
index c4df6f3a33..f749e900f5 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ b/modules/gdnative/pluginscript/pluginscript_language.h
@@ -48,8 +48,8 @@ class PluginScriptLanguage : public ScriptLanguage {
friend class PluginScript;
friend class PluginScriptInstance;
- ResourceFormatLoaderPluginScript *_resource_loader;
- ResourceFormatSaverPluginScript *_resource_saver;
+ Ref<ResourceFormatLoaderPluginScript> _resource_loader;
+ Ref<ResourceFormatSaverPluginScript> _resource_saver;
const godot_pluginscript_language_desc _desc;
godot_pluginscript_language_data *_data;
@@ -59,8 +59,8 @@ class PluginScriptLanguage : public ScriptLanguage {
public:
virtual String get_name() const;
- _FORCE_INLINE_ ResourceFormatLoaderPluginScript *get_resource_loader() { return _resource_loader; };
- _FORCE_INLINE_ ResourceFormatSaverPluginScript *get_resource_saver() { return _resource_saver; };
+ _FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; }
+ _FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; }
/* LANGUAGE FUNCTIONS */
virtual void init();
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h
index 5c17bb932e..ee9869be84 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.h
+++ b/modules/gdnative/pluginscript/pluginscript_loader.h
@@ -39,6 +39,9 @@
class PluginScriptLanguage;
class ResourceFormatLoaderPluginScript : public ResourceFormatLoader {
+
+ GDCLASS(ResourceFormatLoaderPluginScript, ResourceFormatLoader)
+
PluginScriptLanguage *_language;
public:
@@ -50,6 +53,9 @@ public:
};
class ResourceFormatSaverPluginScript : public ResourceFormatSaver {
+
+ GDCLASS(ResourceFormatSaverPluginScript, ResourceFormatSaver)
+
PluginScriptLanguage *_language;
public: