2014-02-10 01:10:30 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* register_core_types.cpp */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "register_core_types.h"
|
|
|
|
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/config/engine.h"
|
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/core_bind.h"
|
2020-05-11 09:56:55 +00:00
|
|
|
#include "core/crypto/aes_context.h"
|
2019-07-11 13:26:44 +00:00
|
|
|
#include "core/crypto/crypto.h"
|
2019-07-19 13:06:43 +00:00
|
|
|
#include "core/crypto/hashing_context.h"
|
2022-02-06 00:55:58 +00:00
|
|
|
#include "core/debugger/engine_profiler.h"
|
2022-12-07 11:11:28 +00:00
|
|
|
#include "core/extension/gdextension.h"
|
|
|
|
#include "core/extension/gdextension_manager.h"
|
2020-04-28 13:19:37 +00:00
|
|
|
#include "core/input/input.h"
|
2020-03-01 22:14:37 +00:00
|
|
|
#include "core/input/input_map.h"
|
2021-08-22 15:37:22 +00:00
|
|
|
#include "core/input/shortcut.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/config_file.h"
|
2022-09-23 23:06:31 +00:00
|
|
|
#include "core/io/dir_access.h"
|
2019-08-21 20:52:24 +00:00
|
|
|
#include "core/io/dtls_server.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/http_client.h"
|
|
|
|
#include "core/io/image_loader.h"
|
2020-11-10 21:31:33 +00:00
|
|
|
#include "core/io/json.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/marshalls.h"
|
2022-04-28 20:49:10 +00:00
|
|
|
#include "core/io/missing_resource.h"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/io/packed_data_container.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/packet_peer.h"
|
2019-08-21 20:52:24 +00:00
|
|
|
#include "core/io/packet_peer_dtls.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/packet_peer_udp.h"
|
|
|
|
#include "core/io/pck_packer.h"
|
|
|
|
#include "core/io/resource_format_binary.h"
|
2019-02-12 12:30:56 +00:00
|
|
|
#include "core/io/resource_importer.h"
|
2021-07-23 19:01:18 +00:00
|
|
|
#include "core/io/resource_uid.h"
|
2022-07-30 09:43:05 +00:00
|
|
|
#include "core/io/stream_peer_gzip.h"
|
2022-09-06 22:46:12 +00:00
|
|
|
#include "core/io/stream_peer_tls.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/tcp_server.h"
|
|
|
|
#include "core/io/translation_loader_po.h"
|
2019-08-22 17:03:35 +00:00
|
|
|
#include "core/io/udp_server.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "core/io/xml_parser.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/math/a_star.h"
|
2022-07-04 18:42:47 +00:00
|
|
|
#include "core/math/a_star_grid_2d.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/math/expression.h"
|
2020-05-25 17:20:45 +00:00
|
|
|
#include "core/math/geometry_2d.h"
|
|
|
|
#include "core/math/geometry_3d.h"
|
2018-09-21 11:32:17 +00:00
|
|
|
#include "core/math/random_number_generator.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/math/triangle_mesh.h"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/object/class_db.h"
|
2022-03-26 15:48:43 +00:00
|
|
|
#include "core/object/script_language_extension.h"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/object/undo_redo.h"
|
2022-07-18 10:09:19 +00:00
|
|
|
#include "core/object/worker_thread_pool.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/os/main_loop.h"
|
2021-05-24 11:54:05 +00:00
|
|
|
#include "core/os/time.h"
|
2021-01-16 15:28:54 +00:00
|
|
|
#include "core/string/optimized_translation.h"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/string/translation.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
|
2018-06-11 00:59:53 +00:00
|
|
|
static Ref<ResourceFormatSaverBinary> resource_saver_binary;
|
|
|
|
static Ref<ResourceFormatLoaderBinary> resource_loader_binary;
|
|
|
|
static Ref<ResourceFormatImporter> resource_format_importer;
|
2022-12-05 18:01:59 +00:00
|
|
|
static Ref<ResourceFormatImporterSaver> resource_format_importer_saver;
|
2018-06-11 00:59:53 +00:00
|
|
|
static Ref<ResourceFormatLoaderImage> resource_format_image;
|
2019-01-10 11:45:57 +00:00
|
|
|
static Ref<TranslationLoaderPO> resource_format_po;
|
2019-07-11 13:26:44 +00:00
|
|
|
static Ref<ResourceFormatSaverCrypto> resource_format_saver_crypto;
|
|
|
|
static Ref<ResourceFormatLoaderCrypto> resource_format_loader_crypto;
|
2022-12-07 11:11:28 +00:00
|
|
|
static Ref<GDExtensionResourceLoader> resource_loader_gdextension;
|
2022-09-03 17:45:24 +00:00
|
|
|
static Ref<ResourceFormatSaverJSON> resource_saver_json;
|
|
|
|
static Ref<ResourceFormatLoaderJSON> resource_loader_json;
|
2018-07-29 19:45:23 +00:00
|
|
|
|
2021-08-13 14:46:14 +00:00
|
|
|
static core_bind::ResourceLoader *_resource_loader = nullptr;
|
|
|
|
static core_bind::ResourceSaver *_resource_saver = nullptr;
|
|
|
|
static core_bind::OS *_os = nullptr;
|
|
|
|
static core_bind::Engine *_engine = nullptr;
|
|
|
|
static core_bind::special::ClassDB *_classdb = nullptr;
|
|
|
|
static core_bind::Marshalls *_marshalls = nullptr;
|
|
|
|
static core_bind::EngineDebugger *_engine_debugger = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-01 23:20:12 +00:00
|
|
|
static IP *ip = nullptr;
|
2023-12-31 10:50:39 +00:00
|
|
|
static Time *_time = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-08-13 14:46:14 +00:00
|
|
|
static core_bind::Geometry2D *_geometry_2d = nullptr;
|
|
|
|
static core_bind::Geometry3D *_geometry_3d = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-07-18 10:09:19 +00:00
|
|
|
static WorkerThreadPool *worker_thread_pool = nullptr;
|
|
|
|
|
2020-02-26 10:28:13 +00:00
|
|
|
extern Mutex _global_mutex;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-12-07 11:11:28 +00:00
|
|
|
static GDExtensionManager *gdextension_manager = nullptr;
|
2021-06-19 15:58:49 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
extern void register_global_constants();
|
|
|
|
extern void unregister_global_constants();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-07-23 19:01:18 +00:00
|
|
|
static ResourceUID *resource_uid = nullptr;
|
|
|
|
|
2022-02-16 17:02:38 +00:00
|
|
|
static bool _is_core_extensions_registered = false;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void register_core_types() {
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_begin_measure("Core", "Register Types");
|
|
|
|
|
2020-02-19 19:27:19 +00:00
|
|
|
//consistency check
|
2020-02-20 14:13:08 +00:00
|
|
|
static_assert(sizeof(Callable) <= 16);
|
2020-02-19 19:27:19 +00:00
|
|
|
|
2017-01-07 21:25:37 +00:00
|
|
|
ObjectDB::setup();
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
StringName::setup();
|
2023-12-31 10:50:39 +00:00
|
|
|
_time = memnew(Time);
|
2019-01-27 22:24:55 +00:00
|
|
|
ResourceLoader::initialize();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
register_global_constants();
|
2020-11-09 03:19:09 +00:00
|
|
|
|
|
|
|
Variant::register_types();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
CoreStringNames::create();
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_format_po.instantiate();
|
2014-02-10 01:10:30 +00:00
|
|
|
ResourceLoader::add_resource_format_loader(resource_format_po);
|
|
|
|
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_saver_binary.instantiate();
|
2014-02-10 01:10:30 +00:00
|
|
|
ResourceSaver::add_resource_format_saver(resource_saver_binary);
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_loader_binary.instantiate();
|
2014-02-10 01:10:30 +00:00
|
|
|
ResourceLoader::add_resource_format_loader(resource_loader_binary);
|
|
|
|
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_format_importer.instantiate();
|
2017-02-01 12:45:45 +00:00
|
|
|
ResourceLoader::add_resource_format_loader(resource_format_importer);
|
|
|
|
|
2022-12-05 18:01:59 +00:00
|
|
|
resource_format_importer_saver.instantiate();
|
|
|
|
ResourceSaver::add_resource_format_saver(resource_format_importer_saver);
|
|
|
|
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_format_image.instantiate();
|
2018-07-29 19:45:23 +00:00
|
|
|
ResourceLoader::add_resource_format_loader(resource_format_image);
|
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(Object);
|
|
|
|
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(Script);
|
2022-03-26 15:48:43 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(ScriptLanguage);
|
|
|
|
|
|
|
|
GDREGISTER_VIRTUAL_CLASS(ScriptExtension);
|
|
|
|
GDREGISTER_VIRTUAL_CLASS(ScriptLanguageExtension);
|
2021-07-11 22:30:33 +00:00
|
|
|
|
|
|
|
GDREGISTER_CLASS(RefCounted);
|
|
|
|
GDREGISTER_CLASS(WeakRef);
|
|
|
|
GDREGISTER_CLASS(Resource);
|
2022-04-28 20:49:10 +00:00
|
|
|
GDREGISTER_VIRTUAL_CLASS(MissingResource);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(Image);
|
|
|
|
|
2021-08-22 15:37:22 +00:00
|
|
|
GDREGISTER_CLASS(Shortcut);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(InputEvent);
|
|
|
|
GDREGISTER_ABSTRACT_CLASS(InputEventWithModifiers);
|
|
|
|
GDREGISTER_ABSTRACT_CLASS(InputEventFromWindow);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(InputEventKey);
|
2021-08-22 15:37:22 +00:00
|
|
|
GDREGISTER_CLASS(InputEventShortcut);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(InputEventMouse);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(InputEventMouseButton);
|
|
|
|
GDREGISTER_CLASS(InputEventMouseMotion);
|
|
|
|
GDREGISTER_CLASS(InputEventJoypadButton);
|
|
|
|
GDREGISTER_CLASS(InputEventJoypadMotion);
|
|
|
|
GDREGISTER_CLASS(InputEventScreenDrag);
|
|
|
|
GDREGISTER_CLASS(InputEventScreenTouch);
|
|
|
|
GDREGISTER_CLASS(InputEventAction);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(InputEventGesture);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(InputEventMagnifyGesture);
|
|
|
|
GDREGISTER_CLASS(InputEventPanGesture);
|
|
|
|
GDREGISTER_CLASS(InputEventMIDI);
|
2017-05-20 15:38:03 +00:00
|
|
|
|
2021-03-23 16:03:29 +00:00
|
|
|
// Network
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(IP);
|
2021-03-23 16:03:29 +00:00
|
|
|
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(StreamPeer);
|
2021-09-06 15:30:20 +00:00
|
|
|
GDREGISTER_CLASS(StreamPeerExtension);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(StreamPeerBuffer);
|
2022-07-30 09:43:05 +00:00
|
|
|
GDREGISTER_CLASS(StreamPeerGZIP);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(StreamPeerTCP);
|
|
|
|
GDREGISTER_CLASS(TCPServer);
|
2021-03-23 16:03:29 +00:00
|
|
|
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(PacketPeer);
|
2021-08-28 15:04:22 +00:00
|
|
|
GDREGISTER_CLASS(PacketPeerExtension);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(PacketPeerStream);
|
|
|
|
GDREGISTER_CLASS(PacketPeerUDP);
|
|
|
|
GDREGISTER_CLASS(UDPServer);
|
2021-03-23 16:03:29 +00:00
|
|
|
|
2022-07-18 10:09:19 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(WorkerThreadPool);
|
|
|
|
|
2021-03-23 16:03:29 +00:00
|
|
|
ClassDB::register_custom_instance_class<HTTPClient>();
|
2019-07-11 13:26:44 +00:00
|
|
|
|
|
|
|
// Crypto
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(HashingContext);
|
|
|
|
GDREGISTER_CLASS(AESContext);
|
2019-07-11 13:26:44 +00:00
|
|
|
ClassDB::register_custom_instance_class<X509Certificate>();
|
|
|
|
ClassDB::register_custom_instance_class<CryptoKey>();
|
2023-01-20 00:51:35 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(TLSOptions);
|
2020-11-14 12:42:47 +00:00
|
|
|
ClassDB::register_custom_instance_class<HMACContext>();
|
2019-07-11 13:26:44 +00:00
|
|
|
ClassDB::register_custom_instance_class<Crypto>();
|
2022-09-06 22:46:12 +00:00
|
|
|
ClassDB::register_custom_instance_class<StreamPeerTLS>();
|
2021-03-23 16:03:29 +00:00
|
|
|
ClassDB::register_custom_instance_class<PacketPeerDTLS>();
|
|
|
|
ClassDB::register_custom_instance_class<DTLSServer>();
|
2019-07-11 13:26:44 +00:00
|
|
|
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_format_saver_crypto.instantiate();
|
2019-07-11 13:26:44 +00:00
|
|
|
ResourceSaver::add_resource_format_saver(resource_format_saver_crypto);
|
2021-06-17 22:03:09 +00:00
|
|
|
resource_format_loader_crypto.instantiate();
|
2019-07-11 13:26:44 +00:00
|
|
|
ResourceLoader::add_resource_format_loader(resource_format_loader_crypto);
|
|
|
|
|
2022-09-03 17:45:24 +00:00
|
|
|
resource_loader_json.instantiate();
|
|
|
|
ResourceLoader::add_resource_format_loader(resource_loader_json);
|
|
|
|
|
|
|
|
resource_saver_json.instantiate();
|
|
|
|
ResourceSaver::add_resource_format_saver(resource_saver_json);
|
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(MainLoop);
|
|
|
|
GDREGISTER_CLASS(Translation);
|
|
|
|
GDREGISTER_CLASS(OptimizedTranslation);
|
|
|
|
GDREGISTER_CLASS(UndoRedo);
|
|
|
|
GDREGISTER_CLASS(TriangleMesh);
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(ResourceFormatLoader);
|
|
|
|
GDREGISTER_CLASS(ResourceFormatSaver);
|
2018-06-11 00:59:53 +00:00
|
|
|
|
2022-09-05 11:01:31 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(FileAccess);
|
|
|
|
GDREGISTER_ABSTRACT_CLASS(DirAccess);
|
2021-08-13 14:46:14 +00:00
|
|
|
GDREGISTER_CLASS(core_bind::Thread);
|
|
|
|
GDREGISTER_CLASS(core_bind::Mutex);
|
|
|
|
GDREGISTER_CLASS(core_bind::Semaphore);
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(XMLParser);
|
|
|
|
GDREGISTER_CLASS(JSON);
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(ConfigFile);
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(PCKPacker);
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(PackedDataContainer);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(PackedDataContainerRef);
|
2022-03-20 14:20:32 +00:00
|
|
|
GDREGISTER_CLASS(AStar3D);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(AStar2D);
|
2022-07-04 18:42:47 +00:00
|
|
|
GDREGISTER_CLASS(AStarGrid2D);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(EncodedObjectAsID);
|
|
|
|
GDREGISTER_CLASS(RandomNumberGenerator);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-07-08 13:01:02 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(ImageFormatLoader);
|
|
|
|
GDREGISTER_CLASS(ImageFormatLoaderExtension);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(ResourceImporter);
|
2019-07-04 14:11:55 +00:00
|
|
|
|
2022-12-07 11:11:28 +00:00
|
|
|
GDREGISTER_CLASS(GDExtension);
|
2021-06-19 15:58:49 +00:00
|
|
|
|
2022-12-07 11:11:28 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(GDExtensionManager);
|
2021-06-19 15:58:49 +00:00
|
|
|
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(ResourceUID);
|
2021-07-23 19:01:18 +00:00
|
|
|
|
2022-02-06 00:55:58 +00:00
|
|
|
GDREGISTER_CLASS(EngineProfiler);
|
|
|
|
|
2021-07-23 19:01:18 +00:00
|
|
|
resource_uid = memnew(ResourceUID);
|
|
|
|
|
2022-12-07 11:11:28 +00:00
|
|
|
gdextension_manager = memnew(GDExtensionManager);
|
2021-06-19 15:58:49 +00:00
|
|
|
|
2022-12-07 11:11:28 +00:00
|
|
|
resource_loader_gdextension.instantiate();
|
|
|
|
ResourceLoader::add_resource_format_loader(resource_loader_gdextension);
|
2021-07-29 13:53:05 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
ip = IP::create();
|
|
|
|
|
2021-08-13 14:46:14 +00:00
|
|
|
_geometry_2d = memnew(core_bind::Geometry2D);
|
|
|
|
_geometry_3d = memnew(core_bind::Geometry3D);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-08-13 14:46:14 +00:00
|
|
|
_resource_loader = memnew(core_bind::ResourceLoader);
|
|
|
|
_resource_saver = memnew(core_bind::ResourceSaver);
|
|
|
|
_os = memnew(core_bind::OS);
|
|
|
|
_engine = memnew(core_bind::Engine);
|
|
|
|
_classdb = memnew(core_bind::special::ClassDB);
|
|
|
|
_marshalls = memnew(core_bind::Marshalls);
|
|
|
|
_engine_debugger = memnew(core_bind::EngineDebugger);
|
2022-03-14 14:52:03 +00:00
|
|
|
|
2022-08-07 10:35:28 +00:00
|
|
|
GDREGISTER_NATIVE_STRUCT(ObjectID, "uint64_t id = 0");
|
2022-03-14 14:52:03 +00:00
|
|
|
GDREGISTER_NATIVE_STRUCT(AudioFrame, "float left;float right");
|
2022-03-26 15:48:43 +00:00
|
|
|
GDREGISTER_NATIVE_STRUCT(ScriptLanguageExtensionProfilingInfo, "StringName signature;uint64_t call_count;uint64_t total_time;uint64_t self_time");
|
2022-07-18 10:09:19 +00:00
|
|
|
|
|
|
|
worker_thread_pool = memnew(WorkerThreadPool);
|
2023-01-13 19:24:12 +00:00
|
|
|
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_end_measure("Core", "Register Types");
|
2017-01-05 12:16:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void register_core_settings() {
|
2020-09-18 11:35:51 +00:00
|
|
|
// Since in register core types, globals may not be present.
|
2022-11-08 18:53:22 +00:00
|
|
|
GLOBAL_DEF(PropertyInfo(Variant::INT, "network/limits/tcp/connect_timeout_seconds", PROPERTY_HINT_RANGE, "1,1800,1"), (30));
|
|
|
|
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "network/limits/packet_peer_stream/max_buffer_po2", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), (16));
|
|
|
|
GLOBAL_DEF(PropertyInfo(Variant::STRING, "network/tls/certificate_bundle_override", PROPERTY_HINT_FILE, "*.crt"), "");
|
2022-07-18 10:09:19 +00:00
|
|
|
|
2023-05-11 10:24:59 +00:00
|
|
|
GLOBAL_DEF("threading/worker_pool/max_threads", -1);
|
|
|
|
GLOBAL_DEF("threading/worker_pool/low_priority_thread_ratio", 0.3);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void register_core_singletons() {
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_begin_measure("Core", "Register Singletons");
|
|
|
|
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(ProjectSettings);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(IP);
|
2021-08-13 14:46:14 +00:00
|
|
|
GDREGISTER_CLASS(core_bind::Geometry2D);
|
|
|
|
GDREGISTER_CLASS(core_bind::Geometry3D);
|
|
|
|
GDREGISTER_CLASS(core_bind::ResourceLoader);
|
|
|
|
GDREGISTER_CLASS(core_bind::ResourceSaver);
|
|
|
|
GDREGISTER_CLASS(core_bind::OS);
|
|
|
|
GDREGISTER_CLASS(core_bind::Engine);
|
|
|
|
GDREGISTER_CLASS(core_bind::special::ClassDB);
|
|
|
|
GDREGISTER_CLASS(core_bind::Marshalls);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(TranslationServer);
|
2022-03-10 07:17:38 +00:00
|
|
|
GDREGISTER_ABSTRACT_CLASS(Input);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(InputMap);
|
|
|
|
GDREGISTER_CLASS(Expression);
|
2021-08-13 14:46:14 +00:00
|
|
|
GDREGISTER_CLASS(core_bind::EngineDebugger);
|
2021-07-11 22:30:33 +00:00
|
|
|
GDREGISTER_CLASS(Time);
|
2017-10-09 21:49:17 +00:00
|
|
|
|
2017-11-13 20:46:57 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
|
2021-06-19 15:58:49 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton(), "IP"));
|
2021-08-13 14:46:14 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry2D", core_bind::Geometry2D::get_singleton()));
|
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry3D", core_bind::Geometry3D::get_singleton()));
|
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", core_bind::ResourceLoader::get_singleton()));
|
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", core_bind::ResourceSaver::get_singleton()));
|
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("OS", core_bind::OS::get_singleton()));
|
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Engine", core_bind::Engine::get_singleton()));
|
2017-11-13 20:46:57 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ClassDB", _classdb));
|
2021-08-13 14:46:14 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Marshalls", core_bind::Marshalls::get_singleton()));
|
2017-11-13 20:46:57 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton()));
|
2020-04-28 13:19:37 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton()));
|
2017-11-13 20:46:57 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton()));
|
2021-08-13 14:46:14 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("EngineDebugger", core_bind::EngineDebugger::get_singleton()));
|
2021-05-24 11:54:05 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("Time", Time::get_singleton()));
|
2022-12-07 11:11:28 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("GDExtensionManager", GDExtensionManager::get_singleton()));
|
2021-07-23 19:01:18 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceUID", ResourceUID::get_singleton()));
|
2022-07-18 10:09:19 +00:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("WorkerThreadPool", worker_thread_pool));
|
2023-12-08 11:52:49 +00:00
|
|
|
|
|
|
|
OS::get_singleton()->benchmark_end_measure("Core", "Register Singletons");
|
2021-06-19 15:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void register_core_extensions() {
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_begin_measure("Core", "Register Extensions");
|
|
|
|
|
Fix various typos with codespell
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-07 15:17:32 +00:00
|
|
|
// Hardcoded for now.
|
2022-12-07 11:11:28 +00:00
|
|
|
GDExtension::initialize_gdextensions();
|
|
|
|
gdextension_manager->load_extensions();
|
|
|
|
gdextension_manager->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_CORE);
|
2022-02-16 17:02:38 +00:00
|
|
|
_is_core_extensions_registered = true;
|
2023-12-08 11:52:49 +00:00
|
|
|
|
|
|
|
OS::get_singleton()->benchmark_end_measure("Core", "Register Extensions");
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-16 17:02:38 +00:00
|
|
|
void unregister_core_extensions() {
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_begin_measure("Core", "Unregister Extensions");
|
|
|
|
|
2022-02-16 17:02:38 +00:00
|
|
|
if (_is_core_extensions_registered) {
|
2022-12-07 11:11:28 +00:00
|
|
|
gdextension_manager->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_CORE);
|
2022-02-16 17:02:38 +00:00
|
|
|
}
|
2023-10-18 15:36:20 +00:00
|
|
|
GDExtension::finalize_gdextensions();
|
2023-12-08 11:52:49 +00:00
|
|
|
|
|
|
|
OS::get_singleton()->benchmark_end_measure("Core", "Unregister Extensions");
|
2022-02-16 17:02:38 +00:00
|
|
|
}
|
2021-06-19 15:58:49 +00:00
|
|
|
|
2022-02-16 17:02:38 +00:00
|
|
|
void unregister_core_types() {
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_begin_measure("Core", "Unregister Types");
|
2023-01-13 19:24:12 +00:00
|
|
|
|
2023-05-29 22:07:47 +00:00
|
|
|
// Destroy singletons in reverse order to ensure dependencies are not broken.
|
|
|
|
|
|
|
|
memdelete(worker_thread_pool);
|
2021-07-23 19:01:18 +00:00
|
|
|
|
2020-05-18 14:55:49 +00:00
|
|
|
memdelete(_engine_debugger);
|
2023-05-29 22:07:47 +00:00
|
|
|
memdelete(_marshalls);
|
|
|
|
memdelete(_classdb);
|
|
|
|
memdelete(_engine);
|
|
|
|
memdelete(_os);
|
|
|
|
memdelete(_resource_saver);
|
|
|
|
memdelete(_resource_loader);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-05-25 17:20:45 +00:00
|
|
|
memdelete(_geometry_3d);
|
2023-05-29 22:07:47 +00:00
|
|
|
memdelete(_geometry_2d);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2023-05-29 22:07:47 +00:00
|
|
|
memdelete(gdextension_manager);
|
|
|
|
|
|
|
|
memdelete(resource_uid);
|
|
|
|
|
|
|
|
if (ip) {
|
|
|
|
memdelete(ip);
|
|
|
|
}
|
2022-07-18 10:09:19 +00:00
|
|
|
|
2019-01-10 11:45:57 +00:00
|
|
|
ResourceLoader::remove_resource_format_loader(resource_format_image);
|
|
|
|
resource_format_image.unref();
|
|
|
|
|
|
|
|
ResourceSaver::remove_resource_format_saver(resource_saver_binary);
|
|
|
|
resource_saver_binary.unref();
|
|
|
|
|
|
|
|
ResourceLoader::remove_resource_format_loader(resource_loader_binary);
|
|
|
|
resource_loader_binary.unref();
|
|
|
|
|
|
|
|
ResourceLoader::remove_resource_format_loader(resource_format_importer);
|
|
|
|
resource_format_importer.unref();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-12-05 18:01:59 +00:00
|
|
|
ResourceSaver::remove_resource_format_saver(resource_format_importer_saver);
|
|
|
|
resource_format_importer_saver.unref();
|
|
|
|
|
2018-06-11 00:59:53 +00:00
|
|
|
ResourceLoader::remove_resource_format_loader(resource_format_po);
|
|
|
|
resource_format_po.unref();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-07-11 13:26:44 +00:00
|
|
|
ResourceSaver::remove_resource_format_saver(resource_format_saver_crypto);
|
|
|
|
resource_format_saver_crypto.unref();
|
|
|
|
ResourceLoader::remove_resource_format_loader(resource_format_loader_crypto);
|
|
|
|
resource_format_loader_crypto.unref();
|
|
|
|
|
2022-09-03 17:45:24 +00:00
|
|
|
ResourceSaver::remove_resource_format_saver(resource_saver_json);
|
|
|
|
resource_saver_json.unref();
|
|
|
|
|
|
|
|
ResourceLoader::remove_resource_format_loader(resource_loader_json);
|
|
|
|
resource_loader_json.unref();
|
|
|
|
|
2022-12-07 11:11:28 +00:00
|
|
|
ResourceLoader::remove_resource_format_loader(resource_loader_gdextension);
|
|
|
|
resource_loader_gdextension.unref();
|
2021-07-29 13:53:05 +00:00
|
|
|
|
2019-01-27 22:24:55 +00:00
|
|
|
ResourceLoader::finalize();
|
|
|
|
|
2019-06-01 13:42:22 +00:00
|
|
|
ClassDB::cleanup_defaults();
|
2023-12-31 10:50:39 +00:00
|
|
|
memdelete(_time);
|
2015-04-20 22:38:02 +00:00
|
|
|
ObjectDB::cleanup();
|
|
|
|
|
2020-11-09 03:19:09 +00:00
|
|
|
Variant::unregister_types();
|
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
unregister_global_constants();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
ResourceCache::clear();
|
2023-07-20 05:16:34 +00:00
|
|
|
ClassDB::cleanup();
|
2015-04-20 22:38:02 +00:00
|
|
|
CoreStringNames::free();
|
2014-02-10 01:10:30 +00:00
|
|
|
StringName::cleanup();
|
2023-01-13 19:24:12 +00:00
|
|
|
|
2023-12-08 11:52:49 +00:00
|
|
|
OS::get_singleton()->benchmark_end_measure("Core", "Unregister Types");
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|