Browse Source

Merge pull request #1744 from dsnopek/4.3-cherrypicks-4

Cherry-picks for the godot-cpp 4.3 branch - 4th batch
David Snopek 5 months ago
parent
commit
dcd0842fab

+ 1 - 1
.github/workflows/ci.yml

@@ -175,7 +175,7 @@ jobs:
           ./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 }}

+ 8 - 3
binding_generator.py

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

+ 0 - 4
include/godot_cpp/core/defs.hpp

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

+ 1 - 1
include/godot_cpp/variant/aabb.hpp

@@ -43,7 +43,7 @@ namespace godot {
 
 class Variant;
 
-struct _NO_DISCARD_ AABB {
+struct [[nodiscard]] AABB {
 	Vector3 position;
 	Vector3 size;
 

+ 1 - 1
include/godot_cpp/variant/basis.hpp

@@ -37,7 +37,7 @@
 
 namespace godot {
 
-struct _NO_DISCARD_ Basis {
+struct [[nodiscard]] Basis {
 	Vector3 rows[3] = {
 		Vector3(1, 0, 0),
 		Vector3(0, 1, 0),

+ 1 - 1
include/godot_cpp/variant/color.hpp

@@ -37,7 +37,7 @@ namespace godot {
 
 class String;
 
-struct _NO_DISCARD_ Color {
+struct [[nodiscard]] Color {
 	union {
 		struct {
 			float r;

+ 1 - 1
include/godot_cpp/variant/plane.hpp

@@ -38,7 +38,7 @@ namespace godot {
 
 class Variant;
 
-struct _NO_DISCARD_ Plane {
+struct [[nodiscard]] Plane {
 	Vector3 normal;
 	real_t d = 0;
 

+ 1 - 1
include/godot_cpp/variant/projection.hpp

@@ -44,7 +44,7 @@ struct Rect2;
 struct Transform3D;
 struct Vector2;
 
-struct _NO_DISCARD_ Projection {
+struct [[nodiscard]] Projection {
 	enum Planes {
 		PLANE_NEAR,
 		PLANE_FAR,

+ 1 - 1
include/godot_cpp/variant/quaternion.hpp

@@ -37,7 +37,7 @@
 
 namespace godot {
 
-struct _NO_DISCARD_ Quaternion {
+struct [[nodiscard]] Quaternion {
 	union {
 		struct {
 			real_t x;

+ 1 - 1
include/godot_cpp/variant/rect2.hpp

@@ -40,7 +40,7 @@ class String;
 struct Rect2i;
 struct Transform2D;
 
-struct _NO_DISCARD_ Rect2 {
+struct [[nodiscard]] Rect2 {
 	Point2 position;
 	Size2 size;
 

+ 1 - 1
include/godot_cpp/variant/rect2i.hpp

@@ -39,7 +39,7 @@ namespace godot {
 class String;
 struct Rect2;
 
-struct _NO_DISCARD_ Rect2i {
+struct [[nodiscard]] Rect2i {
 	Point2i position;
 	Size2i size;
 

+ 1 - 1
include/godot_cpp/variant/transform2d.hpp

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

+ 1 - 1
include/godot_cpp/variant/transform3d.hpp

@@ -39,7 +39,7 @@
 
 namespace godot {
 
-struct _NO_DISCARD_ Transform3D {
+struct [[nodiscard]] Transform3D {
 	Basis basis;
 	Vector3 origin;
 

+ 1 - 1
include/godot_cpp/variant/vector2.hpp

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

+ 1 - 1
include/godot_cpp/variant/vector2i.hpp

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

+ 1 - 1
include/godot_cpp/variant/vector3.hpp

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

+ 1 - 1
include/godot_cpp/variant/vector3i.hpp

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

+ 1 - 1
include/godot_cpp/variant/vector4.hpp

@@ -38,7 +38,7 @@ namespace godot {
 
 class String;
 
-struct _NO_DISCARD_ Vector4 {
+struct [[nodiscard]] Vector4 {
 	static const int AXIS_COUNT = 4;
 
 	enum Axis {

+ 1 - 1
include/godot_cpp/variant/vector4i.hpp

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

+ 1 - 0
misc/scripts/check_get_file_list.py

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

+ 1 - 0
tools/godotcpp.py

@@ -153,6 +153,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"],