Compare commits

...

14 Commits

Author SHA1 Message Date
K. S. Ernest (iFire) Lee a79acc3d6d
Merge 5cf329a8dc into 0ddef6ed96 2024-01-15 14:55:55 +08:00
Rémi Verschelde 0ddef6ed96
Merge pull request #1354 from nightblade9/patch-1
Update README.md with basic pre-requisites
2024-01-11 13:11:30 +01:00
Rémi Verschelde 64529361b4
Merge pull request #1351 from Daylily-Zeleen/daylily-zeleen/remove_namespace_in_global_constants_binding
Remove "godot" namespace when binding global constants.
2024-01-11 13:10:51 +01:00
Rémi Verschelde edf1637c2c
Merge pull request #1349 from AThousandShips/op_fix
Add missing `OP_POWER` operator to `Variant`
2024-01-11 13:10:07 +01:00
nightblade9 ee169b201b Update README.md with basic pre-requisites 2024-01-10 15:29:23 -05:00
Daylily-Zeleen bd40a94424 Remove "godot" namespace when binding global constants. 2024-01-07 15:24:02 +08:00
A Thousand Ships f037a697eb
Add missing `OP_POWER` operator to `Variant` 2024-01-06 21:12:52 +01:00
David Snopek dd62b9685f
Merge pull request #1347 from Chubercik/vector_method_parity
Add `Vector2i/3i/4i` methods: `distance_to` and `distance_squared_to`
2024-01-04 08:36:30 -06:00
David Snopek 8d13acca91
Merge pull request #1346 from AThousandShips/arg_fix
Fix expected argument count for call errors
2024-01-04 08:35:46 -06:00
David Snopek b1769a70f0
Merge pull request #1344 from ArchLinus/ndk-error
Add an error message if android NDK is not installed
2024-01-04 08:35:18 -06:00
Jakub Mateusz Marcowski b733102f4a Add `Vector2i/3i/4i` methods: `distance_to` and `distance_squared_to` 2024-01-03 11:45:05 +01:00
ArchLinus 718d0baea3 Add an error message if android NDK is not installed 2023-12-30 13:56:46 -05:00
A Thousand Ships b77cb648c3 Fix expected argument count for call errors 2023-12-30 13:23:36 +01:00
K. S. Ernest (iFire) Lee 5cf329a8dc Support llvm-mingw. 2023-07-08 16:12:12 -07:00
10 changed files with 70 additions and 26 deletions

View File

@ -74,7 +74,10 @@ so formatting is done before your changes are submitted.
## Getting started ## Getting started
It's a bit similar to what it was for 3.x but also a bit different. You need the same C++ pre-requisites installed that are required for the `godot` repository. Follow the [official build instructions for your target platform](https://docs.godotengine.org/en/latest/contributing/development/compiling/index.html#building-for-target-platforms).
Getting started with GDExtensions is a bit similar to what it was for 3.x but also a bit different.
This new approach is much more akin to how core Godot modules are structured. This new approach is much more akin to how core Godot modules are structured.
Compiling this repository generates a static library to be linked with your shared lib, Compiling this repository generates a static library to be linked with your shared lib,

View File

@ -1778,9 +1778,9 @@ def generate_global_constant_binds(api, output_dir):
continue continue
if enum_def["is_bitfield"]: if enum_def["is_bitfield"]:
header.append(f'VARIANT_BITFIELD_CAST(godot::{enum_def["name"]});') header.append(f'VARIANT_BITFIELD_CAST({enum_def["name"]});')
else: else:
header.append(f'VARIANT_ENUM_CAST(godot::{enum_def["name"]});') header.append(f'VARIANT_ENUM_CAST({enum_def["name"]});')
# Variant::Type is not a global enum, but only one line, it is worth to place in this file instead of creating new file. # Variant::Type is not a global enum, but only one line, it is worth to place in this file instead of creating new file.
header.append(f"VARIANT_ENUM_CAST(godot::Variant::Type);") header.append(f"VARIANT_ENUM_CAST(godot::Variant::Type);")
@ -2433,6 +2433,7 @@ def get_operator_id_name(op):
"unary-": "negate", "unary-": "negate",
"unary+": "positive", "unary+": "positive",
"%": "module", "%": "module",
"**": "power",
"<<": "shift_left", "<<": "shift_left",
">>": "shift_right", ">>": "shift_right",
"&": "bit_and", "&": "bit_and",

View File

@ -281,13 +281,13 @@ void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Vari
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
if ((size_t)p_argcount < sizeof...(P)) { if ((size_t)p_argcount < sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -299,13 +299,13 @@ void call_with_variant_args_ret(T *p_instance, R (T::*p_method)(P...), const Var
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
if ((size_t)p_argcount < sizeof...(P)) { if ((size_t)p_argcount < sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -317,13 +317,13 @@ void call_with_variant_args_retc(T *p_instance, R (T::*p_method)(P...) const, co
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
if ((size_t)p_argcount < sizeof...(P)) { if ((size_t)p_argcount < sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -335,7 +335,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -346,7 +346,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (missing > dvs) { if (missing > dvs) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -370,7 +370,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -381,7 +381,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (missing > dvs) { if (missing > dvs) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -405,7 +405,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -416,7 +416,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (missing > dvs) { if (missing > dvs) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -440,7 +440,7 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -451,7 +451,7 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (missing > dvs) { if (missing > dvs) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -552,7 +552,7 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const GDExtensionC
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = sizeof...(P); r_error.expected = sizeof...(P);
return; return;
} }
#endif #endif
@ -563,7 +563,7 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const GDExtensionC
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (missing > dvs) { if (missing > dvs) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = sizeof...(P); r_error.expected = sizeof...(P);
return; return;
} }
#endif #endif
@ -597,13 +597,13 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
if ((size_t)p_argcount < sizeof...(P)) { if ((size_t)p_argcount < sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -615,13 +615,13 @@ void call_with_variant_args_static_ret(void (*p_method)(P...), const Variant **p
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
if ((size_t)p_argcount < sizeof...(P)) { if ((size_t)p_argcount < sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = (int32_t)sizeof...(P); r_error.expected = (int32_t)sizeof...(P);
return; return;
} }
#endif #endif
@ -644,7 +644,7 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDExtension
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = sizeof...(P); r_error.expected = sizeof...(P);
return; return;
} }
#endif #endif
@ -655,7 +655,7 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDExtension
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (missing > dvs) { if (missing > dvs) {
r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.error = GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = sizeof...(P); r_error.expected = sizeof...(P);
return; return;
} }
#endif #endif

View File

@ -38,7 +38,7 @@
#if !defined(GDE_EXPORT) #if !defined(GDE_EXPORT)
#if defined(_WIN32) #if defined(_WIN32)
#define GDE_EXPORT __declspec(dllexport) #define GDE_EXPORT __declspec(dllexport)
#elif defined(__GNUC__) #elif defined(__GNUC__) && !defined(__MINGW32__)
#define GDE_EXPORT __attribute__((visibility("default"))) #define GDE_EXPORT __attribute__((visibility("default")))
#else #else
#define GDE_EXPORT #define GDE_EXPORT

View File

@ -122,6 +122,7 @@ public:
OP_NEGATE, OP_NEGATE,
OP_POSITIVE, OP_POSITIVE,
OP_MODULE, OP_MODULE,
OP_POWER,
// bitwise // bitwise
OP_SHIFT_LEFT, OP_SHIFT_LEFT,
OP_SHIFT_RIGHT, OP_SHIFT_RIGHT,

View File

@ -117,6 +117,9 @@ struct _NO_DISCARD_ Vector2i {
int64_t length_squared() const; int64_t length_squared() const;
double length() 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; } real_t aspect() const { return width / (real_t)height; }
Vector2i sign() const { return Vector2i(SIGN(x), SIGN(y)); } Vector2i sign() const { return Vector2i(SIGN(x), SIGN(y)); }
Vector2i abs() const { return Vector2i(Math::abs(x), Math::abs(y)); } Vector2i abs() const { return Vector2i(Math::abs(x), Math::abs(y)); }

View File

@ -82,6 +82,9 @@ struct _NO_DISCARD_ Vector3i {
_FORCE_INLINE_ int64_t length_squared() const; _FORCE_INLINE_ int64_t length_squared() const;
_FORCE_INLINE_ double length() 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_ void zero();
_FORCE_INLINE_ Vector3i abs() const; _FORCE_INLINE_ Vector3i abs() const;
@ -136,6 +139,14 @@ double Vector3i::length() const {
return Math::sqrt((double)length_squared()); 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 { Vector3i Vector3i::abs() const {
return Vector3i(Math::abs(x), Math::abs(y), Math::abs(z)); return Vector3i(Math::abs(x), Math::abs(y), Math::abs(z));
} }

View File

@ -84,6 +84,9 @@ struct _NO_DISCARD_ Vector4i {
_FORCE_INLINE_ int64_t length_squared() const; _FORCE_INLINE_ int64_t length_squared() const;
_FORCE_INLINE_ double length() 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_ void zero();
_FORCE_INLINE_ Vector4i abs() const; _FORCE_INLINE_ Vector4i abs() const;
@ -140,6 +143,14 @@ double Vector4i::length() const {
return Math::sqrt((double)length_squared()); 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 { Vector4i Vector4i::abs() const {
return Vector4i(Math::abs(x), Math::abs(y), Math::abs(z), Math::abs(w)); return Vector4i(Math::abs(x), Math::abs(y), Math::abs(z), Math::abs(w));
} }

View File

@ -49,6 +49,14 @@ double Vector2i::length() const {
return Math::sqrt((double)length_squared()); 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 { Vector2i Vector2i::operator+(const Vector2i &p_v) const {
return Vector2i(x + p_v.x, y + p_v.y); return Vector2i(x + p_v.x, y + p_v.y);
} }

View File

@ -64,6 +64,12 @@ def generate(env):
elif sys.platform == "darwin": elif sys.platform == "darwin":
toolchain += "darwin-x86_64" toolchain += "darwin-x86_64"
env.Append(LINKFLAGS=["-shared"]) env.Append(LINKFLAGS=["-shared"])
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.")
env.Exit(1)
env.PrependENVPath("PATH", toolchain + "/bin") # This does nothing half of the time, but we'll put it here anyways env.PrependENVPath("PATH", toolchain + "/bin") # This does nothing half of the time, but we'll put it here anyways
# Get architecture info # Get architecture info