Merge pull request #38799 from bruvzg/gdnative_size_fix_3
[3.2] Fix GDNative Variant type size, add size checks.
This commit is contained in:
commit
43bf8e27b6
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch");
|
||||
|
||||
void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) {
|
||||
const Vector3 *pos = (const Vector3 *)p_pos;
|
||||
const Vector3 *size = (const Vector3 *)p_size;
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch");
|
||||
|
||||
void GDAPI godot_array_new(godot_array *r_dest) {
|
||||
Array *dest = (Array *)r_dest;
|
||||
memnew_placement(dest, Array);
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch");
|
||||
|
||||
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis) {
|
||||
const Vector3 *x_axis = (const Vector3 *)p_x_axis;
|
||||
const Vector3 *y_axis = (const Vector3 *)p_y_axis;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch");
|
||||
|
||||
void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a) {
|
||||
|
||||
Color *dest = (Color *)r_dest;
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch");
|
||||
|
||||
void GDAPI godot_dictionary_new(godot_dictionary *r_dest) {
|
||||
Dictionary *dest = (Dictionary *)r_dest;
|
||||
memnew_placement(dest, Dictionary);
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch");
|
||||
|
||||
void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from) {
|
||||
NodePath *dest = (NodePath *)r_dest;
|
||||
const String *from = (const String *)p_from;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch");
|
||||
|
||||
void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d) {
|
||||
|
||||
Plane *dest = (Plane *)r_dest;
|
||||
|
|
|
@ -42,6 +42,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_pool_byte_array) == sizeof(PoolVector<uint8_t>), "PoolVector<uint8_t> size mismatch");
|
||||
static_assert(sizeof(godot_pool_int_array) == sizeof(PoolVector<godot_int>), "PoolVector<godot_int> size mismatch");
|
||||
static_assert(sizeof(godot_pool_real_array) == sizeof(PoolVector<godot_real>), "PoolVector<godot_real> size mismatch");
|
||||
static_assert(sizeof(godot_pool_string_array) == sizeof(PoolVector<String>), "PoolVector<String> size mismatch");
|
||||
static_assert(sizeof(godot_pool_vector2_array) == sizeof(PoolVector<Vector2>), "PoolVector<Vector2> size mismatch");
|
||||
static_assert(sizeof(godot_pool_vector3_array) == sizeof(PoolVector<Vector3>), "PoolVector<Vector3> size mismatch");
|
||||
static_assert(sizeof(godot_pool_color_array) == sizeof(PoolVector<Color>), "PoolVector<Color> size mismatch");
|
||||
|
||||
#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
|
||||
|
||||
// byte
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_quat) == sizeof(Quat), "Quat size mismatch");
|
||||
|
||||
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w) {
|
||||
|
||||
Quat *dest = (Quat *)r_dest;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_rect2) == sizeof(Rect2), "Rect2 size mismatch");
|
||||
|
||||
void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size) {
|
||||
const Vector2 *position = (const Vector2 *)p_pos;
|
||||
const Vector2 *size = (const Vector2 *)p_size;
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch");
|
||||
|
||||
void GDAPI godot_rid_new(godot_rid *r_dest) {
|
||||
RID *dest = (RID *)r_dest;
|
||||
memnew_placement(dest, RID);
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_char_string) == sizeof(CharString), "CharString size mismatch");
|
||||
static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch");
|
||||
static_assert(sizeof(godot_char_type) == sizeof(CharType), "CharType size mismatch");
|
||||
|
||||
godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) {
|
||||
const CharString *cs = (const CharString *)p_cs;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch");
|
||||
|
||||
void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name) {
|
||||
StringName *dest = (StringName *)r_dest;
|
||||
const String *name = (const String *)p_name;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_transform) == sizeof(Transform), "Transform size mismatch");
|
||||
|
||||
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin) {
|
||||
const Vector3 *x_axis = (const Vector3 *)p_x_axis;
|
||||
const Vector3 *y_axis = (const Vector3 *)p_y_axis;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch");
|
||||
|
||||
void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos) {
|
||||
const Vector2 *pos = (const Vector2 *)p_pos;
|
||||
Transform2D *dest = (Transform2D *)r_dest;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch");
|
||||
|
||||
// Workaround GCC ICE on armv7hl which was affected GCC 6.0 up to 8.0 (GH-16100).
|
||||
// It was fixed upstream in 8.1, and a fix was backported to 7.4.
|
||||
// This can be removed once no supported distro ships with versions older than 7.4.
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_vector2) == sizeof(Vector2), "Vector2 size mismatch");
|
||||
|
||||
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) {
|
||||
|
||||
Vector2 *dest = (Vector2 *)r_dest;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(godot_vector3) == sizeof(Vector3), "Vector3 size mismatch");
|
||||
|
||||
void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z) {
|
||||
|
||||
Vector3 *dest = (Vector3 *)r_dest;
|
||||
|
|
|
@ -37,7 +37,7 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define GODOT_VARIANT_SIZE (16 + sizeof(void *))
|
||||
#define GODOT_VARIANT_SIZE (16 + sizeof(int64_t))
|
||||
|
||||
#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
|
||||
#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
|
||||
|
|
Loading…
Reference in New Issue