Also added helper methods to variant for the other new types.

This commit is contained in:
Relintai 2023-05-31 01:52:24 +02:00
parent ea4ca1895c
commit fff4a84b47
4 changed files with 122 additions and 0 deletions

View File

@ -137,24 +137,60 @@ void GDAPI pandemonium_variant_new_string(pandemonium_variant *r_dest, const pan
memnew_placement_custom(dest, Variant, Variant(*s)); memnew_placement_custom(dest, Variant, Variant(*s));
} }
void GDAPI pandemonium_variant_new_string_name(pandemonium_variant *r_dest, const pandemonium_string_name *p_s) {
Variant *dest = (Variant *)r_dest;
StringName *s = (StringName *)p_s;
memnew_placement_custom(dest, Variant, Variant(*s));
}
void GDAPI pandemonium_variant_new_vector2(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2) { void GDAPI pandemonium_variant_new_vector2(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2) {
Variant *dest = (Variant *)r_dest; Variant *dest = (Variant *)r_dest;
Vector2 *v2 = (Vector2 *)p_v2; Vector2 *v2 = (Vector2 *)p_v2;
memnew_placement_custom(dest, Variant, Variant(*v2)); memnew_placement_custom(dest, Variant, Variant(*v2));
} }
void GDAPI pandemonium_variant_new_vector2i(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2i) {
Variant *dest = (Variant *)r_dest;
Vector2i *v2i = (Vector2i *)p_v2i;
memnew_placement_custom(dest, Variant, Variant(*v2i));
}
void GDAPI pandemonium_variant_new_rect2(pandemonium_variant *r_dest, const pandemonium_rect2 *p_rect2) { void GDAPI pandemonium_variant_new_rect2(pandemonium_variant *r_dest, const pandemonium_rect2 *p_rect2) {
Variant *dest = (Variant *)r_dest; Variant *dest = (Variant *)r_dest;
Rect2 *rect2 = (Rect2 *)p_rect2; Rect2 *rect2 = (Rect2 *)p_rect2;
memnew_placement_custom(dest, Variant, Variant(*rect2)); memnew_placement_custom(dest, Variant, Variant(*rect2));
} }
void GDAPI pandemonium_variant_new_rect2i(pandemonium_variant *r_dest, const pandemonium_rect2i *p_rect2i) {
Variant *dest = (Variant *)r_dest;
Rect2i *rect2i = (Rect2i *)p_rect2i;
memnew_placement_custom(dest, Variant, Variant(*rect2i));
}
void GDAPI pandemonium_variant_new_vector3(pandemonium_variant *r_dest, const pandemonium_vector3 *p_v3) { void GDAPI pandemonium_variant_new_vector3(pandemonium_variant *r_dest, const pandemonium_vector3 *p_v3) {
Variant *dest = (Variant *)r_dest; Variant *dest = (Variant *)r_dest;
Vector3 *v3 = (Vector3 *)p_v3; Vector3 *v3 = (Vector3 *)p_v3;
memnew_placement_custom(dest, Variant, Variant(*v3)); memnew_placement_custom(dest, Variant, Variant(*v3));
} }
void GDAPI pandemonium_variant_new_vector3i(pandemonium_variant *r_dest, const pandemonium_vector3i *p_v3i) {
Variant *dest = (Variant *)r_dest;
Vector3i *v3i = (Vector3i *)p_v3i;
memnew_placement_custom(dest, Variant, Variant(*v3i));
}
void GDAPI pandemonium_variant_new_vector4(pandemonium_variant *r_dest, const pandemonium_vector4 *p_v4) {
Variant *dest = (Variant *)r_dest;
Vector4 *v4 = (Vector4 *)p_v4;
memnew_placement_custom(dest, Variant, Variant(*v4));
}
void GDAPI pandemonium_variant_new_vector4i(pandemonium_variant *r_dest, const pandemonium_vector4i *p_v4i) {
Variant *dest = (Variant *)r_dest;
Vector4i *v4i = (Vector4i *)p_v4i;
memnew_placement_custom(dest, Variant, Variant(*v4i));
}
void GDAPI pandemonium_variant_new_transform2d(pandemonium_variant *r_dest, const pandemonium_transform2d *p_t2d) { void GDAPI pandemonium_variant_new_transform2d(pandemonium_variant *r_dest, const pandemonium_transform2d *p_t2d) {
Variant *dest = (Variant *)r_dest; Variant *dest = (Variant *)r_dest;
Transform2D *t2d = (Transform2D *)p_t2d; Transform2D *t2d = (Transform2D *)p_t2d;
@ -191,6 +227,12 @@ void GDAPI pandemonium_variant_new_transform(pandemonium_variant *r_dest, const
memnew_placement_custom(dest, Variant, Variant(*trans)); memnew_placement_custom(dest, Variant, Variant(*trans));
} }
void GDAPI pandemonium_variant_new_projection(pandemonium_variant *r_dest, const pandemonium_projection *p_proj) {
Variant *dest = (Variant *)r_dest;
Projection *proj = (Projection *)p_proj;
memnew_placement_custom(dest, Variant, Variant(*proj));
}
void GDAPI pandemonium_variant_new_color(pandemonium_variant *r_dest, const pandemonium_color *p_color) { void GDAPI pandemonium_variant_new_color(pandemonium_variant *r_dest, const pandemonium_color *p_color) {
Variant *dest = (Variant *)r_dest; Variant *dest = (Variant *)r_dest;
Color *color = (Color *)p_color; Color *color = (Color *)p_color;
@ -335,6 +377,14 @@ pandemonium_string GDAPI pandemonium_variant_as_string(const pandemonium_variant
return raw_dest; return raw_dest;
} }
pandemonium_string_name GDAPI pandemonium_variant_as_string_name(const pandemonium_variant *p_self) {
pandemonium_string_name raw_dest;
const Variant *self = (const Variant *)p_self;
StringName *dest = (StringName *)&raw_dest;
memnew_placement(dest, StringName(self->operator StringName())); // operator = is overloaded by String
return raw_dest;
}
pandemonium_vector2 GDAPI pandemonium_variant_as_vector2(const pandemonium_variant *p_self) { pandemonium_vector2 GDAPI pandemonium_variant_as_vector2(const pandemonium_variant *p_self) {
pandemonium_vector2 raw_dest; pandemonium_vector2 raw_dest;
const Variant *self = (const Variant *)p_self; const Variant *self = (const Variant *)p_self;
@ -343,6 +393,14 @@ pandemonium_vector2 GDAPI pandemonium_variant_as_vector2(const pandemonium_varia
return raw_dest; return raw_dest;
} }
pandemonium_vector2i GDAPI pandemonium_variant_as_vector2i(const pandemonium_variant *p_self) {
pandemonium_vector2i raw_dest;
const Variant *self = (const Variant *)p_self;
Vector2i *dest = (Vector2i *)&raw_dest;
*dest = *self;
return raw_dest;
}
pandemonium_rect2 GDAPI pandemonium_variant_as_rect2(const pandemonium_variant *p_self) { pandemonium_rect2 GDAPI pandemonium_variant_as_rect2(const pandemonium_variant *p_self) {
pandemonium_rect2 raw_dest; pandemonium_rect2 raw_dest;
const Variant *self = (const Variant *)p_self; const Variant *self = (const Variant *)p_self;
@ -351,6 +409,14 @@ pandemonium_rect2 GDAPI pandemonium_variant_as_rect2(const pandemonium_variant *
return raw_dest; return raw_dest;
} }
pandemonium_rect2i GDAPI pandemonium_variant_as_rect2i(const pandemonium_variant *p_self) {
pandemonium_rect2i raw_dest;
const Variant *self = (const Variant *)p_self;
Rect2i *dest = (Rect2i *)&raw_dest;
*dest = *self;
return raw_dest;
}
pandemonium_vector3 GDAPI pandemonium_variant_as_vector3(const pandemonium_variant *p_self) { pandemonium_vector3 GDAPI pandemonium_variant_as_vector3(const pandemonium_variant *p_self) {
pandemonium_vector3 raw_dest; pandemonium_vector3 raw_dest;
const Variant *self = (const Variant *)p_self; const Variant *self = (const Variant *)p_self;
@ -359,6 +425,30 @@ pandemonium_vector3 GDAPI pandemonium_variant_as_vector3(const pandemonium_varia
return raw_dest; return raw_dest;
} }
pandemonium_vector3i GDAPI pandemonium_variant_as_vector3i(const pandemonium_variant *p_self) {
pandemonium_vector3i raw_dest;
const Variant *self = (const Variant *)p_self;
Vector3i *dest = (Vector3i *)&raw_dest;
*dest = *self;
return raw_dest;
}
pandemonium_vector4 GDAPI pandemonium_variant_as_vector4(const pandemonium_variant *p_self) {
pandemonium_vector4 raw_dest;
const Variant *self = (const Variant *)p_self;
Vector4 *dest = (Vector4 *)&raw_dest;
*dest = *self;
return raw_dest;
}
pandemonium_vector4i GDAPI pandemonium_variant_as_vector4i(const pandemonium_variant *p_self) {
pandemonium_vector4i raw_dest;
const Variant *self = (const Variant *)p_self;
Vector4i *dest = (Vector4i *)&raw_dest;
*dest = *self;
return raw_dest;
}
pandemonium_transform2d GDAPI pandemonium_variant_as_transform2d(const pandemonium_variant *p_self) { pandemonium_transform2d GDAPI pandemonium_variant_as_transform2d(const pandemonium_variant *p_self) {
pandemonium_transform2d raw_dest; pandemonium_transform2d raw_dest;
const Variant *self = (const Variant *)p_self; const Variant *self = (const Variant *)p_self;
@ -407,6 +497,14 @@ pandemonium_transform GDAPI pandemonium_variant_as_transform(const pandemonium_v
return raw_dest; return raw_dest;
} }
pandemonium_projection GDAPI pandemonium_variant_as_projection(const pandemonium_variant *p_self) {
pandemonium_projection raw_dest;
const Variant *self = (const Variant *)p_self;
Projection *dest = (Projection *)&raw_dest;
*dest = *self;
return raw_dest;
}
pandemonium_color GDAPI pandemonium_variant_as_color(const pandemonium_variant *p_self) { pandemonium_color GDAPI pandemonium_variant_as_color(const pandemonium_variant *p_self) {
pandemonium_color raw_dest; pandemonium_color raw_dest;
const Variant *self = (const Variant *)p_self; const Variant *self = (const Variant *)p_self;

View File

@ -56,6 +56,8 @@ typedef struct {
#include <gdn/vector2.h> #include <gdn/vector2.h>
#include <gdn/vector3.h> #include <gdn/vector3.h>
#include <gdn/vector4.h> #include <gdn/vector4.h>
#include <gdn/rect2.h>
#include <gdn/transform.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -56,6 +56,7 @@ typedef struct {
#include <gdn/variant.h> #include <gdn/variant.h>
#include <gdn/vector3.h> #include <gdn/vector3.h>
#include <gdn/vector3i.h> #include <gdn/vector3i.h>
#include <gdn/quaternion.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -169,15 +169,22 @@ typedef enum pandemonium_variant_operator {
#include <gdn/node_path.h> #include <gdn/node_path.h>
#include <gdn/plane.h> #include <gdn/plane.h>
#include <gdn/pool_arrays.h> #include <gdn/pool_arrays.h>
#include <gdn/projection.h>
#include <gdn/quaternion.h> #include <gdn/quaternion.h>
#include <gdn/rect2.h> #include <gdn/rect2.h>
#include <gdn/rect2i.h>
#include <gdn/rid.h> #include <gdn/rid.h>
#include <gdn/string.h> #include <gdn/string.h>
#include <gdn/string_name.h>
#include <gdn/transform.h> #include <gdn/transform.h>
#include <gdn/transform2d.h> #include <gdn/transform2d.h>
#include <gdn/variant.h> #include <gdn/variant.h>
#include <gdn/vector2.h> #include <gdn/vector2.h>
#include <gdn/vector2i.h>
#include <gdn/vector3.h> #include <gdn/vector3.h>
#include <gdn/vector3i.h>
#include <gdn/vector4.h>
#include <gdn/vector4i.h>
#include <gdn/gdnative.h> #include <gdn/gdnative.h>
@ -267,15 +274,22 @@ uint64_t GDAPI pandemonium_variant_as_uint(const pandemonium_variant *p_self);
int64_t GDAPI pandemonium_variant_as_int(const pandemonium_variant *p_self); int64_t GDAPI pandemonium_variant_as_int(const pandemonium_variant *p_self);
double GDAPI pandemonium_variant_as_real(const pandemonium_variant *p_self); double GDAPI pandemonium_variant_as_real(const pandemonium_variant *p_self);
pandemonium_string GDAPI pandemonium_variant_as_string(const pandemonium_variant *p_self); pandemonium_string GDAPI pandemonium_variant_as_string(const pandemonium_variant *p_self);
pandemonium_string_name GDAPI pandemonium_variant_as_string_name(const pandemonium_variant *p_self);
pandemonium_vector2 GDAPI pandemonium_variant_as_vector2(const pandemonium_variant *p_self); pandemonium_vector2 GDAPI pandemonium_variant_as_vector2(const pandemonium_variant *p_self);
pandemonium_vector2i GDAPI pandemonium_variant_as_vector2i(const pandemonium_variant *p_self);
pandemonium_rect2 GDAPI pandemonium_variant_as_rect2(const pandemonium_variant *p_self); pandemonium_rect2 GDAPI pandemonium_variant_as_rect2(const pandemonium_variant *p_self);
pandemonium_rect2i GDAPI pandemonium_variant_as_rect2i(const pandemonium_variant *p_self);
pandemonium_vector3 GDAPI pandemonium_variant_as_vector3(const pandemonium_variant *p_self); pandemonium_vector3 GDAPI pandemonium_variant_as_vector3(const pandemonium_variant *p_self);
pandemonium_vector3i GDAPI pandemonium_variant_as_vector3i(const pandemonium_variant *p_self);
pandemonium_vector4 GDAPI pandemonium_variant_as_vector4(const pandemonium_variant *p_self);
pandemonium_vector4i GDAPI pandemonium_variant_as_vector4i(const pandemonium_variant *p_self);
pandemonium_transform2d GDAPI pandemonium_variant_as_transform2d(const pandemonium_variant *p_self); pandemonium_transform2d GDAPI pandemonium_variant_as_transform2d(const pandemonium_variant *p_self);
pandemonium_plane GDAPI pandemonium_variant_as_plane(const pandemonium_variant *p_self); pandemonium_plane GDAPI pandemonium_variant_as_plane(const pandemonium_variant *p_self);
pandemonium_quaternion GDAPI pandemonium_variant_as_quaternion(const pandemonium_variant *p_self); pandemonium_quaternion GDAPI pandemonium_variant_as_quaternion(const pandemonium_variant *p_self);
pandemonium_aabb GDAPI pandemonium_variant_as_aabb(const pandemonium_variant *p_self); pandemonium_aabb GDAPI pandemonium_variant_as_aabb(const pandemonium_variant *p_self);
pandemonium_basis GDAPI pandemonium_variant_as_basis(const pandemonium_variant *p_self); pandemonium_basis GDAPI pandemonium_variant_as_basis(const pandemonium_variant *p_self);
pandemonium_transform GDAPI pandemonium_variant_as_transform(const pandemonium_variant *p_self); pandemonium_transform GDAPI pandemonium_variant_as_transform(const pandemonium_variant *p_self);
pandemonium_projection GDAPI pandemonium_variant_as_projection(const pandemonium_variant *p_self);
pandemonium_color GDAPI pandemonium_variant_as_color(const pandemonium_variant *p_self); pandemonium_color GDAPI pandemonium_variant_as_color(const pandemonium_variant *p_self);
pandemonium_node_path GDAPI pandemonium_variant_as_node_path(const pandemonium_variant *p_self); pandemonium_node_path GDAPI pandemonium_variant_as_node_path(const pandemonium_variant *p_self);
pandemonium_rid GDAPI pandemonium_variant_as_rid(const pandemonium_variant *p_self); pandemonium_rid GDAPI pandemonium_variant_as_rid(const pandemonium_variant *p_self);
@ -302,15 +316,22 @@ void GDAPI pandemonium_variant_new_uint(pandemonium_variant *r_dest, const uint6
void GDAPI pandemonium_variant_new_int(pandemonium_variant *r_dest, const int64_t p_i); void GDAPI pandemonium_variant_new_int(pandemonium_variant *r_dest, const int64_t p_i);
void GDAPI pandemonium_variant_new_real(pandemonium_variant *r_dest, const double p_r); void GDAPI pandemonium_variant_new_real(pandemonium_variant *r_dest, const double p_r);
void GDAPI pandemonium_variant_new_string(pandemonium_variant *r_dest, const pandemonium_string *p_s); void GDAPI pandemonium_variant_new_string(pandemonium_variant *r_dest, const pandemonium_string *p_s);
void GDAPI pandemonium_variant_new_string_name(pandemonium_variant *r_dest, const pandemonium_string_name *p_s);
void GDAPI pandemonium_variant_new_vector2(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2); void GDAPI pandemonium_variant_new_vector2(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2);
void GDAPI pandemonium_variant_new_vector2i(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2i);
void GDAPI pandemonium_variant_new_rect2(pandemonium_variant *r_dest, const pandemonium_rect2 *p_rect2); void GDAPI pandemonium_variant_new_rect2(pandemonium_variant *r_dest, const pandemonium_rect2 *p_rect2);
void GDAPI pandemonium_variant_new_rect2i(pandemonium_variant *r_dest, const pandemonium_rect2i *p_rect2i);
void GDAPI pandemonium_variant_new_vector3(pandemonium_variant *r_dest, const pandemonium_vector3 *p_v3); void GDAPI pandemonium_variant_new_vector3(pandemonium_variant *r_dest, const pandemonium_vector3 *p_v3);
void GDAPI pandemonium_variant_new_vector3i(pandemonium_variant *r_dest, const pandemonium_vector3i *p_v3i);
void GDAPI pandemonium_variant_new_vector4(pandemonium_variant *r_dest, const pandemonium_vector4 *p_v4);
void GDAPI pandemonium_variant_new_vector4i(pandemonium_variant *r_dest, const pandemonium_vector4i *p_v4i);
void GDAPI pandemonium_variant_new_transform2d(pandemonium_variant *r_dest, const pandemonium_transform2d *p_t2d); void GDAPI pandemonium_variant_new_transform2d(pandemonium_variant *r_dest, const pandemonium_transform2d *p_t2d);
void GDAPI pandemonium_variant_new_plane(pandemonium_variant *r_dest, const pandemonium_plane *p_plane); void GDAPI pandemonium_variant_new_plane(pandemonium_variant *r_dest, const pandemonium_plane *p_plane);
void GDAPI pandemonium_variant_new_quaternion(pandemonium_variant *r_dest, const pandemonium_quaternion *p_quaternion); void GDAPI pandemonium_variant_new_quaternion(pandemonium_variant *r_dest, const pandemonium_quaternion *p_quaternion);
void GDAPI pandemonium_variant_new_aabb(pandemonium_variant *r_dest, const pandemonium_aabb *p_aabb); void GDAPI pandemonium_variant_new_aabb(pandemonium_variant *r_dest, const pandemonium_aabb *p_aabb);
void GDAPI pandemonium_variant_new_basis(pandemonium_variant *r_dest, const pandemonium_basis *p_basis); void GDAPI pandemonium_variant_new_basis(pandemonium_variant *r_dest, const pandemonium_basis *p_basis);
void GDAPI pandemonium_variant_new_transform(pandemonium_variant *r_dest, const pandemonium_transform *p_trans); void GDAPI pandemonium_variant_new_transform(pandemonium_variant *r_dest, const pandemonium_transform *p_trans);
void GDAPI pandemonium_variant_new_projection(pandemonium_variant *r_dest, const pandemonium_projection *p_proj);
void GDAPI pandemonium_variant_new_color(pandemonium_variant *r_dest, const pandemonium_color *p_color); void GDAPI pandemonium_variant_new_color(pandemonium_variant *r_dest, const pandemonium_color *p_color);
void GDAPI pandemonium_variant_new_node_path(pandemonium_variant *r_dest, const pandemonium_node_path *p_np); void GDAPI pandemonium_variant_new_node_path(pandemonium_variant *r_dest, const pandemonium_node_path *p_np);
void GDAPI pandemonium_variant_new_rid(pandemonium_variant *r_dest, const pandemonium_rid *p_rid); void GDAPI pandemonium_variant_new_rid(pandemonium_variant *r_dest, const pandemonium_rid *p_rid);