2021-08-02 16:34:47 +00:00
|
|
|
/*************************************************************************/
|
2021-08-18 14:03:52 +00:00
|
|
|
/* godot.hpp */
|
2021-08-02 16:34:47 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-03-15 09:17:53 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2021-08-02 16:34:47 +00: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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
#ifndef GODOT_HPP
|
|
|
|
#define GODOT_HPP
|
2017-03-03 02:48:27 +00:00
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
#include <godot/gdnative_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
|
|
|
|
2021-10-28 08:20:56 +00:00
|
|
|
extern "C" const GDNativeInterface *gdn_interface;
|
2021-08-18 14:03:52 +00:00
|
|
|
extern "C" GDNativeExtensionClassLibraryPtr library;
|
|
|
|
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 {
|
|
|
|
MODULE_INITIALIZATION_LEVEL_CORE = GDNATIVE_INITIALIZATION_CORE,
|
|
|
|
MODULE_INITIALIZATION_LEVEL_SERVERS = GDNATIVE_INITIALIZATION_SERVERS,
|
|
|
|
MODULE_INITIALIZATION_LEVEL_SCENE = GDNATIVE_INITIALIZATION_SCENE,
|
|
|
|
MODULE_INITIALIZATION_LEVEL_EDITOR = GDNATIVE_INITIALIZATION_EDITOR
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
static GDNativeInitializationLevel minimum_initialization_level;
|
2021-08-18 14:03:52 +00:00
|
|
|
static GDNativeBool init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization);
|
2021-09-10 00:47:45 +00:00
|
|
|
|
|
|
|
public:
|
2021-08-18 14:03:52 +00:00
|
|
|
static void initialize_level(void *userdata, GDNativeInitializationLevel p_level);
|
|
|
|
static void deinitialize_level(void *userdata, GDNativeInitializationLevel p_level);
|
2018-01-20 18:37:23 +00:00
|
|
|
|
2021-09-10 00:47:45 +00:00
|
|
|
class InitObject {
|
2021-10-28 08:20:56 +00:00
|
|
|
const GDNativeInterface *gdn_interface;
|
2021-09-10 00:47:45 +00:00
|
|
|
const GDNativeExtensionClassLibraryPtr library;
|
|
|
|
GDNativeInitialization *initialization;
|
|
|
|
|
|
|
|
public:
|
|
|
|
InitObject(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) :
|
2021-10-28 08:20:56 +00:00
|
|
|
gdn_interface(p_interface),
|
2021-09-10 00:47:45 +00:00
|
|
|
library(p_library),
|
2021-09-21 13:55:05 +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
|
|
|
|
|
|
|
GDNativeBool init() const;
|
|
|
|
};
|
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
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
#endif // ! GODOT_HPP
|