summaryrefslogtreecommitdiff
path: root/modules/gdnative/nativescript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative/nativescript')
-rw-r--r--modules/gdnative/nativescript/nativescript.h2
-rw-r--r--modules/gdnative/nativescript/register_types.cpp14
2 files changed, 10 insertions, 6 deletions
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index e6f3c06ee5..67fb54387d 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -380,6 +380,7 @@ public:
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
+ GDCLASS(ResourceFormatLoaderNativeScript, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -388,6 +389,7 @@ public:
};
class ResourceFormatSaverNativeScript : public ResourceFormatSaver {
+ GDCLASS(ResourceFormatSaverNativeScript, ResourceFormatSaver)
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual bool recognize(const RES &p_resource) const;
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index 4433c0a638..1e0c3d9fd8 100644
--- a/modules/gdnative/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
@@ -39,8 +39,8 @@
NativeScriptLanguage *native_script_language;
-ResourceFormatLoaderNativeScript *resource_loader_gdns = NULL;
-ResourceFormatSaverNativeScript *resource_saver_gdns = NULL;
+Ref<ResourceFormatLoaderNativeScript> resource_loader_gdns;
+Ref<ResourceFormatSaverNativeScript> resource_saver_gdns;
void register_nativescript_types() {
native_script_language = memnew(NativeScriptLanguage);
@@ -50,18 +50,20 @@ void register_nativescript_types() {
native_script_language->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(native_script_language);
- resource_saver_gdns = memnew(ResourceFormatSaverNativeScript);
+ resource_saver_gdns.instance();
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
- resource_loader_gdns = memnew(ResourceFormatLoaderNativeScript);
+ resource_loader_gdns.instance();
ResourceLoader::add_resource_format_loader(resource_loader_gdns);
}
void unregister_nativescript_types() {
- memdelete(resource_loader_gdns);
+ ResourceLoader::remove_resource_format_loader(resource_loader_gdns);
+ resource_loader_gdns.unref();
- memdelete(resource_saver_gdns);
+ ResourceSaver::remove_resource_format_saver(resource_saver_gdns);
+ resource_saver_gdns.unref();
if (native_script_language) {
ScriptServer::unregister_language(native_script_language);