Compare commits

..

154 Commits
4.4 ... 4.5

Author SHA1 Message Date
David Snopek
da26c1732e Merge pull request #1891 from dsnopek/4.5-cherrypicks-2
Cherry-picks for the godot-cpp 4.5 branch - 2nd batch
2025-12-01 05:23:30 -06:00
Chris Cranford
7284ac7573 Align Emscripten version 4.0.11 with Godot Engine
(cherry picked from commit 8daf1ea657)
2025-11-30 06:39:22 -06:00
Guillaume Riou
d6097a8a8e make -fno-exceptions private
(cherry picked from commit 7d114d8d28)
2025-11-30 06:39:12 -06:00
janos-ijgyarto
9745f83d07 Added missing namespace prefixes to GDVIRTUAL macros
(cherry picked from commit 8c5e038744)
2025-11-30 06:39:02 -06:00
Lukas Tenbrink
a5e04f7d77 Make ClassDB::classes pointer-stable again by changing it to HashMap (from AHashMap).
(cherry picked from commit 788edc6bfe)
2025-11-30 06:38:49 -06:00
Samuel Nicholas
a7378c589f CMake: Fix missing -sUSE_PTHREADS=1 in web build
- add -sUSE_PTHREADS=1 to link flags
- add =1 to sSIDE_MODULE=1 in compile flags to match scons.

(cherry picked from commit 42b03da2b1)
2025-11-30 06:38:40 -06:00
David Snopek
7b0ee7466f On Linux default use_static_cpp to disabled
(cherry picked from commit d033e8abea)
2025-11-30 06:38:29 -06:00
David Snopek
abe94570a1 Merge pull request #1870 from dsnopek/4.5-cherrypicks-1
Cherry-picks for the godot-cpp 4.5 branch - 1st batch
2025-10-21 09:51:01 -05:00
Aaron Franke
a278404541 Add header builders script for env.GLSL_HEADER and SVG icons
(cherry picked from commit 51008e1556)
2025-10-20 13:15:41 -05:00
Lukas Tenbrink
bc8dabfe2a Migrate cmake docs to the godot docs.
(cherry picked from commit c7873e1355)
2025-10-20 13:15:28 -05:00
David Snopek
9e8b5827b9 Specifically handle each "meta" value, so new ones don't break code generation
(cherry picked from commit a9773579cb)
2025-10-20 13:15:17 -05:00
Thaddeus Crews
006888ca7a Remove CPPEXTPATH changes, add error macros
(cherry picked from commit 76d1ce6848)
2025-10-20 13:15:04 -05:00
dementive
1b6335278d Update missing hashfuncs
(cherry picked from commit fc70347ef7)
2025-10-20 13:14:49 -05:00
dementive
d600131bad Replace unordered_map with AHashMap
(cherry picked from commit 2fd41b7e16)
2025-10-20 13:14:38 -05:00
=
1e44bbefaa Silenced compiler warning in godot::call_with_variant_args_ret_helper
(cherry picked from commit 3eb3069e09)
2025-10-20 13:14:26 -05:00
Thomas Staudinger
3a2932cce2 README: Add link to 4.5 branch and fix link to Godot compile docs
Signed-off-by: Thomas Staudinger <Staudi.Kaos@gmail.com>
(cherry picked from commit ef63d2e657)
2025-10-20 13:14:17 -05:00
dementive
12cd5cd999 Use LocalVector instead of std::vector
(cherry picked from commit 0b8e76817b)
2025-10-20 13:14:06 -05:00
Lukas Tenbrink
7f4e81fda7 Update contributing section in README.md
(cherry picked from commit c58dfa4d99)
2025-10-20 13:13:56 -05:00
David Snopek
e83fd0904c gdextension: Sync with upstream commit 876b290332ec6f2e6d173d08162a02aa7e6ca46d (4.5-stable) 2025-09-15 16:33:30 -05:00
David Snopek
d884bb1001 Merge pull request #1840 from dementive/no-std-string
Remove <string> includes in headers to improve build time
2025-09-15 11:04:51 -05:00
David Snopek
5f1a8177a5 gdextension: Sync with upstream commit 2dd26a027a99633231184616d4dd287bbdd1c0a3 (4.5-rc2) 2025-09-11 10:11:23 -05:00
dementive
e36e81ac86 Remove <string> includes in headers 2025-09-08 20:45:13 -05:00
David Snopek
24d79abcfa gdextension: Sync with upstream commit 4ebf67c12dcdffcb69242569c118a371a654b6ae (4.5-beta7) 2025-08-29 10:38:01 -05:00
David Snopek
4c78d30822 gdextension: Sync with upstream commit d5ad0556a2c04c50694b5c04dc1b3bf03ecd7113 (4.5-beta6) 2025-08-28 10:16:42 -05:00
David Snopek
449e37fa21 Merge pull request #1814 from enetheru/suffix.fix
CMake: Remove starting `.` from GODOTCPP_SUFFIX
2025-08-21 08:45:26 -05:00
David Snopek
21b73421c6 Merge pull request #1834 from dsnopek/wrapped-stringname-reference
Take reference in `Wrapped(const StringName &)`
2025-08-21 07:20:12 -05:00
David Snopek
b192b880d3 Take reference in Wrapped(const StringName &) 2025-08-20 11:13:28 -05:00
David Snopek
fd708f429b Merge pull request #1828 from BenLubar/guard-unaligned-access
Only check for Godot 4.0 if the pointer is aligned how it would be for the legacy interface.
2025-08-14 10:12:14 -05:00
David Snopek
3830fe4a40 Merge pull request #1829 from BenLubar/web-debug-symbols
Fix debug symbols logic on `platform=web` to match Godot core.
2025-08-11 07:23:53 -05:00
Ben Lubar
9ea9b4797c Fix debug symbols logic on platform=web to match Godot core. 2025-08-09 17:36:34 -05:00
Ben Lubar
05d2ce3006 Only check for Godot 4.0 if the pointer is aligned how it would be for the legacy interface. 2025-08-09 12:19:21 -05:00
David Snopek
1421ba26ad gdextension: Sync with upstream commit c81fd6c51233a727da528cf7f74137d56b5d6efe (4.5-beta5) 2025-08-08 06:50:17 -05:00
David Snopek
e0c0c566a6 Merge pull request #1826 from bruvzg/sync_android_vers
Sync Android SDK and NDK versions with the engine.
2025-08-07 08:11:50 -05:00
Pāvels Nadtočajevs
8646cd31b5 Sync Android SDK and NDK versions with the engine. 2025-08-06 22:48:13 +03:00
David Snopek
e53489bbbe Merge pull request #1824 from Klaim/patch-1
fix: missing `type_traits` include
2025-08-05 08:39:37 -05:00
Klaim (Joël Lamotte)
fbe5262d7b fix: missing type_traits include
Usage of `std::is_trivially_constructible` in `defs.hpp` requires including `type_traits`. This missing include leads to errors about that type not being found when building with clang++-22 with libc++-22.
2025-08-04 15:49:36 +02:00
David Snopek
cb3ad55873 gdextension: Sync with upstream commit 2d113cc224cb9be07866d003819fcef2226a52ea (4.5-beta4) 2025-08-01 09:52:19 -05:00
David Snopek
4f80491c8c Merge pull request #1818 from dsnopek/test-internal-classes
Test that internal classes work as expected
2025-07-23 16:52:19 -05:00
David Snopek
a2b6f91dbc Merge pull request #1817 from Naros/GH-1816
Reintroduce Math_INF and Math_NAN defines
2025-07-23 14:12:56 -05:00
David Snopek
309b17b6eb Test that internal classes work as expected 2025-07-23 13:53:52 -05:00
David Snopek
134e8b756d Merge pull request #1819 from dsnopek/fix-custom-api-file-scons-401
Fix `custom_api_file` with SCons 4.0.1
2025-07-19 06:57:30 -05:00
David Snopek
8e7dfbc71a Fix custom_api_file with SCons 4.0.1 2025-07-17 09:03:11 -05:00
Chris Cranford
6a21f76c4d Reintroduce Math_INF and Math_NAN defines 2025-07-13 00:08:50 -04:00
Samuel Nicholas
b64b941adf CMake: Add GODOTCPP_SUFFIX_GENEX variable
This is the same as GODOTCPP_SUFFIX but without the leading '.'
GODOTCPP_SUFFIX is  then based on the above.
2025-07-11 11:30:34 +09:30
David Snopek
8bb931c6a9 gdextension: Sync with upstream commit 4d1f26e1fd1fa46f2223fe0b6ac300744bf79b88 (4.5-beta3) 2025-07-10 15:40:04 -05:00
David Snopek
6a870949a5 Merge pull request #1669 from Ivorforce/scons-variant_dir-support
Add SCons variant_dir support
2025-07-03 12:17:32 -05:00
David Snopek
f129db3e3d gdextension: Sync with upstream commit e1b4101e3460dd9c6ba0b7f8d88e9751b8383f5b (4.5-beta2) 2025-07-02 06:42:30 -05:00
David Snopek
c943beb4f4 Merge pull request #1795 from dsnopek/scons-dependency-on-build-profile
Files generated by SCons should depend on the `build_profile` (if given)
2025-06-25 08:57:38 -05:00
David Snopek
c45c4aa667 Merge pull request #1804 from dsnopek/github-actions-windows-2019
Update CI to use `windows-2022`
2025-06-24 16:30:44 -05:00
David Snopek
8938e7e4e3 Update CI to use windows-2022 2025-06-24 14:47:40 -05:00
David Snopek
75f95ffbcb Merge pull request #1792 from dsnopek/gdextension-interface-45
Update for GDExtension interface changes in Godot 4.5
2025-06-24 12:27:34 -05:00
David Snopek
7f5f02940d Update for GDExtension interface changes in Godot 4.5 2025-06-23 16:40:43 -05:00
David Snopek
3afe0d53c4 Merge pull request #1799 from dsnopek/disable-double-precision-in-ci
Disable double precisions builds in CI for now
2025-06-22 07:27:29 -05:00
David Snopek
b46c31a50e Disable double precisions builds in CI 2025-06-20 12:23:49 -05:00
David Snopek
61f52cb328 gdextension: Sync with upstream commit 46c495ca21f40f57a7fb9c7cde6143738f1652d4 (4.5-beta1) 2025-06-20 12:04:19 -05:00
David Snopek
835a3abeea Merge pull request #1796 from enetheru/ci-change_detection
[GitHub CI] Fix source detection, added missing include .hpp and .inc to detection rules.
2025-06-20 12:01:56 -05:00
David Snopek
e17a5a78d1 Merge pull request #1794 from bruvzg/fix_typed_dict_ref
Fix binding generation for `TypedArray`/`TypedDictionary` with refcounted elements.
2025-06-20 12:01:45 -05:00
David Snopek
5a0d6565d1 Merge pull request #1773 from tomfull123/method-bind-clean-up
Clean up the MethodBind class
2025-06-20 12:01:26 -05:00
Samuel Nicholas
6d11a780bf added missing include .hpp and .inc detection
removed redundant .py detection.
2025-06-19 10:24:48 +09:30
David Snopek
646ccdf470 Files generated by SCons should depend on the build_profile (if given) 2025-06-18 14:43:12 -05:00
Pāvels Nadtočajevs
ed53a70e71 Fix binding generation for TypedArray/TypedDictionary with refcounted elements. 2025-06-18 13:18:37 +03:00
David Snopek
5cbffab4c6 Merge pull request #1780 from piiertho/expose-object-set-script-instance
Expose gdextension_object_get_script_instance method from engine
2025-06-16 08:25:44 -05:00
David Snopek
86e32cef4a Merge pull request #1786 from marcmarmir/CMake-message-improvement
Fix: Add STATUS to CMake message commands missing them
2025-06-10 07:02:37 -05:00
David Snopek
c8053dfa34 Merge pull request #1790 from MJacred/patch-2
Fix URL to gdextension cpp example in the official docs
2025-06-09 07:23:47 -05:00
MJacred
f25c4df5c4 Fix URL to gdextension cpp example in the official docs 2025-06-09 11:49:03 +02:00
David Snopek
fef59ff89a Merge pull request #1779 from Ivorforce/ndk-version
Make ndk version configurable as a command-like argument.
2025-06-07 14:26:45 -05:00
David Snopek
a7127d3ec7 Merge pull request #1771 from tomfull123/array-constructor-crash
Fix array constructor crash
2025-06-07 14:20:01 -05:00
David Snopek
dde6663d33 Merge pull request #1785 from dgcole/master
Fix CMake double precision builds
2025-06-07 14:14:20 -05:00
David Snopek
dc9ac508f4 Merge pull request #1777 from Repiteo/ci/windows-utf8
CI: Ensure utf-8 support on Windows GHA
2025-06-07 14:13:30 -05:00
David Snopek
d5baa7071e Merge pull request #1757 from Repiteo/ci/version-bumps
CI: Various version bumps; sync with main repo
2025-06-07 14:13:14 -05:00
marcin.mirski
0c2e66e414 Improve CMAKE_BUILD_PARALLEL_LEVEL message 2025-06-05 11:48:03 -07:00
marcin.mirski
8eac097c37 Fix: Add STATUS to CMake message commands missing them 2025-06-04 16:54:45 -07:00
Dyllan Cole
4824aa41e8 Fix incorrect binding_generator_generate_bindings variable names 2025-05-31 19:23:50 -04:00
David Snopek
af4f05ec7e Merge pull request #1783 from Faless/fix/ios_sdk_version_link_flags
fix: Add iOS min SDK version link flags
2025-05-27 16:25:19 -05:00
Fabio Alessandrelli
4879eb7bd0 fix: Add iOS min SDK version link flags
This is required when publishing to the App Store, and consistent with
what we already do for the macOS deployment target.
2025-05-21 16:34:27 +02:00
Pierre-Thomas Meisels
0871c7a93a Expose gdextension_object_get_script_instance and gdextension_object_set_script_instance methods from engine 2025-05-05 18:55:59 +02:00
David Snopek
681fb04f7a Merge pull request #1755 from dsnopek/not-experimental-any-more
Stop referring to GDExtension as experimental in the README
2025-05-02 12:13:13 -05:00
Lukas Tenbrink
16e47d7ae5 Make ndk version configurable as a command-like argument. 2025-05-02 17:12:32 +02:00
David Snopek
543c1f7156 Merge pull request #1774 from BenLubar/unintended-copy
Fix ClassDB iterators making unintended copies
2025-04-29 16:19:58 -05:00
David Snopek
5a16059512 Merge pull request #1776 from dsnopek/fix-default-to-string
Fix classes without `_to_string()` always returning `"[Wrapped:0]"`
2025-04-26 13:39:59 -05:00
Thaddeus Crews
42f6dc6d49 CI: Ensure utf-8 support on Windows GHA 2025-04-26 12:29:50 -05:00
Thaddeus Crews
64cdf089d9 CI: Various version bumps; sync with main repo 2025-04-26 12:23:07 -05:00
David Snopek
f38c056b67 Fix classes without _to_string() always returning "[Wrapped:0]" 2025-04-25 15:54:41 -05:00
Ben Lubar
7fd0999b3c fix iterators making unintended copies 2025-04-21 18:45:05 -05:00
Tom
ca5af3c861 Cleaned up the MethodBind class 2025-04-20 20:47:06 +01:00
David Snopek
08fd033a9e Merge pull request #1743 from dsnopek/get-used-classes
Register the classes used with the Godot editor
2025-04-18 06:56:23 -05:00
David Snopek
195188f321 Merge pull request #1769 from enetheru/defs
CMake: Match #1758 move of DEBUG_METHODS_ENABLED from build options to defs.hpp
2025-04-17 07:41:48 -05:00
Samuel Nicholas
b195a51c6c Match #1758 build option changes
d634a5f8c4 (diff-e2225522e55739f1533a3ce9eee58324ac9c192c8ba30065067964347d22fdacL471)
2025-04-17 08:46:58 +09:30
David Snopek
2a8d218f12 Merge pull request #1756 from Repiteo/scons/external-includes
SCons: Add `CPPEXTPATH` for external includes
2025-04-16 16:10:45 -05:00
David Snopek
70d8ff0c47 Merge pull request #1770 from Zylann/basis_abs
Use Math::abs to avoid ambiguity with integer abs
2025-04-16 16:10:07 -05:00
Tom
ddd4f2513c Fixed a crash with an Array constructor 2025-04-16 20:30:15 +01:00
Marc Gilleron
7670de814f Use Math::abs to avoid ambiguity with integer abs 2025-04-16 20:37:19 +02:00
David Snopek
321af5b827 Merge pull request #1768 from enetheru/sccache_update
CI: bump of mozilla-sccache action to 0.0.9
2025-04-16 08:33:20 -05:00
Samuel Nicholas
bbbcc6adc7 version bump of mozilla-sccache action to 0.0.9
https://github.blog/changelog/2025-03-20-notification-of-upcoming-breaking-changes-in-github-actions/#decommissioned-cache-service-brownouts
2025-04-16 10:31:50 +09:30
David Snopek
62a5c609d3 Merge pull request #1763 from Grublady/typeddict
Fix TypedDictionary binding generation
2025-04-15 11:21:40 -05:00
David Snopek
97ad05beeb Merge pull request #1758 from tomfull123/sync-defs
Sync defs
2025-04-15 11:02:10 -05:00
David Snopek
94a8fad88c Merge pull request #1767 from Zylann/quaterion_abs
Use Math::abs to avoid ambiguity with integer abs
2025-04-15 08:12:53 -05:00
Marc Gilleron
7e6c9c9370 Use Math::abs to avoid ambiguity with integer abs 2025-04-14 23:46:47 +02:00
Grublady
26201dd27a Fix TypedDictionary binding generation 2025-04-08 20:34:29 -04:00
Tom
d634a5f8c4 Synced defs.hpp with godot's typedefs.h 2025-04-07 17:30:55 +01:00
David Snopek
c173cc0159 Merge pull request #1761 from enetheru/CI_compat_fix
Fix compatibility break for CI action 'setup-godot-cpp'
2025-04-07 07:09:36 -05:00
Samuel Nicholas
38e517b98b Fix compatibility break for CI 2025-04-07 08:10:16 +09:30
David Snopek
478e2637bd Merge pull request #1716 from tomfull123/master
Add support for `initializer_list` to Array and TypedArray
2025-04-05 10:32:18 -05:00
David Snopek
1163d1b4a8 Merge pull request #1750 from tomfull123/typed-dictionary-initializer-support
Typed dictionary initializer support
2025-04-05 10:32:06 -05:00
David Snopek
096d9056f0 Merge pull request #1760 from Calinou/update-test-project-4.4
Update test project to Godot 4.4
2025-04-05 10:31:50 -05:00
David Snopek
7888c15233 Merge pull request #1726 from enetheru/continuous_integration
Update CI with new CMake builds.
2025-04-05 10:03:49 -05:00
Samuel Nicholas
b6c0251296 CMake: Update CI
- Duplicated the ci.yml into ci-scons.yml and ci-cmake.yml
- Replaced some manual shell commands to detect changes with  tj-actions/changed-files@v45
- Conditionally run the CI depending on what files change.
- Add ios toolchain from leetal/ios-cmake
- Added a cmake-minimum of 3.10 to silence errors from ios toolchain
2025-04-05 13:31:52 +10:30
Thaddeus Crews
30bfa6f215 SCons: Add CPPEXTPATH for external includes 2025-04-04 09:39:47 -05:00
David Snopek
7660dd28b3 Stop referring to GDExtension as experimental in the README 2025-04-04 09:11:54 -05:00
Tom
335b490061 Added initialiser list support to TypedDictionary 2025-04-03 23:16:12 +01:00
Hugo Locurcio
552a74c96e Update test project to Godot 4.4 2025-04-03 16:40:19 +02:00
Tom
946a693859 . 2025-04-02 19:58:05 +01:00
David Snopek
da064d84d2 Merge pull request #1717 from tomfull123/typed-array-range-based-loop-support
Add support for range based loops for Array
2025-04-02 13:00:38 -05:00
David Snopek
c26e7c9734 Merge pull request #1754 from tomfull123/typed-dictionary-compilation-errors
Add method_ptrcall header include to type_info to fix compiler errors
2025-04-02 12:59:51 -05:00
David Snopek
d72baf192d Merge pull request #1742 from aaronfranke/projection-construct
Add missing Projection constructor with 16 `real_t` values
2025-04-02 12:59:14 -05:00
David Snopek
c2d688bae6 Merge pull request #1747 from unvermuthet/linux-use-static-cpp
Implement `use_static_cpp` flag for Linux
2025-04-02 12:59:04 -05:00
unvermuthet
b0f41909e0 Implement use_static_cpp flag for Linux 2025-04-01 22:35:40 +02:00
Tom
a2c37f8a16 Made the Array's ptr and ptrw methods private 2025-04-01 20:47:35 +01:00
Tom
7ffaecce8c Add method_ptrcall header include to type_info to fix compiler errors 2025-04-01 20:35:19 +01:00
David Snopek
f3deed0270 Merge pull request #1753 from dsnopek/stack-smashing-char-types
Fix stack smashing when Godot methods return `char32_t`, `char16_t` or `wchar_t`
2025-04-01 09:26:42 -05:00
David Snopek
035add9d4f Fix stack smashing when Godot methods return char32_t, char16_t or wchar_t 2025-03-28 07:41:25 -05:00
David Snopek
f088bc9b25 Merge pull request #1752 from bruvzg/rem_libs
[macOS] Remove unnecessary Cocoa reference.
2025-03-28 07:17:53 -05:00
Pāvels Nadtočajevs
d239da3221 [macOS] Remove unnecessary Cocoa reference. 2025-03-28 08:45:43 +02:00
David Snopek
aed195f6dc Register the classes used with the Godot editor 2025-03-17 13:23:32 -05:00
David Snopek
f08e781b0b Merge pull request #1718 from dsnopek/godot-sync-pre44-templates
Synchronize most shared template code with Godot 4.4
2025-03-14 14:13:31 -05:00
David Snopek
2b4802d0a8 Merge pull request #1715 from dsnopek/godot-sync-pre44
Synchronize most shared variant code with Godot 4.4
2025-03-14 14:13:21 -05:00
David Snopek
075b517d96 Synchronize most shared variant code with Godot 4.4 2025-03-14 11:39:56 -05:00
David Snopek
1edfca295b Synchronize most shared template code with Godot 4.4 2025-03-14 11:33:10 -05:00
David Snopek
67ca2fbbad Merge pull request #1740 from enetheru/privatise
CMake: public/private flags
2025-03-14 09:20:46 -05:00
David Snopek
654de13b5c Merge pull request #1702 from zhmt/master
binding_generator.py: Don't error if directory already exists
2025-03-14 08:56:30 -05:00
David Snopek
e4bd867056 Merge pull request #1730 from enetheru/XCode
CMake: XCode dependency chain fixes
2025-03-14 07:34:36 -05:00
Aaron Franke
aa03c32b3e Add missing Projection constructor with 16 real_t values 2025-03-14 02:46:23 -07:00
zhmt
d79959c79e binding_generator.py: Don't error if directory already exists
It should be ok when folders exist. Exception shouldn't be thrown.

Update binding_generator.py

It should be ok when folds exist. It will fail to build without this patch,  in vs code on windows with compiler ( visual studio community 2022 amd 64) .

Co-Authored-By: Chris Cranford <ccranfor@redhat.com>
2025-03-14 14:02:53 +08:00
Samuel Nicholas
5eb16d0c5b CMake: public/private flags
Made all warnings private.
Warning as error private
Consistency in  generator expressions
2025-03-14 11:11:15 +10:30
Samuel Nicholas
f83f364144 CMake: XCode dependency chain fixes - remastered
When attempting to generate XCode projects it would fail due to the target dependency chain not meeting expectations.

This PR, adds the required dependency infomation so that the XCode generator works.
2025-03-14 10:10:33 +10:30
David Snopek
6f981b33cc Merge pull request #1704 from BenLubar/missing-braces
Fix -Wmissing-braces warning (included in -Wall) in array constructor for generated function call bindings
2025-03-13 12:45:03 -05:00
David Snopek
d8807a10d6 Merge pull request #1734 from Repiteo/style/pragma-once
Replace header guards style with `#pragma once`
2025-03-13 11:47:14 -05:00
David Snopek
a5db125d2e Merge pull request #1714 from dsnopek/extension-api-precision
Check that precision of `extension_api.json` matches build options
2025-03-13 11:43:30 -05:00
David Snopek
9f02db1eb8 Merge pull request #1733 from enetheru/single_target_test
CMake: Revert to single cmake target
2025-03-13 11:42:15 -05:00
David Snopek
0b6350dd29 Merge pull request #1738 from ytnuf/exception
Remove unnecessary forced -fno-exceptions for web builds
2025-03-13 11:40:40 -05:00
Samuel Nicholas
89abe15268 CMake: Target as configuration option
Add GODOTCPP_TARGET configuration option
Remove loop to generate the godot-cpp.<target> CMake Targets

Rename test bindings target
Update documentation
2025-03-12 08:58:59 +10:30
ytnuf
43690cb60b Remove unnecessary forced -fno-exceptions for web builds
The SCons build doesn't do this, so neither should CMake
Excpetions are already handled by DISABLE_EXCEPTIONS option
2025-03-10 13:33:56 +00:00
Thaddeus Crews
c963321cdd Ignore #pragma once commit 2025-03-07 17:58:27 -06:00
Thaddeus Crews
7056c996dd Style: Replace header guards with #pragma once 2025-03-07 17:58:10 -06:00
Thaddeus Crews
107cb1da5e Style: Integrate #pragma once in builders/checks 2025-03-07 17:57:16 -06:00
David Snopek
a3f89217df Merge pull request #1723 from enetheru/comments
CMake: Comment Cleanup
2025-03-06 08:21:53 -06:00
David Snopek
55cbea7435 Merge pull request #1728 from enetheru/default_target
CMake: template_debug as default target when godot-cpp is top level
2025-03-06 08:21:29 -06:00
Samuel Nicholas
8b33e73353 CMake: default target when godot-cpp is top level
People seem to want to build godot-cpp without any arguments, not even specifying a target.

We have to detect if we are top level though because it conflicts with being consumed.
2025-03-07 00:04:36 +10:30
Samuel Nicholas
671e309cfa Updating commenting to be consistent 2025-03-06 23:57:02 +10:30
David Snopek
05f5d73876 Merge pull request #1722 from enetheru/gersemi
CMake: Pre-Commit Hook to Gersemi for auto-formatting
2025-03-06 06:42:51 -06:00
Samuel Nicholas
2f6d7f2dad add gersemi to pre-commit hooks for CMake formatting like black 2025-03-04 13:58:39 +10:30
David Snopek
0a73df5f53 Check that precision of extension_api.json matches build options 2025-02-27 13:27:11 -06:00
Ben Lubar
a353be57d8 Fix -Wmissing-braces warning (included in -Wall) in array constructor for generated function call bindings 2025-02-09 17:20:06 -06:00
Cedric Shock
1345c46650 Add SCons variant_dir support, which allows specifying a target build directory. 2025-01-12 18:32:59 +01:00
21 changed files with 14615 additions and 764 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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++) {")

View File

@@ -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

View File

@@ -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

View File

@@ -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();

View File

@@ -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

View File

@@ -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;
};
};

View File

@@ -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); \
} \

View File

@@ -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) {
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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")

View File

@@ -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;
}

View File

@@ -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;
};

View File

@@ -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) {

View File

@@ -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/"

View File

@@ -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)

View File

@@ -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)