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 */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
|
|
|
/* */
|
|
|
|
/* 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-08-18 14:03:52 +00:00
|
|
|
extern "C" const GDNativeInterface *interface;
|
|
|
|
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
|
|
|
|
2021-08-18 14:03:52 +00:00
|
|
|
class GDExtensionBinding {
|
|
|
|
public:
|
2021-09-10 00:47:45 +00:00
|
|
|
using Callback = void (*)();
|
|
|
|
|
2021-09-11 02:31:10 +00:00
|
|
|
static Callback init_callbacks[GDNATIVE_MAX_INITIALIZATION_LEVEL];
|
|
|
|
static Callback terminate_callbacks[GDNATIVE_MAX_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-08-18 14:03:52 +00:00
|
|
|
static void *create_instance_callback(void *p_token, void *p_instance);
|
|
|
|
static void free_instance_callback(void *p_token, void *p_instance, void *p_binding);
|
2021-09-10 00:47:45 +00:00
|
|
|
|
|
|
|
class InitObject {
|
|
|
|
const GDNativeInterface *interface;
|
|
|
|
const GDNativeExtensionClassLibraryPtr library;
|
|
|
|
GDNativeInitialization *initialization;
|
|
|
|
|
|
|
|
public:
|
|
|
|
InitObject(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) :
|
|
|
|
interface(p_interface),
|
|
|
|
library(p_library),
|
2021-09-11 02:31:10 +00:00
|
|
|
initialization(r_initialization) {};
|
2021-09-10 00:47:45 +00:00
|
|
|
|
|
|
|
void register_core_initializer(Callback p_core_init) const;
|
|
|
|
void register_server_initializer(Callback p_server_init) const;
|
|
|
|
void register_scene_initializer(Callback p_scene_init) const;
|
|
|
|
void register_editor_initializer(Callback p_editor_init) const;
|
2021-09-11 02:31:10 +00:00
|
|
|
void register_driver_initializer(Callback p_driver_init) const;
|
2021-09-10 00:47:45 +00:00
|
|
|
void register_core_terminator(Callback p_core_terminate) const;
|
|
|
|
void register_server_terminator(Callback p_server_terminate) const;
|
|
|
|
void register_scene_terminator(Callback p_scene_terminate) const;
|
|
|
|
void register_editor_terminator(Callback p_editor_terminate) const;
|
2021-09-11 02:31:10 +00:00
|
|
|
void register_driver_terminator(Callback p_driver_terminate) 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
|