mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-08 18:10:02 +03:00
Compare commits
154 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da26c1732e | ||
|
|
7284ac7573 | ||
|
|
d6097a8a8e | ||
|
|
9745f83d07 | ||
|
|
a5e04f7d77 | ||
|
|
a7378c589f | ||
|
|
7b0ee7466f | ||
|
|
abe94570a1 | ||
|
|
a278404541 | ||
|
|
bc8dabfe2a | ||
|
|
9e8b5827b9 | ||
|
|
006888ca7a | ||
|
|
1b6335278d | ||
|
|
d600131bad | ||
|
|
1e44bbefaa | ||
|
|
3a2932cce2 | ||
|
|
12cd5cd999 | ||
|
|
7f4e81fda7 | ||
|
|
e83fd0904c | ||
|
|
d884bb1001 | ||
|
|
5f1a8177a5 | ||
|
|
e36e81ac86 | ||
|
|
24d79abcfa | ||
|
|
4c78d30822 | ||
|
|
449e37fa21 | ||
|
|
21b73421c6 | ||
|
|
b192b880d3 | ||
|
|
fd708f429b | ||
|
|
3830fe4a40 | ||
|
|
9ea9b4797c | ||
|
|
05d2ce3006 | ||
|
|
1421ba26ad | ||
|
|
e0c0c566a6 | ||
|
|
8646cd31b5 | ||
|
|
e53489bbbe | ||
|
|
fbe5262d7b | ||
|
|
cb3ad55873 | ||
|
|
4f80491c8c | ||
|
|
a2b6f91dbc | ||
|
|
309b17b6eb | ||
|
|
134e8b756d | ||
|
|
8e7dfbc71a | ||
|
|
6a21f76c4d | ||
|
|
b64b941adf | ||
|
|
8bb931c6a9 | ||
|
|
6a870949a5 | ||
|
|
f129db3e3d | ||
|
|
c943beb4f4 | ||
|
|
c45c4aa667 | ||
|
|
8938e7e4e3 | ||
|
|
75f95ffbcb | ||
|
|
7f5f02940d | ||
|
|
3afe0d53c4 | ||
|
|
b46c31a50e | ||
|
|
61f52cb328 | ||
|
|
835a3abeea | ||
|
|
e17a5a78d1 | ||
|
|
5a0d6565d1 | ||
|
|
6d11a780bf | ||
|
|
646ccdf470 | ||
|
|
ed53a70e71 | ||
|
|
5cbffab4c6 | ||
|
|
86e32cef4a | ||
|
|
c8053dfa34 | ||
|
|
f25c4df5c4 | ||
|
|
fef59ff89a | ||
|
|
a7127d3ec7 | ||
|
|
dde6663d33 | ||
|
|
dc9ac508f4 | ||
|
|
d5baa7071e | ||
|
|
0c2e66e414 | ||
|
|
8eac097c37 | ||
|
|
4824aa41e8 | ||
|
|
af4f05ec7e | ||
|
|
4879eb7bd0 | ||
|
|
0871c7a93a | ||
|
|
681fb04f7a | ||
|
|
16e47d7ae5 | ||
|
|
543c1f7156 | ||
|
|
5a16059512 | ||
|
|
42f6dc6d49 | ||
|
|
64cdf089d9 | ||
|
|
f38c056b67 | ||
|
|
7fd0999b3c | ||
|
|
ca5af3c861 | ||
|
|
08fd033a9e | ||
|
|
195188f321 | ||
|
|
b195a51c6c | ||
|
|
2a8d218f12 | ||
|
|
70d8ff0c47 | ||
|
|
ddd4f2513c | ||
|
|
7670de814f | ||
|
|
321af5b827 | ||
|
|
bbbcc6adc7 | ||
|
|
62a5c609d3 | ||
|
|
97ad05beeb | ||
|
|
94a8fad88c | ||
|
|
7e6c9c9370 | ||
|
|
26201dd27a | ||
|
|
d634a5f8c4 | ||
|
|
c173cc0159 | ||
|
|
38e517b98b | ||
|
|
478e2637bd | ||
|
|
1163d1b4a8 | ||
|
|
096d9056f0 | ||
|
|
7888c15233 | ||
|
|
b6c0251296 | ||
|
|
30bfa6f215 | ||
|
|
7660dd28b3 | ||
|
|
335b490061 | ||
|
|
552a74c96e | ||
|
|
946a693859 | ||
|
|
da064d84d2 | ||
|
|
c26e7c9734 | ||
|
|
d72baf192d | ||
|
|
c2d688bae6 | ||
|
|
b0f41909e0 | ||
|
|
a2c37f8a16 | ||
|
|
7ffaecce8c | ||
|
|
f3deed0270 | ||
|
|
035add9d4f | ||
|
|
f088bc9b25 | ||
|
|
d239da3221 | ||
|
|
aed195f6dc | ||
|
|
f08e781b0b | ||
|
|
2b4802d0a8 | ||
|
|
075b517d96 | ||
|
|
1edfca295b | ||
|
|
67ca2fbbad | ||
|
|
654de13b5c | ||
|
|
e4bd867056 | ||
|
|
aa03c32b3e | ||
|
|
d79959c79e | ||
|
|
5eb16d0c5b | ||
|
|
f83f364144 | ||
|
|
6f981b33cc | ||
|
|
d8807a10d6 | ||
|
|
a5db125d2e | ||
|
|
9f02db1eb8 | ||
|
|
0b6350dd29 | ||
|
|
89abe15268 | ||
|
|
43690cb60b | ||
|
|
c963321cdd | ||
|
|
7056c996dd | ||
|
|
107cb1da5e | ||
|
|
a3f89217df | ||
|
|
55cbea7435 | ||
|
|
8b33e73353 | ||
|
|
671e309cfa | ||
|
|
05f5d73876 | ||
|
|
2f6d7f2dad | ||
|
|
0a73df5f53 | ||
|
|
a353be57d8 | ||
|
|
1345c46650 |
4
.github/actions/setup-godot-cpp/action.yml
vendored
4
.github/actions/setup-godot-cpp/action.yml
vendored
@@ -6,7 +6,7 @@ inputs:
|
||||
required: true
|
||||
description: Target platform.
|
||||
em-version:
|
||||
default: 3.1.62
|
||||
default: 4.0.11
|
||||
description: Emscripten version.
|
||||
windows-compiler:
|
||||
required: true
|
||||
@@ -20,7 +20,7 @@ inputs:
|
||||
default: 12.2.0
|
||||
description: MinGW version.
|
||||
ndk-version:
|
||||
default: r23c
|
||||
default: r28b
|
||||
description: Android NDK version.
|
||||
buildtool:
|
||||
default: scons
|
||||
|
||||
6
.github/workflows/ci-cmake.yml
vendored
6
.github/workflows/ci-cmake.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
EM_VERSION: 3.1.39
|
||||
EM_VERSION: 4.0.11
|
||||
config-flags:
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=sccache
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
|
||||
@@ -73,8 +73,8 @@ jobs:
|
||||
platform: android
|
||||
config-flags:
|
||||
-G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
--toolchain ${ANDROID_HOME}/ndk/23.2.8568313/build/cmake/android.toolchain.cmake
|
||||
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a
|
||||
--toolchain ${ANDROID_HOME}/ndk/28.1.13356709/build/cmake/android.toolchain.cmake
|
||||
-DANDROID_PLATFORM=24 -DANDROID_ABI=arm64-v8a
|
||||
artifact-name: godot-cpp-android-arm64-release.cmake
|
||||
artifact-path: cmake-build/bin/libgodot-cpp.android.template_release.arm64.a
|
||||
flags: arch=arm64
|
||||
|
||||
2
.github/workflows/ci-scons.yml
vendored
2
.github/workflows/ci-scons.yml
vendored
@@ -87,7 +87,7 @@ jobs:
|
||||
|
||||
env:
|
||||
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
||||
EM_VERSION: 3.1.39
|
||||
EM_VERSION: 4.0.11
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@@ -911,7 +911,6 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
result.append("\tconst Variant &operator[](int64_t p_index) const;")
|
||||
result.append("\tVariant &operator[](int64_t p_index);")
|
||||
result.append("\tvoid set_typed(uint32_t p_type, const StringName &p_class_name, const Variant &p_script);")
|
||||
result.append("\tvoid _ref(const Array &p_from) const;")
|
||||
result.append("""
|
||||
struct Iterator {
|
||||
_FORCE_INLINE_ Variant &operator*() const;
|
||||
@@ -2503,7 +2502,7 @@ def make_varargs_template(
|
||||
function_signature += " {"
|
||||
result.append(function_signature)
|
||||
|
||||
args_array = f"\tstd::array<Variant, {len(method_arguments)} + sizeof...(Args)> variant_args{{ "
|
||||
args_array = f"\tstd::array<Variant, {len(method_arguments)} + sizeof...(Args)> variant_args{{{{ "
|
||||
for argument in method_arguments:
|
||||
if argument["type"] == "Variant":
|
||||
args_array += escape_argument(argument["name"])
|
||||
@@ -2511,7 +2510,7 @@ def make_varargs_template(
|
||||
args_array += f"Variant({escape_argument(argument['name'])})"
|
||||
args_array += ", "
|
||||
|
||||
args_array += "Variant(p_args)... };"
|
||||
args_array += "Variant(p_args)... }};"
|
||||
result.append(args_array)
|
||||
result.append(f"\tstd::array<const Variant *, {len(method_arguments)} + sizeof...(Args)> call_args;")
|
||||
result.append("\tfor (size_t i = 0; i < variant_args.size(); i++) {")
|
||||
|
||||
@@ -34,7 +34,7 @@ function(android_options)
|
||||
https://docs.godotengine.org/en/latest/tutorials/scripting/cpp/build_system/cmake.html
|
||||
|
||||
android_api_level : Target Android API level.
|
||||
Default = 21
|
||||
Default = 24
|
||||
|
||||
ANDROID_HOME : Path to your Android SDK installation.
|
||||
Default = os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,22 +28,22 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GDEXTENSION_INTERFACE_H
|
||||
#define GDEXTENSION_INTERFACE_H
|
||||
#pragma once
|
||||
|
||||
/* This is a C class header, you can copy it and use it directly in your own binders.
|
||||
* Together with the JSON file, you should be able to generate any binder.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef uint32_t char32_t;
|
||||
typedef uint16_t char16_t;
|
||||
#endif
|
||||
#else
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -399,8 +399,13 @@ typedef struct {
|
||||
void *class_userdata; // Per-class user data, later accessible in instance bindings.
|
||||
} GDExtensionClassCreationInfo4;
|
||||
|
||||
typedef GDExtensionClassCreationInfo4 GDExtensionClassCreationInfo5;
|
||||
|
||||
typedef void *GDExtensionClassLibraryPtr;
|
||||
|
||||
/* Passed a pointer to a PackedStringArray that should be filled with the classes that may be used by the GDExtension. */
|
||||
typedef void (*GDExtensionEditorGetClassesUsedCallback)(GDExtensionTypePtr p_packed_string_array);
|
||||
|
||||
/* Method */
|
||||
|
||||
typedef enum {
|
||||
@@ -721,6 +726,9 @@ typedef struct {
|
||||
|
||||
} GDExtensionScriptInstanceInfo3;
|
||||
|
||||
typedef void (*GDExtensionWorkerThreadPoolGroupTask)(void *, uint32_t);
|
||||
typedef void (*GDExtensionWorkerThreadPoolTask)(void *);
|
||||
|
||||
/* INITIALIZATION */
|
||||
|
||||
typedef enum {
|
||||
@@ -731,6 +739,9 @@ typedef enum {
|
||||
GDEXTENSION_MAX_INITIALIZATION_LEVEL,
|
||||
} GDExtensionInitializationLevel;
|
||||
|
||||
typedef void (*GDExtensionInitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
|
||||
typedef void (*GDExtensionDeinitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
|
||||
|
||||
typedef struct {
|
||||
/* Minimum initialization level required.
|
||||
* If Core or Servers, the extension needs editor or game restart to take effect */
|
||||
@@ -738,8 +749,8 @@ typedef struct {
|
||||
/* Up to the user to supply when initializing */
|
||||
void *userdata;
|
||||
/* This function will be called multiple times for each initialization level. */
|
||||
void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level);
|
||||
void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level);
|
||||
GDExtensionInitializeCallback initialize;
|
||||
GDExtensionDeinitializeCallback deinitialize;
|
||||
} GDExtensionInitialization;
|
||||
|
||||
typedef void (*GDExtensionInterfaceFunctionPtr)();
|
||||
@@ -790,9 +801,41 @@ typedef struct {
|
||||
const char *string;
|
||||
} GDExtensionGodotVersion;
|
||||
|
||||
typedef struct {
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
uint32_t patch;
|
||||
uint32_t hex; // Full version encoded as hexadecimal with one byte (2 hex digits) per number (e.g. for "3.1.12" it would be 0x03010C)
|
||||
const char *status; // (e.g. "stable", "beta", "rc1", "rc2")
|
||||
const char *build; // (e.g. "custom_build")
|
||||
const char *hash; // Full Git commit hash.
|
||||
uint64_t timestamp; // Git commit date UNIX timestamp in seconds, or 0 if unavailable.
|
||||
const char *string; // (e.g. "Godot v3.1.4.stable.official.mono")
|
||||
} GDExtensionGodotVersion2;
|
||||
|
||||
/* Called when starting the main loop. */
|
||||
typedef void (*GDExtensionMainLoopStartupCallback)();
|
||||
|
||||
/* Called when shutting down the main loop. */
|
||||
typedef void (*GDExtensionMainLoopShutdownCallback)();
|
||||
|
||||
/* Called for every frame iteration of the main loop. */
|
||||
typedef void (*GDExtensionMainLoopFrameCallback)();
|
||||
|
||||
typedef struct {
|
||||
// Will be called after Godot is started and is fully initialized.
|
||||
GDExtensionMainLoopStartupCallback startup_func;
|
||||
// Will be called before Godot is shutdown when it is still fully initialized.
|
||||
GDExtensionMainLoopShutdownCallback shutdown_func;
|
||||
// Will be called for each process frame. This will run after all `_process()` methods on Node, and before `ScriptServer::frame()`.
|
||||
// This is intended to be the equivalent of `ScriptLanguage::frame()` for GDExtension language bindings that don't use the script API.
|
||||
GDExtensionMainLoopFrameCallback frame_func;
|
||||
} GDExtensionMainLoopCallbacks;
|
||||
|
||||
/**
|
||||
* @name get_godot_version
|
||||
* @since 4.1
|
||||
* @deprecated in Godot 4.5. Use `get_godot_version2` instead.
|
||||
*
|
||||
* Gets the Godot version that the GDExtension was loaded into.
|
||||
*
|
||||
@@ -800,6 +843,16 @@ typedef struct {
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
|
||||
|
||||
/**
|
||||
* @name get_godot_version2
|
||||
* @since 4.5
|
||||
*
|
||||
* Gets the Godot version that the GDExtension was loaded into.
|
||||
*
|
||||
* @param r_godot_version A pointer to the structure to write the version information into.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceGetGodotVersion2)(GDExtensionGodotVersion2 *r_godot_version);
|
||||
|
||||
/* INTERFACE: Memory */
|
||||
|
||||
/**
|
||||
@@ -994,7 +1047,7 @@ typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GD
|
||||
*
|
||||
* Calls a static method on a Variant.
|
||||
*
|
||||
* @param p_self A pointer to the Variant.
|
||||
* @param p_type The variant type.
|
||||
* @param p_method A pointer to a StringName identifying the method.
|
||||
* @param p_args A pointer to a C array of Variant.
|
||||
* @param p_argument_count The number of arguments.
|
||||
@@ -1280,7 +1333,7 @@ typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtension
|
||||
* @param p_self A pointer to the Variant.
|
||||
* @param p_method A pointer to a StringName with the method name.
|
||||
*
|
||||
* @return
|
||||
* @return true if the variant has the given method; otherwise false.
|
||||
*/
|
||||
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
|
||||
|
||||
@@ -1293,7 +1346,7 @@ typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConst
|
||||
* @param p_type The Variant type.
|
||||
* @param p_member A pointer to a StringName with the member name.
|
||||
*
|
||||
* @return
|
||||
* @return true if the variant has the given method; otherwise false.
|
||||
*/
|
||||
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
|
||||
|
||||
@@ -1464,7 +1517,7 @@ typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(
|
||||
* Constructs a Variant of the given type, using the first constructor that matches the given arguments.
|
||||
*
|
||||
* @param p_type The Variant type.
|
||||
* @param p_base A pointer to a Variant to store the constructed value.
|
||||
* @param r_base A pointer to a Variant to store the constructed value.
|
||||
* @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
|
||||
* @param p_argument_count The number of arguments to pass to the constructor.
|
||||
* @param r_error A pointer the structure which will be updated with error information.
|
||||
@@ -1687,7 +1740,7 @@ typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDEx
|
||||
*
|
||||
* @param r_dest A pointer to a Variant to hold the newly created String.
|
||||
* @param p_contents A pointer to a UTF-16 encoded C string.
|
||||
* @param p_size The number of characters (not bytes).
|
||||
* @param p_char_count The number of characters (not bytes).
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
|
||||
|
||||
@@ -1699,7 +1752,7 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUni
|
||||
*
|
||||
* @param r_dest A pointer to a Variant to hold the newly created String.
|
||||
* @param p_contents A pointer to a UTF-16 encoded C string.
|
||||
* @param p_size The number of characters (not bytes).
|
||||
* @param p_char_count The number of characters (not bytes).
|
||||
* @param p_default_little_endian If true, UTF-16 use little endian.
|
||||
*
|
||||
* @return Error code signifying if the operation successful.
|
||||
@@ -1714,7 +1767,7 @@ typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDE
|
||||
*
|
||||
* @param r_dest A pointer to a Variant to hold the newly created String.
|
||||
* @param p_contents A pointer to a UTF-32 encoded C string.
|
||||
* @param p_size The number of characters (not bytes).
|
||||
* @param p_char_count The number of characters (not bytes).
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count);
|
||||
|
||||
@@ -1726,7 +1779,7 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUni
|
||||
*
|
||||
* @param r_dest A pointer to a Variant to hold the newly created String.
|
||||
* @param p_contents A pointer to a wide C string.
|
||||
* @param p_size The number of characters (not bytes).
|
||||
* @param p_char_count The number of characters (not bytes).
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count);
|
||||
|
||||
@@ -2043,6 +2096,7 @@ typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_in
|
||||
* @param p_instance A pointer to a WorkerThreadPool object.
|
||||
* @param p_func A pointer to a function to run in the thread pool.
|
||||
* @param p_userdata A pointer to arbitrary data which will be passed to p_func.
|
||||
* @param p_elements The number of element needed in the group.
|
||||
* @param p_tasks The number of tasks needed in the group.
|
||||
* @param p_high_priority Whether or not this is a high priority task.
|
||||
* @param p_description A pointer to a String with the task description.
|
||||
@@ -2051,7 +2105,7 @@ typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_in
|
||||
*
|
||||
* @see WorkerThreadPool::add_group_task()
|
||||
*/
|
||||
typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
|
||||
typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolGroupTask p_func, void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
|
||||
|
||||
/**
|
||||
* @name worker_thread_pool_add_native_task
|
||||
@@ -2067,7 +2121,7 @@ typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExte
|
||||
*
|
||||
* @return The task ID.
|
||||
*/
|
||||
typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
|
||||
typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolTask p_func, void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
|
||||
|
||||
/* INTERFACE: Packed Array */
|
||||
|
||||
@@ -2360,6 +2414,7 @@ typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDE
|
||||
/**
|
||||
* @name array_ref
|
||||
* @since 4.1
|
||||
* @deprecated in Godot 4.5. use `Array::operator=` instead.
|
||||
*
|
||||
* Sets an Array to be a reference to another Array object.
|
||||
*
|
||||
@@ -2484,10 +2539,10 @@ typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensi
|
||||
* Gets a pointer representing an Object's instance binding.
|
||||
*
|
||||
* @param p_o A pointer to the Object.
|
||||
* @param p_library A token the library received by the GDExtension's entry point function.
|
||||
* @param p_token A token the library received by the GDExtension's entry point function.
|
||||
* @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
|
||||
*
|
||||
* @return
|
||||
* @return A pointer to the instance binding.
|
||||
*/
|
||||
typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
|
||||
|
||||
@@ -2498,7 +2553,7 @@ typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectP
|
||||
* Sets an Object's instance binding.
|
||||
*
|
||||
* @param p_o A pointer to the Object.
|
||||
* @param p_library A token the library received by the GDExtension's entry point function.
|
||||
* @param p_token A token the library received by the GDExtension's entry point function.
|
||||
* @param p_binding A pointer to the instance binding.
|
||||
* @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
|
||||
*/
|
||||
@@ -2511,7 +2566,7 @@ typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPt
|
||||
* Free an Object's instance binding.
|
||||
*
|
||||
* @param p_o A pointer to the Object.
|
||||
* @param p_library A token the library received by the GDExtension's entry point function.
|
||||
* @param p_token A token the library received by the GDExtension's entry point function.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token);
|
||||
|
||||
@@ -2521,11 +2576,13 @@ typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectP
|
||||
*
|
||||
* Sets an extension class instance on a Object.
|
||||
*
|
||||
* `p_classname` should be a registered extension class and should extend the `p_o` Object's class.
|
||||
*
|
||||
* @param p_o A pointer to the Object.
|
||||
* @param p_classname A pointer to a StringName with the registered extension class's name.
|
||||
* @param p_instance A pointer to the extension class instance.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */
|
||||
typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance);
|
||||
|
||||
/**
|
||||
* @name object_get_class_name
|
||||
@@ -2590,7 +2647,7 @@ typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensio
|
||||
* @param p_object A pointer to the Object.
|
||||
* @param p_method A pointer to a StringName identifying the method.
|
||||
*
|
||||
* @returns true if the object has a script and that script has a method with the given name. Returns false if the object has no script.
|
||||
* @return true if the object has a script and that script has a method with the given name. Returns false if the object has no script.
|
||||
*/
|
||||
typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
|
||||
|
||||
@@ -2721,6 +2778,17 @@ typedef void (*GDExtensionInterfacePlaceHolderScriptInstanceUpdate)(GDExtensionS
|
||||
*/
|
||||
typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
|
||||
|
||||
/**
|
||||
* @name object_set_script_instance
|
||||
* @since 4.5
|
||||
*
|
||||
* Set the script instance data attached to this object.
|
||||
*
|
||||
* @param p_object A pointer to the Object.
|
||||
* @param p_script_instance A pointer to the script instance data to attach to this object.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceObjectSetScriptInstance)(GDExtensionObjectPtr p_object, GDExtensionScriptInstanceDataPtr p_script_instance);
|
||||
|
||||
/* INTERFACE: Callable */
|
||||
|
||||
/**
|
||||
@@ -2760,6 +2828,8 @@ typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializ
|
||||
*
|
||||
* @param p_callable A pointer to a Callable.
|
||||
* @param p_token A pointer to an address that uniquely identifies the GDExtension.
|
||||
*
|
||||
* @return The userdata pointer given when creating this custom Callable.
|
||||
*/
|
||||
typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token);
|
||||
|
||||
@@ -2868,13 +2938,14 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionCl
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param p_class_name A pointer to a StringName with the class name.
|
||||
* @param p_parent_class_name A pointer to a StringName with the parent class name.
|
||||
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
|
||||
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo3 struct.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass3)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo3 *p_extension_funcs);
|
||||
|
||||
/**
|
||||
* @name classdb_register_extension_class4
|
||||
* @since 4.4
|
||||
* @deprecated in Godot 4.5. Use `classdb_register_extension_class5` instead.
|
||||
*
|
||||
* Registers an extension class in the ClassDB.
|
||||
*
|
||||
@@ -2883,10 +2954,25 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass3)(GDExtensionCl
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param p_class_name A pointer to a StringName with the class name.
|
||||
* @param p_parent_class_name A pointer to a StringName with the parent class name.
|
||||
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
|
||||
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo4 struct.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass4)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo4 *p_extension_funcs);
|
||||
|
||||
/**
|
||||
* @name classdb_register_extension_class5
|
||||
* @since 4.5
|
||||
*
|
||||
* Registers an extension class in the ClassDB.
|
||||
*
|
||||
* Provided struct can be safely freed once the function returns.
|
||||
*
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param p_class_name A pointer to a StringName with the class name.
|
||||
* @param p_parent_class_name A pointer to a StringName with the parent class name.
|
||||
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo5 struct.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass5)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo5 *p_extension_funcs);
|
||||
|
||||
/**
|
||||
* @name classdb_register_extension_class_method
|
||||
* @since 4.1
|
||||
@@ -3015,10 +3101,12 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtens
|
||||
*
|
||||
* Unregisters an extension class in the ClassDB.
|
||||
*
|
||||
* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first.
|
||||
*
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param p_class_name A pointer to a StringName with the class name.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */
|
||||
typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name);
|
||||
|
||||
/**
|
||||
* @name get_library_path
|
||||
@@ -3078,8 +3166,33 @@ typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars)(const char *
|
||||
*/
|
||||
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen)(const char *p_data, GDExtensionInt p_size);
|
||||
|
||||
/**
|
||||
* @name editor_register_get_classes_used_callback
|
||||
* @since 4.5
|
||||
*
|
||||
* Registers a callback that Godot can call to get the list of all classes (from ClassDB) that may be used by the calling GDExtension.
|
||||
*
|
||||
* This is used by the editor to generate a build profile (in "Tools" > "Engine Compilation Configuration Editor..." > "Detect from project"),
|
||||
* in order to recompile Godot with only the classes used.
|
||||
* In the provided callback, the GDExtension should provide the list of classes that _may_ be used statically, thus the time of invocation shouldn't matter.
|
||||
* If a GDExtension doesn't register a callback, Godot will assume that it could be using any classes.
|
||||
*
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param p_callback The callback to retrieve the list of classes used.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceEditorRegisterGetClassesUsedCallback)(GDExtensionClassLibraryPtr p_library, GDExtensionEditorGetClassesUsedCallback p_callback);
|
||||
|
||||
/**
|
||||
* @name register_main_loop_callbacks
|
||||
* @since 4.5
|
||||
*
|
||||
* Registers callbacks to be called at different phases of the main loop.
|
||||
*
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param p_callbacks A pointer to the structure that contains the callbacks.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceRegisterMainLoopCallbacks)(GDExtensionClassLibraryPtr p_library, const GDExtensionMainLoopCallbacks *p_callbacks);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // GDEXTENSION_INTERFACE_H
|
||||
|
||||
@@ -157,6 +157,8 @@ public:
|
||||
instance_binding_callbacks[p_name] = p_callbacks;
|
||||
}
|
||||
|
||||
static void _editor_get_classes_used_callback(GDExtensionTypePtr p_packed_string_array);
|
||||
|
||||
static void _register_engine_singleton(const StringName &p_class_name, Object *p_singleton) {
|
||||
std::lock_guard<std::mutex> lock(engine_singletons_mutex);
|
||||
AHashMap<StringName, Object *>::ConstIterator i = engine_singletons.find(p_class_name);
|
||||
@@ -240,7 +242,7 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
|
||||
class_register_order.push_back(cl.name);
|
||||
|
||||
// Register this class with Godot
|
||||
GDExtensionClassCreationInfo4 class_info = {
|
||||
GDExtensionClassCreationInfo5 class_info = {
|
||||
p_virtual, // GDExtensionBool is_virtual;
|
||||
is_abstract, // GDExtensionBool is_abstract;
|
||||
p_exposed, // GDExtensionBool is_exposed;
|
||||
@@ -266,7 +268,7 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
|
||||
(void *)&T::get_class_static(), // void *class_userdata;
|
||||
};
|
||||
|
||||
internal::gdextension_interface_classdb_register_extension_class4(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||
internal::gdextension_interface_classdb_register_extension_class5(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||
|
||||
// call bind_methods etc. to register all members of the class
|
||||
T::initialize_class();
|
||||
|
||||
@@ -338,4 +338,47 @@ struct is_zero_constructible<const volatile T> : is_zero_constructible<T> {};
|
||||
template <typename T>
|
||||
inline constexpr bool is_zero_constructible_v = is_zero_constructible<T>::value;
|
||||
|
||||
// Warning suppression helper macros.
|
||||
#if defined(__clang__)
|
||||
#define GODOT_CLANG_PRAGMA(m_content) _Pragma(#m_content)
|
||||
#define GODOT_CLANG_WARNING_PUSH GODOT_CLANG_PRAGMA(clang diagnostic push)
|
||||
#define GODOT_CLANG_WARNING_IGNORE(m_warning) GODOT_CLANG_PRAGMA(clang diagnostic ignored m_warning)
|
||||
#define GODOT_CLANG_WARNING_POP GODOT_CLANG_PRAGMA(clang diagnostic pop)
|
||||
#define GODOT_CLANG_WARNING_PUSH_AND_IGNORE(m_warning) GODOT_CLANG_WARNING_PUSH GODOT_CLANG_WARNING_IGNORE(m_warning)
|
||||
#else
|
||||
#define GODOT_CLANG_PRAGMA(m_content)
|
||||
#define GODOT_CLANG_WARNING_PUSH
|
||||
#define GODOT_CLANG_WARNING_IGNORE(m_warning)
|
||||
#define GODOT_CLANG_WARNING_POP
|
||||
#define GODOT_CLANG_WARNING_PUSH_AND_IGNORE(m_warning)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#define GODOT_GCC_PRAGMA(m_content) _Pragma(#m_content)
|
||||
#define GODOT_GCC_WARNING_PUSH GODOT_GCC_PRAGMA(GCC diagnostic push)
|
||||
#define GODOT_GCC_WARNING_IGNORE(m_warning) GODOT_GCC_PRAGMA(GCC diagnostic ignored m_warning)
|
||||
#define GODOT_GCC_WARNING_POP GODOT_GCC_PRAGMA(GCC diagnostic pop)
|
||||
#define GODOT_GCC_WARNING_PUSH_AND_IGNORE(m_warning) GODOT_GCC_WARNING_PUSH GODOT_GCC_WARNING_IGNORE(m_warning)
|
||||
#else
|
||||
#define GODOT_GCC_PRAGMA(m_content)
|
||||
#define GODOT_GCC_WARNING_PUSH
|
||||
#define GODOT_GCC_WARNING_IGNORE(m_warning)
|
||||
#define GODOT_GCC_WARNING_POP
|
||||
#define GODOT_GCC_WARNING_PUSH_AND_IGNORE(m_warning)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define GODOT_MSVC_PRAGMA(m_content) __pragma(m_content)
|
||||
#define GODOT_MSVC_WARNING_PUSH GODOT_MSVC_PRAGMA(warning(push))
|
||||
#define GODOT_MSVC_WARNING_IGNORE(m_warning) GODOT_MSVC_PRAGMA(warning(disable : m_warning))
|
||||
#define GODOT_MSVC_WARNING_POP GODOT_MSVC_PRAGMA(warning(pop))
|
||||
#define GODOT_MSVC_WARNING_PUSH_AND_IGNORE(m_warning) GODOT_MSVC_WARNING_PUSH GODOT_MSVC_WARNING_IGNORE(m_warning)
|
||||
#else
|
||||
#define GODOT_MSVC_PRAGMA(m_content)
|
||||
#define GODOT_MSVC_WARNING_PUSH
|
||||
#define GODOT_MSVC_WARNING_IGNORE(m_warning)
|
||||
#define GODOT_MSVC_WARNING_POP
|
||||
#define GODOT_MSVC_WARNING_PUSH_AND_IGNORE(m_warning)
|
||||
#endif
|
||||
|
||||
} //namespace godot
|
||||
|
||||
@@ -40,10 +40,10 @@ extern "C" GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_add
|
||||
extern "C" GDExtensionClassLibraryPtr library;
|
||||
extern "C" void *token;
|
||||
|
||||
extern "C" GDExtensionGodotVersion godot_version;
|
||||
extern "C" GDExtensionGodotVersion2 godot_version;
|
||||
|
||||
// All of the GDExtension interface functions.
|
||||
extern "C" GDExtensionInterfaceGetGodotVersion gdextension_interface_get_godot_version;
|
||||
extern "C" GDExtensionInterfaceGetGodotVersion2 gdextension_interface_get_godot_version2;
|
||||
extern "C" GDExtensionInterfaceMemAlloc gdextension_interface_mem_alloc;
|
||||
extern "C" GDExtensionInterfaceMemRealloc gdextension_interface_mem_realloc;
|
||||
extern "C" GDExtensionInterfaceMemFree gdextension_interface_mem_free;
|
||||
@@ -155,7 +155,6 @@ extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_inter
|
||||
extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const;
|
||||
extern "C" GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index;
|
||||
extern "C" GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const;
|
||||
extern "C" GDExtensionInterfaceArrayRef gdextension_interface_array_ref;
|
||||
extern "C" GDExtensionInterfaceArraySetTyped gdextension_interface_array_set_typed;
|
||||
extern "C" GDExtensionInterfaceDictionaryOperatorIndex gdextension_interface_dictionary_operator_index;
|
||||
extern "C" GDExtensionInterfaceDictionaryOperatorIndexConst gdextension_interface_dictionary_operator_index_const;
|
||||
@@ -181,10 +180,12 @@ extern "C" GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object
|
||||
extern "C" GDExtensionInterfaceScriptInstanceCreate3 gdextension_interface_script_instance_create3;
|
||||
extern "C" GDExtensionInterfacePlaceHolderScriptInstanceCreate gdextension_interface_placeholder_script_instance_create;
|
||||
extern "C" GDExtensionInterfacePlaceHolderScriptInstanceUpdate gdextension_interface_placeholder_script_instance_update;
|
||||
extern "C" GDExtensionInterfaceObjectGetScriptInstance gdextension_interface_object_get_script_instance;
|
||||
extern "C" GDExtensionInterfaceObjectSetScriptInstance gdextension_interface_object_set_script_instance;
|
||||
extern "C" GDExtensionInterfaceClassdbConstructObject2 gdextension_interface_classdb_construct_object2;
|
||||
extern "C" GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind;
|
||||
extern "C" GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass4 gdextension_interface_classdb_register_extension_class4;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass5 gdextension_interface_classdb_register_extension_class5;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod gdextension_interface_classdb_register_extension_class_virtual_method;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant;
|
||||
@@ -197,10 +198,12 @@ extern "C" GDExtensionInterfaceClassdbUnregisterExtensionClass gdextension_inter
|
||||
extern "C" GDExtensionInterfaceGetLibraryPath gdextension_interface_get_library_path;
|
||||
extern "C" GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_plugin;
|
||||
extern "C" GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin;
|
||||
extern "C" GDExtensionInterfaceEditorRegisterGetClassesUsedCallback gdextension_interface_editor_register_get_classes_used_callback;
|
||||
extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars;
|
||||
extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len;
|
||||
extern "C" GDExtensionInterfaceImagePtrw gdextension_interface_image_ptrw;
|
||||
extern "C" GDExtensionInterfaceImagePtr gdextension_interface_image_ptr;
|
||||
extern "C" GDExtensionInterfaceRegisterMainLoopCallbacks gdextension_interface_register_main_loop_callbacks;
|
||||
|
||||
class DocDataRegistration {
|
||||
public:
|
||||
@@ -225,6 +228,11 @@ public:
|
||||
GDExtensionInitializationLevel minimum_initialization_level = GDEXTENSION_INITIALIZATION_CORE;
|
||||
Callback init_callback = nullptr;
|
||||
Callback terminate_callback = nullptr;
|
||||
GDExtensionMainLoopCallbacks main_loop_callbacks = {};
|
||||
|
||||
inline bool has_main_loop_callbacks() const {
|
||||
return main_loop_callbacks.frame_func || main_loop_callbacks.startup_func || main_loop_callbacks.shutdown_func;
|
||||
}
|
||||
};
|
||||
|
||||
class InitDataList {
|
||||
@@ -259,6 +267,13 @@ public:
|
||||
void register_terminator(Callback p_init) const;
|
||||
void set_minimum_library_initialization_level(ModuleInitializationLevel p_level) const;
|
||||
|
||||
// Register a callback that is called after all initialization levels when Godot is fully initialized.
|
||||
void register_startup_callback(GDExtensionMainLoopStartupCallback p_callback) const;
|
||||
// Register a callback that is called for every process frame. This will run after all `_process()` methods on Node, and before `ScriptServer::frame()`.
|
||||
void register_frame_callback(GDExtensionMainLoopFrameCallback p_callback) const;
|
||||
// Register a callback that is called before Godot is shutdown when it is still fully initialized.
|
||||
void register_shutdown_callback(GDExtensionMainLoopShutdownCallback p_callback) const;
|
||||
|
||||
GDExtensionBool init() const;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ class TypedArray : public Array {
|
||||
public:
|
||||
_FORCE_INLINE_ void operator=(const Array &p_array) {
|
||||
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type.");
|
||||
_ref(p_array);
|
||||
Array::operator=(p_array);
|
||||
}
|
||||
_FORCE_INLINE_ TypedArray(const Variant &p_variant) :
|
||||
TypedArray(Array(p_variant)) {
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
_FORCE_INLINE_ TypedArray(const Array &p_array) {
|
||||
set_typed(Variant::OBJECT, T::get_class_static(), Variant());
|
||||
if (is_same_typed(p_array)) {
|
||||
_ref(p_array);
|
||||
Array::operator=(p_array);
|
||||
} else {
|
||||
assign(p_array);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
public: \
|
||||
_FORCE_INLINE_ void operator=(const Array &p_array) { \
|
||||
ERR_FAIL_COND_MSG(!is_same_typed(p_array), "Cannot assign an array with a different element type."); \
|
||||
_ref(p_array); \
|
||||
Array::operator=(p_array); \
|
||||
} \
|
||||
_FORCE_INLINE_ TypedArray(std::initializer_list<Variant> p_init) : \
|
||||
Array(Array(p_init), m_variant_type, StringName(), Variant()) { \
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
_FORCE_INLINE_ TypedArray(const Array &p_array) { \
|
||||
set_typed(m_variant_type, StringName(), Variant()); \
|
||||
if (is_same_typed(p_array)) { \
|
||||
_ref(p_array); \
|
||||
Array::operator=(p_array); \
|
||||
} else { \
|
||||
assign(p_array); \
|
||||
} \
|
||||
|
||||
@@ -386,6 +386,15 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
|
||||
}
|
||||
}
|
||||
|
||||
void ClassDB::_editor_get_classes_used_callback(GDExtensionTypePtr p_packed_string_array) {
|
||||
PackedStringArray *arr = reinterpret_cast<PackedStringArray *>(p_packed_string_array);
|
||||
arr->resize(instance_binding_callbacks.size());
|
||||
int index = 0;
|
||||
for (const KeyValue<StringName, const GDExtensionInstanceBindingCallbacks *> &pair : instance_binding_callbacks) {
|
||||
(*arr)[index++] = pair.key;
|
||||
}
|
||||
}
|
||||
|
||||
void ClassDB::initialize_class(const ClassInfo &p_cl) {
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_address = null
|
||||
GDExtensionClassLibraryPtr library = nullptr;
|
||||
void *token = nullptr;
|
||||
|
||||
GDExtensionGodotVersion godot_version = { 0, 0, 0, nullptr };
|
||||
GDExtensionGodotVersion2 godot_version = {};
|
||||
|
||||
// All of the GDExtension interface functions.
|
||||
GDExtensionInterfaceGetGodotVersion gdextension_interface_get_godot_version = nullptr;
|
||||
GDExtensionInterfaceGetGodotVersion2 gdextension_interface_get_godot_version2 = nullptr;
|
||||
GDExtensionInterfaceMemAlloc gdextension_interface_mem_alloc = nullptr;
|
||||
GDExtensionInterfaceMemRealloc gdextension_interface_mem_realloc = nullptr;
|
||||
GDExtensionInterfaceMemFree gdextension_interface_mem_free = nullptr;
|
||||
@@ -164,7 +164,6 @@ GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed
|
||||
GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const = nullptr;
|
||||
GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index = nullptr;
|
||||
GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const = nullptr;
|
||||
GDExtensionInterfaceArrayRef gdextension_interface_array_ref = nullptr;
|
||||
GDExtensionInterfaceArraySetTyped gdextension_interface_array_set_typed = nullptr;
|
||||
GDExtensionInterfaceDictionaryOperatorIndex gdextension_interface_dictionary_operator_index = nullptr;
|
||||
GDExtensionInterfaceDictionaryOperatorIndexConst gdextension_interface_dictionary_operator_index_const = nullptr;
|
||||
@@ -190,10 +189,12 @@ GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object = nullptr;
|
||||
GDExtensionInterfaceScriptInstanceCreate3 gdextension_interface_script_instance_create3 = nullptr;
|
||||
GDExtensionInterfacePlaceHolderScriptInstanceCreate gdextension_interface_placeholder_script_instance_create = nullptr;
|
||||
GDExtensionInterfacePlaceHolderScriptInstanceUpdate gdextension_interface_placeholder_script_instance_update = nullptr;
|
||||
GDExtensionInterfaceObjectGetScriptInstance gdextension_interface_object_get_script_instance = nullptr;
|
||||
GDExtensionInterfaceObjectSetScriptInstance gdextension_interface_object_set_script_instance = nullptr;
|
||||
GDExtensionInterfaceClassdbConstructObject2 gdextension_interface_classdb_construct_object2 = nullptr;
|
||||
GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind = nullptr;
|
||||
GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClass4 gdextension_interface_classdb_register_extension_class4 = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClass5 gdextension_interface_classdb_register_extension_class5 = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod gdextension_interface_classdb_register_extension_class_virtual_method = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant = nullptr;
|
||||
@@ -206,10 +207,12 @@ GDExtensionInterfaceClassdbUnregisterExtensionClass gdextension_interface_classd
|
||||
GDExtensionInterfaceGetLibraryPath gdextension_interface_get_library_path = nullptr;
|
||||
GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_plugin = nullptr;
|
||||
GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin = nullptr;
|
||||
GDExtensionInterfaceEditorRegisterGetClassesUsedCallback gdextension_interface_editor_register_get_classes_used_callback = nullptr;
|
||||
GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars = nullptr;
|
||||
GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len = nullptr;
|
||||
GDExtensionInterfaceImagePtrw gdextension_interface_image_ptrw = nullptr;
|
||||
GDExtensionInterfaceImagePtr gdextension_interface_image_ptr = nullptr;
|
||||
GDExtensionInterfaceRegisterMainLoopCallbacks gdextension_interface_register_main_loop_callbacks = nullptr;
|
||||
|
||||
struct DocData {
|
||||
const char *hash = nullptr;
|
||||
@@ -307,8 +310,8 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
internal::library = p_library;
|
||||
internal::token = p_library;
|
||||
|
||||
LOAD_PROC_ADDRESS(get_godot_version, GDExtensionInterfaceGetGodotVersion);
|
||||
internal::gdextension_interface_get_godot_version(&internal::godot_version);
|
||||
LOAD_PROC_ADDRESS(get_godot_version2, GDExtensionInterfaceGetGodotVersion2);
|
||||
internal::gdextension_interface_get_godot_version2(&internal::godot_version);
|
||||
|
||||
// Check that godot-cpp was compiled using an extension_api.json older or at the
|
||||
// same version as the Godot that is loading it.
|
||||
@@ -446,7 +449,6 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
LOAD_PROC_ADDRESS(packed_vector4_array_operator_index_const, GDExtensionInterfacePackedVector4ArrayOperatorIndexConst);
|
||||
LOAD_PROC_ADDRESS(array_operator_index, GDExtensionInterfaceArrayOperatorIndex);
|
||||
LOAD_PROC_ADDRESS(array_operator_index_const, GDExtensionInterfaceArrayOperatorIndexConst);
|
||||
LOAD_PROC_ADDRESS(array_ref, GDExtensionInterfaceArrayRef);
|
||||
LOAD_PROC_ADDRESS(array_set_typed, GDExtensionInterfaceArraySetTyped);
|
||||
LOAD_PROC_ADDRESS(dictionary_operator_index, GDExtensionInterfaceDictionaryOperatorIndex);
|
||||
LOAD_PROC_ADDRESS(dictionary_operator_index_const, GDExtensionInterfaceDictionaryOperatorIndexConst);
|
||||
@@ -472,10 +474,12 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
LOAD_PROC_ADDRESS(script_instance_create3, GDExtensionInterfaceScriptInstanceCreate3);
|
||||
LOAD_PROC_ADDRESS(placeholder_script_instance_create, GDExtensionInterfacePlaceHolderScriptInstanceCreate);
|
||||
LOAD_PROC_ADDRESS(placeholder_script_instance_update, GDExtensionInterfacePlaceHolderScriptInstanceUpdate);
|
||||
LOAD_PROC_ADDRESS(object_get_script_instance, GDExtensionInterfaceObjectGetScriptInstance);
|
||||
LOAD_PROC_ADDRESS(object_set_script_instance, GDExtensionInterfaceObjectSetScriptInstance);
|
||||
LOAD_PROC_ADDRESS(classdb_construct_object2, GDExtensionInterfaceClassdbConstructObject2);
|
||||
LOAD_PROC_ADDRESS(classdb_get_method_bind, GDExtensionInterfaceClassdbGetMethodBind);
|
||||
LOAD_PROC_ADDRESS(classdb_get_class_tag, GDExtensionInterfaceClassdbGetClassTag);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class4, GDExtensionInterfaceClassdbRegisterExtensionClass4);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class5, GDExtensionInterfaceClassdbRegisterExtensionClass5);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class_method, GDExtensionInterfaceClassdbRegisterExtensionClassMethod);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class_virtual_method, GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class_integer_constant, GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant);
|
||||
@@ -488,10 +492,12 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
LOAD_PROC_ADDRESS(get_library_path, GDExtensionInterfaceGetLibraryPath);
|
||||
LOAD_PROC_ADDRESS(editor_add_plugin, GDExtensionInterfaceEditorAddPlugin);
|
||||
LOAD_PROC_ADDRESS(editor_remove_plugin, GDExtensionInterfaceEditorRemovePlugin);
|
||||
LOAD_PROC_ADDRESS(editor_register_get_classes_used_callback, GDExtensionInterfaceEditorRegisterGetClassesUsedCallback);
|
||||
LOAD_PROC_ADDRESS(editor_help_load_xml_from_utf8_chars, GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars);
|
||||
LOAD_PROC_ADDRESS(editor_help_load_xml_from_utf8_chars_and_len, GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen);
|
||||
LOAD_PROC_ADDRESS(image_ptrw, GDExtensionInterfaceImagePtrw);
|
||||
LOAD_PROC_ADDRESS(image_ptr, GDExtensionInterfaceImagePtr);
|
||||
LOAD_PROC_ADDRESS(register_main_loop_callbacks, GDExtensionInterfaceRegisterMainLoopCallbacks);
|
||||
|
||||
r_initialization->initialize = initialize_level;
|
||||
r_initialization->deinitialize = deinitialize_level;
|
||||
@@ -522,7 +528,13 @@ void GDExtensionBinding::initialize_level(void *p_userdata, GDExtensionInitializ
|
||||
}
|
||||
level_initialized[p_level]++;
|
||||
|
||||
if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_CORE && init_data && init_data->has_main_loop_callbacks()) {
|
||||
internal::gdextension_interface_register_main_loop_callbacks(internal::library, &init_data->main_loop_callbacks);
|
||||
}
|
||||
|
||||
if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
internal::gdextension_interface_editor_register_get_classes_used_callback(internal::library, &ClassDB::_editor_get_classes_used_callback);
|
||||
|
||||
const internal::DocData &doc_data = internal::get_doc_data();
|
||||
if (doc_data.is_valid()) {
|
||||
doc_data.load_data();
|
||||
@@ -590,6 +602,18 @@ void GDExtensionBinding::InitObject::set_minimum_library_initialization_level(Mo
|
||||
init_data->minimum_initialization_level = static_cast<GDExtensionInitializationLevel>(p_level);
|
||||
}
|
||||
|
||||
void GDExtensionBinding::InitObject::register_startup_callback(GDExtensionMainLoopStartupCallback p_callback) const {
|
||||
init_data->main_loop_callbacks.startup_func = p_callback;
|
||||
}
|
||||
|
||||
void GDExtensionBinding::InitObject::register_frame_callback(GDExtensionMainLoopFrameCallback p_callback) const {
|
||||
init_data->main_loop_callbacks.frame_func = p_callback;
|
||||
}
|
||||
|
||||
void GDExtensionBinding::InitObject::register_shutdown_callback(GDExtensionMainLoopShutdownCallback p_callback) const {
|
||||
init_data->main_loop_callbacks.shutdown_func = p_callback;
|
||||
}
|
||||
|
||||
GDExtensionBool GDExtensionBinding::InitObject::init() const {
|
||||
return GDExtensionBinding::init(get_proc_address, library, init_data, initialization);
|
||||
}
|
||||
|
||||
@@ -232,10 +232,6 @@ void Array::set_typed(uint32_t p_type, const StringName &p_class_name, const Var
|
||||
internal::gdextension_interface_array_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_type, (GDExtensionConstStringNamePtr)&p_class_name, (GDExtensionConstVariantPtr)&p_script);
|
||||
}
|
||||
|
||||
void Array::_ref(const Array &p_from) const {
|
||||
internal::gdextension_interface_array_ref((GDExtensionTypePtr *)this, (GDExtensionConstTypePtr *)&p_from);
|
||||
}
|
||||
|
||||
const Variant *Array::ptr() const {
|
||||
return (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, 0);
|
||||
}
|
||||
|
||||
@@ -287,6 +287,13 @@ func _ready():
|
||||
assert_equal(library_path, ProjectSettings.globalize_path(library_path))
|
||||
assert_equal(FileAccess.file_exists(library_path), true)
|
||||
|
||||
# Test that internal classes work as expected (at least for Godot 4.5+).
|
||||
assert_equal(ClassDB.can_instantiate("ExampleInternal"), false)
|
||||
assert_equal(ClassDB.instantiate("ExampleInternal"), null)
|
||||
var internal_class = example.test_get_internal_class()
|
||||
assert_equal(internal_class.get_the_answer(), 42)
|
||||
assert_equal(internal_class.get_class(), "ExampleInternal")
|
||||
|
||||
# Test a class with a unicode name.
|
||||
var przykład = ExamplePrzykład.new()
|
||||
assert_equal(przykład.get_the_word(), "słowo to przykład")
|
||||
|
||||
@@ -252,6 +252,8 @@ void Example::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_use_engine_singleton"), &Example::test_use_engine_singleton);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_get_internal_class"), &Example::test_get_internal_class);
|
||||
|
||||
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
|
||||
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
|
||||
|
||||
@@ -744,6 +746,12 @@ String Example::test_library_path() {
|
||||
return library_path;
|
||||
}
|
||||
|
||||
Ref<RefCounted> Example::test_get_internal_class() const {
|
||||
Ref<ExampleInternal> it;
|
||||
it.instantiate();
|
||||
return it;
|
||||
}
|
||||
|
||||
int64_t Example::test_get_internal(const Variant &p_input) const {
|
||||
if (p_input.get_type() != Variant::INT) {
|
||||
return -1;
|
||||
@@ -779,3 +787,11 @@ void ExamplePrzykład::_bind_methods() {
|
||||
String ExamplePrzykład::get_the_word() const {
|
||||
return U"słowo to przykład";
|
||||
}
|
||||
|
||||
void ExampleInternal::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_the_answer"), &ExampleInternal::get_the_answer);
|
||||
}
|
||||
|
||||
int ExampleInternal::get_the_answer() const {
|
||||
return 42;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
using namespace godot;
|
||||
|
||||
class ExampleInternal;
|
||||
|
||||
class ExampleRef : public RefCounted {
|
||||
GDCLASS(ExampleRef, RefCounted);
|
||||
|
||||
@@ -203,6 +205,8 @@ public:
|
||||
String test_use_engine_singleton() const;
|
||||
|
||||
static String test_library_path();
|
||||
|
||||
Ref<RefCounted> test_get_internal_class() const;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Example::Constants);
|
||||
@@ -288,3 +292,13 @@ protected:
|
||||
public:
|
||||
String get_the_word() const;
|
||||
};
|
||||
|
||||
class ExampleInternal : public RefCounted {
|
||||
GDCLASS(ExampleInternal, RefCounted);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
int get_the_answer() const;
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@ void initialize_example_module(ModuleInitializationLevel p_level) {
|
||||
GDREGISTER_CLASS(ExampleChild);
|
||||
GDREGISTER_RUNTIME_CLASS(ExampleRuntime);
|
||||
GDREGISTER_CLASS(ExamplePrzykład);
|
||||
GDREGISTER_INTERNAL_CLASS(ExampleInternal);
|
||||
}
|
||||
|
||||
void uninitialize_example_module(ModuleInitializationLevel p_level) {
|
||||
|
||||
@@ -9,12 +9,12 @@ def options(opts):
|
||||
opts.Add(
|
||||
"android_api_level",
|
||||
"Target Android API level",
|
||||
"21",
|
||||
"24",
|
||||
)
|
||||
opts.Add(
|
||||
"ndk_version",
|
||||
"Fully qualified version of ndk to use for compilation.",
|
||||
"23.2.8568313",
|
||||
"28.1.13356709",
|
||||
)
|
||||
opts.Add(
|
||||
"ANDROID_HOME",
|
||||
@@ -48,9 +48,9 @@ def generate(env):
|
||||
my_spawn.configure(env)
|
||||
|
||||
# Validate API level
|
||||
if int(env["android_api_level"]) < 21:
|
||||
print("WARNING: minimum supported Android target api is 21. Forcing target api 21.")
|
||||
env["android_api_level"] = "21"
|
||||
if int(env["android_api_level"]) < 24:
|
||||
print("WARNING: minimum supported Android target api is 24. Forcing target api 24.")
|
||||
env["android_api_level"] = "24"
|
||||
|
||||
# Setup toolchain
|
||||
toolchain = get_android_ndk_root(env) + "/toolchains/llvm/prebuilt/"
|
||||
|
||||
@@ -446,17 +446,6 @@ def generate(env):
|
||||
else: # Release
|
||||
opt_level = "speed"
|
||||
|
||||
# Allow marking includes as external/system to avoid raising warnings.
|
||||
if env.scons_version < (4, 2):
|
||||
env["_CPPEXTINCFLAGS"] = "${_concat(EXTINCPREFIX, CPPEXTPATH, EXTINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}"
|
||||
else:
|
||||
env["_CPPEXTINCFLAGS"] = (
|
||||
"${_concat(EXTINCPREFIX, CPPEXTPATH, EXTINCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}"
|
||||
)
|
||||
env["CPPEXTPATH"] = []
|
||||
env["EXTINCPREFIX"] = "-isystem "
|
||||
env["EXTINCSUFFIX"] = ""
|
||||
|
||||
env["optimize"] = ARGUMENTS.get("optimize", opt_level)
|
||||
env["debug_symbols"] = get_cmdline_bool("debug_symbols", env.dev_build)
|
||||
|
||||
|
||||
@@ -130,11 +130,6 @@ def generate(env):
|
||||
if env["silence_msvc"] and not env.GetOption("clean"):
|
||||
silence_msvc(env)
|
||||
|
||||
if not env["use_llvm"]:
|
||||
env.AppendUnique(CCFLAGS=["/experimental:external", "/external:anglebrackets"])
|
||||
env.AppendUnique(CCFLAGS=["/external:W0"])
|
||||
env["EXTINCPREFIX"] = "/external:I"
|
||||
|
||||
elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]:
|
||||
env["use_mingw"] = True
|
||||
mingw.generate(env)
|
||||
|
||||
Reference in New Issue
Block a user