mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-11 06:09:44 +03:00
Compare commits
251 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5cc777a89 | ||
|
|
b1e2ac5cbb | ||
|
|
53caa6adbc | ||
|
|
a9abdb5f0c | ||
|
|
9892f63abb | ||
|
|
7b4ca64761 | ||
|
|
6cdac999c2 | ||
|
|
48544896ee | ||
|
|
443c075fa3 | ||
|
|
52937a3850 | ||
|
|
888f46bbcc | ||
|
|
de7e5b9145 | ||
|
|
8fffe3b558 | ||
|
|
dcd0842fab | ||
|
|
dacaa81f2f | ||
|
|
40e65753f9 | ||
|
|
2dee0cc4de | ||
|
|
3f454d142d | ||
|
|
f3a1a2fd45 | ||
|
|
08e4c89da9 | ||
|
|
86d0dbe695 | ||
|
|
dc87cb6b97 | ||
|
|
4b9cd6ae9d | ||
|
|
fba9ecd0da | ||
|
|
59ad323dd1 | ||
|
|
9dc2e15d90 | ||
|
|
2d96b62774 | ||
|
|
2cd6221286 | ||
|
|
d6a47a28c7 | ||
|
|
f2303ba0cc | ||
|
|
c9da56cca2 | ||
|
|
3449c4e1d3 | ||
|
|
0899cf6098 | ||
|
|
06fbf3ce95 | ||
|
|
d5bdde9509 | ||
|
|
9ded2402dc | ||
|
|
575f317bf1 | ||
|
|
56571dc584 | ||
|
|
94d74979ce | ||
|
|
bf26191ead | ||
|
|
af78f2778f | ||
|
|
30a395bf43 | ||
|
|
a3d5d6d4d3 | ||
|
|
e751531290 | ||
|
|
2de650b82a | ||
|
|
5fe58bcd1e | ||
|
|
daf8ac1c33 | ||
|
|
b12aeb1b38 | ||
|
|
fa0b4cffc0 | ||
|
|
e52b4ea4fd | ||
|
|
20459da676 | ||
|
|
1cce4d15ab | ||
|
|
17ca325aeb | ||
|
|
e298f430b5 | ||
|
|
1ac33c906e | ||
|
|
842a7f621f | ||
|
|
37d255af6c | ||
|
|
762db4e4d6 | ||
|
|
c823e84ff2 | ||
|
|
26cb3292a0 | ||
|
|
150e45071b | ||
|
|
fbbf9ec4ef | ||
|
|
2e4c350b83 | ||
|
|
9b98377a62 | ||
|
|
92e6ea7303 | ||
|
|
11773e52b0 | ||
|
|
937b1d809a | ||
|
|
738859f49b | ||
|
|
9da1e0cee1 | ||
|
|
3f4590f8e1 | ||
|
|
e3e8101e8c | ||
|
|
26459dc47b | ||
|
|
daf6ad3649 | ||
|
|
c77d44f3f6 | ||
|
|
f2b521f55a | ||
|
|
628606b28b | ||
|
|
958776dfc3 | ||
|
|
0a1e31fa45 | ||
|
|
8012716ee3 | ||
|
|
76b38de01a | ||
|
|
6d939e6878 | ||
|
|
56cd3fd99e | ||
|
|
99926d8e20 | ||
|
|
e65ec904b8 | ||
|
|
2b34bd0d8b | ||
|
|
53b546e1df | ||
|
|
7abe4ca9e4 | ||
|
|
316dde80ba | ||
|
|
7d7799b56e | ||
|
|
90c6ea2a12 | ||
|
|
1989b1bf57 | ||
|
|
7a96d0314e | ||
|
|
999018e7d1 | ||
|
|
e0d363aad8 | ||
|
|
c414c2b37d | ||
|
|
78b63203d4 | ||
|
|
0efc6cddbc | ||
|
|
e7a13e3bf4 | ||
|
|
ed1e963a31 | ||
|
|
068e930c6a | ||
|
|
2dd8917508 | ||
|
|
89831ff333 | ||
|
|
f2ac49aea5 | ||
|
|
1186c488bd | ||
|
|
8cdd56e149 | ||
|
|
f1b7ba3e06 | ||
|
|
5d8f80bc55 | ||
|
|
9e2771f918 | ||
|
|
ee9acbcf10 | ||
|
|
64f1bc847a | ||
|
|
1bb543b6f4 | ||
|
|
37e7a6da05 | ||
|
|
6c4064125b | ||
|
|
9f6fe36633 | ||
|
|
2360f84513 | ||
|
|
6cd6c8923a | ||
|
|
e04a26b2bc | ||
|
|
c5986e666f | ||
|
|
7d4758eace | ||
|
|
4f7439d4cf | ||
|
|
fe0647202b | ||
|
|
7f74fe7bb2 | ||
|
|
41aa71f8c3 | ||
|
|
8c6cc1ec15 | ||
|
|
21d526e5e5 | ||
|
|
246a803954 | ||
|
|
45be6d0bd4 | ||
|
|
21b86b6770 | ||
|
|
76cbc66785 | ||
|
|
3e9afccae8 | ||
|
|
b697ba8896 | ||
|
|
e4a4d76cb3 | ||
|
|
3db8549e19 | ||
|
|
340dde31a2 | ||
|
|
6b39ed0732 | ||
|
|
16cad7ba24 | ||
|
|
798fbab653 | ||
|
|
88df025aa0 | ||
|
|
85172dad1b | ||
|
|
996d229b26 | ||
|
|
5bad5d6958 | ||
|
|
e3f3cb58b7 | ||
|
|
17a82e7f94 | ||
|
|
f5c2b38724 | ||
|
|
3d0d9cd0e2 | ||
|
|
43be24f34c | ||
|
|
a434850069 | ||
|
|
d0bdd6096c | ||
|
|
12a1283663 | ||
|
|
23178e81ff | ||
|
|
505076c9a9 | ||
|
|
b0296bb562 | ||
|
|
54fe2f9891 | ||
|
|
8cc78cfea9 | ||
|
|
2cd3d39108 | ||
|
|
1d829f2e4a | ||
|
|
ca46ef4d25 | ||
|
|
e23b117ac3 | ||
|
|
d304f12dcd | ||
|
|
61450b3e1b | ||
|
|
06373ce1cf | ||
|
|
e1b3b32db5 | ||
|
|
2a041b5240 | ||
|
|
ad307e4b9c | ||
|
|
6873658d26 | ||
|
|
9ff49b7b1b | ||
|
|
048f49af39 | ||
|
|
e160966163 | ||
|
|
e4ae69f607 | ||
|
|
4b7661a60a | ||
|
|
d389171905 | ||
|
|
b65970860e | ||
|
|
1fa7a9cb19 | ||
|
|
a537b4af4d | ||
|
|
b05c21bb1d | ||
|
|
37542dc2ec | ||
|
|
b02124595f | ||
|
|
d055b575fb | ||
|
|
7d4a24caab | ||
|
|
3715bfe253 | ||
|
|
44d78ec881 | ||
|
|
5c12bd2287 | ||
|
|
87ecf17242 | ||
|
|
a62f633ceb | ||
|
|
ec166295ba | ||
|
|
916b4ff2d5 | ||
|
|
fb79d5ff98 | ||
|
|
e6b6df5893 | ||
|
|
d78fe9853f | ||
|
|
12ebe4b180 | ||
|
|
efb46f7f82 | ||
|
|
7cff8ca896 | ||
|
|
87f5fb0691 | ||
|
|
e607790647 | ||
|
|
7ed8ef7221 | ||
|
|
cc1217a43c | ||
|
|
f444616553 | ||
|
|
fc986c2d12 | ||
|
|
8c98a90f32 | ||
|
|
8b92368165 | ||
|
|
e55b792fea | ||
|
|
c4fde852e6 | ||
|
|
23c010900c | ||
|
|
f90085917b | ||
|
|
a6d9393341 | ||
|
|
16df4bff30 | ||
|
|
620104e700 | ||
|
|
349b081b18 | ||
|
|
baaad7ada2 | ||
|
|
fb884573ea | ||
|
|
5fcc43e54d | ||
|
|
9a13efa0e3 | ||
|
|
8fbb7cf795 | ||
|
|
6a3753c076 | ||
|
|
7c547c6c6b | ||
|
|
349b5a3146 | ||
|
|
b173a4d935 | ||
|
|
32ca574f49 | ||
|
|
36847f6af0 | ||
|
|
8a535d0ecc | ||
|
|
cd5673bf2e | ||
|
|
0145e900f3 | ||
|
|
6c04514039 | ||
|
|
480a0f8c06 | ||
|
|
5f350e2572 | ||
|
|
3943e41d2f | ||
|
|
0ddef6ed96 | ||
|
|
64529361b4 | ||
|
|
edf1637c2c | ||
|
|
ee169b201b | ||
|
|
59a5a8b104 | ||
|
|
bd40a94424 | ||
|
|
f037a697eb | ||
|
|
dd62b9685f | ||
|
|
8d13acca91 | ||
|
|
b1769a70f0 | ||
|
|
b733102f4a | ||
|
|
718d0baea3 | ||
|
|
b77cb648c3 | ||
|
|
3f44e9b404 | ||
|
|
1c19d627aa | ||
|
|
646c71c277 | ||
|
|
e17c7bf530 | ||
|
|
0a078d9ec9 | ||
|
|
31179ee47c | ||
|
|
48afa82f29 | ||
|
|
39ca745d0d | ||
|
|
a7becb43e6 | ||
|
|
41517eacb1 | ||
|
|
17137b2e2e | ||
|
|
cad5be53b1 |
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -9,7 +9,7 @@ body:
|
||||
- Write a descriptive issue title above.
|
||||
- The golden rule is to **always open *one* issue for *one* bug**. If you notice several bugs and want to report them, make sure to create one new issue for each of them.
|
||||
- Search [open](https://github.com/godotengine/godot-cpp/issues) and [closed](https://github.com/godotengine/godot-cpp/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. If you don't find a relevant match or if you're unsure, don't hesitate to **open a new issue**. The bugsquad will handle it from there if it's a duplicate.
|
||||
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
|
||||
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/latest/about/release_policy.html).
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
|
||||
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
@@ -6,7 +6,7 @@ env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: master
|
||||
# Used to select the version of Godot to run the tests with.
|
||||
GODOT_TEST_VERSION: 4.2.2-stable
|
||||
GODOT_TEST_VERSION: 4.3-stable
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- name: 🐧 Linux (GCC)
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
platform: linux
|
||||
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.linux.template_release.x86_64.a
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
cache-name: linux-x86_64
|
||||
|
||||
- name: 🐧 Linux (GCC, Double Precision)
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
platform: linux
|
||||
artifact-name: godot-cpp-linux-glibc2.27-x86_64-double-release
|
||||
artifact-path: bin/libgodot-cpp.linux.template_release.double.x86_64.a
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
cache-name: linux-x86_64-f64
|
||||
|
||||
- name: 🏁 Windows (x86_64, MSVC)
|
||||
os: windows-2019
|
||||
os: windows-2022
|
||||
platform: windows
|
||||
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.windows.template_release.x86_64.lib
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
cache-name: windows-x86_64-msvc
|
||||
|
||||
- name: 🏁 Windows (x86_64, MinGW)
|
||||
os: windows-2019
|
||||
os: windows-2022
|
||||
platform: windows
|
||||
artifact-name: godot-cpp-linux-mingw-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.windows.template_release.x86_64.a
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
cache-name: macos-universal
|
||||
|
||||
- name: 🤖 Android (arm64)
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
platform: android
|
||||
artifact-name: godot-cpp-android-arm64-release
|
||||
artifact-path: bin/libgodot-cpp.android.template_release.arm64.a
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
cache-name: ios-arm64
|
||||
|
||||
- name: 🌐 Web (wasm32)
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-22.04
|
||||
platform: web
|
||||
artifact-name: godot-cpp-web-wasm32-release
|
||||
artifact-path: bin/libgodot-cpp.web.template_release.wasm32.a
|
||||
@@ -171,11 +171,11 @@ jobs:
|
||||
$GODOT --headless --version
|
||||
cd test
|
||||
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
|
||||
(cd project && (timeout 30 $GODOT --editor --headless --quit >/dev/null 2>&1 || true))
|
||||
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
|
||||
./run-tests.sh
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact-name }}
|
||||
path: ${{ matrix.artifact-path }}
|
||||
@@ -183,7 +183,7 @@ jobs:
|
||||
|
||||
linux-cmake:
|
||||
name: 🐧 Build (Linux, GCC, CMake)
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -207,7 +207,7 @@ jobs:
|
||||
|
||||
linux-cmake-ninja:
|
||||
name: 🐧 Build (Linux, GCC, CMake Ninja)
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -231,7 +231,7 @@ jobs:
|
||||
|
||||
windows-msvc-cmake:
|
||||
name: 🏁 Build (Windows, MSVC, CMake)
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -240,10 +240,10 @@ jobs:
|
||||
|
||||
- name: Build godot-cpp
|
||||
run: |
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" .
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" .
|
||||
cmake --build . --verbose --config Release
|
||||
|
||||
- name: Build test GDExtension library
|
||||
run: |
|
||||
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -G"Visual Studio 16 2019" .
|
||||
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -G"Visual Studio 17 2022" .
|
||||
cmake --build . --verbose --config Release
|
||||
|
||||
25
README.md
25
README.md
@@ -1,12 +1,14 @@
|
||||
# godot-cpp
|
||||
|
||||
> **Warning**
|
||||
> [!WARNING]
|
||||
>
|
||||
> This repository's `master` branch is only usable with
|
||||
> [GDExtension](https://godotengine.org/article/introducing-gd-extensions)
|
||||
> from Godot's `master` branch.
|
||||
>
|
||||
> For users of stable branches, switch to the branch matching your target Godot version:
|
||||
> - [`4.4`](https://github.com/godotengine/godot-cpp/tree/4.4)
|
||||
> - [`4.3`](https://github.com/godotengine/godot-cpp/tree/4.3)
|
||||
> - [`4.2`](https://github.com/godotengine/godot-cpp/tree/4.2)
|
||||
> - [`4.1`](https://github.com/godotengine/godot-cpp/tree/4.1)
|
||||
> - [`4.0`](https://github.com/godotengine/godot-cpp/tree/4.0)
|
||||
@@ -22,7 +24,7 @@ This repository contains the *C++ bindings* for the [**Godot Engine**](https://
|
||||
- [**Compatibility**](#compatibility)
|
||||
- [**Contributing**](#contributing)
|
||||
- [**Getting started**](#getting-started)
|
||||
- [**Included example**](#included-example)
|
||||
- [**Examples and templates**](#examples-and-templates)
|
||||
|
||||
## Versioning
|
||||
|
||||
@@ -49,18 +51,13 @@ Godot version.**
|
||||
|
||||
## Compatibility
|
||||
|
||||
**Warning:** The GDExtension API is brand new in Godot 4.0, and is still
|
||||
considered in **beta** stage, despite Godot 4.0 itself being released.
|
||||
GDExtensions targeting an earlier version of Godot should work in later minor versions,
|
||||
but not vice-versa. For example, a GDExtension targeting Godot 4.2 should work just fine
|
||||
in Godot 4.3, but one targeting Godot 4.3 won't work in Godot 4.2.
|
||||
|
||||
This applies to both the GDExtension interface header, the API JSON, and this
|
||||
first-party `godot-cpp` extension.
|
||||
|
||||
Some compatibility breakage is to be expected as GDExtension and `godot-cpp`
|
||||
get more used, documented, and critical issues get resolved. See the
|
||||
[Godot issue tracker](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aopen+label%3Atopic%3Agdextension)
|
||||
and the [godot-cpp issue tracker](https://github.com/godotengine/godot-cpp/issues)
|
||||
for a list of known issues, and be sure to provide feedback on issues and PRs
|
||||
which affect your use of this extension.
|
||||
There is one exception to this: extensions targeting Godot 4.0 will _not_ work with
|
||||
Godot 4.1 and later.
|
||||
See [Updating your GDExtension for 4.1](https://docs.godotengine.org/en/latest/tutorials/migrating/upgrading_to_godot_4.1.html#updating-your-gdextension-for-godot-4-1).
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -143,4 +140,4 @@ See the [godot-cpp-template](https://github.com/godotengine/godot-cpp-template)
|
||||
generic reusable template.
|
||||
|
||||
Or checkout the code for the [Summator example](https://github.com/paddy-exe/GDExtensionSummator)
|
||||
as shown in the [official documentation](https://docs.godotengine.org/en/latest/tutorials/scripting/gdextension/gdextension_cpp_example.html).
|
||||
as shown in the [official documentation](https://docs.godotengine.org/en/latest/tutorials/scripting/cpp/gdextension_cpp_example.html).
|
||||
|
||||
@@ -70,7 +70,134 @@ def generate_wrappers(target):
|
||||
f.write(txt)
|
||||
|
||||
|
||||
def get_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||
def generate_virtual_version(argcount, const=False, returns=False):
|
||||
s = """#define GDVIRTUAL$VER($RET m_name $ARG)\\
|
||||
::godot::StringName _gdvirtual_##m_name##_sn = #m_name;\\
|
||||
template <bool required>\\
|
||||
_FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST {\\
|
||||
if (::godot::internal::gdextension_interface_object_has_script_method(_owner, &_gdvirtual_##m_name##_sn)) { \\
|
||||
GDExtensionCallError ce;\\
|
||||
$CALLSIARGS\\
|
||||
::godot::Variant ret;\\
|
||||
::godot::internal::gdextension_interface_object_call_script_method(_owner, &_gdvirtual_##m_name##_sn, $CALLSIARGPASS, &ret, &ce);\\
|
||||
if (ce.error == GDEXTENSION_CALL_OK) {\\
|
||||
$CALLSIRET\\
|
||||
return true;\\
|
||||
}\\
|
||||
}\\
|
||||
if (required) {\\
|
||||
ERR_PRINT_ONCE("Required virtual method " + get_class() + "::" + #m_name + " must be overridden before calling.");\\
|
||||
$RVOID\\
|
||||
}\\
|
||||
return false;\\
|
||||
}\\
|
||||
_FORCE_INLINE_ bool _gdvirtual_##m_name##_overridden() const {\\
|
||||
return ::godot::internal::gdextension_interface_object_has_script_method(_owner, &_gdvirtual_##m_name##_sn); \\
|
||||
}\\
|
||||
_FORCE_INLINE_ static ::godot::MethodInfo _gdvirtual_##m_name##_get_method_info() {\\
|
||||
::godot::MethodInfo method_info;\\
|
||||
method_info.name = #m_name;\\
|
||||
method_info.flags = $METHOD_FLAGS;\\
|
||||
$FILL_METHOD_INFO\\
|
||||
return method_info;\\
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
sproto = str(argcount)
|
||||
method_info = ""
|
||||
if returns:
|
||||
sproto += "R"
|
||||
s = s.replace("$RET", "m_ret,")
|
||||
s = s.replace("$RVOID", "(void)r_ret;") # If required, may lead to uninitialized errors
|
||||
method_info += "method_info.return_val = ::godot::GetTypeInfo<m_ret>::get_class_info();\\\n"
|
||||
method_info += "\t\tmethod_info.return_val_metadata = ::godot::GetTypeInfo<m_ret>::METADATA;"
|
||||
else:
|
||||
s = s.replace("$RET ", "")
|
||||
s = s.replace("\t\t\t$RVOID\\\n", "")
|
||||
|
||||
if const:
|
||||
sproto += "C"
|
||||
s = s.replace("$CONST", "const")
|
||||
s = s.replace("$METHOD_FLAGS", "::godot::METHOD_FLAG_VIRTUAL | ::godot::METHOD_FLAG_CONST")
|
||||
else:
|
||||
s = s.replace("$CONST ", "")
|
||||
s = s.replace("$METHOD_FLAGS", "::godot::METHOD_FLAG_VIRTUAL")
|
||||
|
||||
s = s.replace("$VER", sproto)
|
||||
argtext = ""
|
||||
callargtext = ""
|
||||
callsiargs = ""
|
||||
callsiargptrs = ""
|
||||
if argcount > 0:
|
||||
argtext += ", "
|
||||
callsiargs = f"::godot::Variant vargs[{argcount}] = {{ "
|
||||
callsiargptrs = f"\t\t\tconst ::godot::Variant *vargptrs[{argcount}] = {{ "
|
||||
for i in range(argcount):
|
||||
if i > 0:
|
||||
argtext += ", "
|
||||
callargtext += ", "
|
||||
callsiargs += ", "
|
||||
callsiargptrs += ", "
|
||||
argtext += f"m_type{i + 1}"
|
||||
callargtext += f"m_type{i + 1} arg{i + 1}"
|
||||
callsiargs += f"::godot::Variant(arg{i + 1})"
|
||||
callsiargptrs += f"&vargs[{i}]"
|
||||
if method_info:
|
||||
method_info += "\\\n\t\t"
|
||||
method_info += f"method_info.arguments.push_back(::godot::GetTypeInfo<m_type{i + 1}>::get_class_info());\\\n"
|
||||
method_info += f"\t\tmethod_info.arguments_metadata.push_back(::godot::GetTypeInfo<m_type{i + 1}>::METADATA);"
|
||||
|
||||
if argcount:
|
||||
callsiargs += " };\\\n"
|
||||
callsiargptrs += " };"
|
||||
s = s.replace("$CALLSIARGS", callsiargs + callsiargptrs)
|
||||
s = s.replace("$CALLSIARGPASS", f"(const GDExtensionConstVariantPtr *)vargptrs, {argcount}")
|
||||
else:
|
||||
s = s.replace("\t\t\t$CALLSIARGS\\\n", "")
|
||||
s = s.replace("$CALLSIARGPASS", "nullptr, 0")
|
||||
|
||||
if returns:
|
||||
if argcount > 0:
|
||||
callargtext += ", "
|
||||
callargtext += "m_ret &r_ret"
|
||||
s = s.replace("$CALLSIRET", "r_ret = ::godot::VariantCaster<m_ret>::cast(ret);")
|
||||
else:
|
||||
s = s.replace("\t\t\t\t$CALLSIRET\\\n", "")
|
||||
|
||||
s = s.replace(" $ARG", argtext)
|
||||
s = s.replace("$CALLARGS", callargtext)
|
||||
if method_info:
|
||||
s = s.replace("$FILL_METHOD_INFO", method_info)
|
||||
else:
|
||||
s = s.replace("\t\t$FILL_METHOD_INFO\\\n", method_info)
|
||||
|
||||
return s
|
||||
|
||||
|
||||
def generate_virtuals(target):
|
||||
max_versions = 12
|
||||
|
||||
txt = """/* THIS FILE IS GENERATED DO NOT EDIT */
|
||||
#ifndef GDEXTENSION_GDVIRTUAL_GEN_H
|
||||
#define GDEXTENSION_GDVIRTUAL_GEN_H
|
||||
|
||||
"""
|
||||
|
||||
for i in range(max_versions + 1):
|
||||
txt += f"/* {i} Arguments */\n\n"
|
||||
txt += generate_virtual_version(i, False, False)
|
||||
txt += generate_virtual_version(i, False, True)
|
||||
txt += generate_virtual_version(i, True, False)
|
||||
txt += generate_virtual_version(i, True, True)
|
||||
|
||||
txt += "#endif // GDEXTENSION_GDVIRTUAL_GEN_H\n"
|
||||
|
||||
with open(target, "w", encoding="utf-8") as f:
|
||||
f.write(txt)
|
||||
|
||||
|
||||
def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||
api = {}
|
||||
with open(api_filepath, encoding="utf-8") as api_file:
|
||||
api = json.load(api_file)
|
||||
@@ -86,6 +213,7 @@ def _get_file_list(api, output_dir, headers=False, sources=False):
|
||||
source_gen_folder = Path(output_dir) / "gen" / "src"
|
||||
|
||||
files.append(str((core_gen_folder / "ext_wrappers.gen.inc").as_posix()))
|
||||
files.append(str((core_gen_folder / "gdvirtual.gen.inc").as_posix()))
|
||||
|
||||
for builtin_class in api["builtin_classes"]:
|
||||
if is_pod_type(builtin_class["name"]):
|
||||
@@ -150,14 +278,19 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision=
|
||||
api = {}
|
||||
with open(api_filepath, encoding="utf-8") as api_file:
|
||||
api = json.load(api_file)
|
||||
_generate_bindings(api, use_template_get_node, bits, precision, output_dir)
|
||||
_generate_bindings(api, api_filepath, use_template_get_node, bits, precision, output_dir)
|
||||
|
||||
|
||||
def _generate_bindings(api, use_template_get_node, bits="64", precision="single", output_dir="."):
|
||||
def _generate_bindings(api, api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."):
|
||||
if "precision" in api["header"] and precision != api["header"]["precision"]:
|
||||
raise Exception(
|
||||
f"Cannot do a precision={precision} build using '{api_filepath}' which was generated by Godot built with precision={api['header']['precision']}"
|
||||
)
|
||||
|
||||
target_dir = Path(output_dir) / "gen"
|
||||
|
||||
shutil.rmtree(target_dir, ignore_errors=True)
|
||||
target_dir.mkdir(parents=True)
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
real_t = "double" if precision == "double" else "float"
|
||||
print("Built-in type config: " + real_t + "_" + bits)
|
||||
@@ -197,6 +330,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
|
||||
source_gen_folder.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
generate_wrappers(core_gen_folder / "ext_wrappers.gen.inc")
|
||||
generate_virtuals(core_gen_folder / "gdvirtual.gen.inc")
|
||||
|
||||
# Store types beforehand.
|
||||
for builtin_api in api["builtin_classes"]:
|
||||
@@ -307,14 +441,8 @@ def generate_builtin_bindings(api, output_dir, build_config):
|
||||
|
||||
builtin_header.append("")
|
||||
|
||||
includes = []
|
||||
for builtin in builtin_classes:
|
||||
includes.append(f"godot_cpp/variant/{camel_to_snake(builtin)}.hpp")
|
||||
|
||||
includes.sort()
|
||||
|
||||
for include in includes:
|
||||
builtin_header.append(f"#include <{include}>")
|
||||
builtin_header.append(f"#include <godot_cpp/variant/{camel_to_snake(builtin)}.hpp>")
|
||||
|
||||
builtin_header.append("")
|
||||
|
||||
@@ -370,10 +498,11 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
|
||||
continue
|
||||
|
||||
result += make_varargs_template(
|
||||
method, "is_static" in method and method["is_static"], class_name, False, True
|
||||
method, "is_static" in method and method["is_static"], class_name, False, False, True
|
||||
)
|
||||
result.append("")
|
||||
|
||||
result.append("")
|
||||
result.append(f"#endif // ! {header_guard}")
|
||||
|
||||
return "\n".join(result)
|
||||
@@ -398,50 +527,38 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
|
||||
# Special cases.
|
||||
if class_name == "String":
|
||||
result.append("#include <godot_cpp/classes/global_constants.hpp>")
|
||||
result.append("#include <godot_cpp/variant/char_string.hpp>")
|
||||
result.append("#include <godot_cpp/variant/char_utils.hpp>")
|
||||
result.append("")
|
||||
result.append("#include <godot_cpp/classes/global_constants.hpp>")
|
||||
|
||||
if class_name == "PackedStringArray":
|
||||
result.append("#include <godot_cpp/variant/string.hpp>")
|
||||
result.append("")
|
||||
if class_name == "PackedColorArray":
|
||||
result.append("#include <godot_cpp/variant/color.hpp>")
|
||||
result.append("")
|
||||
if class_name == "PackedVector2Array":
|
||||
result.append("#include <godot_cpp/variant/vector2.hpp>")
|
||||
result.append("")
|
||||
if class_name == "PackedVector3Array":
|
||||
result.append("#include <godot_cpp/variant/vector3.hpp>")
|
||||
result.append("")
|
||||
if class_name == "PackedVector4Array":
|
||||
result.append("#include <godot_cpp/variant/vector4.hpp>")
|
||||
|
||||
if is_packed_array(class_name):
|
||||
result.append("#include <godot_cpp/core/error_macros.hpp>")
|
||||
result.append("#include <initializer_list>")
|
||||
result.append("")
|
||||
|
||||
if class_name == "Array":
|
||||
result.append("#include <godot_cpp/variant/array_helpers.hpp>")
|
||||
result.append("")
|
||||
|
||||
if class_name == "Callable":
|
||||
result.append("#include <godot_cpp/variant/callable_custom.hpp>")
|
||||
result.append("")
|
||||
|
||||
for include in fully_used_classes:
|
||||
if include == "TypedArray":
|
||||
result.append("#include <godot_cpp/variant/typed_array.hpp>")
|
||||
else:
|
||||
result.append(f"#include <godot_cpp/{get_include_path(include)}>")
|
||||
|
||||
if len(fully_used_classes) > 0:
|
||||
includes = []
|
||||
for include in fully_used_classes:
|
||||
if include == "TypedArray":
|
||||
includes.append("godot_cpp/variant/typed_array.hpp")
|
||||
else:
|
||||
includes.append(f"godot_cpp/{get_include_path(include)}")
|
||||
|
||||
includes.sort()
|
||||
|
||||
for include in includes:
|
||||
result.append(f"#include <{include}>")
|
||||
|
||||
result.append("")
|
||||
|
||||
result.append("#include <gdextension_interface.h>")
|
||||
@@ -519,7 +636,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
result.append("public:")
|
||||
|
||||
result.append(
|
||||
f"\t_FORCE_INLINE_ GDExtensionTypePtr _native_ptr() const {{ return const_cast<uint8_t(*)[{snake_class_name}_SIZE]>(&opaque); }}"
|
||||
f"\t_FORCE_INLINE_ GDExtensionTypePtr _native_ptr() const {{ return const_cast<uint8_t (*)[{snake_class_name}_SIZE]>(&opaque); }}"
|
||||
)
|
||||
|
||||
copy_constructor_index = -1
|
||||
@@ -612,9 +729,11 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
# Special cases.
|
||||
if class_name == "String":
|
||||
result.append("\tstatic String utf8(const char *p_from, int64_t p_len = -1);")
|
||||
result.append("\tvoid parse_utf8(const char *p_from, int64_t p_len = -1);")
|
||||
result.append("\tError parse_utf8(const char *p_from, int64_t p_len = -1);")
|
||||
result.append("\tstatic String utf16(const char16_t *p_from, int64_t p_len = -1);")
|
||||
result.append("\tvoid parse_utf16(const char16_t *p_from, int64_t p_len = -1);")
|
||||
result.append(
|
||||
"\tError parse_utf16(const char16_t *p_from, int64_t p_len = -1, bool p_default_little_endian = true);"
|
||||
)
|
||||
result.append("\tCharString utf8() const;")
|
||||
result.append("\tCharString ascii() const;")
|
||||
result.append("\tChar16String utf16() const;")
|
||||
@@ -698,7 +817,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
result.append(f"\tconst {return_type} *ptr() const;")
|
||||
result.append(f"\t{return_type} *ptrw();")
|
||||
iterators = """
|
||||
struct Iterator {
|
||||
struct Iterator {
|
||||
_FORCE_INLINE_ $TYPE &operator*() const {
|
||||
return *elem_ptr;
|
||||
}
|
||||
@@ -760,17 +879,19 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
}
|
||||
_FORCE_INLINE_ ConstIterator end() const {
|
||||
return ConstIterator(ptr() + size());
|
||||
}"""
|
||||
}
|
||||
"""
|
||||
result.append(iterators.replace("$TYPE", return_type))
|
||||
init_list = """
|
||||
_FORCE_INLINE_ $CLASS(std::initializer_list<$TYPE> p_init) {
|
||||
_FORCE_INLINE_ $CLASS(std::initializer_list<$TYPE> p_init) {
|
||||
ERR_FAIL_COND(resize(p_init.size()) != 0);
|
||||
|
||||
size_t i = 0;
|
||||
for (const $TYPE &element : p_init) {
|
||||
set(i++, element);
|
||||
}
|
||||
}"""
|
||||
}
|
||||
"""
|
||||
result.append(init_list.replace("$TYPE", return_type).replace("$CLASS", class_name))
|
||||
|
||||
if class_name == "Array":
|
||||
@@ -809,9 +930,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||
result.append("")
|
||||
result.append("} // namespace godot")
|
||||
|
||||
result.append("")
|
||||
result.append(f"#endif // ! {header_guard}")
|
||||
result.append("")
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
@@ -825,6 +944,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||
|
||||
add_header(f"{snake_class_name}.cpp", result)
|
||||
|
||||
result.append("")
|
||||
result.append(f"#include <godot_cpp/variant/{snake_class_name}.hpp>")
|
||||
result.append("")
|
||||
result.append("#include <godot_cpp/core/binder_common.hpp>")
|
||||
@@ -833,16 +953,10 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||
result.append("")
|
||||
|
||||
# Only used since the "fully used" is included in header already.
|
||||
for include in used_classes:
|
||||
result.append(f"#include <godot_cpp/{get_include_path(include)}>")
|
||||
|
||||
if len(used_classes) > 0:
|
||||
includes = []
|
||||
for included in used_classes:
|
||||
includes.append(f"godot_cpp/{get_include_path(included)}")
|
||||
|
||||
includes.sort()
|
||||
|
||||
for included in includes:
|
||||
result.append(f"#include <{included}>")
|
||||
|
||||
result.append("")
|
||||
|
||||
result.append("#include <godot_cpp/core/builtin_ptrcall.hpp>")
|
||||
@@ -1092,7 +1206,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||
f'{correct_type(operator["return_type"])} {class_name}::operator{get_operator_cpp_name(operator["name"])}() const {{'
|
||||
)
|
||||
result.append(
|
||||
f'\treturn internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr) nullptr);'
|
||||
f'\treturn internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr)nullptr);'
|
||||
)
|
||||
result.append("}")
|
||||
result.append("")
|
||||
@@ -1128,7 +1242,6 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||
|
||||
result.append("")
|
||||
result.append("} //namespace godot")
|
||||
result.append("")
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
@@ -1304,18 +1417,11 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
||||
|
||||
result.append("")
|
||||
|
||||
if len(used_classes) > 0:
|
||||
includes = []
|
||||
for included in used_classes:
|
||||
includes.append(f"godot_cpp/{get_include_path(included)}")
|
||||
for included in used_classes:
|
||||
result.append(f"#include <godot_cpp/{get_include_path(included)}>")
|
||||
|
||||
includes.sort()
|
||||
|
||||
for include in includes:
|
||||
result.append(f"#include <{include}>")
|
||||
else:
|
||||
if len(used_classes) == 0:
|
||||
result.append("#include <godot_cpp/core/method_ptrcall.hpp>")
|
||||
|
||||
result.append("")
|
||||
|
||||
result.append("namespace godot {")
|
||||
@@ -1355,23 +1461,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
|
||||
result.append("")
|
||||
|
||||
if len(fully_used_classes) > 0:
|
||||
includes = []
|
||||
for included in fully_used_classes:
|
||||
if included == "TypedArray":
|
||||
includes.append("godot_cpp/variant/typed_array.hpp")
|
||||
else:
|
||||
includes.append(f"godot_cpp/{get_include_path(included)}")
|
||||
|
||||
includes.sort()
|
||||
|
||||
for include in includes:
|
||||
result.append(f"#include <{include}>")
|
||||
|
||||
result.append("")
|
||||
for included in fully_used_classes:
|
||||
if included == "TypedArray":
|
||||
result.append("#include <godot_cpp/variant/typed_array.hpp>")
|
||||
else:
|
||||
result.append(f"#include <godot_cpp/{get_include_path(included)}>")
|
||||
|
||||
if class_name == "EditorPlugin":
|
||||
result.append("#include <godot_cpp/classes/editor_plugin_registration.hpp>")
|
||||
|
||||
if len(fully_used_classes) > 0:
|
||||
result.append("")
|
||||
|
||||
if class_name != "Object" and class_name != "ClassDBSingleton":
|
||||
@@ -1410,6 +1509,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
result.append("")
|
||||
|
||||
result.append("public:")
|
||||
result.append("")
|
||||
|
||||
if "enums" in class_api:
|
||||
for enum_api in class_api["enums"]:
|
||||
@@ -1442,10 +1542,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
|
||||
vararg = "is_vararg" in method and method["is_vararg"]
|
||||
|
||||
if vararg:
|
||||
result.append("")
|
||||
result.append("private:")
|
||||
|
||||
method_signature = "\t"
|
||||
method_signature += make_signature(
|
||||
class_name, method, for_header=True, use_template_get_node=use_template_get_node
|
||||
@@ -1453,8 +1549,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
result.append(method_signature + ";")
|
||||
|
||||
if vararg:
|
||||
result.append("")
|
||||
result.append("public:")
|
||||
# Add templated version.
|
||||
result += make_varargs_template(method)
|
||||
|
||||
@@ -1469,8 +1563,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
)
|
||||
result.append(method_signature + ";")
|
||||
|
||||
result.append("")
|
||||
|
||||
result.append("protected:")
|
||||
# T is the custom class we want to register (from which the call initiates, going up the inheritance chain),
|
||||
# B is its base class (can be a custom class too, that's why we pass it).
|
||||
@@ -1487,7 +1579,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
# If the method is different from the base class, it means T overrides it, so it needs to be bound.
|
||||
# Note that with an `if constexpr`, the code inside the `if` will not even be compiled if the
|
||||
# condition returns false (in such cases it can't compile due to ambiguity).
|
||||
f"\t\tif constexpr (!std::is_same_v<decltype(&B::{method_name}), decltype(&T::{method_name})>) {{"
|
||||
f"\t\tif constexpr (!std::is_same_v<decltype(&B::{method_name}),decltype(&T::{method_name})>) {{"
|
||||
)
|
||||
result.append(f"\t\t\tBIND_VIRTUAL_METHOD(T, {method_name});")
|
||||
result.append("\t\t}")
|
||||
@@ -1499,19 +1591,33 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
result.append(f"\t~{class_name}();")
|
||||
result.append("")
|
||||
|
||||
if class_name == "Object":
|
||||
result.append('\tString _to_string() const { return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; }')
|
||||
result.append("")
|
||||
|
||||
if class_name == "Node":
|
||||
result.append(
|
||||
'\tString _to_string() const { return (!get_name().is_empty() ? String(get_name()) + ":" : "") + Object::_to_string(); }'
|
||||
)
|
||||
result.append("")
|
||||
|
||||
result.append("public:")
|
||||
|
||||
# Special cases.
|
||||
if class_name == "XMLParser":
|
||||
result.append("\tError _open_buffer(const uint8_t *p_buffer, size_t p_size);")
|
||||
|
||||
if class_name == "Image":
|
||||
result.append("\tuint8_t *ptrw();")
|
||||
result.append("\tconst uint8_t *ptr();")
|
||||
|
||||
if class_name == "FileAccess":
|
||||
result.append("\tuint64_t get_buffer(uint8_t *p_dst, uint64_t p_length) const;")
|
||||
result.append("\tvoid store_buffer(const uint8_t *p_src, uint64_t p_length);")
|
||||
|
||||
if class_name == "WorkerThreadPool":
|
||||
result.append("\tenum {")
|
||||
result.append("\t\tINVALID_TASK_ID = -1")
|
||||
result.append("\tINVALID_TASK_ID = -1")
|
||||
result.append("\t};")
|
||||
result.append("\ttypedef int64_t TaskID;")
|
||||
result.append("\ttypedef int64_t GroupID;")
|
||||
@@ -1523,6 +1629,8 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
)
|
||||
|
||||
if class_name == "Object":
|
||||
result.append("")
|
||||
|
||||
result.append("\ttemplate <typename T>")
|
||||
result.append("\tstatic T *cast_to(Object *p_object);")
|
||||
|
||||
@@ -1537,6 +1645,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
|
||||
)
|
||||
|
||||
result.append("")
|
||||
result.append("};")
|
||||
result.append("")
|
||||
|
||||
@@ -1620,7 +1729,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
|
||||
result.append(method_body)
|
||||
result.append("\t} \\")
|
||||
result.append("\t")
|
||||
result.append("\t;")
|
||||
result.append("")
|
||||
|
||||
result.append("#define CLASSDB_SINGLETON_VARIANT_CAST \\")
|
||||
@@ -1632,11 +1741,10 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||
else:
|
||||
result.append(f'\tVARIANT_ENUM_CAST({class_api["alias_for"]}::{enum_api["name"]}); \\')
|
||||
|
||||
result.append("\t")
|
||||
result.append("\t;")
|
||||
result.append("")
|
||||
|
||||
result.append(f"#endif // ! {header_guard}")
|
||||
result.append("")
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
@@ -1658,16 +1766,10 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
|
||||
result.append("#include <godot_cpp/core/error_macros.hpp>")
|
||||
result.append("")
|
||||
|
||||
for included in used_classes:
|
||||
result.append(f"#include <godot_cpp/{get_include_path(included)}>")
|
||||
|
||||
if len(used_classes) > 0:
|
||||
includes = []
|
||||
for included in used_classes:
|
||||
includes.append(f"godot_cpp/{get_include_path(included)}")
|
||||
|
||||
includes.sort()
|
||||
|
||||
for included in includes:
|
||||
result.append(f"#include <{included}>")
|
||||
|
||||
result.append("")
|
||||
|
||||
result.append("namespace godot {")
|
||||
@@ -1817,8 +1919,8 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
|
||||
result.append(method_signature)
|
||||
result.append("")
|
||||
|
||||
result.append("} // namespace godot")
|
||||
result.append("")
|
||||
result.append("} // namespace godot ")
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
@@ -1846,24 +1948,23 @@ def generate_global_constants(api, output_dir):
|
||||
header.append("namespace godot {")
|
||||
header.append("")
|
||||
|
||||
if len(api["global_constants"]) > 0:
|
||||
for constant in api["global_constants"]:
|
||||
header.append(f'const int64_t {escape_identifier(constant["name"])} = {constant["value"]};')
|
||||
for constant in api["global_constants"]:
|
||||
header.append(f'\tconst int64_t {escape_identifier(constant["name"])} = {constant["value"]};')
|
||||
|
||||
header.append("")
|
||||
header.append("")
|
||||
|
||||
for enum_def in api["global_enums"]:
|
||||
if enum_def["name"].startswith("Variant."):
|
||||
continue
|
||||
|
||||
if enum_def["is_bitfield"]:
|
||||
header.append(f'enum {enum_def["name"]} : uint64_t {{')
|
||||
header.append(f'\tenum {enum_def["name"]} : uint64_t {{')
|
||||
else:
|
||||
header.append(f'enum {enum_def["name"]} {{')
|
||||
header.append(f'\tenum {enum_def["name"]} {{')
|
||||
|
||||
for value in enum_def["values"]:
|
||||
header.append(f'\t{value["name"]} = {value["value"]},')
|
||||
header.append("};")
|
||||
header.append(f'\t\t{value["name"]} = {value["value"]},')
|
||||
header.append("\t};")
|
||||
header.append("")
|
||||
|
||||
header.append("} // namespace godot")
|
||||
@@ -1976,17 +2077,11 @@ def generate_utility_functions(api, output_dir):
|
||||
for function in api["utility_functions"]:
|
||||
vararg = "is_vararg" in function and function["is_vararg"]
|
||||
|
||||
if vararg:
|
||||
header.append("")
|
||||
header.append("private:")
|
||||
|
||||
function_signature = "\t"
|
||||
function_signature += make_signature("UtilityFunctions", function, for_header=True, static=True)
|
||||
header.append(function_signature + ";")
|
||||
|
||||
if vararg:
|
||||
header.append("")
|
||||
header.append("public:")
|
||||
# Add templated version.
|
||||
header += make_varargs_template(function, static=True)
|
||||
|
||||
@@ -2007,8 +2102,8 @@ def generate_utility_functions(api, output_dir):
|
||||
|
||||
source.append("#include <godot_cpp/variant/utility_functions.hpp>")
|
||||
source.append("")
|
||||
source.append("#include <godot_cpp/core/engine_ptrcall.hpp>")
|
||||
source.append("#include <godot_cpp/core/error_macros.hpp>")
|
||||
source.append("#include <godot_cpp/core/engine_ptrcall.hpp>")
|
||||
source.append("")
|
||||
source.append("namespace godot {")
|
||||
source.append("")
|
||||
@@ -2107,7 +2202,7 @@ def make_function_parameters(parameters, include_default=False, for_builtin=Fals
|
||||
signature.append(parameter)
|
||||
|
||||
if is_vararg:
|
||||
signature.append("const Args &...p_args")
|
||||
signature.append("const Args&... p_args")
|
||||
|
||||
return ", ".join(signature)
|
||||
|
||||
@@ -2169,6 +2264,9 @@ def make_signature(
|
||||
if "is_virtual" in function_data and function_data["is_virtual"]:
|
||||
function_signature += "virtual "
|
||||
|
||||
if is_vararg:
|
||||
function_signature += "private: "
|
||||
|
||||
if static:
|
||||
function_signature += "static "
|
||||
|
||||
@@ -2221,6 +2319,7 @@ def make_varargs_template(
|
||||
function_data,
|
||||
static=False,
|
||||
class_befor_signature="",
|
||||
with_public_declare=True,
|
||||
with_indent=True,
|
||||
for_builtin_classes=False,
|
||||
):
|
||||
@@ -2228,7 +2327,10 @@ def make_varargs_template(
|
||||
|
||||
function_signature = ""
|
||||
|
||||
result.append("template <typename... Args>")
|
||||
if with_public_declare:
|
||||
function_signature = "public: "
|
||||
|
||||
function_signature += "template <typename... Args> "
|
||||
|
||||
if static:
|
||||
function_signature += "static "
|
||||
@@ -2271,7 +2373,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"])
|
||||
@@ -2388,6 +2490,7 @@ def is_packed_array(type_name):
|
||||
"PackedStringArray",
|
||||
"PackedVector2Array",
|
||||
"PackedVector3Array",
|
||||
"PackedVector4Array",
|
||||
]
|
||||
|
||||
|
||||
@@ -2506,6 +2609,8 @@ def correct_type(type_name, meta=None, use_alias=True):
|
||||
if meta is not None:
|
||||
if "int" in meta:
|
||||
return f"{meta}_t"
|
||||
elif "char" in meta:
|
||||
return f"{meta}_t"
|
||||
else:
|
||||
return meta
|
||||
if type_name in type_conversion:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -96,6 +96,7 @@ typedef enum {
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY,
|
||||
|
||||
GDEXTENSION_VARIANT_TYPE_VARIANT_MAX
|
||||
} GDExtensionVariantType;
|
||||
@@ -256,6 +257,7 @@ typedef struct {
|
||||
|
||||
typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
|
||||
typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list);
|
||||
typedef void (*GDExtensionClassFreePropertyList2)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count);
|
||||
typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name);
|
||||
typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
|
||||
typedef GDExtensionBool (*GDExtensionClassValidateProperty)(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property);
|
||||
@@ -290,7 +292,7 @@ typedef struct {
|
||||
GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
|
||||
GDExtensionClassGetRID get_rid_func;
|
||||
void *class_userdata; // Per-class user data, later accessible in instance bindings.
|
||||
} GDExtensionClassCreationInfo; // Deprecated. Use GDExtensionClassCreationInfo2 instead.
|
||||
} GDExtensionClassCreationInfo; // Deprecated. Use GDExtensionClassCreationInfo3 instead.
|
||||
|
||||
typedef struct {
|
||||
GDExtensionBool is_virtual;
|
||||
@@ -323,7 +325,41 @@ typedef struct {
|
||||
GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
|
||||
GDExtensionClassGetRID get_rid_func;
|
||||
void *class_userdata; // Per-class user data, later accessible in instance bindings.
|
||||
} GDExtensionClassCreationInfo2;
|
||||
} GDExtensionClassCreationInfo2; // Deprecated. Use GDExtensionClassCreationInfo3 instead.
|
||||
|
||||
typedef struct {
|
||||
GDExtensionBool is_virtual;
|
||||
GDExtensionBool is_abstract;
|
||||
GDExtensionBool is_exposed;
|
||||
GDExtensionBool is_runtime;
|
||||
GDExtensionClassSet set_func;
|
||||
GDExtensionClassGet get_func;
|
||||
GDExtensionClassGetPropertyList get_property_list_func;
|
||||
GDExtensionClassFreePropertyList2 free_property_list_func;
|
||||
GDExtensionClassPropertyCanRevert property_can_revert_func;
|
||||
GDExtensionClassPropertyGetRevert property_get_revert_func;
|
||||
GDExtensionClassValidateProperty validate_property_func;
|
||||
GDExtensionClassNotification2 notification_func;
|
||||
GDExtensionClassToString to_string_func;
|
||||
GDExtensionClassReference reference_func;
|
||||
GDExtensionClassUnreference unreference_func;
|
||||
GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
|
||||
GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
|
||||
GDExtensionClassRecreateInstance recreate_instance_func;
|
||||
// Queries a virtual function by name and returns a callback to invoke the requested virtual function.
|
||||
GDExtensionClassGetVirtual get_virtual_func;
|
||||
// Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
|
||||
// need or benefit from extra data when calling virtual functions.
|
||||
// Returns user data that will be passed to `call_virtual_with_data_func`.
|
||||
// Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
|
||||
// Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
|
||||
// You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
|
||||
GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
|
||||
// Used to call virtual functions when `get_virtual_call_data_func` is not null.
|
||||
GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
|
||||
GDExtensionClassGetRID get_rid_func;
|
||||
void *class_userdata; // Per-class user data, later accessible in instance bindings.
|
||||
} GDExtensionClassCreationInfo3;
|
||||
|
||||
typedef void *GDExtensionClassLibraryPtr;
|
||||
|
||||
@@ -364,13 +400,18 @@ typedef struct {
|
||||
GDExtensionClassMethodPtrCall ptrcall_func;
|
||||
uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
|
||||
|
||||
/* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored. */
|
||||
/* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored.
|
||||
*
|
||||
* @todo Consider dropping `has_return_value` and making the other two properties match `GDExtensionMethodInfo` and `GDExtensionClassVirtualMethod` for consistency in future version of this struct.
|
||||
*/
|
||||
GDExtensionBool has_return_value;
|
||||
GDExtensionPropertyInfo *return_value_info;
|
||||
GDExtensionClassMethodArgumentMetadata return_value_metadata;
|
||||
|
||||
/* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
|
||||
* Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
|
||||
*
|
||||
* @todo Consider renaming `arguments_info` to `arguments` for consistency in future version of this struct.
|
||||
*/
|
||||
uint32_t argument_count;
|
||||
GDExtensionPropertyInfo *arguments_info;
|
||||
@@ -381,6 +422,18 @@ typedef struct {
|
||||
GDExtensionVariantPtr *default_arguments;
|
||||
} GDExtensionClassMethodInfo;
|
||||
|
||||
typedef struct {
|
||||
GDExtensionStringNamePtr name;
|
||||
uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
|
||||
|
||||
GDExtensionPropertyInfo return_value;
|
||||
GDExtensionClassMethodArgumentMetadata return_value_metadata;
|
||||
|
||||
uint32_t argument_count;
|
||||
GDExtensionPropertyInfo *arguments;
|
||||
GDExtensionClassMethodArgumentMetadata *arguments_metadata;
|
||||
} GDExtensionClassVirtualMethodInfo;
|
||||
|
||||
typedef void (*GDExtensionCallableCustomCall)(void *callable_userdata, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
typedef GDExtensionBool (*GDExtensionCallableCustomIsValid)(void *callable_userdata);
|
||||
typedef void (*GDExtensionCallableCustomFree)(void *callable_userdata);
|
||||
@@ -391,6 +444,8 @@ typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_user
|
||||
|
||||
typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
|
||||
|
||||
typedef GDExtensionInt (*GDExtensionCallableCustomGetArgumentCount)(void *callable_userdata, GDExtensionBool *r_is_valid);
|
||||
|
||||
typedef struct {
|
||||
/* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
|
||||
*
|
||||
@@ -420,7 +475,40 @@ typedef struct {
|
||||
GDExtensionCallableCustomLessThan less_than_func;
|
||||
|
||||
GDExtensionCallableCustomToString to_string_func;
|
||||
} GDExtensionCallableCustomInfo;
|
||||
} GDExtensionCallableCustomInfo; // Deprecated. Use GDExtensionCallableCustomInfo2 instead.
|
||||
|
||||
typedef struct {
|
||||
/* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
|
||||
*
|
||||
* `token` should point to an address that uniquely identifies the GDExtension (for example, the
|
||||
* `GDExtensionClassLibraryPtr` passed to the entry symbol function.
|
||||
*
|
||||
* `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
|
||||
* `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
|
||||
*
|
||||
* The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
|
||||
*
|
||||
* `is_valid_func` is necessary if the validity of the callable can change before destruction.
|
||||
*
|
||||
* `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
|
||||
*/
|
||||
void *callable_userdata;
|
||||
void *token;
|
||||
|
||||
GDObjectInstanceID object_id;
|
||||
|
||||
GDExtensionCallableCustomCall call_func;
|
||||
GDExtensionCallableCustomIsValid is_valid_func;
|
||||
GDExtensionCallableCustomFree free_func;
|
||||
|
||||
GDExtensionCallableCustomHash hash_func;
|
||||
GDExtensionCallableCustomEqual equal_func;
|
||||
GDExtensionCallableCustomLessThan less_than_func;
|
||||
|
||||
GDExtensionCallableCustomToString to_string_func;
|
||||
|
||||
GDExtensionCallableCustomGetArgumentCount get_argument_count_func;
|
||||
} GDExtensionCallableCustomInfo2;
|
||||
|
||||
/* SCRIPT INSTANCE EXTENSION */
|
||||
|
||||
@@ -429,7 +517,8 @@ typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInsta
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
|
||||
typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
|
||||
typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list);
|
||||
typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreePropertyList2 instead.
|
||||
typedef void (*GDExtensionScriptInstanceFreePropertyList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count);
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceGetClassCategory)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_class_category);
|
||||
|
||||
typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
|
||||
@@ -443,10 +532,13 @@ typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstString
|
||||
typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
|
||||
|
||||
typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
|
||||
typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list);
|
||||
typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreeMethodList2 instead.
|
||||
typedef void (*GDExtensionScriptInstanceFreeMethodList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list, uint32_t p_count);
|
||||
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
|
||||
|
||||
typedef GDExtensionInt (*GDExtensionScriptInstanceGetMethodArgumentCount)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
|
||||
|
||||
typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionScriptInstanceNotification2 instead.
|
||||
typedef void (*GDExtensionScriptInstanceNotification2)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
|
||||
@@ -503,7 +595,7 @@ typedef struct {
|
||||
|
||||
GDExtensionScriptInstanceFree free_func;
|
||||
|
||||
} GDExtensionScriptInstanceInfo; // Deprecated. Use GDExtensionScriptInstanceInfo2 instead.
|
||||
} GDExtensionScriptInstanceInfo; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead.
|
||||
|
||||
typedef struct {
|
||||
GDExtensionScriptInstanceSet set_func;
|
||||
@@ -544,7 +636,50 @@ typedef struct {
|
||||
|
||||
GDExtensionScriptInstanceFree free_func;
|
||||
|
||||
} GDExtensionScriptInstanceInfo2;
|
||||
} GDExtensionScriptInstanceInfo2; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead.
|
||||
|
||||
typedef struct {
|
||||
GDExtensionScriptInstanceSet set_func;
|
||||
GDExtensionScriptInstanceGet get_func;
|
||||
GDExtensionScriptInstanceGetPropertyList get_property_list_func;
|
||||
GDExtensionScriptInstanceFreePropertyList2 free_property_list_func;
|
||||
GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior.
|
||||
|
||||
GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
|
||||
GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
|
||||
|
||||
GDExtensionScriptInstanceGetOwner get_owner_func;
|
||||
GDExtensionScriptInstanceGetPropertyState get_property_state_func;
|
||||
|
||||
GDExtensionScriptInstanceGetMethodList get_method_list_func;
|
||||
GDExtensionScriptInstanceFreeMethodList2 free_method_list_func;
|
||||
GDExtensionScriptInstanceGetPropertyType get_property_type_func;
|
||||
GDExtensionScriptInstanceValidateProperty validate_property_func;
|
||||
|
||||
GDExtensionScriptInstanceHasMethod has_method_func;
|
||||
|
||||
GDExtensionScriptInstanceGetMethodArgumentCount get_method_argument_count_func;
|
||||
|
||||
GDExtensionScriptInstanceCall call_func;
|
||||
GDExtensionScriptInstanceNotification2 notification_func;
|
||||
|
||||
GDExtensionScriptInstanceToString to_string_func;
|
||||
|
||||
GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
|
||||
GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
|
||||
|
||||
GDExtensionScriptInstanceGetScript get_script_func;
|
||||
|
||||
GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
|
||||
|
||||
GDExtensionScriptInstanceSet set_fallback_func;
|
||||
GDExtensionScriptInstanceGet get_fallback_func;
|
||||
|
||||
GDExtensionScriptInstanceGetLanguage get_language_func;
|
||||
|
||||
GDExtensionScriptInstanceFree free_func;
|
||||
|
||||
} GDExtensionScriptInstanceInfo3;
|
||||
|
||||
/* INITIALIZATION */
|
||||
|
||||
@@ -1447,6 +1582,7 @@ typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUn
|
||||
/**
|
||||
* @name string_new_with_utf8_chars_and_len
|
||||
* @since 4.1
|
||||
* @deprecated in Godot 4.3. Use `string_new_with_utf8_chars_and_len2` instead.
|
||||
*
|
||||
* Creates a String from a UTF-8 encoded C string with the given length.
|
||||
*
|
||||
@@ -1456,9 +1592,24 @@ typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUn
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
|
||||
|
||||
/**
|
||||
* @name string_new_with_utf8_chars_and_len2
|
||||
* @since 4.3
|
||||
*
|
||||
* Creates a String from a UTF-8 encoded C string with the given length.
|
||||
*
|
||||
* @param r_dest A pointer to a Variant to hold the newly created String.
|
||||
* @param p_contents A pointer to a UTF-8 encoded C string.
|
||||
* @param p_size The number of bytes (not code units).
|
||||
*
|
||||
* @return Error code signifying if the operation successful.
|
||||
*/
|
||||
typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
|
||||
|
||||
/**
|
||||
* @name string_new_with_utf16_chars_and_len
|
||||
* @since 4.1
|
||||
* @deprecated in Godot 4.3. Use `string_new_with_utf16_chars_and_len2` instead.
|
||||
*
|
||||
* Creates a String from a UTF-16 encoded C string with the given length.
|
||||
*
|
||||
@@ -1468,6 +1619,21 @@ typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUnin
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
|
||||
|
||||
/**
|
||||
* @name string_new_with_utf16_chars_and_len2
|
||||
* @since 4.3
|
||||
*
|
||||
* Creates a String from a UTF-16 encoded C string with the given length.
|
||||
*
|
||||
* @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_default_little_endian If true, UTF-16 use little endian.
|
||||
*
|
||||
* @return Error code signifying if the operation successful.
|
||||
*/
|
||||
typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count, GDExtensionBool p_default_little_endian);
|
||||
|
||||
/**
|
||||
* @name string_new_with_utf32_chars_and_len
|
||||
* @since 4.1
|
||||
@@ -1764,6 +1930,36 @@ typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p
|
||||
*/
|
||||
typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
|
||||
|
||||
/* INTERFACE: Image Utilities */
|
||||
|
||||
/**
|
||||
* @name image_ptrw
|
||||
* @since 4.3
|
||||
*
|
||||
* Returns writable pointer to internal Image buffer.
|
||||
*
|
||||
* @param p_instance A pointer to a Image object.
|
||||
*
|
||||
* @return Pointer to internal Image buffer.
|
||||
*
|
||||
* @see Image::ptrw()
|
||||
*/
|
||||
typedef uint8_t *(*GDExtensionInterfaceImagePtrw)(GDExtensionObjectPtr p_instance);
|
||||
|
||||
/**
|
||||
* @name image_ptr
|
||||
* @since 4.3
|
||||
*
|
||||
* Returns read only pointer to internal Image buffer.
|
||||
*
|
||||
* @param p_instance A pointer to a Image object.
|
||||
*
|
||||
* @return Pointer to internal Image buffer.
|
||||
*
|
||||
* @see Image::ptr()
|
||||
*/
|
||||
typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_instance);
|
||||
|
||||
/* INTERFACE: WorkerThreadPool Utilities */
|
||||
|
||||
/**
|
||||
@@ -1829,32 +2025,6 @@ typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtension
|
||||
*/
|
||||
typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_color_array_operator_index
|
||||
* @since 4.1
|
||||
*
|
||||
* Gets a pointer to a color in a PackedColorArray.
|
||||
*
|
||||
* @param p_self A pointer to a PackedColorArray object.
|
||||
* @param p_index The index of the Color to get.
|
||||
*
|
||||
* @return A pointer to the requested Color.
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_color_array_operator_index_const
|
||||
* @since 4.1
|
||||
*
|
||||
* Gets a const pointer to a color in a PackedColorArray.
|
||||
*
|
||||
* @param p_self A const pointer to a const PackedColorArray object.
|
||||
* @param p_index The index of the Color to get.
|
||||
*
|
||||
* @return A const pointer to the requested Color.
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_float32_array_operator_index
|
||||
* @since 4.1
|
||||
@@ -2037,6 +2207,58 @@ typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_vector4_array_operator_index
|
||||
* @since 4.3
|
||||
*
|
||||
* Gets a pointer to a Vector4 in a PackedVector4Array.
|
||||
*
|
||||
* @param p_self A pointer to a PackedVector4Array object.
|
||||
* @param p_index The index of the Vector4 to get.
|
||||
*
|
||||
* @return A pointer to the requested Vector4.
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_vector4_array_operator_index_const
|
||||
* @since 4.3
|
||||
*
|
||||
* Gets a const pointer to a Vector4 in a PackedVector4Array.
|
||||
*
|
||||
* @param p_self A const pointer to a PackedVector4Array object.
|
||||
* @param p_index The index of the Vector4 to get.
|
||||
*
|
||||
* @return A const pointer to the requested Vector4.
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_color_array_operator_index
|
||||
* @since 4.1
|
||||
*
|
||||
* Gets a pointer to a color in a PackedColorArray.
|
||||
*
|
||||
* @param p_self A pointer to a PackedColorArray object.
|
||||
* @param p_index The index of the Color to get.
|
||||
*
|
||||
* @return A pointer to the requested Color.
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name packed_color_array_operator_index_const
|
||||
* @since 4.1
|
||||
*
|
||||
* Gets a const pointer to a color in a PackedColorArray.
|
||||
*
|
||||
* @param p_self A const pointer to a PackedColorArray object.
|
||||
* @param p_index The index of the Color to get.
|
||||
*
|
||||
* @return A const pointer to the requested Color.
|
||||
*/
|
||||
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/**
|
||||
* @name array_operator_index
|
||||
* @since 4.1
|
||||
@@ -2223,6 +2445,9 @@ typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o,
|
||||
*
|
||||
* Gets the class name of an Object.
|
||||
*
|
||||
* If the GDExtension wraps the Godot object in an abstraction specific to its class, this is the
|
||||
* function that should be used to determine which wrapper to use.
|
||||
*
|
||||
* @param p_object A pointer to the Object.
|
||||
* @param p_library A pointer the library received by the GDExtension's entry point function.
|
||||
* @param r_class_name A pointer to a String to receive the class name.
|
||||
@@ -2268,6 +2493,34 @@ typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDOb
|
||||
*/
|
||||
typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object);
|
||||
|
||||
/**
|
||||
* @name object_has_script_method
|
||||
* @since 4.3
|
||||
*
|
||||
* Checks if this object has a script with the given method.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
|
||||
|
||||
/**
|
||||
* @name object_call_script_method
|
||||
* @since 4.3
|
||||
*
|
||||
* Call the given script method on this object.
|
||||
*
|
||||
* @param p_object A pointer to the Object.
|
||||
* @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.
|
||||
* @param r_return A pointer a Variant which will be assigned the return value.
|
||||
* @param r_error A pointer the structure which will hold error information.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceObjectCallScriptMethod)(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
|
||||
/* INTERFACE: Reference */
|
||||
|
||||
/**
|
||||
@@ -2298,7 +2551,7 @@ typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExte
|
||||
/**
|
||||
* @name script_instance_create
|
||||
* @since 4.1
|
||||
* @deprecated in Godot 4.2. Use `script_instance_create2` instead.
|
||||
* @deprecated in Godot 4.2. Use `script_instance_create3` instead.
|
||||
*
|
||||
* Creates a script instance that contains the given info and instance data.
|
||||
*
|
||||
@@ -2312,6 +2565,7 @@ typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)
|
||||
/**
|
||||
* @name script_instance_create2
|
||||
* @since 4.2
|
||||
* @deprecated in Godot 4.3. Use `script_instance_create3` instead.
|
||||
*
|
||||
* Creates a script instance that contains the given info and instance data.
|
||||
*
|
||||
@@ -2322,6 +2576,19 @@ typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)
|
||||
*/
|
||||
typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate2)(const GDExtensionScriptInstanceInfo2 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
|
||||
|
||||
/**
|
||||
* @name script_instance_create3
|
||||
* @since 4.3
|
||||
*
|
||||
* Creates a script instance that contains the given info and instance data.
|
||||
*
|
||||
* @param p_info A pointer to a GDExtensionScriptInstanceInfo3 struct.
|
||||
* @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info.
|
||||
*
|
||||
* @return A pointer to a ScriptInstanceExtension object.
|
||||
*/
|
||||
typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate3)(const GDExtensionScriptInstanceInfo3 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
|
||||
|
||||
/**
|
||||
* @name placeholder_script_instance_create
|
||||
* @since 4.2
|
||||
@@ -2371,6 +2638,7 @@ typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptIn
|
||||
/**
|
||||
* @name callable_custom_create
|
||||
* @since 4.2
|
||||
* @deprecated in Godot 4.3. Use `callable_custom_create2` instead.
|
||||
*
|
||||
* Creates a custom Callable object from a function pointer.
|
||||
*
|
||||
@@ -2381,6 +2649,19 @@ typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptIn
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceCallableCustomCreate)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_callable_custom_info);
|
||||
|
||||
/**
|
||||
* @name callable_custom_create2
|
||||
* @since 4.3
|
||||
*
|
||||
* Creates a custom Callable object from a function pointer.
|
||||
*
|
||||
* Provided struct can be safely freed once the function returns.
|
||||
*
|
||||
* @param r_callable A pointer that will receive the new Callable.
|
||||
* @param p_callable_custom_info The info required to construct a Callable.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo2 *p_callable_custom_info);
|
||||
|
||||
/**
|
||||
* @name callable_custom_get_userdata
|
||||
* @since 4.2
|
||||
@@ -2441,7 +2722,7 @@ typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNa
|
||||
/**
|
||||
* @name classdb_register_extension_class
|
||||
* @since 4.1
|
||||
* @deprecated in Godot 4.2. Use `classdb_register_extension_class2` instead.
|
||||
* @deprecated in Godot 4.2. Use `classdb_register_extension_class3` instead.
|
||||
*
|
||||
* Registers an extension class in the ClassDB.
|
||||
*
|
||||
@@ -2457,6 +2738,7 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionCla
|
||||
/**
|
||||
* @name classdb_register_extension_class2
|
||||
* @since 4.2
|
||||
* @deprecated in Godot 4.3. Use `classdb_register_extension_class3` instead.
|
||||
*
|
||||
* Registers an extension class in the ClassDB.
|
||||
*
|
||||
@@ -2469,6 +2751,21 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionCla
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo2 *p_extension_funcs);
|
||||
|
||||
/**
|
||||
* @name classdb_register_extension_class3
|
||||
* @since 4.3
|
||||
*
|
||||
* 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 GDExtensionClassCreationInfo2 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_class_method
|
||||
* @since 4.1
|
||||
@@ -2483,18 +2780,36 @@ typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionCl
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
|
||||
|
||||
/**
|
||||
* @name classdb_register_extension_class_virtual_method
|
||||
* @since 4.3
|
||||
*
|
||||
* Registers a virtual method on an extension class in ClassDB, that can be implemented by scripts or other extensions.
|
||||
*
|
||||
* 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_method_info A pointer to a GDExtensionClassMethodInfo struct.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassVirtualMethodInfo *p_method_info);
|
||||
|
||||
/**
|
||||
* @name classdb_register_extension_class_integer_constant
|
||||
* @since 4.1
|
||||
*
|
||||
* Registers an integer constant on an extension class in the ClassDB.
|
||||
*
|
||||
* Note about registering bitfield values (if p_is_bitfield is true): even though p_constant_value is signed, language bindings are
|
||||
* advised to treat bitfields as uint64_t, since this is generally clearer and can prevent mistakes like using -1 for setting all bits.
|
||||
* Language APIs should thus provide an abstraction that registers bitfields (uint64_t) separately from regular constants (int64_t).
|
||||
*
|
||||
* @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_enum_name A pointer to a StringName with the enum name.
|
||||
* @param p_constant_name A pointer to a StringName with the constant name.
|
||||
* @param p_constant_value The constant value.
|
||||
* @param p_is_bitfield Whether or not this is a bit field.
|
||||
* @param p_is_bitfield Whether or not this constant is part of a bitfield.
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield);
|
||||
|
||||
@@ -2617,6 +2932,31 @@ typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePt
|
||||
*/
|
||||
typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);
|
||||
|
||||
/**
|
||||
* @name editor_help_load_xml_from_utf8_chars
|
||||
* @since 4.3
|
||||
*
|
||||
* Loads new XML-formatted documentation data in the editor.
|
||||
*
|
||||
* The provided pointer can be immediately freed once the function returns.
|
||||
*
|
||||
* @param p_data A pointer to a UTF-8 encoded C string (null terminated).
|
||||
*/
|
||||
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars)(const char *p_data);
|
||||
|
||||
/**
|
||||
* @name editor_help_load_xml_from_utf8_chars_and_len
|
||||
* @since 4.3
|
||||
*
|
||||
* Loads new XML-formatted documentation data in the editor.
|
||||
*
|
||||
* The provided pointer can be immediately freed once the function returns.
|
||||
*
|
||||
* @param p_data A pointer to a UTF-8 encoded C string.
|
||||
* @param p_size The number of bytes (not code units).
|
||||
*/
|
||||
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen)(const char *p_data, GDExtensionInt p_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -265,8 +265,8 @@ struct PtrToArg<const Ref<T> &> {
|
||||
|
||||
template <typename T>
|
||||
struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
|
||||
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
|
||||
static inline PropertyInfo get_class_info() {
|
||||
return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static());
|
||||
@@ -275,8 +275,8 @@ struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::value>
|
||||
|
||||
template <typename T>
|
||||
struct GetTypeInfo<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T>::value>::type> {
|
||||
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
|
||||
static inline PropertyInfo get_class_info() {
|
||||
return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static());
|
||||
|
||||
@@ -36,33 +36,56 @@
|
||||
#include <godot_cpp/core/property_info.hpp>
|
||||
|
||||
#include <godot_cpp/templates/list.hpp>
|
||||
#include <godot_cpp/templates/vector.hpp>
|
||||
|
||||
#include <godot_cpp/godot.hpp>
|
||||
|
||||
#if defined(MACOS_ENABLED) && defined(HOT_RELOAD_ENABLED)
|
||||
#include <mutex>
|
||||
#define _GODOT_CPP_AVOID_THREAD_LOCAL
|
||||
#define _GODOT_CPP_THREAD_LOCAL
|
||||
#else
|
||||
#define _GODOT_CPP_THREAD_LOCAL thread_local
|
||||
#endif
|
||||
|
||||
namespace godot {
|
||||
|
||||
class ClassDB;
|
||||
|
||||
typedef void GodotObject;
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_base_of<::godot::Wrapped, T>::value, bool> = true>
|
||||
_ALWAYS_INLINE_ void _pre_initialize();
|
||||
|
||||
// Base for all engine classes, to contain the pointer to the engine instance.
|
||||
class Wrapped {
|
||||
friend class GDExtensionBinding;
|
||||
friend class ClassDB;
|
||||
friend void postinitialize_handler(Wrapped *);
|
||||
|
||||
protected:
|
||||
#ifdef HOT_RELOAD_ENABLED
|
||||
struct RecreateInstance {
|
||||
GDExtensionClassInstancePtr wrapper;
|
||||
GDExtensionObjectPtr owner;
|
||||
RecreateInstance *next;
|
||||
};
|
||||
inline static RecreateInstance *recreate_instance = nullptr;
|
||||
template <typename T, std::enable_if_t<std::is_base_of<::godot::Wrapped, T>::value, bool>>
|
||||
friend _ALWAYS_INLINE_ void _pre_initialize();
|
||||
|
||||
#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL
|
||||
static std::recursive_mutex _constructing_mutex;
|
||||
#endif
|
||||
|
||||
virtual const StringName *_get_extension_class_name() const; // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
|
||||
virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const = 0;
|
||||
_GODOT_CPP_THREAD_LOCAL static const StringName *_constructing_extension_class_name;
|
||||
_GODOT_CPP_THREAD_LOCAL static const GDExtensionInstanceBindingCallbacks *_constructing_class_binding_callbacks;
|
||||
|
||||
#ifdef HOT_RELOAD_ENABLED
|
||||
_GODOT_CPP_THREAD_LOCAL static GDExtensionObjectPtr _constructing_recreate_owner;
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
_ALWAYS_INLINE_ static void _set_construct_info() {
|
||||
_constructing_extension_class_name = T::_get_extension_class_name();
|
||||
_constructing_class_binding_callbacks = &T::_gde_binding_callbacks;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool _is_extension_class() const { return false; }
|
||||
static const StringName *_get_extension_class_name(); // This is needed to retrieve the class name before the godot object has its _extension and _extension_instance members assigned.
|
||||
|
||||
void _notification(int p_what) {}
|
||||
bool _set(const StringName &p_name, const Variant &p_property) { return false; }
|
||||
@@ -71,13 +94,13 @@ protected:
|
||||
bool _property_can_revert(const StringName &p_name) const { return false; }
|
||||
bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; }
|
||||
void _validate_property(PropertyInfo &p_property) const {}
|
||||
String _to_string() const { return "[" + String(get_class_static()) + ":" + itos(get_instance_id()) + "]"; }
|
||||
String _to_string() const { return "<Wrapped#0>"; }
|
||||
|
||||
static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed) {}
|
||||
static GDExtensionBool set_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value) { return false; }
|
||||
static GDExtensionBool get_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret) { return false; }
|
||||
static const GDExtensionPropertyInfo *get_property_list_bind(GDExtensionClassInstancePtr p_instance, uint32_t *r_count) { return nullptr; }
|
||||
static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list) {}
|
||||
static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count) {}
|
||||
static GDExtensionBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name) { return false; }
|
||||
static GDExtensionBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret) { return false; }
|
||||
static GDExtensionBool validate_property_bind(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property) { return false; }
|
||||
@@ -100,14 +123,38 @@ public:
|
||||
return string_name;
|
||||
}
|
||||
|
||||
uint64_t get_instance_id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Must be public but you should not touch this.
|
||||
GodotObject *_owner = nullptr;
|
||||
};
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_base_of<::godot::Wrapped, T>::value, bool>>
|
||||
_ALWAYS_INLINE_ void _pre_initialize() {
|
||||
#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL
|
||||
Wrapped::_constructing_mutex.lock();
|
||||
#endif
|
||||
Wrapped::_set_construct_info<T>();
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void snarray_add_str(Vector<StringName> &arr) {
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void snarray_add_str(Vector<StringName> &arr, const StringName &p_str) {
|
||||
arr.push_back(p_str);
|
||||
}
|
||||
|
||||
template <typename... P>
|
||||
_FORCE_INLINE_ void snarray_add_str(Vector<StringName> &arr, const StringName &p_str, P... p_args) {
|
||||
arr.push_back(p_str);
|
||||
snarray_add_str(arr, p_args...);
|
||||
}
|
||||
|
||||
template <typename... P>
|
||||
_FORCE_INLINE_ Vector<StringName> snarray(P... p_args) {
|
||||
Vector<StringName> arr;
|
||||
snarray_add_str(arr, p_args...);
|
||||
return arr;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
GDExtensionPropertyInfo *create_c_property_list(const ::godot::List<::godot::PropertyInfo> &plist_cpp, uint32_t *r_size);
|
||||
@@ -140,15 +187,14 @@ struct EngineClassRegistration {
|
||||
private: \
|
||||
void operator=(const m_class & /*p_rval*/) {} \
|
||||
friend class ::godot::ClassDB; \
|
||||
friend class ::godot::Wrapped; \
|
||||
\
|
||||
protected: \
|
||||
virtual const ::godot::StringName *_get_extension_class_name() const override { \
|
||||
static ::godot::StringName string_name = get_class_static(); \
|
||||
return &string_name; \
|
||||
} \
|
||||
virtual bool _is_extension_class() const override { return true; } \
|
||||
\
|
||||
virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
|
||||
return &_gde_binding_callbacks; \
|
||||
static const ::godot::StringName *_get_extension_class_name() { \
|
||||
const ::godot::StringName &string_name = get_class_static(); \
|
||||
return &string_name; \
|
||||
} \
|
||||
\
|
||||
static void (*_get_bind_methods())() { \
|
||||
@@ -276,7 +322,7 @@ public:
|
||||
return ::godot::internal::create_c_property_list(plist_cpp, r_count); \
|
||||
} \
|
||||
\
|
||||
static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list) { \
|
||||
static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t /*p_count*/) { \
|
||||
if (p_instance) { \
|
||||
m_class *cls = reinterpret_cast<m_class *>(p_instance); \
|
||||
cls->plist_owned.clear(); \
|
||||
@@ -371,12 +417,9 @@ private:
|
||||
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
|
||||
void operator=(const m_class &p_rval) {} \
|
||||
friend class ::godot::ClassDB; \
|
||||
friend class ::godot::Wrapped; \
|
||||
\
|
||||
protected: \
|
||||
virtual const GDExtensionInstanceBindingCallbacks *_get_bindings_callbacks() const override { \
|
||||
return &_gde_binding_callbacks; \
|
||||
} \
|
||||
\
|
||||
m_class(const char *p_godot_class) : m_inherits(p_godot_class) {} \
|
||||
m_class(GodotObject *p_godot_object) : m_inherits(p_godot_object) {} \
|
||||
\
|
||||
@@ -464,4 +507,14 @@ private:
|
||||
// Don't use this for your classes, use GDCLASS() instead.
|
||||
#define GDEXTENSION_CLASS(m_class, m_inherits) GDEXTENSION_CLASS_ALIAS(m_class, m_class, m_inherits)
|
||||
|
||||
#define GDVIRTUAL_CALL(m_name, ...) _gdvirtual_##m_name##_call<false>(__VA_ARGS__)
|
||||
#define GDVIRTUAL_CALL_PTR(m_obj, m_name, ...) m_obj->_gdvirtual_##m_name##_call<false>(__VA_ARGS__)
|
||||
|
||||
#define GDVIRTUAL_REQUIRED_CALL(m_name, ...) _gdvirtual_##m_name##_call<true>(__VA_ARGS__)
|
||||
#define GDVIRTUAL_REQUIRED_CALL_PTR(m_obj, m_name, ...) m_obj->_gdvirtual_##m_name##_call<true>(__VA_ARGS__)
|
||||
|
||||
#define GDVIRTUAL_BIND(m_name, ...) ::godot::ClassDB::add_virtual_method(get_class_static(), _gdvirtual_##m_name##_get_method_info(), ::godot::snarray(__VA_ARGS__));
|
||||
#define GDVIRTUAL_IS_OVERRIDDEN(m_name) _gdvirtual_##m_name##_overridden()
|
||||
#define GDVIRTUAL_IS_OVERRIDDEN_PTR(m_obj, m_name) m_obj->_gdvirtual_##m_name##_overridden()
|
||||
|
||||
#endif // GODOT_WRAPPED_HPP
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <godot_cpp/core/error_macros.hpp>
|
||||
#include <godot_cpp/core/method_bind.hpp>
|
||||
#include <godot_cpp/core/object.hpp>
|
||||
#include <godot_cpp/core/print_string.hpp>
|
||||
|
||||
#include <godot_cpp/classes/class_db_singleton.hpp>
|
||||
|
||||
@@ -113,7 +114,7 @@ private:
|
||||
static void bind_method_godot(const StringName &p_class_name, MethodBind *p_method);
|
||||
|
||||
template <typename T, bool is_abstract>
|
||||
static void _register_class(bool p_virtual = false, bool p_exposed = true);
|
||||
static void _register_class(bool p_virtual = false, bool p_exposed = true, bool p_runtime = false);
|
||||
|
||||
template <typename T>
|
||||
static GDExtensionObjectPtr _create_instance_func(void *data) {
|
||||
@@ -129,9 +130,11 @@ private:
|
||||
static GDExtensionClassInstancePtr _recreate_instance_func(void *data, GDExtensionObjectPtr obj) {
|
||||
if constexpr (!std::is_abstract_v<T>) {
|
||||
#ifdef HOT_RELOAD_ENABLED
|
||||
#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL
|
||||
std::lock_guard<std::recursive_mutex> lk(Wrapped::_constructing_mutex);
|
||||
#endif
|
||||
Wrapped::_constructing_recreate_owner = obj;
|
||||
T *new_instance = (T *)memalloc(sizeof(T));
|
||||
Wrapped::RecreateInstance recreate_data = { new_instance, obj, Wrapped::recreate_instance };
|
||||
Wrapped::recreate_instance = &recreate_data;
|
||||
memnew_placement(new_instance, T);
|
||||
return new_instance;
|
||||
#else
|
||||
@@ -149,6 +152,8 @@ public:
|
||||
static void register_abstract_class();
|
||||
template <typename T>
|
||||
static void register_internal_class();
|
||||
template <typename T>
|
||||
static void register_runtime_class();
|
||||
|
||||
_FORCE_INLINE_ static void _register_engine_class(const StringName &p_name, const GDExtensionInstanceBindingCallbacks *p_callbacks) {
|
||||
instance_binding_callbacks[p_name] = p_callbacks;
|
||||
@@ -183,7 +188,10 @@ public:
|
||||
static void add_property(const StringName &p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1);
|
||||
static void add_signal(const StringName &p_class, const MethodInfo &p_signal);
|
||||
static void bind_integer_constant(const StringName &p_class_name, const StringName &p_enum_name, const StringName &p_constant_name, GDExtensionInt p_constant_value, bool p_is_bitfield = false);
|
||||
// Binds an implementation of a virtual method defined in Godot.
|
||||
static void bind_virtual_method(const StringName &p_class, const StringName &p_method, GDExtensionClassCallVirtual p_call);
|
||||
// Add a new virtual method that can be implemented by scripts.
|
||||
static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, const Vector<StringName> &p_arg_names = Vector<StringName>());
|
||||
|
||||
static MethodBind *get_method(const StringName &p_class, const StringName &p_method);
|
||||
|
||||
@@ -214,7 +222,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename T, bool is_abstract>
|
||||
void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
|
||||
void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
|
||||
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
|
||||
static_assert(!FunctionsAreSame<T::self_type::_bind_methods, T::parent_type::_bind_methods>::value, "Class must declare 'static void _bind_methods'.");
|
||||
static_assert(!std::is_abstract_v<T> || is_abstract, "Class is abstract, please use GDREGISTER_ABSTRACT_CLASS.");
|
||||
@@ -234,14 +242,15 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
|
||||
class_register_order.push_back(cl.name);
|
||||
|
||||
// Register this class with Godot
|
||||
GDExtensionClassCreationInfo2 class_info = {
|
||||
GDExtensionClassCreationInfo3 class_info = {
|
||||
p_virtual, // GDExtensionBool is_virtual;
|
||||
is_abstract, // GDExtensionBool is_abstract;
|
||||
p_exposed, // GDExtensionBool is_exposed;
|
||||
p_runtime, // GDExtensionBool is_runtime;
|
||||
T::set_bind, // GDExtensionClassSet set_func;
|
||||
T::get_bind, // GDExtensionClassGet get_func;
|
||||
T::has_get_property_list() ? T::get_property_list_bind : nullptr, // GDExtensionClassGetPropertyList get_property_list_func;
|
||||
T::free_property_list_bind, // GDExtensionClassFreePropertyList free_property_list_func;
|
||||
T::free_property_list_bind, // GDExtensionClassFreePropertyList2 free_property_list_func;
|
||||
T::property_can_revert_bind, // GDExtensionClassPropertyCanRevert property_can_revert_func;
|
||||
T::property_get_revert_bind, // GDExtensionClassPropertyGetRevert property_get_revert_func;
|
||||
T::validate_property_bind, // GDExtensionClassValidateProperty validate_property_func;
|
||||
@@ -259,7 +268,7 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed) {
|
||||
(void *)&T::get_class_static(), // void *class_userdata;
|
||||
};
|
||||
|
||||
internal::gdextension_interface_classdb_register_extension_class2(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||
internal::gdextension_interface_classdb_register_extension_class3(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();
|
||||
@@ -283,6 +292,11 @@ void ClassDB::register_internal_class() {
|
||||
ClassDB::_register_class<T, false>(false, false);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ClassDB::register_runtime_class() {
|
||||
ClassDB::_register_class<T, false>(false, true, true);
|
||||
}
|
||||
|
||||
template <typename N, typename M, typename... VarArgs>
|
||||
MethodBind *ClassDB::bind_method(N p_method_name, M p_method, VarArgs... p_args) {
|
||||
Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
|
||||
@@ -342,6 +356,7 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p
|
||||
#define GDREGISTER_VIRTUAL_CLASS(m_class) ::godot::ClassDB::register_class<m_class>(true);
|
||||
#define GDREGISTER_ABSTRACT_CLASS(m_class) ::godot::ClassDB::register_abstract_class<m_class>();
|
||||
#define GDREGISTER_INTERNAL_CLASS(m_class) ::godot::ClassDB::register_internal_class<m_class>();
|
||||
#define GDREGISTER_RUNTIME_CLASS(m_class) ::godot::ClassDB::register_runtime_class<m_class>();
|
||||
|
||||
} // namespace godot
|
||||
|
||||
|
||||
@@ -74,10 +74,6 @@ namespace godot {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _NO_DISCARD_
|
||||
#define _NO_DISCARD_ [[nodiscard]]
|
||||
#endif
|
||||
|
||||
// Windows badly defines a lot of stuff we'll never use. Undefine it.
|
||||
#ifdef _WIN32
|
||||
#undef min // override standard definition
|
||||
|
||||
@@ -56,10 +56,10 @@ O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, co
|
||||
|
||||
template <typename R, typename... Args>
|
||||
R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
|
||||
R ret;
|
||||
typename PtrToArg<R>::EncodeT ret;
|
||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||
internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
|
||||
return ret;
|
||||
return static_cast<R>(ret);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
@@ -70,10 +70,10 @@ void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, c
|
||||
|
||||
template <typename R, typename... Args>
|
||||
R _call_utility_ret(GDExtensionPtrUtilityFunction func, const Args &...args) {
|
||||
R ret;
|
||||
typename PtrToArg<R>::EncodeT ret;
|
||||
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
|
||||
func(&ret, mb_args.data(), mb_args.size());
|
||||
return ret;
|
||||
return static_cast<R>(ret);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
|
||||
@@ -82,6 +82,9 @@ public:
|
||||
static void free_static(void *p_ptr, bool p_pad_align = false);
|
||||
};
|
||||
|
||||
template <typename T, std::enable_if_t<!std::is_base_of<::godot::Wrapped, T>::value, bool> = true>
|
||||
_ALWAYS_INLINE_ void _pre_initialize() {}
|
||||
|
||||
_ALWAYS_INLINE_ void postinitialize_handler(void *) {}
|
||||
|
||||
template <typename T>
|
||||
@@ -94,10 +97,10 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
|
||||
#define memrealloc(m_mem, m_size) ::godot::Memory::realloc_static(m_mem, m_size)
|
||||
#define memfree(m_mem) ::godot::Memory::free_static(m_mem)
|
||||
|
||||
#define memnew(m_class) ::godot::_post_initialize(new ("", "") m_class)
|
||||
#define memnew(m_class) (::godot::_pre_initialize<std::remove_pointer_t<decltype(new ("", "") m_class)>>(), ::godot::_post_initialize(new ("", "") m_class))
|
||||
|
||||
#define memnew_allocator(m_class, m_allocator) ::godot::_post_initialize(new ("", m_allocator::alloc) m_class)
|
||||
#define memnew_placement(m_placement, m_class) ::godot::_post_initialize(new ("", m_placement, sizeof(m_class), "") m_class)
|
||||
#define memnew_allocator(m_class, m_allocator) (::godot::_pre_initialize<std::remove_pointer_t<decltype(new ("", "") m_class)>>(), ::godot::_post_initialize(new ("", m_allocator::alloc) m_class))
|
||||
#define memnew_placement(m_placement, m_class) (::godot::_pre_initialize<std::remove_pointer_t<decltype(new ("", "") m_class)>>(), ::godot::_post_initialize(new ("", m_placement, sizeof(m_class), "") m_class))
|
||||
|
||||
// Generic comparator used in Map, List, etc.
|
||||
template <typename T>
|
||||
|
||||
@@ -48,14 +48,14 @@
|
||||
namespace godot {
|
||||
|
||||
class MethodBind {
|
||||
uint32_t hint_flags = METHOD_FLAGS_DEFAULT;
|
||||
StringName name;
|
||||
StringName instance_class;
|
||||
int argument_count = 0;
|
||||
uint32_t hint_flags = METHOD_FLAGS_DEFAULT;
|
||||
|
||||
bool _static = false;
|
||||
bool _is_const = false;
|
||||
bool _has_return = false;
|
||||
bool _const = false;
|
||||
bool _returns = false;
|
||||
bool _vararg = false;
|
||||
|
||||
std::vector<StringName> argument_names;
|
||||
@@ -63,20 +63,20 @@ class MethodBind {
|
||||
std::vector<Variant> default_arguments;
|
||||
|
||||
protected:
|
||||
void _set_const(bool p_const);
|
||||
void _set_static(bool p_static);
|
||||
void _set_returns(bool p_returns);
|
||||
void _set_vararg(bool p_vararg);
|
||||
virtual GDExtensionVariantType gen_argument_type(int p_arg) const = 0;
|
||||
virtual PropertyInfo gen_argument_type_info(int p_arg) const = 0;
|
||||
void generate_argument_types(int p_count);
|
||||
void set_const(bool p_const);
|
||||
void set_return(bool p_return);
|
||||
void set_static(bool p_static);
|
||||
void set_vararg(bool p_vararg);
|
||||
void set_argument_count(int p_count);
|
||||
void _generate_argument_types(int p_count);
|
||||
|
||||
void set_argument_count(int p_count) { argument_count = p_count; }
|
||||
|
||||
public:
|
||||
StringName get_name() const;
|
||||
void set_name(const StringName &p_name);
|
||||
_FORCE_INLINE_ int get_default_argument_count() const { return (int)default_arguments.size(); }
|
||||
_FORCE_INLINE_ const std::vector<Variant> &get_default_arguments() const { return default_arguments; }
|
||||
_FORCE_INLINE_ int get_default_argument_count() const { return (int)default_arguments.size(); }
|
||||
|
||||
_FORCE_INLINE_ Variant has_default_argument(int p_arg) const {
|
||||
const int num_default_args = (int)(default_arguments.size());
|
||||
const int idx = p_arg - (argument_count - num_default_args);
|
||||
@@ -97,19 +97,6 @@ public:
|
||||
return default_arguments[idx];
|
||||
}
|
||||
}
|
||||
_FORCE_INLINE_ StringName get_instance_class() const { return instance_class; }
|
||||
_FORCE_INLINE_ void set_instance_class(StringName p_class) { instance_class = p_class; }
|
||||
|
||||
_FORCE_INLINE_ int get_argument_count() const { return argument_count; }
|
||||
_FORCE_INLINE_ bool is_const() const { return _is_const; }
|
||||
_FORCE_INLINE_ bool is_static() const { return _static; }
|
||||
_FORCE_INLINE_ bool is_vararg() const { return _vararg; }
|
||||
_FORCE_INLINE_ bool has_return() const { return _has_return; }
|
||||
_FORCE_INLINE_ uint32_t get_hint_flags() const { return hint_flags | (is_const() ? GDEXTENSION_METHOD_FLAG_CONST : 0) | (is_vararg() ? GDEXTENSION_METHOD_FLAG_VARARG : 0) | (is_static() ? GDEXTENSION_METHOD_FLAG_STATIC : 0); }
|
||||
_FORCE_INLINE_ void set_hint_flags(uint32_t p_hint_flags) { hint_flags = p_hint_flags; }
|
||||
void set_argument_names(const std::vector<StringName> &p_names);
|
||||
std::vector<StringName> get_argument_names() const;
|
||||
void set_default_arguments(const std::vector<Variant> &p_default_arguments) { default_arguments = p_default_arguments; }
|
||||
|
||||
_FORCE_INLINE_ GDExtensionVariantType get_argument_type(int p_argument) const {
|
||||
ERR_FAIL_COND_V(p_argument < -1 || p_argument > argument_count, GDEXTENSION_VARIANT_TYPE_NIL);
|
||||
@@ -117,7 +104,6 @@ public:
|
||||
}
|
||||
|
||||
PropertyInfo get_argument_info(int p_argument) const;
|
||||
virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const = 0;
|
||||
|
||||
std::vector<PropertyInfo> get_arguments_info_list() const {
|
||||
std::vector<PropertyInfo> vec;
|
||||
@@ -128,6 +114,31 @@ public:
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
void set_argument_names(const std::vector<StringName> &p_names);
|
||||
std::vector<StringName> get_argument_names() const;
|
||||
|
||||
virtual GDExtensionClassMethodArgumentMetadata get_argument_metadata(int p_argument) const = 0;
|
||||
|
||||
_FORCE_INLINE_ void set_hint_flags(uint32_t p_hint_flags) { hint_flags = p_hint_flags; }
|
||||
_FORCE_INLINE_ uint32_t get_hint_flags() const { return hint_flags | (is_const() ? GDEXTENSION_METHOD_FLAG_CONST : 0) | (is_vararg() ? GDEXTENSION_METHOD_FLAG_VARARG : 0) | (is_static() ? GDEXTENSION_METHOD_FLAG_STATIC : 0); }
|
||||
_FORCE_INLINE_ StringName get_instance_class() const { return instance_class; }
|
||||
_FORCE_INLINE_ void set_instance_class(StringName p_class) { instance_class = p_class; }
|
||||
|
||||
_FORCE_INLINE_ int get_argument_count() const { return argument_count; }
|
||||
|
||||
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const = 0;
|
||||
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return) const = 0;
|
||||
|
||||
StringName get_name() const;
|
||||
void set_name(const StringName &p_name);
|
||||
_FORCE_INLINE_ bool is_const() const { return _const; }
|
||||
_FORCE_INLINE_ bool is_static() const { return _static; }
|
||||
_FORCE_INLINE_ bool is_vararg() const { return _vararg; }
|
||||
_FORCE_INLINE_ bool has_return() const { return _returns; }
|
||||
|
||||
void set_default_arguments(const std::vector<Variant> &p_default_arguments) { default_arguments = p_default_arguments; }
|
||||
|
||||
std::vector<GDExtensionClassMethodArgumentMetadata> get_arguments_metadata_list() const {
|
||||
std::vector<GDExtensionClassMethodArgumentMetadata> vec;
|
||||
// First element is return value
|
||||
@@ -138,9 +149,6 @@ public:
|
||||
return vec;
|
||||
}
|
||||
|
||||
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionCallError &r_error) const = 0;
|
||||
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return) const = 0;
|
||||
|
||||
static void bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
static void bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return);
|
||||
|
||||
@@ -182,8 +190,8 @@ public:
|
||||
const MethodInfo &p_method_info,
|
||||
bool p_return_nil_is_variant) :
|
||||
method(p_method) {
|
||||
set_vararg(true);
|
||||
set_const(true);
|
||||
_set_vararg(true);
|
||||
_set_const(true);
|
||||
set_argument_count(p_method_info.arguments.size());
|
||||
if (p_method_info.arguments.size()) {
|
||||
arguments = p_method_info.arguments;
|
||||
@@ -196,8 +204,8 @@ public:
|
||||
set_argument_names(names);
|
||||
}
|
||||
|
||||
generate_argument_types((int)p_method_info.arguments.size());
|
||||
set_return(should_returns);
|
||||
_generate_argument_types((int)p_method_info.arguments.size());
|
||||
_set_returns(should_returns);
|
||||
}
|
||||
|
||||
~MethodBindVarArgBase() {}
|
||||
@@ -334,7 +342,7 @@ public:
|
||||
|
||||
MethodBindT(void (MB_T::*p_method)(P...)) {
|
||||
method = p_method;
|
||||
generate_argument_types(sizeof...(P));
|
||||
_generate_argument_types(sizeof...(P));
|
||||
set_argument_count(sizeof...(P));
|
||||
}
|
||||
};
|
||||
@@ -410,9 +418,9 @@ public:
|
||||
|
||||
MethodBindTC(void (MB_T::*p_method)(P...) const) {
|
||||
method = p_method;
|
||||
generate_argument_types(sizeof...(P));
|
||||
_generate_argument_types(sizeof...(P));
|
||||
set_argument_count(sizeof...(P));
|
||||
set_const(true);
|
||||
_set_const(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -493,9 +501,9 @@ public:
|
||||
|
||||
MethodBindTR(R (MB_T::*p_method)(P...)) {
|
||||
method = p_method;
|
||||
generate_argument_types(sizeof...(P));
|
||||
_generate_argument_types(sizeof...(P));
|
||||
set_argument_count(sizeof...(P));
|
||||
set_return(true);
|
||||
_set_returns(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -576,10 +584,10 @@ public:
|
||||
|
||||
MethodBindTRC(R (MB_T::*p_method)(P...) const) {
|
||||
method = p_method;
|
||||
generate_argument_types(sizeof...(P));
|
||||
_generate_argument_types(sizeof...(P));
|
||||
set_argument_count(sizeof...(P));
|
||||
set_return(true);
|
||||
set_const(true);
|
||||
_set_returns(true);
|
||||
_set_const(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -648,9 +656,9 @@ public:
|
||||
|
||||
MethodBindTS(void (*p_function)(P...)) {
|
||||
function = p_function;
|
||||
generate_argument_types(sizeof...(P));
|
||||
_generate_argument_types(sizeof...(P));
|
||||
set_argument_count(sizeof...(P));
|
||||
set_static(true);
|
||||
_set_static(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -717,10 +725,10 @@ public:
|
||||
|
||||
MethodBindTRS(R (*p_function)(P...)) {
|
||||
function = p_function;
|
||||
generate_argument_types(sizeof...(P));
|
||||
_generate_argument_types(sizeof...(P));
|
||||
set_argument_count(sizeof...(P));
|
||||
set_static(true);
|
||||
set_return(true);
|
||||
_set_static(true);
|
||||
_set_returns(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -122,6 +122,9 @@ MAKE_PTRARGCONV(uint16_t, int64_t);
|
||||
MAKE_PTRARGCONV(int16_t, int64_t);
|
||||
MAKE_PTRARGCONV(uint32_t, int64_t);
|
||||
MAKE_PTRARGCONV(int32_t, int64_t);
|
||||
MAKE_PTRARGCONV(char16_t, int64_t);
|
||||
MAKE_PTRARGCONV(char32_t, int64_t);
|
||||
MAKE_PTRARGCONV(wchar_t, int64_t);
|
||||
MAKE_PTRARG(int64_t);
|
||||
MAKE_PTRARG(uint64_t);
|
||||
// Float types
|
||||
@@ -161,6 +164,7 @@ MAKE_PTRARG(PackedFloat64Array);
|
||||
MAKE_PTRARG(PackedStringArray);
|
||||
MAKE_PTRARG(PackedVector2Array);
|
||||
MAKE_PTRARG(PackedVector3Array);
|
||||
MAKE_PTRARG(PackedVector4Array);
|
||||
MAKE_PTRARG(PackedColorArray);
|
||||
MAKE_PTRARG_BY_REFERENCE(Variant);
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ struct MethodInfo {
|
||||
int id = 0;
|
||||
std::vector<PropertyInfo> arguments;
|
||||
std::vector<Variant> default_arguments;
|
||||
GDExtensionClassMethodArgumentMetadata return_val_metadata;
|
||||
std::vector<GDExtensionClassMethodArgumentMetadata> arguments_metadata;
|
||||
|
||||
inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; }
|
||||
inline bool operator<(const MethodInfo &p_method) const { return id == p_method.id ? (name < p_method.name) : (id < p_method.id); }
|
||||
|
||||
73
include/godot_cpp/core/print_string.hpp
Normal file
73
include/godot_cpp/core/print_string.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/**************************************************************************/
|
||||
/* print_string.hpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef GODOT_PRINT_STRING_HPP
|
||||
#define GODOT_PRINT_STRING_HPP
|
||||
|
||||
#include <godot_cpp/variant/utility_functions.hpp>
|
||||
|
||||
namespace godot {
|
||||
inline void print_error(const Variant &p_variant) {
|
||||
UtilityFunctions::printerr(p_variant);
|
||||
}
|
||||
|
||||
inline void print_line(const Variant &p_variant) {
|
||||
UtilityFunctions::print(p_variant);
|
||||
}
|
||||
|
||||
inline void print_line_rich(const Variant &p_variant) {
|
||||
UtilityFunctions::print_rich(p_variant);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void print_error(const Variant &p_variant, Args... p_args) {
|
||||
UtilityFunctions::printerr(p_variant, p_args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void print_line(const Variant &p_variant, Args... p_args) {
|
||||
UtilityFunctions::print(p_variant, p_args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void print_line_rich(const Variant &p_variant, Args... p_args) {
|
||||
UtilityFunctions::print_rich(p_variant, p_args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void print_verbose(const Variant &p_variant, Args... p_args) {
|
||||
UtilityFunctions::print_verbose(p_variant, p_args...);
|
||||
}
|
||||
|
||||
bool is_print_verbose_enabled();
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#endif // GODOT_PRINT_STRING_HPP
|
||||
@@ -114,6 +114,17 @@ struct PropertyInfo {
|
||||
p_info->usage = usage;
|
||||
*(reinterpret_cast<StringName *>(p_info->class_name)) = class_name;
|
||||
}
|
||||
|
||||
GDExtensionPropertyInfo _to_gdextension() const {
|
||||
return {
|
||||
(GDExtensionVariantType)type,
|
||||
name._native_ptr(),
|
||||
class_name._native_ptr(),
|
||||
hint,
|
||||
hint_string._native_ptr(),
|
||||
usage,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -185,6 +185,7 @@ MAKE_TYPE_INFO(PackedFloat64Array, GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY
|
||||
MAKE_TYPE_INFO(PackedStringArray, GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY)
|
||||
MAKE_TYPE_INFO(PackedVector2Array, GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY)
|
||||
MAKE_TYPE_INFO(PackedVector3Array, GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY)
|
||||
MAKE_TYPE_INFO(PackedVector4Array, GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY)
|
||||
MAKE_TYPE_INFO(PackedColorArray, GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY)
|
||||
|
||||
// For variant.
|
||||
@@ -208,8 +209,8 @@ struct GetTypeInfo<const Variant &> {
|
||||
|
||||
template <typename T>
|
||||
struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
|
||||
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
static inline PropertyInfo get_class_info() {
|
||||
return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static());
|
||||
}
|
||||
@@ -217,8 +218,8 @@ struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type>
|
||||
|
||||
template <typename T>
|
||||
struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
|
||||
static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
static constexpr GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT;
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||
static inline PropertyInfo get_class_info() {
|
||||
return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static());
|
||||
}
|
||||
@@ -236,8 +237,8 @@ inline String enum_qualified_name_to_class_info_name(const String &p_qualified_n
|
||||
#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \
|
||||
template <> \
|
||||
struct GetTypeInfo<m_impl> { \
|
||||
static const Variant::Type VARIANT_TYPE = Variant::INT; \
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \
|
||||
static constexpr Variant::Type VARIANT_TYPE = Variant::INT; \
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \
|
||||
static inline PropertyInfo get_class_info() { \
|
||||
return make_property_info(Variant::Type::INT, "", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, \
|
||||
enum_qualified_name_to_class_info_name(#m_enum)); \
|
||||
@@ -274,8 +275,8 @@ public:
|
||||
#define TEMPL_MAKE_BITFIELD_TYPE_INFO(m_enum, m_impl) \
|
||||
template <> \
|
||||
struct GetTypeInfo<m_impl> { \
|
||||
static const Variant::Type VARIANT_TYPE = Variant::INT; \
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \
|
||||
static constexpr Variant::Type VARIANT_TYPE = Variant::INT; \
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \
|
||||
static inline PropertyInfo get_class_info() { \
|
||||
return make_property_info(Variant::Type::INT, "", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \
|
||||
enum_qualified_name_to_class_info_name(#m_enum)); \
|
||||
@@ -283,8 +284,8 @@ public:
|
||||
}; \
|
||||
template <> \
|
||||
struct GetTypeInfo<BitField<m_impl>> { \
|
||||
static const Variant::Type VARIANT_TYPE = Variant::INT; \
|
||||
static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \
|
||||
static constexpr Variant::Type VARIANT_TYPE = Variant::INT; \
|
||||
static constexpr GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; \
|
||||
static inline PropertyInfo get_class_info() { \
|
||||
return make_property_info(Variant::Type::INT, "", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \
|
||||
enum_qualified_name_to_class_info_name(#m_enum)); \
|
||||
@@ -380,11 +381,14 @@ MAKE_TYPED_ARRAY_INFO(Rect2i, Variant::RECT2I)
|
||||
MAKE_TYPED_ARRAY_INFO(Vector3, Variant::VECTOR3)
|
||||
MAKE_TYPED_ARRAY_INFO(Vector3i, Variant::VECTOR3I)
|
||||
MAKE_TYPED_ARRAY_INFO(Transform2D, Variant::TRANSFORM2D)
|
||||
MAKE_TYPED_ARRAY_INFO(Vector4, Variant::VECTOR4)
|
||||
MAKE_TYPED_ARRAY_INFO(Vector4i, Variant::VECTOR4I)
|
||||
MAKE_TYPED_ARRAY_INFO(Plane, Variant::PLANE)
|
||||
MAKE_TYPED_ARRAY_INFO(Quaternion, Variant::QUATERNION)
|
||||
MAKE_TYPED_ARRAY_INFO(AABB, Variant::AABB)
|
||||
MAKE_TYPED_ARRAY_INFO(Basis, Variant::BASIS)
|
||||
MAKE_TYPED_ARRAY_INFO(Transform3D, Variant::TRANSFORM3D)
|
||||
MAKE_TYPED_ARRAY_INFO(Projection, Variant::PROJECTION)
|
||||
MAKE_TYPED_ARRAY_INFO(Color, Variant::COLOR)
|
||||
MAKE_TYPED_ARRAY_INFO(StringName, Variant::STRING_NAME)
|
||||
MAKE_TYPED_ARRAY_INFO(NodePath, Variant::NODE_PATH)
|
||||
@@ -401,7 +405,13 @@ MAKE_TYPED_ARRAY_INFO(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY)
|
||||
MAKE_TYPED_ARRAY_INFO(PackedStringArray, Variant::PACKED_STRING_ARRAY)
|
||||
MAKE_TYPED_ARRAY_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY)
|
||||
MAKE_TYPED_ARRAY_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY)
|
||||
MAKE_TYPED_ARRAY_INFO(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY)
|
||||
MAKE_TYPED_ARRAY_INFO(PackedColorArray, Variant::PACKED_COLOR_ARRAY)
|
||||
/*
|
||||
MAKE_TYPED_ARRAY_INFO(IPAddress, Variant::STRING)
|
||||
*/
|
||||
|
||||
#undef MAKE_TYPED_ARRAY_INFO
|
||||
|
||||
#define CLASS_INFO(m_type) (GetTypeInfo<m_type *>::get_class_info())
|
||||
|
||||
|
||||
@@ -108,7 +108,9 @@ extern "C" GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_str
|
||||
extern "C" GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars;
|
||||
extern "C" GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len;
|
||||
extern "C" GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len;
|
||||
extern "C" GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2;
|
||||
extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len;
|
||||
extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2;
|
||||
extern "C" GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len;
|
||||
extern "C" GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len;
|
||||
extern "C" GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars;
|
||||
@@ -148,6 +150,8 @@ extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_inter
|
||||
extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const;
|
||||
extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index;
|
||||
extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const;
|
||||
extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index;
|
||||
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;
|
||||
@@ -166,18 +170,21 @@ extern "C" GDExtensionInterfaceObjectGetClassName gdextension_interface_object_g
|
||||
extern "C" GDExtensionInterfaceObjectCastTo gdextension_interface_object_cast_to;
|
||||
extern "C" GDExtensionInterfaceObjectGetInstanceFromId gdextension_interface_object_get_instance_from_id;
|
||||
extern "C" GDExtensionInterfaceObjectGetInstanceId gdextension_interface_object_get_instance_id;
|
||||
extern "C" GDExtensionInterfaceCallableCustomCreate gdextension_interface_callable_custom_create;
|
||||
extern "C" GDExtensionInterfaceObjectHasScriptMethod gdextension_interface_object_has_script_method;
|
||||
extern "C" GDExtensionInterfaceObjectCallScriptMethod gdextension_interface_object_call_script_method;
|
||||
extern "C" GDExtensionInterfaceCallableCustomCreate2 gdextension_interface_callable_custom_create2;
|
||||
extern "C" GDExtensionInterfaceCallableCustomGetUserData gdextension_interface_callable_custom_get_userdata;
|
||||
extern "C" GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object;
|
||||
extern "C" GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object;
|
||||
extern "C" GDExtensionInterfaceScriptInstanceCreate2 gdextension_interface_script_instance_create2;
|
||||
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" GDExtensionInterfaceClassdbConstructObject gdextension_interface_classdb_construct_object;
|
||||
extern "C" GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind;
|
||||
extern "C" GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass2 gdextension_interface_classdb_register_extension_class2;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass3 gdextension_interface_classdb_register_extension_class3;
|
||||
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;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property;
|
||||
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed gdextension_interface_classdb_register_extension_class_property_indexed;
|
||||
@@ -188,6 +195,15 @@ 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" 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;
|
||||
|
||||
class DocDataRegistration {
|
||||
public:
|
||||
DocDataRegistration(const char *p_hash, int p_uncompressed_size, int p_compressed_size, const unsigned char *p_data);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
@@ -139,31 +139,6 @@ public:
|
||||
|
||||
typedef T ValueType;
|
||||
|
||||
struct Iterator {
|
||||
_FORCE_INLINE_ T &operator*() const {
|
||||
return E->get();
|
||||
}
|
||||
_FORCE_INLINE_ T *operator->() const { return &E->get(); }
|
||||
_FORCE_INLINE_ Iterator &operator++() {
|
||||
E = E->next();
|
||||
return *this;
|
||||
}
|
||||
_FORCE_INLINE_ Iterator &operator--() {
|
||||
E = E->prev();
|
||||
return *this;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; }
|
||||
_FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; }
|
||||
|
||||
Iterator(Element *p_E) { E = p_E; }
|
||||
Iterator() {}
|
||||
Iterator(const Iterator &p_it) { E = p_it.E; }
|
||||
|
||||
private:
|
||||
Element *E = nullptr;
|
||||
};
|
||||
|
||||
struct ConstIterator {
|
||||
_FORCE_INLINE_ const T &operator*() const {
|
||||
return E->get();
|
||||
@@ -189,6 +164,35 @@ public:
|
||||
const Element *E = nullptr;
|
||||
};
|
||||
|
||||
struct Iterator {
|
||||
_FORCE_INLINE_ T &operator*() const {
|
||||
return E->get();
|
||||
}
|
||||
_FORCE_INLINE_ T *operator->() const { return &E->get(); }
|
||||
_FORCE_INLINE_ Iterator &operator++() {
|
||||
E = E->next();
|
||||
return *this;
|
||||
}
|
||||
_FORCE_INLINE_ Iterator &operator--() {
|
||||
E = E->prev();
|
||||
return *this;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; }
|
||||
_FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; }
|
||||
|
||||
Iterator(Element *p_E) { E = p_E; }
|
||||
Iterator() {}
|
||||
Iterator(const Iterator &p_it) { E = p_it.E; }
|
||||
|
||||
operator ConstIterator() const {
|
||||
return ConstIterator(E);
|
||||
}
|
||||
|
||||
private:
|
||||
Element *E = nullptr;
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ Iterator begin() {
|
||||
return Iterator(front());
|
||||
}
|
||||
@@ -519,7 +523,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
T &operator[](int p_index) {
|
||||
// Index operator, kept for compatibility.
|
||||
_FORCE_INLINE_ T &operator[](int p_index) {
|
||||
return get(p_index);
|
||||
}
|
||||
|
||||
// Random access to elements, use with care,
|
||||
// do not use for iteration.
|
||||
T &get(int p_index) {
|
||||
CRASH_BAD_INDEX(p_index, size());
|
||||
|
||||
Element *I = front();
|
||||
@@ -532,7 +543,14 @@ public:
|
||||
return I->get();
|
||||
}
|
||||
|
||||
const T &operator[](int p_index) const {
|
||||
// Index operator, kept for compatibility.
|
||||
_FORCE_INLINE_ const T &operator[](int p_index) const {
|
||||
return get(p_index);
|
||||
}
|
||||
|
||||
// Random access to elements, use with care,
|
||||
// do not use for iteration.
|
||||
const T &get(int p_index) const {
|
||||
CRASH_BAD_INDEX(p_index, size());
|
||||
|
||||
const Element *I = front();
|
||||
|
||||
@@ -257,6 +257,10 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool has(const T &p_val) const {
|
||||
return find(p_val) != -1;
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
void sort_custom() {
|
||||
U len = count;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace godot {
|
||||
|
||||
class Variant;
|
||||
|
||||
struct _NO_DISCARD_ AABB {
|
||||
struct [[nodiscard]] AABB {
|
||||
Vector3 position;
|
||||
Vector3 size;
|
||||
|
||||
@@ -103,7 +103,7 @@ struct _NO_DISCARD_ AABB {
|
||||
_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */
|
||||
|
||||
_FORCE_INLINE_ AABB abs() const {
|
||||
return AABB(Vector3(position.x + MIN(size.x, (real_t)0), position.y + MIN(size.y, (real_t)0), position.z + MIN(size.z, (real_t)0)), size.abs());
|
||||
return AABB(position + size.minf(0), size.abs());
|
||||
}
|
||||
|
||||
Variant intersects_segment_bind(const Vector3 &p_from, const Vector3 &p_to) const;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
struct _NO_DISCARD_ Basis {
|
||||
struct [[nodiscard]] Basis {
|
||||
Vector3 rows[3] = {
|
||||
Vector3(1, 0, 0),
|
||||
Vector3(0, 1, 0),
|
||||
|
||||
@@ -41,6 +41,7 @@ class Object;
|
||||
class CallableCustomBase {
|
||||
public:
|
||||
virtual ObjectID get_object() const = 0;
|
||||
virtual int get_argument_count(bool &r_is_valid) const;
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const = 0;
|
||||
virtual ~CallableCustomBase() {}
|
||||
};
|
||||
|
||||
@@ -73,6 +73,11 @@ public:
|
||||
return ObjectID(data.instance->get_instance_id());
|
||||
}
|
||||
|
||||
virtual int get_argument_count(bool &r_is_valid) const override {
|
||||
r_is_valid = true;
|
||||
return sizeof...(P);
|
||||
}
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const override {
|
||||
call_with_variant_args(data.instance, data.method, p_arguments, p_argcount, r_call_error);
|
||||
}
|
||||
@@ -110,6 +115,11 @@ public:
|
||||
return ObjectID(data.instance->get_instance_id());
|
||||
}
|
||||
|
||||
virtual int get_argument_count(bool &r_is_valid) const override {
|
||||
r_is_valid = true;
|
||||
return sizeof...(P);
|
||||
}
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const override {
|
||||
call_with_variant_args_ret(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
|
||||
}
|
||||
@@ -147,6 +157,11 @@ public:
|
||||
return ObjectID(data.instance->get_instance_id());
|
||||
}
|
||||
|
||||
virtual int get_argument_count(bool &r_is_valid) const override {
|
||||
r_is_valid = true;
|
||||
return sizeof...(P);
|
||||
}
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const override {
|
||||
call_with_variant_args_retc(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
|
||||
}
|
||||
@@ -182,6 +197,11 @@ public:
|
||||
return ObjectID();
|
||||
}
|
||||
|
||||
virtual int get_argument_count(bool &r_is_valid) const override {
|
||||
r_is_valid = true;
|
||||
return sizeof...(P);
|
||||
}
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const override {
|
||||
call_with_variant_args_static_ret(data.method, p_arguments, p_argcount, r_return_value, r_call_error);
|
||||
r_return_value = Variant();
|
||||
@@ -218,6 +238,11 @@ public:
|
||||
return ObjectID();
|
||||
}
|
||||
|
||||
virtual int get_argument_count(bool &r_is_valid) const override {
|
||||
r_is_valid = true;
|
||||
return sizeof...(P);
|
||||
}
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const override {
|
||||
call_with_variant_args_static_ret(data.method, p_arguments, p_argcount, r_return_value, r_call_error);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace godot {
|
||||
|
||||
class String;
|
||||
|
||||
struct _NO_DISCARD_ Color {
|
||||
struct [[nodiscard]] Color {
|
||||
union {
|
||||
struct {
|
||||
float r;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace godot {
|
||||
|
||||
class Variant;
|
||||
|
||||
struct _NO_DISCARD_ Plane {
|
||||
struct [[nodiscard]] Plane {
|
||||
Vector3 normal;
|
||||
real_t d = 0;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ struct Rect2;
|
||||
struct Transform3D;
|
||||
struct Vector2;
|
||||
|
||||
struct _NO_DISCARD_ Projection {
|
||||
struct [[nodiscard]] Projection {
|
||||
enum Planes {
|
||||
PLANE_NEAR,
|
||||
PLANE_FAR,
|
||||
@@ -153,6 +153,7 @@ struct _NO_DISCARD_ Projection {
|
||||
|
||||
Projection();
|
||||
Projection(const Vector4 &p_x, const Vector4 &p_y, const Vector4 &p_z, const Vector4 &p_w);
|
||||
Projection(real_t p_xx, real_t p_xy, real_t p_xz, real_t p_xw, real_t p_yx, real_t p_yy, real_t p_yz, real_t p_yw, real_t p_zx, real_t p_zy, real_t p_zz, real_t p_zw, real_t p_wx, real_t p_wy, real_t p_wz, real_t p_ww);
|
||||
Projection(const Transform3D &p_transform);
|
||||
~Projection();
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
struct _NO_DISCARD_ Quaternion {
|
||||
struct [[nodiscard]] Quaternion {
|
||||
union {
|
||||
struct {
|
||||
real_t x;
|
||||
|
||||
@@ -40,7 +40,7 @@ class String;
|
||||
struct Rect2i;
|
||||
struct Transform2D;
|
||||
|
||||
struct _NO_DISCARD_ Rect2 {
|
||||
struct [[nodiscard]] Rect2 {
|
||||
Point2 position;
|
||||
Size2 size;
|
||||
|
||||
@@ -154,14 +154,12 @@ struct _NO_DISCARD_ Rect2 {
|
||||
return Rect2();
|
||||
}
|
||||
|
||||
new_rect.position.x = Math::max(p_rect.position.x, position.x);
|
||||
new_rect.position.y = Math::max(p_rect.position.y, position.y);
|
||||
new_rect.position = p_rect.position.max(position);
|
||||
|
||||
Point2 p_rect_end = p_rect.position + p_rect.size;
|
||||
Point2 end = position + size;
|
||||
|
||||
new_rect.size.x = Math::min(p_rect_end.x, end.x) - new_rect.position.x;
|
||||
new_rect.size.y = Math::min(p_rect_end.y, end.y) - new_rect.position.y;
|
||||
new_rect.size = p_rect_end.min(end) - new_rect.position;
|
||||
|
||||
return new_rect;
|
||||
}
|
||||
@@ -174,11 +172,9 @@ struct _NO_DISCARD_ Rect2 {
|
||||
#endif
|
||||
Rect2 new_rect;
|
||||
|
||||
new_rect.position.x = Math::min(p_rect.position.x, position.x);
|
||||
new_rect.position.y = Math::min(p_rect.position.y, position.y);
|
||||
new_rect.position = p_rect.position.min(position);
|
||||
|
||||
new_rect.size.x = Math::max(p_rect.position.x + p_rect.size.x, position.x + size.x);
|
||||
new_rect.size.y = Math::max(p_rect.position.y + p_rect.size.y, position.y + size.y);
|
||||
new_rect.size = (p_rect.position + p_rect.size).max(position + size);
|
||||
|
||||
new_rect.size = new_rect.size - new_rect.position; // Make relative again.
|
||||
|
||||
@@ -284,7 +280,7 @@ struct _NO_DISCARD_ Rect2 {
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Rect2 abs() const {
|
||||
return Rect2(Point2(position.x + Math::min(size.x, (real_t)0), position.y + Math::min(size.y, (real_t)0)), size.abs());
|
||||
return Rect2(position + size.minf(0), size.abs());
|
||||
}
|
||||
|
||||
Vector2 get_support(const Vector2 &p_normal) const {
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace godot {
|
||||
class String;
|
||||
struct Rect2;
|
||||
|
||||
struct _NO_DISCARD_ Rect2i {
|
||||
struct [[nodiscard]] Rect2i {
|
||||
Point2i position;
|
||||
Size2i size;
|
||||
|
||||
@@ -97,14 +97,12 @@ struct _NO_DISCARD_ Rect2i {
|
||||
return Rect2i();
|
||||
}
|
||||
|
||||
new_rect.position.x = Math::max(p_rect.position.x, position.x);
|
||||
new_rect.position.y = Math::max(p_rect.position.y, position.y);
|
||||
new_rect.position = p_rect.position.max(position);
|
||||
|
||||
Point2i p_rect_end = p_rect.position + p_rect.size;
|
||||
Point2i end = position + size;
|
||||
|
||||
new_rect.size.x = Math::min(p_rect_end.x, end.x) - new_rect.position.x;
|
||||
new_rect.size.y = Math::min(p_rect_end.y, end.y) - new_rect.position.y;
|
||||
new_rect.size = p_rect_end.min(end) - new_rect.position;
|
||||
|
||||
return new_rect;
|
||||
}
|
||||
@@ -117,11 +115,9 @@ struct _NO_DISCARD_ Rect2i {
|
||||
#endif
|
||||
Rect2i new_rect;
|
||||
|
||||
new_rect.position.x = Math::min(p_rect.position.x, position.x);
|
||||
new_rect.position.y = Math::min(p_rect.position.y, position.y);
|
||||
new_rect.position = p_rect.position.min(position);
|
||||
|
||||
new_rect.size.x = Math::max(p_rect.position.x + p_rect.size.x, position.x + size.x);
|
||||
new_rect.size.y = Math::max(p_rect.position.y + p_rect.size.y, position.y + size.y);
|
||||
new_rect.size = (p_rect.position + p_rect.size).max(position + size);
|
||||
|
||||
new_rect.size = new_rect.size - new_rect.position; // Make relative again.
|
||||
|
||||
@@ -219,7 +215,7 @@ struct _NO_DISCARD_ Rect2i {
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Rect2i abs() const {
|
||||
return Rect2i(Point2i(position.x + Math::min(size.x, 0), position.y + Math::min(size.y, 0)), size.abs());
|
||||
return Rect2i(position + size.mini(0), size.abs());
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_end(const Vector2i &p_end) {
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace godot {
|
||||
|
||||
class String;
|
||||
|
||||
struct _NO_DISCARD_ Transform2D {
|
||||
struct [[nodiscard]] Transform2D {
|
||||
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of columns array, the basis matrix looks like "on paper":
|
||||
// M = (columns[0][0] columns[1][0])
|
||||
// (columns[0][1] columns[1][1])
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
struct _NO_DISCARD_ Transform3D {
|
||||
struct [[nodiscard]] Transform3D {
|
||||
Basis basis;
|
||||
Vector3 origin;
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ public:
|
||||
} \
|
||||
};
|
||||
|
||||
// All Variant::OBJECT types are intentionally omitted from this list because they are handled by
|
||||
// the unspecialized TypedArray definition.
|
||||
MAKE_TYPED_ARRAY(bool, Variant::BOOL)
|
||||
MAKE_TYPED_ARRAY(uint8_t, Variant::INT)
|
||||
MAKE_TYPED_ARRAY(int8_t, Variant::INT)
|
||||
@@ -104,11 +106,14 @@ MAKE_TYPED_ARRAY(Rect2i, Variant::RECT2I)
|
||||
MAKE_TYPED_ARRAY(Vector3, Variant::VECTOR3)
|
||||
MAKE_TYPED_ARRAY(Vector3i, Variant::VECTOR3I)
|
||||
MAKE_TYPED_ARRAY(Transform2D, Variant::TRANSFORM2D)
|
||||
MAKE_TYPED_ARRAY(Vector4, Variant::VECTOR4)
|
||||
MAKE_TYPED_ARRAY(Vector4i, Variant::VECTOR4I)
|
||||
MAKE_TYPED_ARRAY(Plane, Variant::PLANE)
|
||||
MAKE_TYPED_ARRAY(Quaternion, Variant::QUATERNION)
|
||||
MAKE_TYPED_ARRAY(AABB, Variant::AABB)
|
||||
MAKE_TYPED_ARRAY(Basis, Variant::BASIS)
|
||||
MAKE_TYPED_ARRAY(Transform3D, Variant::TRANSFORM3D)
|
||||
MAKE_TYPED_ARRAY(Projection, Variant::PROJECTION)
|
||||
MAKE_TYPED_ARRAY(Color, Variant::COLOR)
|
||||
MAKE_TYPED_ARRAY(StringName, Variant::STRING_NAME)
|
||||
MAKE_TYPED_ARRAY(NodePath, Variant::NODE_PATH)
|
||||
@@ -125,7 +130,12 @@ MAKE_TYPED_ARRAY(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY)
|
||||
MAKE_TYPED_ARRAY(PackedStringArray, Variant::PACKED_STRING_ARRAY)
|
||||
MAKE_TYPED_ARRAY(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY)
|
||||
MAKE_TYPED_ARRAY(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY)
|
||||
MAKE_TYPED_ARRAY(PackedVector4Array, Variant::PACKED_VECTOR4_ARRAY)
|
||||
MAKE_TYPED_ARRAY(PackedColorArray, Variant::PACKED_COLOR_ARRAY)
|
||||
// If the IPAddress struct is added to godot-cpp, the following could also be added:
|
||||
//MAKE_TYPED_ARRAY(IPAddress, Variant::STRING)
|
||||
|
||||
#undef MAKE_TYPED_ARRAY
|
||||
|
||||
} // namespace godot
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
PACKED_VECTOR2_ARRAY,
|
||||
PACKED_VECTOR3_ARRAY,
|
||||
PACKED_COLOR_ARRAY,
|
||||
PACKED_VECTOR4_ARRAY,
|
||||
|
||||
VARIANT_MAX
|
||||
};
|
||||
@@ -212,6 +213,7 @@ public:
|
||||
Variant(const PackedVector2Array &v);
|
||||
Variant(const PackedVector3Array &v);
|
||||
Variant(const PackedColorArray &v);
|
||||
Variant(const PackedVector4Array &v);
|
||||
~Variant();
|
||||
|
||||
operator bool() const;
|
||||
@@ -260,6 +262,7 @@ public:
|
||||
operator PackedVector2Array() const;
|
||||
operator PackedVector3Array() const;
|
||||
operator PackedColorArray() const;
|
||||
operator PackedVector4Array() const;
|
||||
|
||||
Variant &operator=(const Variant &other);
|
||||
Variant &operator=(Variant &&other);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace godot {
|
||||
class String;
|
||||
struct Vector2i;
|
||||
|
||||
struct _NO_DISCARD_ Vector2 {
|
||||
struct [[nodiscard]] Vector2 {
|
||||
static const int AXIS_COUNT = 2;
|
||||
|
||||
enum Axis {
|
||||
@@ -91,10 +91,18 @@ struct _NO_DISCARD_ Vector2 {
|
||||
return Vector2(MIN(x, p_vector2.x), MIN(y, p_vector2.y));
|
||||
}
|
||||
|
||||
Vector2 minf(real_t p_scalar) const {
|
||||
return Vector2(MIN(x, p_scalar), MIN(y, p_scalar));
|
||||
}
|
||||
|
||||
Vector2 max(const Vector2 &p_vector2) const {
|
||||
return Vector2(MAX(x, p_vector2.x), MAX(y, p_vector2.y));
|
||||
}
|
||||
|
||||
Vector2 maxf(real_t p_scalar) const {
|
||||
return Vector2(MAX(x, p_scalar), MAX(y, p_scalar));
|
||||
}
|
||||
|
||||
real_t distance_to(const Vector2 &p_vector2) const;
|
||||
real_t distance_squared_to(const Vector2 &p_vector2) const;
|
||||
real_t angle_to(const Vector2 &p_vector2) const;
|
||||
@@ -169,7 +177,9 @@ struct _NO_DISCARD_ Vector2 {
|
||||
Vector2 ceil() const;
|
||||
Vector2 round() const;
|
||||
Vector2 snapped(const Vector2 &p_by) const;
|
||||
Vector2 snappedf(real_t p_by) const;
|
||||
Vector2 clamp(const Vector2 &p_min, const Vector2 &p_max) const;
|
||||
Vector2 clampf(real_t p_min, real_t p_max) const;
|
||||
real_t aspect() const { return width / height; }
|
||||
|
||||
operator String() const;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace godot {
|
||||
class String;
|
||||
struct Vector2;
|
||||
|
||||
struct _NO_DISCARD_ Vector2i {
|
||||
struct [[nodiscard]] Vector2i {
|
||||
static const int AXIS_COUNT = 2;
|
||||
|
||||
enum Axis {
|
||||
@@ -83,10 +83,18 @@ struct _NO_DISCARD_ Vector2i {
|
||||
return Vector2i(MIN(x, p_vector2i.x), MIN(y, p_vector2i.y));
|
||||
}
|
||||
|
||||
Vector2i mini(int32_t p_scalar) const {
|
||||
return Vector2i(MIN(x, p_scalar), MIN(y, p_scalar));
|
||||
}
|
||||
|
||||
Vector2i max(const Vector2i &p_vector2i) const {
|
||||
return Vector2i(MAX(x, p_vector2i.x), MAX(y, p_vector2i.y));
|
||||
}
|
||||
|
||||
Vector2i maxi(int32_t p_scalar) const {
|
||||
return Vector2i(MAX(x, p_scalar), MAX(y, p_scalar));
|
||||
}
|
||||
|
||||
Vector2i operator+(const Vector2i &p_v) const;
|
||||
void operator+=(const Vector2i &p_v);
|
||||
Vector2i operator-(const Vector2i &p_v) const;
|
||||
@@ -117,10 +125,16 @@ struct _NO_DISCARD_ Vector2i {
|
||||
int64_t length_squared() const;
|
||||
double length() const;
|
||||
|
||||
int64_t distance_squared_to(const Vector2i &p_to) const;
|
||||
double distance_to(const Vector2i &p_to) const;
|
||||
|
||||
real_t aspect() const { return width / (real_t)height; }
|
||||
Vector2i sign() const { return Vector2i(SIGN(x), SIGN(y)); }
|
||||
Vector2i abs() const { return Vector2i(Math::abs(x), Math::abs(y)); }
|
||||
Vector2i snapped(const Vector2i &p_step) const;
|
||||
Vector2i snappedi(int32_t p_step) const;
|
||||
Vector2i clamp(const Vector2i &p_min, const Vector2i &p_max) const;
|
||||
Vector2i clampi(int32_t p_min, int32_t p_max) const;
|
||||
|
||||
operator String() const;
|
||||
operator Vector2() const;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct Basis;
|
||||
struct Vector2;
|
||||
struct Vector3i;
|
||||
|
||||
struct _NO_DISCARD_ Vector3 {
|
||||
struct [[nodiscard]] Vector3 {
|
||||
static const int AXIS_COUNT = 3;
|
||||
|
||||
enum Axis {
|
||||
@@ -82,10 +82,18 @@ struct _NO_DISCARD_ Vector3 {
|
||||
return Vector3(MIN(x, p_vector3.x), MIN(y, p_vector3.y), MIN(z, p_vector3.z));
|
||||
}
|
||||
|
||||
Vector3 minf(real_t p_scalar) const {
|
||||
return Vector3(MIN(x, p_scalar), MIN(y, p_scalar), MIN(z, p_scalar));
|
||||
}
|
||||
|
||||
Vector3 max(const Vector3 &p_vector3) const {
|
||||
return Vector3(MAX(x, p_vector3.x), MAX(y, p_vector3.y), MAX(z, p_vector3.z));
|
||||
}
|
||||
|
||||
Vector3 maxf(real_t p_scalar) const {
|
||||
return Vector3(MAX(x, p_scalar), MAX(y, p_scalar), MAX(z, p_scalar));
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ real_t length() const;
|
||||
_FORCE_INLINE_ real_t length_squared() const;
|
||||
|
||||
@@ -98,7 +106,9 @@ struct _NO_DISCARD_ Vector3 {
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
void snap(const Vector3 p_val);
|
||||
void snapf(real_t p_val);
|
||||
Vector3 snapped(const Vector3 p_val) const;
|
||||
Vector3 snappedf(real_t p_val) const;
|
||||
|
||||
void rotate(const Vector3 &p_axis, const real_t p_angle);
|
||||
Vector3 rotated(const Vector3 &p_axis, const real_t p_angle) const;
|
||||
@@ -128,6 +138,7 @@ struct _NO_DISCARD_ Vector3 {
|
||||
_FORCE_INLINE_ Vector3 ceil() const;
|
||||
_FORCE_INLINE_ Vector3 round() const;
|
||||
Vector3 clamp(const Vector3 &p_min, const Vector3 &p_max) const;
|
||||
Vector3 clampf(real_t p_min, real_t p_max) const;
|
||||
|
||||
_FORCE_INLINE_ real_t distance_to(const Vector3 &p_to) const;
|
||||
_FORCE_INLINE_ real_t distance_squared_to(const Vector3 &p_to) const;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace godot {
|
||||
class String;
|
||||
struct Vector3;
|
||||
|
||||
struct _NO_DISCARD_ Vector3i {
|
||||
struct [[nodiscard]] Vector3i {
|
||||
static const int AXIS_COUNT = 3;
|
||||
|
||||
enum Axis {
|
||||
@@ -75,18 +75,32 @@ struct _NO_DISCARD_ Vector3i {
|
||||
return Vector3i(MIN(x, p_vector3i.x), MIN(y, p_vector3i.y), MIN(z, p_vector3i.z));
|
||||
}
|
||||
|
||||
Vector3i mini(int32_t p_scalar) const {
|
||||
return Vector3i(MIN(x, p_scalar), MIN(y, p_scalar), MIN(z, p_scalar));
|
||||
}
|
||||
|
||||
Vector3i max(const Vector3i &p_vector3i) const {
|
||||
return Vector3i(MAX(x, p_vector3i.x), MAX(y, p_vector3i.y), MAX(z, p_vector3i.z));
|
||||
}
|
||||
|
||||
Vector3i maxi(int32_t p_scalar) const {
|
||||
return Vector3i(MAX(x, p_scalar), MAX(y, p_scalar), MAX(z, p_scalar));
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int64_t length_squared() const;
|
||||
_FORCE_INLINE_ double length() const;
|
||||
|
||||
_FORCE_INLINE_ int64_t distance_squared_to(const Vector3i &p_to) const;
|
||||
_FORCE_INLINE_ double distance_to(const Vector3i &p_to) const;
|
||||
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
_FORCE_INLINE_ Vector3i abs() const;
|
||||
_FORCE_INLINE_ Vector3i sign() const;
|
||||
Vector3i snapped(const Vector3i &p_step) const;
|
||||
Vector3i snappedi(int32_t p_step) const;
|
||||
Vector3i clamp(const Vector3i &p_min, const Vector3i &p_max) const;
|
||||
Vector3i clampi(int32_t p_min, int32_t p_max) const;
|
||||
|
||||
/* Operators */
|
||||
|
||||
@@ -136,6 +150,14 @@ double Vector3i::length() const {
|
||||
return Math::sqrt((double)length_squared());
|
||||
}
|
||||
|
||||
int64_t Vector3i::distance_squared_to(const Vector3i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
double Vector3i::distance_to(const Vector3i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
Vector3i Vector3i::abs() const {
|
||||
return Vector3i(Math::abs(x), Math::abs(y), Math::abs(z));
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace godot {
|
||||
|
||||
class String;
|
||||
|
||||
struct _NO_DISCARD_ Vector4 {
|
||||
struct [[nodiscard]] Vector4 {
|
||||
static const int AXIS_COUNT = 4;
|
||||
|
||||
enum Axis {
|
||||
@@ -75,10 +75,18 @@ struct _NO_DISCARD_ Vector4 {
|
||||
return Vector4(MIN(x, p_vector4.x), MIN(y, p_vector4.y), MIN(z, p_vector4.z), MIN(w, p_vector4.w));
|
||||
}
|
||||
|
||||
Vector4 minf(real_t p_scalar) const {
|
||||
return Vector4(MIN(x, p_scalar), MIN(y, p_scalar), MIN(z, p_scalar), MIN(w, p_scalar));
|
||||
}
|
||||
|
||||
Vector4 max(const Vector4 &p_vector4) const {
|
||||
return Vector4(MAX(x, p_vector4.x), MAX(y, p_vector4.y), MAX(z, p_vector4.z), MAX(w, p_vector4.w));
|
||||
}
|
||||
|
||||
Vector4 maxf(real_t p_scalar) const {
|
||||
return Vector4(MAX(x, p_scalar), MAX(y, p_scalar), MAX(z, p_scalar), MAX(w, p_scalar));
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ real_t length_squared() const;
|
||||
bool is_equal_approx(const Vector4 &p_vec4) const;
|
||||
bool is_zero_approx() const;
|
||||
@@ -104,8 +112,11 @@ struct _NO_DISCARD_ Vector4 {
|
||||
Vector4 posmod(const real_t p_mod) const;
|
||||
Vector4 posmodv(const Vector4 &p_modv) const;
|
||||
void snap(const Vector4 &p_step);
|
||||
void snapf(real_t p_step);
|
||||
Vector4 snapped(const Vector4 &p_step) const;
|
||||
Vector4 snappedf(real_t p_step) const;
|
||||
Vector4 clamp(const Vector4 &p_min, const Vector4 &p_max) const;
|
||||
Vector4 clampf(real_t p_min, real_t p_max) const;
|
||||
|
||||
Vector4 inverse() const;
|
||||
_FORCE_INLINE_ real_t dot(const Vector4 &p_vec4) const;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace godot {
|
||||
class String;
|
||||
struct Vector4;
|
||||
|
||||
struct _NO_DISCARD_ Vector4i {
|
||||
struct [[nodiscard]] Vector4i {
|
||||
static const int AXIS_COUNT = 4;
|
||||
|
||||
enum Axis {
|
||||
@@ -77,18 +77,32 @@ struct _NO_DISCARD_ Vector4i {
|
||||
return Vector4i(MIN(x, p_vector4i.x), MIN(y, p_vector4i.y), MIN(z, p_vector4i.z), MIN(w, p_vector4i.w));
|
||||
}
|
||||
|
||||
Vector4i mini(int32_t p_scalar) const {
|
||||
return Vector4i(MIN(x, p_scalar), MIN(y, p_scalar), MIN(z, p_scalar), MIN(w, p_scalar));
|
||||
}
|
||||
|
||||
Vector4i max(const Vector4i &p_vector4i) const {
|
||||
return Vector4i(MAX(x, p_vector4i.x), MAX(y, p_vector4i.y), MAX(z, p_vector4i.z), MAX(w, p_vector4i.w));
|
||||
}
|
||||
|
||||
Vector4i maxi(int32_t p_scalar) const {
|
||||
return Vector4i(MAX(x, p_scalar), MAX(y, p_scalar), MAX(z, p_scalar), MAX(w, p_scalar));
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ int64_t length_squared() const;
|
||||
_FORCE_INLINE_ double length() const;
|
||||
|
||||
_FORCE_INLINE_ int64_t distance_squared_to(const Vector4i &p_to) const;
|
||||
_FORCE_INLINE_ double distance_to(const Vector4i &p_to) const;
|
||||
|
||||
_FORCE_INLINE_ void zero();
|
||||
|
||||
_FORCE_INLINE_ Vector4i abs() const;
|
||||
_FORCE_INLINE_ Vector4i sign() const;
|
||||
Vector4i snapped(const Vector4i &p_step) const;
|
||||
Vector4i snappedi(int32_t p_step) const;
|
||||
Vector4i clamp(const Vector4i &p_min, const Vector4i &p_max) const;
|
||||
Vector4i clampi(int32_t p_min, int32_t p_max) const;
|
||||
|
||||
/* Operators */
|
||||
|
||||
@@ -140,6 +154,14 @@ double Vector4i::length() const {
|
||||
return Math::sqrt((double)length_squared());
|
||||
}
|
||||
|
||||
int64_t Vector4i::distance_squared_to(const Vector4i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
double Vector4i::distance_to(const Vector4i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
Vector4i Vector4i::abs() const {
|
||||
return Vector4i(Math::abs(x), Math::abs(y), Math::abs(z), Math::abs(w));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ def test(profile_filepath=""):
|
||||
api = generate_trimmed_api(api_filepath, profile_filepath)
|
||||
_generate_bindings(
|
||||
api,
|
||||
api_filepath,
|
||||
use_template_get_node=False,
|
||||
bits=bits,
|
||||
precision=precision,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include <godot_cpp/classes/file_access.hpp>
|
||||
#include <godot_cpp/classes/image.hpp>
|
||||
#include <godot_cpp/classes/worker_thread_pool.hpp>
|
||||
#include <godot_cpp/classes/xml_parser.hpp>
|
||||
|
||||
@@ -55,4 +56,12 @@ WorkerThreadPool::GroupID WorkerThreadPool::add_native_group_task(void (*p_func)
|
||||
return (GroupID)internal::gdextension_interface_worker_thread_pool_add_native_group_task(_owner, p_func, p_userdata, p_elements, p_tasks, p_high_priority, (GDExtensionConstStringPtr)&p_description);
|
||||
}
|
||||
|
||||
uint8_t *Image::ptrw() {
|
||||
return internal::gdextension_interface_image_ptrw(_owner);
|
||||
}
|
||||
|
||||
const uint8_t *Image::ptr() {
|
||||
return internal::gdextension_interface_image_ptr(_owner);
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -40,42 +40,54 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
const StringName *Wrapped::_get_extension_class_name() const {
|
||||
#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL
|
||||
std::recursive_mutex Wrapped::_constructing_mutex;
|
||||
#endif
|
||||
|
||||
_GODOT_CPP_THREAD_LOCAL const StringName *Wrapped::_constructing_extension_class_name = nullptr;
|
||||
_GODOT_CPP_THREAD_LOCAL const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr;
|
||||
|
||||
#ifdef HOT_RELOAD_ENABLED
|
||||
_GODOT_CPP_THREAD_LOCAL GDExtensionObjectPtr Wrapped::_constructing_recreate_owner = nullptr;
|
||||
#endif
|
||||
|
||||
const StringName *Wrapped::_get_extension_class_name() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Wrapped::_postinitialize() {
|
||||
const StringName *extension_class = _get_extension_class_name();
|
||||
if (extension_class) {
|
||||
godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(extension_class), this);
|
||||
}
|
||||
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
|
||||
if (extension_class) {
|
||||
#ifdef _GODOT_CPP_AVOID_THREAD_LOCAL
|
||||
Wrapped::_constructing_mutex.unlock();
|
||||
#endif
|
||||
|
||||
// Only send NOTIFICATION_POSTINITIALIZE for extension classes.
|
||||
if (_is_extension_class()) {
|
||||
_notificationv(Object::NOTIFICATION_POSTINITIALIZE);
|
||||
}
|
||||
}
|
||||
|
||||
Wrapped::Wrapped(const StringName p_godot_class) {
|
||||
#ifdef HOT_RELOAD_ENABLED
|
||||
if (unlikely(Wrapped::recreate_instance)) {
|
||||
RecreateInstance *recreate_data = Wrapped::recreate_instance;
|
||||
RecreateInstance *previous = nullptr;
|
||||
while (recreate_data) {
|
||||
if (recreate_data->wrapper == this) {
|
||||
_owner = recreate_data->owner;
|
||||
if (previous) {
|
||||
previous->next = recreate_data->next;
|
||||
} else {
|
||||
Wrapped::recreate_instance = recreate_data->next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
previous = recreate_data;
|
||||
recreate_data = recreate_data->next;
|
||||
}
|
||||
}
|
||||
if (unlikely(Wrapped::_constructing_recreate_owner)) {
|
||||
_owner = Wrapped::_constructing_recreate_owner;
|
||||
Wrapped::_constructing_recreate_owner = nullptr;
|
||||
} else
|
||||
#endif
|
||||
_owner = godot::internal::gdextension_interface_classdb_construct_object(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr()));
|
||||
{
|
||||
_owner = godot::internal::gdextension_interface_classdb_construct_object(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr()));
|
||||
}
|
||||
|
||||
if (_constructing_extension_class_name) {
|
||||
godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(_constructing_extension_class_name), this);
|
||||
_constructing_extension_class_name = nullptr;
|
||||
}
|
||||
|
||||
if (likely(_constructing_class_binding_callbacks)) {
|
||||
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _constructing_class_binding_callbacks);
|
||||
_constructing_class_binding_callbacks = nullptr;
|
||||
} else {
|
||||
CRASH_NOW_MSG("BUG: Godot Object created without binding callbacks. Did you forget to use memnew()?");
|
||||
}
|
||||
}
|
||||
|
||||
Wrapped::Wrapped(GodotObject *p_godot_object) {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <godot_cpp/core/error_macros.hpp>
|
||||
#include <godot_cpp/godot.hpp>
|
||||
#include <godot_cpp/templates/vector.hpp>
|
||||
|
||||
#include <godot_cpp/core/memory.hpp>
|
||||
|
||||
@@ -339,11 +340,56 @@ void ClassDB::bind_virtual_method(const StringName &p_class, const StringName &p
|
||||
type.virtual_methods[p_method] = p_call;
|
||||
}
|
||||
|
||||
void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_method, const Vector<StringName> &p_arg_names) {
|
||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class);
|
||||
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(Array::make(p_class)));
|
||||
|
||||
GDExtensionClassVirtualMethodInfo mi;
|
||||
mi.name = (GDExtensionStringNamePtr)&p_method.name;
|
||||
mi.method_flags = p_method.flags;
|
||||
mi.return_value = p_method.return_val._to_gdextension();
|
||||
mi.return_value_metadata = p_method.return_val_metadata;
|
||||
mi.argument_count = p_method.arguments.size();
|
||||
if (mi.argument_count > 0) {
|
||||
mi.arguments = (GDExtensionPropertyInfo *)memalloc(sizeof(GDExtensionPropertyInfo) * mi.argument_count);
|
||||
mi.arguments_metadata = (GDExtensionClassMethodArgumentMetadata *)memalloc(sizeof(GDExtensionClassMethodArgumentMetadata) * mi.argument_count);
|
||||
if (mi.argument_count != p_method.arguments_metadata.size()) {
|
||||
WARN_PRINT("Mismatch argument metadata count for virtual method: " + String(p_class) + "::" + p_method.name);
|
||||
}
|
||||
for (uint32_t i = 0; i < mi.argument_count; i++) {
|
||||
mi.arguments[i] = p_method.arguments[i]._to_gdextension();
|
||||
if (i < p_method.arguments_metadata.size()) {
|
||||
mi.arguments_metadata[i] = p_method.arguments_metadata[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mi.arguments = nullptr;
|
||||
mi.arguments_metadata = nullptr;
|
||||
}
|
||||
|
||||
if (p_arg_names.size() != mi.argument_count) {
|
||||
WARN_PRINT("Mismatch argument name count for virtual method: " + String(p_class) + "::" + p_method.name);
|
||||
} else {
|
||||
for (int i = 0; i < p_arg_names.size(); i++) {
|
||||
mi.arguments[i].name = (GDExtensionStringNamePtr)&p_arg_names[i];
|
||||
}
|
||||
}
|
||||
|
||||
internal::gdextension_interface_classdb_register_extension_class_virtual_method(internal::library, &p_class, &mi);
|
||||
|
||||
if (mi.arguments) {
|
||||
memfree(mi.arguments);
|
||||
}
|
||||
if (mi.arguments_metadata) {
|
||||
memfree(mi.arguments_metadata);
|
||||
}
|
||||
}
|
||||
|
||||
void ClassDB::initialize_class(const ClassInfo &p_cl) {
|
||||
}
|
||||
|
||||
void ClassDB::initialize(GDExtensionInitializationLevel p_level) {
|
||||
for (const std::pair<StringName, ClassInfo> pair : classes) {
|
||||
for (const std::pair<const StringName, ClassInfo> &pair : classes) {
|
||||
const ClassInfo &cl = pair.second;
|
||||
if (cl.level != p_level) {
|
||||
continue;
|
||||
|
||||
@@ -32,6 +32,22 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
void MethodBind::_set_const(bool p_const) {
|
||||
_const = p_const;
|
||||
}
|
||||
|
||||
void MethodBind::_set_static(bool p_static) {
|
||||
_static = p_static;
|
||||
}
|
||||
|
||||
void MethodBind::_set_returns(bool p_returns) {
|
||||
_returns = p_returns;
|
||||
}
|
||||
|
||||
void MethodBind::_set_vararg(bool p_vararg) {
|
||||
_vararg = p_vararg;
|
||||
}
|
||||
|
||||
StringName MethodBind::get_name() const {
|
||||
return name;
|
||||
}
|
||||
@@ -40,26 +56,6 @@ void MethodBind::set_name(const StringName &p_name) {
|
||||
name = p_name;
|
||||
}
|
||||
|
||||
void MethodBind::set_argument_count(int p_count) {
|
||||
argument_count = p_count;
|
||||
}
|
||||
|
||||
void MethodBind::set_const(bool p_const) {
|
||||
_is_const = p_const;
|
||||
}
|
||||
|
||||
void MethodBind::set_return(bool p_return) {
|
||||
_has_return = p_return;
|
||||
}
|
||||
|
||||
void MethodBind::set_static(bool p_static) {
|
||||
_static = p_static;
|
||||
}
|
||||
|
||||
void MethodBind::set_vararg(bool p_vararg) {
|
||||
_vararg = p_vararg;
|
||||
}
|
||||
|
||||
void MethodBind::set_argument_names(const std::vector<StringName> &p_names) {
|
||||
argument_names = p_names;
|
||||
}
|
||||
@@ -68,7 +64,7 @@ std::vector<StringName> MethodBind::get_argument_names() const {
|
||||
return argument_names;
|
||||
}
|
||||
|
||||
void MethodBind::generate_argument_types(int p_count) {
|
||||
void MethodBind::_generate_argument_types(int p_count) {
|
||||
set_argument_count(p_count);
|
||||
|
||||
if (argument_types != nullptr) {
|
||||
|
||||
39
src/core/print_string.cpp
Normal file
39
src/core/print_string.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************/
|
||||
/* print_string.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include <godot_cpp/core/print_string.hpp>
|
||||
|
||||
#include <godot_cpp/classes/os.hpp>
|
||||
|
||||
namespace godot {
|
||||
bool is_print_verbose_enabled() {
|
||||
return OS::get_singleton()->is_stdout_verbose();
|
||||
}
|
||||
} // namespace godot
|
||||
@@ -114,7 +114,9 @@ GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_string_new_wit
|
||||
GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars = nullptr;
|
||||
GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len = nullptr;
|
||||
GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len = nullptr;
|
||||
GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2 = nullptr;
|
||||
GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len = nullptr;
|
||||
GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2 = nullptr;
|
||||
GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len = nullptr;
|
||||
GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len = nullptr;
|
||||
GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars = nullptr;
|
||||
@@ -154,6 +156,8 @@ GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_interface_packed
|
||||
GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const = nullptr;
|
||||
GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index = nullptr;
|
||||
GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const = nullptr;
|
||||
GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index = nullptr;
|
||||
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;
|
||||
@@ -172,18 +176,21 @@ GDExtensionInterfaceObjectGetClassName gdextension_interface_object_get_class_na
|
||||
GDExtensionInterfaceObjectCastTo gdextension_interface_object_cast_to = nullptr;
|
||||
GDExtensionInterfaceObjectGetInstanceFromId gdextension_interface_object_get_instance_from_id = nullptr;
|
||||
GDExtensionInterfaceObjectGetInstanceId gdextension_interface_object_get_instance_id = nullptr;
|
||||
GDExtensionInterfaceCallableCustomCreate gdextension_interface_callable_custom_create = nullptr;
|
||||
GDExtensionInterfaceObjectHasScriptMethod gdextension_interface_object_has_script_method = nullptr;
|
||||
GDExtensionInterfaceObjectCallScriptMethod gdextension_interface_object_call_script_method = nullptr;
|
||||
GDExtensionInterfaceCallableCustomCreate2 gdextension_interface_callable_custom_create2 = nullptr;
|
||||
GDExtensionInterfaceCallableCustomGetUserData gdextension_interface_callable_custom_get_userdata = nullptr;
|
||||
GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object = nullptr;
|
||||
GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object = nullptr;
|
||||
GDExtensionInterfaceScriptInstanceCreate2 gdextension_interface_script_instance_create2 = nullptr;
|
||||
GDExtensionInterfaceScriptInstanceCreate3 gdextension_interface_script_instance_create3 = nullptr;
|
||||
GDExtensionInterfacePlaceHolderScriptInstanceCreate gdextension_interface_placeholder_script_instance_create = nullptr;
|
||||
GDExtensionInterfacePlaceHolderScriptInstanceUpdate gdextension_interface_placeholder_script_instance_update = nullptr;
|
||||
GDExtensionInterfaceClassdbConstructObject gdextension_interface_classdb_construct_object = nullptr;
|
||||
GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind = nullptr;
|
||||
GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClass2 gdextension_interface_classdb_register_extension_class2 = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClass3 gdextension_interface_classdb_register_extension_class3 = 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;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property = nullptr;
|
||||
GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed gdextension_interface_classdb_register_extension_class_property_indexed = nullptr;
|
||||
@@ -194,6 +201,40 @@ 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;
|
||||
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;
|
||||
|
||||
struct DocData {
|
||||
const char *hash = nullptr;
|
||||
int uncompressed_size = 0;
|
||||
int compressed_size = 0;
|
||||
const unsigned char *data = nullptr;
|
||||
|
||||
inline bool is_valid() const {
|
||||
return hash != nullptr && uncompressed_size > 0 && compressed_size > 0 && data != nullptr;
|
||||
}
|
||||
|
||||
void load_data() const;
|
||||
};
|
||||
|
||||
static DocData &get_doc_data() {
|
||||
static DocData doc_data;
|
||||
return doc_data;
|
||||
}
|
||||
|
||||
DocDataRegistration::DocDataRegistration(const char *p_hash, int p_uncompressed_size, int p_compressed_size, const unsigned char *p_data) {
|
||||
DocData &doc_data = get_doc_data();
|
||||
if (doc_data.is_valid()) {
|
||||
printf("ERROR: Attempting to register documentation data when we already have some - discarding.\n");
|
||||
return;
|
||||
}
|
||||
doc_data.hash = p_hash;
|
||||
doc_data.uncompressed_size = p_uncompressed_size;
|
||||
doc_data.compressed_size = p_compressed_size;
|
||||
doc_data.data = p_data;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@@ -352,7 +393,9 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
LOAD_PROC_ADDRESS(string_new_with_wide_chars, GDExtensionInterfaceStringNewWithWideChars);
|
||||
LOAD_PROC_ADDRESS(string_new_with_latin1_chars_and_len, GDExtensionInterfaceStringNewWithLatin1CharsAndLen);
|
||||
LOAD_PROC_ADDRESS(string_new_with_utf8_chars_and_len, GDExtensionInterfaceStringNewWithUtf8CharsAndLen);
|
||||
LOAD_PROC_ADDRESS(string_new_with_utf8_chars_and_len2, GDExtensionInterfaceStringNewWithUtf8CharsAndLen2);
|
||||
LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len, GDExtensionInterfaceStringNewWithUtf16CharsAndLen);
|
||||
LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len2, GDExtensionInterfaceStringNewWithUtf16CharsAndLen2);
|
||||
LOAD_PROC_ADDRESS(string_new_with_utf32_chars_and_len, GDExtensionInterfaceStringNewWithUtf32CharsAndLen);
|
||||
LOAD_PROC_ADDRESS(string_new_with_wide_chars_and_len, GDExtensionInterfaceStringNewWithWideCharsAndLen);
|
||||
LOAD_PROC_ADDRESS(string_to_latin1_chars, GDExtensionInterfaceStringToLatin1Chars);
|
||||
@@ -392,6 +435,8 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
LOAD_PROC_ADDRESS(packed_vector2_array_operator_index_const, GDExtensionInterfacePackedVector2ArrayOperatorIndexConst);
|
||||
LOAD_PROC_ADDRESS(packed_vector3_array_operator_index, GDExtensionInterfacePackedVector3ArrayOperatorIndex);
|
||||
LOAD_PROC_ADDRESS(packed_vector3_array_operator_index_const, GDExtensionInterfacePackedVector3ArrayOperatorIndexConst);
|
||||
LOAD_PROC_ADDRESS(packed_vector4_array_operator_index, GDExtensionInterfacePackedVector4ArrayOperatorIndex);
|
||||
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);
|
||||
@@ -410,18 +455,21 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||
LOAD_PROC_ADDRESS(object_cast_to, GDExtensionInterfaceObjectCastTo);
|
||||
LOAD_PROC_ADDRESS(object_get_instance_from_id, GDExtensionInterfaceObjectGetInstanceFromId);
|
||||
LOAD_PROC_ADDRESS(object_get_instance_id, GDExtensionInterfaceObjectGetInstanceId);
|
||||
LOAD_PROC_ADDRESS(callable_custom_create, GDExtensionInterfaceCallableCustomCreate);
|
||||
LOAD_PROC_ADDRESS(object_has_script_method, GDExtensionInterfaceObjectHasScriptMethod);
|
||||
LOAD_PROC_ADDRESS(object_call_script_method, GDExtensionInterfaceObjectCallScriptMethod);
|
||||
LOAD_PROC_ADDRESS(callable_custom_create2, GDExtensionInterfaceCallableCustomCreate2);
|
||||
LOAD_PROC_ADDRESS(callable_custom_get_userdata, GDExtensionInterfaceCallableCustomGetUserData);
|
||||
LOAD_PROC_ADDRESS(ref_get_object, GDExtensionInterfaceRefGetObject);
|
||||
LOAD_PROC_ADDRESS(ref_set_object, GDExtensionInterfaceRefSetObject);
|
||||
LOAD_PROC_ADDRESS(script_instance_create2, GDExtensionInterfaceScriptInstanceCreate2);
|
||||
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(classdb_construct_object, GDExtensionInterfaceClassdbConstructObject);
|
||||
LOAD_PROC_ADDRESS(classdb_get_method_bind, GDExtensionInterfaceClassdbGetMethodBind);
|
||||
LOAD_PROC_ADDRESS(classdb_get_class_tag, GDExtensionInterfaceClassdbGetClassTag);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class2, GDExtensionInterfaceClassdbRegisterExtensionClass2);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class3, GDExtensionInterfaceClassdbRegisterExtensionClass3);
|
||||
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);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class_property, GDExtensionInterfaceClassdbRegisterExtensionClassProperty);
|
||||
LOAD_PROC_ADDRESS(classdb_register_extension_class_property_indexed, GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed);
|
||||
@@ -432,6 +480,10 @@ 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_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);
|
||||
|
||||
r_initialization->initialize = initialize_level;
|
||||
r_initialization->deinitialize = deinitialize_level;
|
||||
@@ -461,6 +513,13 @@ void GDExtensionBinding::initialize_level(void *p_userdata, GDExtensionInitializ
|
||||
ClassDB::initialize(p_level);
|
||||
}
|
||||
level_initialized[p_level]++;
|
||||
|
||||
if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
const internal::DocData &doc_data = internal::get_doc_data();
|
||||
if (doc_data.is_valid()) {
|
||||
doc_data.load_data();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GDExtensionBinding::deinitialize_level(void *p_userdata, GDExtensionInitializationLevel p_level) {
|
||||
@@ -527,4 +586,15 @@ GDExtensionBool GDExtensionBinding::InitObject::init() const {
|
||||
return GDExtensionBinding::init(get_proc_address, library, init_data, initialization);
|
||||
}
|
||||
|
||||
void internal::DocData::load_data() const {
|
||||
PackedByteArray compressed;
|
||||
compressed.resize(compressed_size);
|
||||
memcpy(compressed.ptrw(), data, compressed_size);
|
||||
|
||||
// FileAccess::COMPRESSION_DEFLATE = 1
|
||||
PackedByteArray decompressed = compressed.decompress(uncompressed_size, 1);
|
||||
|
||||
internal::gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len(reinterpret_cast<const char *>(decompressed.ptr()), uncompressed_size);
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
int CallableCustomBase::get_argument_count(bool &r_is_valid) const {
|
||||
r_is_valid = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void callable_custom_call(void *p_userdata, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error) {
|
||||
CallableCustom *callable_custom = (CallableCustom *)p_userdata;
|
||||
callable_custom->call((const Variant **)p_args, p_argument_count, *(Variant *)r_return, *r_error);
|
||||
@@ -84,13 +89,21 @@ static GDExtensionBool callable_custom_less_than_func(void *p_a, void *p_b) {
|
||||
return func_a(a, b);
|
||||
}
|
||||
|
||||
static GDExtensionInt custom_callable_get_argument_count_func(void *p_userdata, GDExtensionBool *r_is_valid) {
|
||||
CallableCustom *callable_custom = (CallableCustom *)p_userdata;
|
||||
bool valid = false;
|
||||
int ret = callable_custom->get_argument_count(valid);
|
||||
*r_is_valid = valid;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CallableCustom::is_valid() const {
|
||||
// The same default implementation as in Godot.
|
||||
return ObjectDB::get_instance(get_object());
|
||||
}
|
||||
|
||||
Callable::Callable(CallableCustom *p_callable_custom) {
|
||||
GDExtensionCallableCustomInfo info = {};
|
||||
GDExtensionCallableCustomInfo2 info = {};
|
||||
info.callable_userdata = p_callable_custom;
|
||||
info.token = internal::token;
|
||||
info.object_id = p_callable_custom->get_object();
|
||||
@@ -101,8 +114,9 @@ Callable::Callable(CallableCustom *p_callable_custom) {
|
||||
info.equal_func = &callable_custom_equal_func;
|
||||
info.less_than_func = &callable_custom_less_than_func;
|
||||
info.to_string_func = &callable_custom_to_string;
|
||||
info.get_argument_count_func = &custom_callable_get_argument_count_func;
|
||||
|
||||
::godot::internal::gdextension_interface_callable_custom_create(_native_ptr(), &info);
|
||||
::godot::internal::gdextension_interface_callable_custom_create2(_native_ptr(), &info);
|
||||
}
|
||||
|
||||
CallableCustom *Callable::get_custom() const {
|
||||
|
||||
@@ -77,6 +77,14 @@ static GDExtensionBool custom_callable_mp_less_than_func(void *p_a, void *p_b) {
|
||||
return memcmp(a->get_comp_ptr(), b->get_comp_ptr(), a->get_comp_size() * 4) < 0;
|
||||
}
|
||||
|
||||
static GDExtensionInt custom_callable_mp_get_argument_count_func(void *p_userdata, GDExtensionBool *r_is_valid) {
|
||||
CallableCustomMethodPointerBase *callable_method_pointer = (CallableCustomMethodPointerBase *)p_userdata;
|
||||
bool valid = false;
|
||||
int ret = callable_method_pointer->get_argument_count(valid);
|
||||
*r_is_valid = valid;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CallableCustomMethodPointerBase::_setup(uint32_t *p_base_ptr, uint32_t p_ptr_size) {
|
||||
comp_ptr = p_base_ptr;
|
||||
comp_size = p_ptr_size / 4;
|
||||
@@ -93,7 +101,7 @@ void CallableCustomMethodPointerBase::_setup(uint32_t *p_base_ptr, uint32_t p_pt
|
||||
namespace internal {
|
||||
|
||||
Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_method_pointer) {
|
||||
GDExtensionCallableCustomInfo info = {};
|
||||
GDExtensionCallableCustomInfo2 info = {};
|
||||
info.callable_userdata = p_callable_method_pointer;
|
||||
info.token = internal::token;
|
||||
info.object_id = p_callable_method_pointer->get_object();
|
||||
@@ -103,9 +111,10 @@ Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_m
|
||||
info.hash_func = &custom_callable_mp_hash;
|
||||
info.equal_func = &custom_callable_mp_equal_func;
|
||||
info.less_than_func = &custom_callable_mp_less_than_func;
|
||||
info.get_argument_count_func = &custom_callable_mp_get_argument_count_func;
|
||||
|
||||
Callable callable;
|
||||
::godot::internal::gdextension_interface_callable_custom_create(callable._native_ptr(), &info);
|
||||
::godot::internal::gdextension_interface_callable_custom_create2(callable._native_ptr(), &info);
|
||||
return callable;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,8 @@ String String::utf8(const char *from, int64_t len) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void String::parse_utf8(const char *from, int64_t len) {
|
||||
internal::gdextension_interface_string_new_with_utf8_chars_and_len(_native_ptr(), from, len);
|
||||
Error String::parse_utf8(const char *from, int64_t len) {
|
||||
return (Error)internal::gdextension_interface_string_new_with_utf8_chars_and_len2(_native_ptr(), from, len);
|
||||
}
|
||||
|
||||
String String::utf16(const char16_t *from, int64_t len) {
|
||||
@@ -188,8 +188,8 @@ String String::utf16(const char16_t *from, int64_t len) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void String::parse_utf16(const char16_t *from, int64_t len) {
|
||||
internal::gdextension_interface_string_new_with_utf16_chars_and_len(_native_ptr(), from, len);
|
||||
Error String::parse_utf16(const char16_t *from, int64_t len, bool default_little_endian) {
|
||||
return (Error)internal::gdextension_interface_string_new_with_utf16_chars_and_len2(_native_ptr(), from, len, default_little_endian);
|
||||
}
|
||||
|
||||
String String::num_real(double p_num, bool p_trailing) {
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <godot_cpp/variant/packed_string_array.hpp>
|
||||
#include <godot_cpp/variant/packed_vector2_array.hpp>
|
||||
#include <godot_cpp/variant/packed_vector3_array.hpp>
|
||||
#include <godot_cpp/variant/packed_vector4_array.hpp>
|
||||
|
||||
namespace godot {
|
||||
|
||||
@@ -198,6 +199,24 @@ Vector3 *PackedVector3Array::ptrw() {
|
||||
return (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0);
|
||||
}
|
||||
|
||||
const Vector4 &PackedVector4Array::operator[](int64_t p_index) const {
|
||||
const Vector4 *vec = (const Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
|
||||
return *vec;
|
||||
}
|
||||
|
||||
Vector4 &PackedVector4Array::operator[](int64_t p_index) {
|
||||
Vector4 *vec = (Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index((GDExtensionTypePtr *)this, p_index);
|
||||
return *vec;
|
||||
}
|
||||
|
||||
const Vector4 *PackedVector4Array::ptr() const {
|
||||
return (const Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, 0);
|
||||
}
|
||||
|
||||
Vector4 *PackedVector4Array::ptrw() {
|
||||
return (Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index((GDExtensionTypePtr *)this, 0);
|
||||
}
|
||||
|
||||
const Variant &Array::operator[](int64_t p_index) const {
|
||||
const Variant *var = (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
|
||||
return *var;
|
||||
|
||||
@@ -913,6 +913,13 @@ Projection::Projection(const Vector4 &p_x, const Vector4 &p_y, const Vector4 &p_
|
||||
columns[3] = p_w;
|
||||
}
|
||||
|
||||
Projection::Projection(real_t p_xx, real_t p_xy, real_t p_xz, real_t p_xw, real_t p_yx, real_t p_yy, real_t p_yz, real_t p_yw, real_t p_zx, real_t p_zy, real_t p_zz, real_t p_zw, real_t p_wx, real_t p_wy, real_t p_wz, real_t p_ww) {
|
||||
columns[0] = Vector4(p_xx, p_xy, p_xz, p_xw);
|
||||
columns[1] = Vector4(p_yx, p_yy, p_yz, p_yw);
|
||||
columns[2] = Vector4(p_zx, p_zy, p_zz, p_zw);
|
||||
columns[3] = Vector4(p_wx, p_wy, p_wz, p_ww);
|
||||
}
|
||||
|
||||
Projection::Projection(const Transform3D &p_transform) {
|
||||
const Transform3D &tr = p_transform;
|
||||
real_t *m = &columns[0][0];
|
||||
|
||||
@@ -66,6 +66,7 @@ void Variant::init_bindings() {
|
||||
PackedStringArray::init_bindings();
|
||||
PackedVector2Array::init_bindings();
|
||||
PackedVector3Array::init_bindings();
|
||||
PackedVector4Array::init_bindings();
|
||||
PackedColorArray::init_bindings();
|
||||
}
|
||||
|
||||
@@ -248,6 +249,10 @@ Variant::Variant(const PackedColorArray &v) {
|
||||
from_type_constructor[PACKED_COLOR_ARRAY](_native_ptr(), v._native_ptr());
|
||||
}
|
||||
|
||||
Variant::Variant(const PackedVector4Array &v) {
|
||||
from_type_constructor[PACKED_VECTOR4_ARRAY](_native_ptr(), v._native_ptr());
|
||||
}
|
||||
|
||||
Variant::~Variant() {
|
||||
internal::gdextension_interface_variant_destroy(_native_ptr());
|
||||
}
|
||||
@@ -506,6 +511,10 @@ Variant::operator PackedColorArray() const {
|
||||
return PackedColorArray(this);
|
||||
}
|
||||
|
||||
Variant::operator PackedVector4Array() const {
|
||||
return PackedVector4Array(this);
|
||||
}
|
||||
|
||||
Variant &Variant::operator=(const Variant &other) {
|
||||
clear();
|
||||
internal::gdextension_interface_variant_new_copy(_native_ptr(), other._native_ptr());
|
||||
|
||||
@@ -137,12 +137,24 @@ Vector2 Vector2::clamp(const Vector2 &p_min, const Vector2 &p_max) const {
|
||||
CLAMP(y, p_min.y, p_max.y));
|
||||
}
|
||||
|
||||
Vector2 Vector2::clampf(real_t p_min, real_t p_max) const {
|
||||
return Vector2(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max));
|
||||
}
|
||||
|
||||
Vector2 Vector2::snapped(const Vector2 &p_step) const {
|
||||
return Vector2(
|
||||
Math::snapped(x, p_step.x),
|
||||
Math::snapped(y, p_step.y));
|
||||
}
|
||||
|
||||
Vector2 Vector2::snappedf(real_t p_step) const {
|
||||
return Vector2(
|
||||
Math::snapped(x, p_step),
|
||||
Math::snapped(y, p_step));
|
||||
}
|
||||
|
||||
Vector2 Vector2::limit_length(const real_t p_len) const {
|
||||
const real_t l = length();
|
||||
Vector2 v = *this;
|
||||
|
||||
@@ -35,12 +35,30 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
Vector2i Vector2i::snapped(const Vector2i &p_step) const {
|
||||
return Vector2i(
|
||||
Math::snapped(x, p_step.x),
|
||||
Math::snapped(y, p_step.y));
|
||||
}
|
||||
|
||||
Vector2i Vector2i::snappedi(int32_t p_step) const {
|
||||
return Vector2i(
|
||||
Math::snapped(x, p_step),
|
||||
Math::snapped(y, p_step));
|
||||
}
|
||||
|
||||
Vector2i Vector2i::clamp(const Vector2i &p_min, const Vector2i &p_max) const {
|
||||
return Vector2i(
|
||||
CLAMP(x, p_min.x, p_max.x),
|
||||
CLAMP(y, p_min.y, p_max.y));
|
||||
}
|
||||
|
||||
Vector2i Vector2i::clampi(int32_t p_min, int32_t p_max) const {
|
||||
return Vector2i(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max));
|
||||
}
|
||||
|
||||
int64_t Vector2i::length_squared() const {
|
||||
return x * (int64_t)x + y * (int64_t)y;
|
||||
}
|
||||
@@ -49,6 +67,14 @@ double Vector2i::length() const {
|
||||
return Math::sqrt((double)length_squared());
|
||||
}
|
||||
|
||||
int64_t Vector2i::distance_squared_to(const Vector2i &p_to) const {
|
||||
return (p_to - *this).length_squared();
|
||||
}
|
||||
|
||||
double Vector2i::distance_to(const Vector2i &p_to) const {
|
||||
return (p_to - *this).length();
|
||||
}
|
||||
|
||||
Vector2i Vector2i::operator+(const Vector2i &p_v) const {
|
||||
return Vector2i(x + p_v.x, y + p_v.y);
|
||||
}
|
||||
|
||||
@@ -54,18 +54,37 @@ Vector3 Vector3::clamp(const Vector3 &p_min, const Vector3 &p_max) const {
|
||||
CLAMP(z, p_min.z, p_max.z));
|
||||
}
|
||||
|
||||
Vector3 Vector3::clampf(real_t p_min, real_t p_max) const {
|
||||
return Vector3(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max),
|
||||
CLAMP(z, p_min, p_max));
|
||||
}
|
||||
|
||||
void Vector3::snap(const Vector3 p_step) {
|
||||
x = Math::snapped(x, p_step.x);
|
||||
y = Math::snapped(y, p_step.y);
|
||||
z = Math::snapped(z, p_step.z);
|
||||
}
|
||||
|
||||
void Vector3::snapf(real_t p_step) {
|
||||
x = Math::snapped(x, p_step);
|
||||
y = Math::snapped(y, p_step);
|
||||
z = Math::snapped(z, p_step);
|
||||
}
|
||||
|
||||
Vector3 Vector3::snapped(const Vector3 p_step) const {
|
||||
Vector3 v = *this;
|
||||
v.snap(p_step);
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector3 Vector3::snappedf(real_t p_step) const {
|
||||
Vector3 v = *this;
|
||||
v.snapf(p_step);
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector3 Vector3::limit_length(const real_t p_len) const {
|
||||
const real_t l = length();
|
||||
Vector3 v = *this;
|
||||
|
||||
@@ -35,6 +35,20 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
Vector3i Vector3i::snapped(const Vector3i &p_step) const {
|
||||
return Vector3i(
|
||||
Math::snapped(x, p_step.x),
|
||||
Math::snapped(y, p_step.y),
|
||||
Math::snapped(z, p_step.z));
|
||||
}
|
||||
|
||||
Vector3i Vector3i::snappedi(int32_t p_step) const {
|
||||
return Vector3i(
|
||||
Math::snapped(x, p_step),
|
||||
Math::snapped(y, p_step),
|
||||
Math::snapped(z, p_step));
|
||||
}
|
||||
|
||||
Vector3i::Axis Vector3i::min_axis_index() const {
|
||||
return x < y ? (x < z ? Vector3i::AXIS_X : Vector3i::AXIS_Z) : (y < z ? Vector3i::AXIS_Y : Vector3i::AXIS_Z);
|
||||
}
|
||||
@@ -50,6 +64,13 @@ Vector3i Vector3i::clamp(const Vector3i &p_min, const Vector3i &p_max) const {
|
||||
CLAMP(z, p_min.z, p_max.z));
|
||||
}
|
||||
|
||||
Vector3i Vector3i::clampi(int32_t p_min, int32_t p_max) const {
|
||||
return Vector3i(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max),
|
||||
CLAMP(z, p_min, p_max));
|
||||
}
|
||||
|
||||
Vector3i::operator String() const {
|
||||
return "(" + itos(x) + ", " + itos(y) + ", " + itos(z) + ")";
|
||||
}
|
||||
|
||||
@@ -173,12 +173,25 @@ void Vector4::snap(const Vector4 &p_step) {
|
||||
w = Math::snapped(w, p_step.w);
|
||||
}
|
||||
|
||||
void Vector4::snapf(real_t p_step) {
|
||||
x = Math::snapped(x, p_step);
|
||||
y = Math::snapped(y, p_step);
|
||||
z = Math::snapped(z, p_step);
|
||||
w = Math::snapped(w, p_step);
|
||||
}
|
||||
|
||||
Vector4 Vector4::snapped(const Vector4 &p_step) const {
|
||||
Vector4 v = *this;
|
||||
v.snap(p_step);
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector4 Vector4::snappedf(real_t p_step) const {
|
||||
Vector4 v = *this;
|
||||
v.snapf(p_step);
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector4 Vector4::inverse() const {
|
||||
return Vector4(1.0f / x, 1.0f / y, 1.0f / z, 1.0f / w);
|
||||
}
|
||||
@@ -191,6 +204,14 @@ Vector4 Vector4::clamp(const Vector4 &p_min, const Vector4 &p_max) const {
|
||||
CLAMP(w, p_min.w, p_max.w));
|
||||
}
|
||||
|
||||
Vector4 Vector4::clampf(real_t p_min, real_t p_max) const {
|
||||
return Vector4(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max),
|
||||
CLAMP(z, p_min, p_max),
|
||||
CLAMP(w, p_min, p_max));
|
||||
}
|
||||
|
||||
Vector4::operator String() const {
|
||||
return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ", " + String::num_real(z, false) + ", " + String::num_real(w, false) + ")";
|
||||
}
|
||||
|
||||
@@ -35,6 +35,22 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
Vector4i Vector4i::snapped(const Vector4i &p_step) const {
|
||||
return Vector4i(
|
||||
Math::snapped(x, p_step.x),
|
||||
Math::snapped(y, p_step.y),
|
||||
Math::snapped(z, p_step.z),
|
||||
Math::snapped(w, p_step.w));
|
||||
}
|
||||
|
||||
Vector4i Vector4i::snappedi(int32_t p_step) const {
|
||||
return Vector4i(
|
||||
Math::snapped(x, p_step),
|
||||
Math::snapped(y, p_step),
|
||||
Math::snapped(z, p_step),
|
||||
Math::snapped(w, p_step));
|
||||
}
|
||||
|
||||
Vector4i::Axis Vector4i::min_axis_index() const {
|
||||
uint32_t min_index = 0;
|
||||
int32_t min_value = x;
|
||||
@@ -67,6 +83,14 @@ Vector4i Vector4i::clamp(const Vector4i &p_min, const Vector4i &p_max) const {
|
||||
CLAMP(w, p_min.w, p_max.w));
|
||||
}
|
||||
|
||||
Vector4i Vector4i::clampi(int32_t p_min, int32_t p_max) const {
|
||||
return Vector4i(
|
||||
CLAMP(x, p_min, p_max),
|
||||
CLAMP(y, p_min, p_max),
|
||||
CLAMP(z, p_min, p_max),
|
||||
CLAMP(w, p_min, p_max));
|
||||
}
|
||||
|
||||
Vector4i::operator String() const {
|
||||
return "(" + itos(x) + ", " + itos(y) + ", " + itos(z) + ", " + itos(w) + ")";
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ env = SConscript("../SConstruct")
|
||||
env.Append(CPPPATH=["src/"])
|
||||
sources = Glob("src/*.cpp")
|
||||
|
||||
if env["target"] in ["editor", "template_debug"]:
|
||||
doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
|
||||
sources.append(doc_data)
|
||||
|
||||
if env["platform"] == "macos":
|
||||
library = env.SharedLibrary(
|
||||
"project/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
|
||||
|
||||
25
test/doc_classes/Example.xml
Normal file
25
test/doc_classes/Example.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Example" inherits="Control" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
|
||||
<brief_description>
|
||||
A test control defined in GDExtension.
|
||||
</brief_description>
|
||||
<description>
|
||||
A control used for the automated GDExtension tests.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="simple_func">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Tests a simple function call.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
</members>
|
||||
<signals>
|
||||
</signals>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
||||
5
test/project/example.gd
Normal file
5
test/project/example.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends Example
|
||||
|
||||
func _do_something_virtual(p_name, p_value):
|
||||
custom_signal.emit(p_name, p_value)
|
||||
return "Implemented"
|
||||
@@ -9,14 +9,16 @@ class TestClass:
|
||||
func _ready():
|
||||
var example: Example = $Example
|
||||
|
||||
# Timing of set instance binding.
|
||||
assert_equal(example.is_object_binding_set_by_parent_constructor(), true)
|
||||
|
||||
# Signal.
|
||||
example.emit_custom_signal("Button", 42)
|
||||
assert_equal(custom_signal_emitted, ["Button", 42])
|
||||
|
||||
# To string.
|
||||
assert_equal(example.to_string(),'Example:[ GDExtension::Example <--> Instance ID:%s ]' % example.get_instance_id())
|
||||
# It appears there's a bug with instance ids :-(
|
||||
#assert_equal($Example/ExampleMin.to_string(), 'ExampleMin:[Wrapped:%s]' % $Example/ExampleMin.get_instance_id())
|
||||
assert_equal(example.to_string(),'[ GDExtension::Example <--> Instance ID:%s ]' % example.get_instance_id())
|
||||
assert_equal($Example/ExampleMin.to_string(), 'ExampleMin:<ExampleMin#%s>' % $Example/ExampleMin.get_instance_id())
|
||||
|
||||
# Call static methods.
|
||||
assert_equal(Example.test_static(9, 100), 109);
|
||||
@@ -102,6 +104,7 @@ func _ready():
|
||||
# mp_callable() with void method.
|
||||
var mp_callable: Callable = example.test_callable_mp()
|
||||
assert_equal(mp_callable.is_valid(), true)
|
||||
assert_equal(mp_callable.get_argument_count(), 3)
|
||||
mp_callable.call(example, "void", 36)
|
||||
assert_equal(custom_signal_emitted, ["unbound_method1: Example - void", 36])
|
||||
|
||||
@@ -117,14 +120,17 @@ func _ready():
|
||||
|
||||
# mp_callable() with return value.
|
||||
var mp_callable_ret: Callable = example.test_callable_mp_ret()
|
||||
assert_equal(mp_callable_ret.get_argument_count(), 3)
|
||||
assert_equal(mp_callable_ret.call(example, "test", 77), "unbound_method2: Example - test - 77")
|
||||
|
||||
# mp_callable() with const method and return value.
|
||||
var mp_callable_retc: Callable = example.test_callable_mp_retc()
|
||||
assert_equal(mp_callable_retc.get_argument_count(), 3)
|
||||
assert_equal(mp_callable_retc.call(example, "const", 101), "unbound_method3: Example - const - 101")
|
||||
|
||||
# mp_callable_static() with void method.
|
||||
var mp_callable_static: Callable = example.test_callable_mp_static()
|
||||
assert_equal(mp_callable_static.get_argument_count(), 3)
|
||||
mp_callable_static.call(example, "static", 83)
|
||||
assert_equal(custom_signal_emitted, ["unbound_static_method1: Example - static", 83])
|
||||
|
||||
@@ -140,6 +146,7 @@ func _ready():
|
||||
|
||||
# mp_callable_static() with return value.
|
||||
var mp_callable_static_ret: Callable = example.test_callable_mp_static_ret()
|
||||
assert_equal(mp_callable_static_ret.get_argument_count(), 3)
|
||||
assert_equal(mp_callable_static_ret.call(example, "static-ret", 84), "unbound_static_method2: Example - static-ret - 84")
|
||||
|
||||
# CallableCustom.
|
||||
@@ -150,6 +157,7 @@ func _ready():
|
||||
assert_equal(custom_callable.hash(), 27);
|
||||
assert_equal(custom_callable.get_object(), null);
|
||||
assert_equal(custom_callable.get_method(), "");
|
||||
assert_equal(custom_callable.get_argument_count(), 2)
|
||||
assert_equal(str(custom_callable), "<MyCallableCustom>");
|
||||
|
||||
# PackedArray iterators
|
||||
@@ -246,6 +254,10 @@ func _ready():
|
||||
assert_equal(new_example_ref.was_post_initialized(), true)
|
||||
assert_equal(example.test_post_initialize(), true)
|
||||
|
||||
# Test a virtual method defined in GDExtension and implemented in script.
|
||||
assert_equal(example.test_virtual_implemented_in_script("Virtual", 939), "Implemented")
|
||||
assert_equal(custom_signal_emitted, ["Virtual", 939])
|
||||
|
||||
# Test that we can access an engine singleton.
|
||||
assert_equal(example.test_use_engine_singleton(), OS.get_name())
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dmx2xuigcpvt4"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dmx2xuigcpvt4"]
|
||||
|
||||
[ext_resource type="Script" path="res://main.gd" id="1_qesh5"]
|
||||
[ext_resource type="Script" path="res://example.gd" id="2_jju25"]
|
||||
|
||||
[node name="Node" type="Node"]
|
||||
script = ExtResource("1_qesh5")
|
||||
|
||||
[node name="Example" type="Example" parent="."]
|
||||
script = ExtResource("2_jju25")
|
||||
|
||||
[node name="ExampleMin" type="ExampleMin" parent="Example"]
|
||||
layout_mode = 0
|
||||
|
||||
@@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="GDExtension Test Project"
|
||||
run/main_scene="res://main.tscn"
|
||||
config/features=PackedStringArray("4.2")
|
||||
config/features=PackedStringArray("4.3")
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[native_extensions]
|
||||
|
||||
@@ -50,6 +50,11 @@ public:
|
||||
return ObjectID();
|
||||
}
|
||||
|
||||
virtual int get_argument_count(bool &r_is_valid) const {
|
||||
r_is_valid = true;
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const {
|
||||
r_return_value = "Hi";
|
||||
r_call_error.error = GDEXTENSION_CALL_OK;
|
||||
@@ -188,6 +193,8 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("return_extended_ref"), &Example::return_extended_ref);
|
||||
ClassDB::bind_method(D_METHOD("extended_ref_checks", "ref"), &Example::extended_ref_checks);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_object_binding_set_by_parent_constructor"), &Example::is_object_binding_set_by_parent_constructor);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_array"), &Example::test_array);
|
||||
ClassDB::bind_method(D_METHOD("test_tarray_arg", "array"), &Example::test_tarray_arg);
|
||||
ClassDB::bind_method(D_METHOD("test_tarray"), &Example::test_tarray);
|
||||
@@ -233,6 +240,10 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind);
|
||||
ClassDB::bind_method(D_METHOD("test_post_initialize"), &Example::test_post_initialize);
|
||||
|
||||
GDVIRTUAL_BIND(_do_something_virtual, "name", "value");
|
||||
ClassDB::bind_method(D_METHOD("test_virtual_implemented_in_script"), &Example::test_virtual_implemented_in_script);
|
||||
GDVIRTUAL_BIND(_do_something_virtual_with_control, "control");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_use_engine_singleton"), &Example::test_use_engine_singleton);
|
||||
|
||||
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
|
||||
@@ -285,7 +296,17 @@ void Example::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(OUTSIDE_OF_CLASS);
|
||||
}
|
||||
|
||||
Example::Example() {
|
||||
bool Example::has_object_instance_binding() const {
|
||||
return internal::gdextension_interface_object_get_instance_binding(_owner, internal::token, nullptr);
|
||||
}
|
||||
|
||||
Example::Example() :
|
||||
object_instance_binding_set_by_parent_constructor(has_object_instance_binding()) {
|
||||
// Test conversion, to ensure users can use all parent class functions at this time.
|
||||
// It would crash if instance binding still not be initialized.
|
||||
Variant v = Variant(this);
|
||||
Object *o = (Object *)v;
|
||||
|
||||
//UtilityFunctions::print("Constructor.");
|
||||
}
|
||||
|
||||
@@ -365,6 +386,10 @@ void Example::emit_custom_signal(const String &name, int value) {
|
||||
emit_signal("custom_signal", name, value);
|
||||
}
|
||||
|
||||
bool Example::is_object_binding_set_by_parent_constructor() const {
|
||||
return object_instance_binding_set_by_parent_constructor;
|
||||
}
|
||||
|
||||
Array Example::test_array() const {
|
||||
Array arr;
|
||||
|
||||
@@ -674,6 +699,14 @@ void ExampleChild::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
String Example::test_virtual_implemented_in_script(const String &p_name, int p_value) {
|
||||
String ret;
|
||||
if (GDVIRTUAL_CALL(_do_something_virtual, p_name, p_value, ret)) {
|
||||
return ret;
|
||||
}
|
||||
return "Unimplemented";
|
||||
}
|
||||
|
||||
String Example::test_use_engine_singleton() const {
|
||||
return OS::get_singleton()->get_name();
|
||||
}
|
||||
@@ -683,3 +716,23 @@ String Example::test_library_path() {
|
||||
internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr());
|
||||
return library_path;
|
||||
}
|
||||
|
||||
void ExampleRuntime::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value);
|
||||
ClassDB::bind_method(D_METHOD("get_prop_value"), &ExampleRuntime::get_prop_value);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "prop_value"), "set_prop_value", "get_prop_value");
|
||||
}
|
||||
|
||||
void ExampleRuntime::set_prop_value(int p_prop_value) {
|
||||
prop_value = p_prop_value;
|
||||
}
|
||||
|
||||
int ExampleRuntime::get_prop_value() const {
|
||||
return prop_value;
|
||||
}
|
||||
|
||||
ExampleRuntime::ExampleRuntime() {
|
||||
}
|
||||
|
||||
ExampleRuntime::~ExampleRuntime() {
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <godot_cpp/variant/variant.hpp>
|
||||
|
||||
#include <godot_cpp/core/binder_common.hpp>
|
||||
#include <godot_cpp/core/gdvirtual.gen.inc>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
@@ -81,6 +82,9 @@ private:
|
||||
Vector2 dprop[3];
|
||||
int last_rpc_arg = 0;
|
||||
|
||||
const bool object_instance_binding_set_by_parent_constructor;
|
||||
bool has_object_instance_binding() const;
|
||||
|
||||
public:
|
||||
// Constants.
|
||||
enum Constants {
|
||||
@@ -119,6 +123,8 @@ public:
|
||||
void emit_custom_signal(const String &name, int value);
|
||||
int def_args(int p_a = 100, int p_b = 200);
|
||||
|
||||
bool is_object_binding_set_by_parent_constructor() const;
|
||||
|
||||
Array test_array() const;
|
||||
int test_tarray_arg(const TypedArray<int64_t> &p_array);
|
||||
TypedArray<Vector2> test_tarray() const;
|
||||
@@ -184,6 +190,10 @@ public:
|
||||
virtual bool _has_point(const Vector2 &point) const override;
|
||||
virtual void _input(const Ref<InputEvent> &event) override;
|
||||
|
||||
GDVIRTUAL2R(String, _do_something_virtual, String, int);
|
||||
String test_virtual_implemented_in_script(const String &p_name, int p_value);
|
||||
GDVIRTUAL1(_do_something_virtual_with_control, Control *);
|
||||
|
||||
String test_use_engine_singleton() const;
|
||||
|
||||
static String test_library_path();
|
||||
@@ -247,4 +257,20 @@ protected:
|
||||
void _notification(int p_what);
|
||||
};
|
||||
|
||||
class ExampleRuntime : public Node {
|
||||
GDCLASS(ExampleRuntime, Node);
|
||||
|
||||
int prop_value = 12;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_prop_value(int p_prop_value);
|
||||
int get_prop_value() const;
|
||||
|
||||
ExampleRuntime();
|
||||
~ExampleRuntime();
|
||||
};
|
||||
|
||||
#endif // EXAMPLE_CLASS_H
|
||||
|
||||
@@ -29,6 +29,7 @@ void initialize_example_module(ModuleInitializationLevel p_level) {
|
||||
GDREGISTER_CLASS(ExampleConcrete);
|
||||
GDREGISTER_CLASS(ExampleBase);
|
||||
GDREGISTER_CLASS(ExampleChild);
|
||||
GDREGISTER_RUNTIME_CLASS(ExampleRuntime);
|
||||
}
|
||||
|
||||
void uninitialize_example_module(ModuleInitializationLevel p_level) {
|
||||
|
||||
@@ -11,6 +11,11 @@ def options(opts):
|
||||
"Target Android API level",
|
||||
"21",
|
||||
)
|
||||
opts.Add(
|
||||
"ndk_version",
|
||||
"Fully qualified version of ndk to use for compilation.",
|
||||
"23.2.8568313",
|
||||
)
|
||||
opts.Add(
|
||||
"ANDROID_HOME",
|
||||
"Path to your Android SDK installation. By default, uses ANDROID_HOME from your defined environment variables.",
|
||||
@@ -22,14 +27,9 @@ def exists(env):
|
||||
return get_android_ndk_root(env) is not None
|
||||
|
||||
|
||||
# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58.
|
||||
def get_ndk_version():
|
||||
return "23.2.8568313"
|
||||
|
||||
|
||||
def get_android_ndk_root(env):
|
||||
if env["ANDROID_HOME"]:
|
||||
return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version()
|
||||
return env["ANDROID_HOME"] + "/ndk/" + env["ndk_version"]
|
||||
else:
|
||||
return os.environ.get("ANDROID_NDK_ROOT")
|
||||
|
||||
@@ -68,7 +68,7 @@ def generate(env):
|
||||
|
||||
if not os.path.exists(toolchain):
|
||||
print("ERROR: Could not find NDK toolchain at " + toolchain + ".")
|
||||
print("Make sure NDK version " + get_ndk_version() + " is installed.")
|
||||
print("Make sure NDK version " + env["ndk_version"] + " is installed.")
|
||||
env.Exit(1)
|
||||
|
||||
env.PrependENVPath("PATH", toolchain + "/bin") # This does nothing half of the time, but we'll put it here anyways
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
from SCons import __version__ as scons_raw_version
|
||||
from SCons.Action import Action
|
||||
from SCons.Builder import Builder
|
||||
from SCons.Errors import UserError
|
||||
@@ -153,6 +154,7 @@ def scons_generate_bindings(target, source, env):
|
||||
|
||||
_generate_bindings(
|
||||
api,
|
||||
str(source[0]),
|
||||
env["generate_template_get_node"],
|
||||
"32" if "32" in env["arch"] else "64",
|
||||
env["precision"],
|
||||
@@ -377,7 +379,54 @@ def options(opts, env):
|
||||
tool.options(opts)
|
||||
|
||||
|
||||
def make_doc_source(target, source, env):
|
||||
import zlib
|
||||
|
||||
dst = str(target[0])
|
||||
g = open(dst, "w", encoding="utf-8")
|
||||
buf = ""
|
||||
docbegin = ""
|
||||
docend = ""
|
||||
for src in source:
|
||||
src_path = str(src)
|
||||
if not src_path.endswith(".xml"):
|
||||
continue
|
||||
with open(src_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
buf += content
|
||||
|
||||
buf = (docbegin + buf + docend).encode("utf-8")
|
||||
decomp_size = len(buf)
|
||||
|
||||
# Use maximum zlib compression level to further reduce file size
|
||||
# (at the cost of initial build times).
|
||||
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)
|
||||
|
||||
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
||||
g.write("\n")
|
||||
g.write("#include <godot_cpp/godot.hpp>\n")
|
||||
g.write("\n")
|
||||
|
||||
g.write('static const char *_doc_data_hash = "' + str(hash(buf)) + '";\n')
|
||||
g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n")
|
||||
g.write("static const int _doc_data_compressed_size = " + str(len(buf)) + ";\n")
|
||||
g.write("static const unsigned char _doc_data_compressed[] = {\n")
|
||||
for i in range(len(buf)):
|
||||
g.write("\t" + str(buf[i]) + ",\n")
|
||||
g.write("};\n")
|
||||
g.write("\n")
|
||||
|
||||
g.write(
|
||||
"static godot::internal::DocDataRegistration _doc_data_registration(_doc_data_hash, _doc_data_uncompressed_size, _doc_data_compressed_size, _doc_data_compressed);\n"
|
||||
)
|
||||
g.write("\n")
|
||||
|
||||
g.close()
|
||||
|
||||
|
||||
def generate(env):
|
||||
env.scons_version = env._get_major_minor_revision(scons_raw_version)
|
||||
|
||||
# Default num_jobs to local cpu count if not user specified.
|
||||
# SCons has a peculiarity where user-specified options won't be overridden
|
||||
# by SetOption, so we can rely on this to know if we should use our default.
|
||||
@@ -435,6 +484,17 @@ 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)
|
||||
|
||||
@@ -508,7 +568,8 @@ def generate(env):
|
||||
# Builders
|
||||
env.Append(
|
||||
BUILDERS={
|
||||
"GodotCPPBindings": Builder(action=Action(scons_generate_bindings, "$GENCOMSTR"), emitter=scons_emit_files)
|
||||
"GodotCPPBindings": Builder(action=Action(scons_generate_bindings, "$GENCOMSTR"), emitter=scons_emit_files),
|
||||
"GodotCPPDocData": Builder(action=make_doc_source),
|
||||
}
|
||||
)
|
||||
env.AddMethod(_godot_cpp, "GodotCPP")
|
||||
|
||||
@@ -36,9 +36,11 @@ def generate(env):
|
||||
if env["ios_simulator"]:
|
||||
sdk_name = "iphonesimulator"
|
||||
env.Append(CCFLAGS=["-mios-simulator-version-min=" + env["ios_min_version"]])
|
||||
env.Append(LINKFLAGS=["-mios-simulator-version-min=" + env["ios_min_version"]])
|
||||
else:
|
||||
sdk_name = "iphoneos"
|
||||
env.Append(CCFLAGS=["-miphoneos-version-min=" + env["ios_min_version"]])
|
||||
env.Append(LINKFLAGS=["-miphoneos-version-min=" + env["ios_min_version"]])
|
||||
|
||||
if sys.platform == "darwin":
|
||||
if env["IOS_SDK_PATH"] == "":
|
||||
|
||||
@@ -42,6 +42,10 @@ def generate(env):
|
||||
env.Append(CCFLAGS=["-sSIDE_MODULE=1"])
|
||||
env.Append(LINKFLAGS=["-sSIDE_MODULE=1"])
|
||||
|
||||
# Enable WebAssembly BigInt <-> i64 conversion.
|
||||
# This must match the flag used to build Godot (true in official builds since 4.3)
|
||||
env.Append(LINKFLAGS=["-sWASM_BIGINT"])
|
||||
|
||||
# Force wasm longjmp mode.
|
||||
env.Append(CCFLAGS=["-sSUPPORT_LONGJMP='wasm'"])
|
||||
env.Append(LINKFLAGS=["-sSUPPORT_LONGJMP='wasm'"])
|
||||
|
||||
@@ -125,6 +125,11 @@ 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