2023-01-10 15:14:30 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* godot.hpp */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2021-08-02 16:34:47 +00:00
|
|
|
|
2022-10-09 06:47:07 +00:00
|
|
|
#ifndef GODOT_GODOT_HPP
|
|
|
|
#define GODOT_GODOT_HPP
|
2017-03-03 02:48:27 +00:00
|
|
|
|
2022-12-13 23:40:17 +00:00
|
|
|
#include <gdextension_interface.h>
|
2017-03-03 02:48:27 +00:00
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
namespace internal {
|
2017-03-03 02:48:27 +00:00
|
|
|
|
2022-12-07 13:11:44 +00:00
|
|
|
extern "C" const GDExtensionInterface *gde_interface;
|
|
|
|
extern "C" GDExtensionClassLibraryPtr library;
|
2021-08-18 14:03:52 +00:00
|
|
|
extern "C" void *token;
|
2017-03-03 02:48:27 +00:00
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
} // namespace internal
|
2020-08-04 16:42:00 +00:00
|
|
|
|
2022-05-04 08:00:14 +00:00
|
|
|
enum ModuleInitializationLevel {
|
2022-12-07 13:11:44 +00:00
|
|
|
MODULE_INITIALIZATION_LEVEL_CORE = GDEXTENSION_INITIALIZATION_CORE,
|
|
|
|
MODULE_INITIALIZATION_LEVEL_SERVERS = GDEXTENSION_INITIALIZATION_SERVERS,
|
|
|
|
MODULE_INITIALIZATION_LEVEL_SCENE = GDEXTENSION_INITIALIZATION_SCENE,
|
|
|
|
MODULE_INITIALIZATION_LEVEL_EDITOR = GDEXTENSION_INITIALIZATION_EDITOR
|
2022-05-04 08:00:14 +00:00
|
|
|
};
|
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
class GDExtensionBinding {
|
|
|
|
public:
|
2022-05-04 08:00:14 +00:00
|
|
|
using Callback = void (*)(ModuleInitializationLevel p_level);
|
2021-09-10 00:47:45 +00:00
|
|
|
|
2022-05-04 08:00:14 +00:00
|
|
|
static Callback init_callback;
|
|
|
|
static Callback terminate_callback;
|
2022-12-07 13:11:44 +00:00
|
|
|
static GDExtensionInitializationLevel minimum_initialization_level;
|
|
|
|
static GDExtensionBool init(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
|
2021-09-10 00:47:45 +00:00
|
|
|
|
|
|
|
public:
|
2022-12-07 13:11:44 +00:00
|
|
|
static void initialize_level(void *userdata, GDExtensionInitializationLevel p_level);
|
|
|
|
static void deinitialize_level(void *userdata, GDExtensionInitializationLevel p_level);
|
2018-01-20 18:37:23 +00:00
|
|
|
|
2021-09-10 00:47:45 +00:00
|
|
|
class InitObject {
|
2022-12-07 13:11:44 +00:00
|
|
|
const GDExtensionInterface *gde_interface;
|
|
|
|
GDExtensionClassLibraryPtr library;
|
|
|
|
GDExtensionInitialization *initialization;
|
2021-09-10 00:47:45 +00:00
|
|
|
|
|
|
|
public:
|
2022-12-07 13:11:44 +00:00
|
|
|
InitObject(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) :
|
|
|
|
gde_interface(p_interface),
|
2021-09-10 00:47:45 +00:00
|
|
|
library(p_library),
|
2022-11-18 18:33:28 +00:00
|
|
|
initialization(r_initialization) {}
|
2021-09-10 00:47:45 +00:00
|
|
|
|
2022-05-04 08:00:14 +00:00
|
|
|
void register_initializer(Callback p_init) const;
|
|
|
|
void register_terminator(Callback p_init) const;
|
|
|
|
void set_minimum_library_initialization_level(ModuleInitializationLevel p_level) const;
|
2021-09-10 00:47:45 +00:00
|
|
|
|
2022-12-07 13:11:44 +00:00
|
|
|
GDExtensionBool init() const;
|
2021-09-10 00:47:45 +00:00
|
|
|
};
|
2017-03-03 02:48:27 +00:00
|
|
|
};
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
} // namespace godot
|
2017-03-03 02:48:27 +00:00
|
|
|
|
2022-10-09 06:47:07 +00:00
|
|
|
#endif // GODOT_GODOT_HPP
|