2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* register_core_types.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2014-02-10 02:10:30 +01: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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "register_core_types.h"
|
|
|
|
|
|
|
|
#include "io/tcp_server.h"
|
2014-11-12 15:23:23 +01:00
|
|
|
#include "io/packet_peer_udp.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "io/config_file.h"
|
|
|
|
#include "os/main_loop.h"
|
|
|
|
#include "io/packet_peer.h"
|
2016-09-13 23:17:18 +02:00
|
|
|
#include "math/a_star.h"
|
2016-10-29 22:45:26 +02:00
|
|
|
#include "math/triangle_mesh.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "globals.h"
|
2017-01-16 08:04:19 +01:00
|
|
|
#include "class_db.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "geometry.h"
|
|
|
|
#include "bind/core_bind.h"
|
|
|
|
#include "core_string_names.h"
|
|
|
|
#include "path_remap.h"
|
|
|
|
#include "translation.h"
|
|
|
|
#include "compressed_translation.h"
|
|
|
|
#include "io/translation_loader_po.h"
|
|
|
|
#include "io/resource_format_binary.h"
|
2017-02-01 13:45:45 +01:00
|
|
|
#include "io/resource_import.h"
|
2014-04-29 02:56:43 +02:00
|
|
|
#include "io/stream_peer_ssl.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "os/input.h"
|
|
|
|
#include "core/io/xml_parser.h"
|
|
|
|
#include "io/http_client.h"
|
2016-10-01 22:04:10 +02:00
|
|
|
#include "io/pck_packer.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "packed_data_container.h"
|
2014-03-14 02:57:24 +01:00
|
|
|
#include "func_ref.h"
|
2014-04-24 07:53:45 +02:00
|
|
|
#include "input_map.h"
|
2016-02-28 03:10:44 +01:00
|
|
|
#include "undo_redo.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
static ResourceFormatSaverBinary *resource_saver_binary=NULL;
|
|
|
|
static ResourceFormatLoaderBinary *resource_loader_binary=NULL;
|
2017-02-01 13:45:45 +01:00
|
|
|
static ResourceFormatImporter *resource_format_importer=NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
static _ResourceLoader *_resource_loader=NULL;
|
|
|
|
static _ResourceSaver *_resource_saver=NULL;
|
|
|
|
static _OS *_os=NULL;
|
2017-01-13 16:51:14 +01:00
|
|
|
static _Engine *_engine=NULL;
|
2017-01-03 03:03:46 +01:00
|
|
|
static _ClassDB *_classdb=NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
static _Marshalls *_marshalls = NULL;
|
|
|
|
static TranslationLoaderPO *resource_format_po=NULL;
|
|
|
|
|
|
|
|
static IP* ip = NULL;
|
|
|
|
|
|
|
|
static _Geometry *_geometry=NULL;
|
|
|
|
|
|
|
|
extern Mutex *_global_mutex;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void register_variant_methods();
|
|
|
|
extern void unregister_variant_methods();
|
|
|
|
|
|
|
|
|
|
|
|
void register_core_types() {
|
|
|
|
|
2017-01-07 22:25:37 +01:00
|
|
|
ObjectDB::setup();
|
|
|
|
ResourceCache::setup();
|
|
|
|
MemoryPool::setup();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
_global_mutex=Mutex::create();
|
|
|
|
|
|
|
|
|
|
|
|
StringName::setup();
|
|
|
|
|
|
|
|
|
|
|
|
register_variant_methods();
|
|
|
|
|
|
|
|
|
|
|
|
CoreStringNames::create();
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
resource_format_po = memnew( TranslationLoaderPO );
|
|
|
|
ResourceLoader::add_resource_format_loader( resource_format_po );
|
|
|
|
|
|
|
|
|
|
|
|
resource_saver_binary = memnew( ResourceFormatSaverBinary );
|
|
|
|
ResourceSaver::add_resource_format_saver(resource_saver_binary);
|
|
|
|
resource_loader_binary = memnew( ResourceFormatLoaderBinary );
|
|
|
|
ResourceLoader::add_resource_format_loader(resource_loader_binary);
|
|
|
|
|
2017-02-01 13:45:45 +01:00
|
|
|
resource_format_importer = memnew( ResourceFormatImporter );
|
|
|
|
ResourceLoader::add_resource_format_loader(resource_format_importer);
|
|
|
|
|
2017-01-03 03:03:46 +01:00
|
|
|
ClassDB::register_class<Object>();
|
|
|
|
|
|
|
|
|
|
|
|
ClassDB::register_class<Reference>();
|
|
|
|
ClassDB::register_class<WeakRef>();
|
|
|
|
ClassDB::register_class<Resource>();
|
|
|
|
ClassDB::register_class<FuncRef>();
|
|
|
|
ClassDB::register_virtual_class<StreamPeer>();
|
|
|
|
ClassDB::register_class<StreamPeerBuffer>();
|
|
|
|
ClassDB::register_custom_instance_class<StreamPeerTCP>();
|
|
|
|
ClassDB::register_custom_instance_class<TCP_Server>();
|
|
|
|
ClassDB::register_custom_instance_class<PacketPeerUDP>();
|
|
|
|
ClassDB::register_custom_instance_class<StreamPeerSSL>();
|
|
|
|
ClassDB::register_virtual_class<IP>();
|
|
|
|
ClassDB::register_virtual_class<PacketPeer>();
|
|
|
|
ClassDB::register_class<PacketPeerStream>();
|
|
|
|
ClassDB::register_class<MainLoop>();
|
2017-01-14 12:26:56 +01:00
|
|
|
//ClassDB::register_type<OptimizedSaver>();
|
2017-01-03 03:03:46 +01:00
|
|
|
ClassDB::register_class<Translation>();
|
|
|
|
ClassDB::register_class<PHashTranslation>();
|
|
|
|
ClassDB::register_class<UndoRedo>();
|
|
|
|
ClassDB::register_class<HTTPClient>();
|
|
|
|
ClassDB::register_class<TriangleMesh>();
|
|
|
|
|
|
|
|
ClassDB::register_virtual_class<ResourceInteractiveLoader>();
|
|
|
|
|
|
|
|
ClassDB::register_class<_File>();
|
|
|
|
ClassDB::register_class<_Directory>();
|
|
|
|
ClassDB::register_class<_Thread>();
|
|
|
|
ClassDB::register_class<_Mutex>();
|
|
|
|
ClassDB::register_class<_Semaphore>();
|
|
|
|
|
|
|
|
ClassDB::register_class<XMLParser>();
|
|
|
|
|
|
|
|
ClassDB::register_class<ConfigFile>();
|
|
|
|
|
|
|
|
ClassDB::register_class<PCKPacker>();
|
|
|
|
|
|
|
|
ClassDB::register_class<PackedDataContainer>();
|
|
|
|
ClassDB::register_virtual_class<PackedDataContainerRef>();
|
|
|
|
ClassDB::register_class<AStar>();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ip = IP::create();
|
|
|
|
|
|
|
|
|
|
|
|
_geometry = memnew(_Geometry);
|
|
|
|
|
|
|
|
|
|
|
|
_resource_loader=memnew(_ResourceLoader);
|
|
|
|
_resource_saver=memnew(_ResourceSaver);
|
|
|
|
_os=memnew(_OS);
|
2017-01-13 16:51:14 +01:00
|
|
|
_engine=memnew(_Engine);
|
2017-01-03 03:03:46 +01:00
|
|
|
_classdb=memnew(_ClassDB);
|
2014-02-10 02:10:30 +01:00
|
|
|
_marshalls = memnew(_Marshalls);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-05 13:16:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void register_core_settings() {
|
|
|
|
//since in register core types, globals may not e present
|
|
|
|
GLOBAL_DEF( "network/packets/packet_stream_peer_max_buffer_po2",(16));
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void register_core_singletons() {
|
|
|
|
|
2017-01-05 13:16:00 +01:00
|
|
|
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("GlobalConfig",GlobalConfig::get_singleton()) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("IP",IP::get_singleton()) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Geometry",_Geometry::get_singleton()) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ResourceLoader",_ResourceLoader::get_singleton()) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ResourceSaver",_ResourceSaver::get_singleton()) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("OS",_OS::get_singleton() ) );
|
2017-01-13 16:51:14 +01:00
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Engine",_Engine::get_singleton() ) );
|
2017-01-05 13:16:00 +01:00
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ClassDB",_classdb ) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Marshalls",_Marshalls::get_singleton() ) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("TranslationServer",TranslationServer::get_singleton() ) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Input",Input::get_singleton() ) );
|
|
|
|
GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("InputMap",InputMap::get_singleton() ) );
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void unregister_core_types() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memdelete( _resource_loader );
|
|
|
|
memdelete( _resource_saver );
|
|
|
|
memdelete( _os);
|
2017-01-13 16:51:14 +01:00
|
|
|
memdelete( _engine );
|
2017-01-03 03:03:46 +01:00
|
|
|
memdelete( _classdb );
|
2014-02-10 02:10:30 +01:00
|
|
|
memdelete( _marshalls );
|
|
|
|
|
|
|
|
memdelete( _geometry );
|
|
|
|
|
|
|
|
if (resource_saver_binary)
|
|
|
|
memdelete(resource_saver_binary);
|
|
|
|
if (resource_loader_binary)
|
|
|
|
memdelete(resource_loader_binary);
|
2017-02-01 13:45:45 +01:00
|
|
|
if (resource_format_importer)
|
|
|
|
memdelete(resource_format_importer);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
memdelete( resource_format_po );
|
|
|
|
|
|
|
|
if (ip)
|
|
|
|
memdelete(ip);
|
|
|
|
|
2015-04-21 00:38:02 +02:00
|
|
|
|
|
|
|
ObjectDB::cleanup();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
unregister_variant_methods();
|
|
|
|
|
2017-01-03 03:03:46 +01:00
|
|
|
ClassDB::cleanup();
|
2014-02-10 02:10:30 +01:00
|
|
|
ResourceCache::clear();
|
2015-04-21 00:38:02 +02:00
|
|
|
CoreStringNames::free();
|
2014-02-10 02:10:30 +01:00
|
|
|
StringName::cleanup();
|
|
|
|
|
|
|
|
if (_global_mutex) {
|
|
|
|
memdelete(_global_mutex);
|
|
|
|
_global_mutex=NULL; //still needed at a few places
|
|
|
|
};
|
2017-01-07 22:25:37 +01:00
|
|
|
|
|
|
|
MemoryPool::cleanup();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|