2016-06-26 16:02:15 +02:00
|
|
|
/*************************************************************************/
|
2017-07-14 01:44:14 +02:00
|
|
|
/* register_types.cpp */
|
2016-06-26 16:02:15 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2016-06-26 16:02:15 +02:00
|
|
|
/*************************************************************************/
|
2018-01-01 14:40:08 +01:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2016-06-26 16:02:15 +02:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
#include "register_types.h"
|
2016-06-26 16:02:15 +02:00
|
|
|
|
2018-09-11 18:13:45 +02:00
|
|
|
#include "core/io/resource_loader.h"
|
|
|
|
#include "core/io/resource_saver.h"
|
2017-04-03 16:11:38 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
#include "nativescript.h"
|
2017-04-03 16:11:38 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
#include "core/os/os.h"
|
2017-04-03 16:11:38 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
NativeScriptLanguage *native_script_language;
|
2017-04-03 16:11:38 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
ResourceFormatLoaderNativeScript *resource_loader_gdns = NULL;
|
|
|
|
ResourceFormatSaverNativeScript *resource_saver_gdns = NULL;
|
2017-04-03 16:11:38 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
void register_nativescript_types() {
|
|
|
|
native_script_language = memnew(NativeScriptLanguage);
|
2017-04-17 21:42:11 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
ClassDB::register_class<NativeScript>();
|
2017-04-17 21:42:11 +02:00
|
|
|
|
2018-02-09 15:04:41 +01:00
|
|
|
native_script_language->set_language_index(ScriptServer::get_language_count());
|
2017-07-14 01:44:14 +02:00
|
|
|
ScriptServer::register_language(native_script_language);
|
2017-04-17 21:42:11 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
resource_saver_gdns = memnew(ResourceFormatSaverNativeScript);
|
|
|
|
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
|
2017-04-03 16:11:38 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
resource_loader_gdns = memnew(ResourceFormatLoaderNativeScript);
|
|
|
|
ResourceLoader::add_resource_format_loader(resource_loader_gdns);
|
2016-06-26 16:02:15 +02:00
|
|
|
}
|
2017-04-09 21:07:53 +02:00
|
|
|
|
2017-07-14 01:44:14 +02:00
|
|
|
void unregister_nativescript_types() {
|
|
|
|
|
|
|
|
memdelete(resource_loader_gdns);
|
|
|
|
|
|
|
|
memdelete(resource_saver_gdns);
|
|
|
|
|
|
|
|
if (native_script_language) {
|
|
|
|
ScriptServer::unregister_language(native_script_language);
|
|
|
|
memdelete(native_script_language);
|
|
|
|
}
|
|
|
|
}
|