|
@@ -133,8 +133,7 @@ Create the file ``init.h`` in the ``src`` folder, with the following contents:
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
- #ifndef INIT_H
|
|
|
- #define INIT_H
|
|
|
+ #pragma once
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
@@ -144,8 +143,6 @@ Create the file ``init.h`` in the ``src`` folder, with the following contents:
|
|
|
void deinitialize_gdexample_module(void *p_userdata, GDExtensionInitializationLevel p_level);
|
|
|
GDExtensionBool GDE_EXPORT gdexample_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
|
|
|
|
|
|
- #endif // INIT_H
|
|
|
-
|
|
|
The functions declared here have the signatures expected by the GDExtension API.
|
|
|
|
|
|
Note the inclusion of the ``defs.h`` file. This is one of our helpers to
|
|
@@ -158,8 +155,7 @@ Create the ``defs.h`` file in the ``src`` folder with the following contents:
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
- #ifndef DEFS_H
|
|
|
- #define DEFS_H
|
|
|
+ #pragma once
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
#include <stddef.h>
|
|
@@ -175,8 +171,6 @@ Create the ``defs.h`` file in the ``src`` folder with the following contents:
|
|
|
#endif
|
|
|
#endif // ! GDE_EXPORT
|
|
|
|
|
|
- #endif // DEFS_H
|
|
|
-
|
|
|
We also include some standard headers to make things easier. Now we only have to
|
|
|
include ``defs.h`` and those will come as a bonus.
|
|
|
|
|
@@ -224,8 +218,7 @@ contents:
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
- #ifndef GDEXAMPLE_H
|
|
|
- #define GDEXAMPLE_H
|
|
|
+ #pragma once
|
|
|
|
|
|
#include "gdextension_interface.h"
|
|
|
|
|
@@ -247,8 +240,6 @@ contents:
|
|
|
// Bindings.
|
|
|
void gdexample_class_bind_methods();
|
|
|
|
|
|
- #endif // GDEXAMPLE_H
|
|
|
-
|
|
|
Noteworthy here is the ``object`` field, which holds a pointer to
|
|
|
the Godot object, and the ``gdexample_class_bind_methods()`` function, which will
|
|
|
register the metadata of our custom class (properties, methods, and signals).
|
|
@@ -299,8 +290,7 @@ We'll start by creating an ``api.h`` file in the ``src`` folder:
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
- #ifndef API_H
|
|
|
- #define API_H
|
|
|
+ #pragma once
|
|
|
|
|
|
/*
|
|
|
This file works as a collection of helpers to call the GDExtension API
|
|
@@ -333,10 +323,6 @@ We'll start by creating an ``api.h`` file in the ``src`` folder:
|
|
|
|
|
|
void load_api(GDExtensionInterfaceGetProcAddress p_get_proc_address);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- #endif // API_H
|
|
|
-
|
|
|
This file will include many other helpers as we fill our extension with
|
|
|
something useful. For now it only has a pointer to a function that creates a
|
|
|
StringName from a C string (in Latin-1 encoding) and another to destruct a
|