Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ MAKE_TYPED_ARRAY does not include newer Variant types #87991

Closed
allenwp opened this issue Feb 5, 2024 · 2 comments · Fixed by #87992 or godotengine/godot-cpp#1384
Closed

C++ MAKE_TYPED_ARRAY does not include newer Variant types #87991

allenwp opened this issue Feb 5, 2024 · 2 comments · Fixed by #87992 or godotengine/godot-cpp#1384
Milestone

Comments

@allenwp
Copy link
Contributor

allenwp commented Feb 5, 2024

Tested versions

4.2.1 tag, current master ( d335281 )

System information

N/A

Issue description

typed_array.h has a number of lines that use the MAKE_TYPED_ARRAY macro for almost all Variant types. This was introduced back in 2020. But when the VECTOR4, VECTOR4I, and PROJECTION types were added, it seems that this list was never updated to include them.

MAKE_TYPED_ARRAY(bool, Variant::BOOL)
MAKE_TYPED_ARRAY(uint8_t, Variant::INT)
MAKE_TYPED_ARRAY(int8_t, Variant::INT)
MAKE_TYPED_ARRAY(uint16_t, Variant::INT)
MAKE_TYPED_ARRAY(int16_t, Variant::INT)
MAKE_TYPED_ARRAY(uint32_t, Variant::INT)
MAKE_TYPED_ARRAY(int32_t, Variant::INT)
MAKE_TYPED_ARRAY(uint64_t, Variant::INT)
MAKE_TYPED_ARRAY(int64_t, Variant::INT)
MAKE_TYPED_ARRAY(float, Variant::FLOAT)
MAKE_TYPED_ARRAY(double, Variant::FLOAT)
MAKE_TYPED_ARRAY(String, Variant::STRING)
MAKE_TYPED_ARRAY(Vector2, Variant::VECTOR2)
MAKE_TYPED_ARRAY(Vector2i, Variant::VECTOR2I)
MAKE_TYPED_ARRAY(Rect2, Variant::RECT2)
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(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(Color, Variant::COLOR)
MAKE_TYPED_ARRAY(StringName, Variant::STRING_NAME)
MAKE_TYPED_ARRAY(NodePath, Variant::NODE_PATH)
MAKE_TYPED_ARRAY(RID, Variant::RID)
MAKE_TYPED_ARRAY(Callable, Variant::CALLABLE)
MAKE_TYPED_ARRAY(Signal, Variant::SIGNAL)
MAKE_TYPED_ARRAY(Dictionary, Variant::DICTIONARY)
MAKE_TYPED_ARRAY(Array, Variant::ARRAY)
MAKE_TYPED_ARRAY(Vector<uint8_t>, Variant::PACKED_BYTE_ARRAY)
MAKE_TYPED_ARRAY(Vector<int32_t>, Variant::PACKED_INT32_ARRAY)
MAKE_TYPED_ARRAY(Vector<int64_t>, Variant::PACKED_INT64_ARRAY)
MAKE_TYPED_ARRAY(Vector<float>, Variant::PACKED_FLOAT32_ARRAY)
MAKE_TYPED_ARRAY(Vector<double>, Variant::PACKED_FLOAT64_ARRAY)
MAKE_TYPED_ARRAY(Vector<String>, Variant::PACKED_STRING_ARRAY)
MAKE_TYPED_ARRAY(Vector<Vector2>, Variant::PACKED_VECTOR2_ARRAY)
MAKE_TYPED_ARRAY(Vector<Vector3>, Variant::PACKED_VECTOR3_ARRAY)
MAKE_TYPED_ARRAY(Vector<Color>, Variant::PACKED_COLOR_ARRAY)
MAKE_TYPED_ARRAY(IPAddress, Variant::STRING)

This means that it is not possible to write something like this:

TypedArray<Vector4>

...even though it is possible to write this:

TypedArray<Vector3>

I also noticed that the OBJECT type was never included in this list. I can only presume this was an intentional omission...?

Steps to reproduce

Try to compile TypedArray<Vector4> my_array;. Note that this results in this compile error: typed_array.hpp(53): error C2039: 'get_class_static': is not a member of 'godot::Vector4'

Minimal reproduction project (MRP)

N/A

@AThousandShips
Copy link
Member

Object is by design, as without a dedicated declaration it solves it by the get_class_static method that it fails with there

@allenwp
Copy link
Contributor Author

allenwp commented Feb 5, 2024

Object is by design, as without a dedicated declaration it solves it by the get_class_static method that it fails with there

Ah, thanks for the explanation!

allenwp added a commit to allenwp/godot-cpp that referenced this issue Feb 6, 2024
allenwp added a commit to allenwp/godot-cpp that referenced this issue Feb 6, 2024
allenwp added a commit to allenwp/godot-cpp that referenced this issue Feb 6, 2024
allenwp added a commit to allenwp/godot-cpp that referenced this issue Feb 6, 2024
This is a companion commit to the godot PR godotengine/godot#87992 which fixes godotengine/godot#87991
Also syncs up change from godot to undefine typed array templates after use.
allenwp added a commit to allenwp/godot-cpp that referenced this issue Feb 6, 2024
This is a companion commit to the godot PR godotengine/godot#87992 which fixes godotengine/godot#87991
Also undefines typed array templates after use to match Godot's typed_array.h
@akien-mga akien-mga added this to the 4.3 milestone Feb 7, 2024
enetheru pushed a commit to enetheru/godot-cpp that referenced this issue Mar 12, 2024
This is a companion commit to the godot PR godotengine/godot#87992 which fixes godotengine/godot#87991
Also undefines typed array templates after use to match Godot's typed_array.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants