2017-04-09 19:07:53 +00:00
|
|
|
/*************************************************************************/
|
2017-07-13 23:44:14 +00:00
|
|
|
/* variant.cpp */
|
2017-04-09 19:07:53 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2017-04-09 19:07:53 +00:00
|
|
|
/*************************************************************************/
|
2021-01-01 19:13:46 +00:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-04-09 19:07:53 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2017-09-03 10:40:41 +00:00
|
|
|
#include "gdnative/variant.h"
|
2017-08-02 00:46:45 +00:00
|
|
|
|
2017-08-19 12:41:11 +00:00
|
|
|
#include "core/reference.h"
|
2017-04-17 19:42:11 +00:00
|
|
|
#include "core/variant.h"
|
2017-04-03 14:11:38 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-05-17 13:11:49 +00:00
|
|
|
static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch");
|
|
|
|
|
2019-01-26 13:37:36 +00:00
|
|
|
// 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.
|
|
|
|
#if defined(__arm__) && defined(__GNUC__) && !defined(__clang__) && \
|
|
|
|
(__GNUC__ == 6 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) || (__GNUC__ == 8 && __GNUC_MINOR__ < 1))
|
|
|
|
#pragma GCC push_options
|
|
|
|
#pragma GCC optimize("-O0")
|
|
|
|
#endif
|
|
|
|
|
2017-04-03 14:11:38 +00:00
|
|
|
#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
|
|
|
|
|
2019-01-26 13:37:36 +00:00
|
|
|
#if defined(__arm__) && defined(__GNUC__) && !defined(__clang__) && \
|
|
|
|
(__GNUC__ == 6 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) || (__GNUC__ == 8 && __GNUC_MINOR__ < 1))
|
|
|
|
#pragma GCC pop_options
|
|
|
|
#endif
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
// Constructors
|
|
|
|
|
|
|
|
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
return (godot_variant_type)self->get_type();
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-05-20 13:52:56 +00:00
|
|
|
void GDAPI godot_variant_new_copy(godot_variant *p_dest, const godot_variant *p_src) {
|
2017-04-03 14:11:38 +00:00
|
|
|
Variant *dest = (Variant *)p_dest;
|
|
|
|
Variant *src = (Variant *)p_src;
|
2017-05-20 13:52:56 +00:00
|
|
|
memnew_placement(dest, Variant(*src));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_nil(godot_variant *r_dest) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
|
|
|
memnew_placement(dest, Variant);
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(p_b));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(p_i));
|
2017-04-04 17:38:46 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(p_i));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(p_r));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
String *s = (String *)p_s;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*s));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Vector2 *v2 = (Vector2 *)p_v2;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*v2));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Rect2 *rect2 = (Rect2 *)p_rect2;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*rect2));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Vector3 *v3 = (Vector3 *)p_v3;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*v3));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Transform2D *t2d = (Transform2D *)p_t2d;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*t2d));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Plane *plane = (Plane *)p_plane;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*plane));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Quat *quat = (Quat *)p_quat;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*quat));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 02:09:00 +00:00
|
|
|
void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) {
|
2017-04-17 19:42:11 +00:00
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB *aabb = (AABB *)p_aabb;
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(*aabb));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Basis *basis = (Basis *)p_basis;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*basis));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Transform *trans = (Transform *)p_trans;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*trans));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Color *color = (Color *)p_color;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*color));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
NodePath *np = (NodePath *)p_np;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*np));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
RID *rid = (RID *)p_rid;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*rid));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Object *obj = (Object *)p_obj;
|
2017-08-19 12:41:11 +00:00
|
|
|
Reference *reference = Object::cast_to<Reference>(obj);
|
|
|
|
REF ref;
|
|
|
|
if (reference) {
|
|
|
|
ref = REF(reference);
|
|
|
|
}
|
|
|
|
if (!ref.is_null()) {
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(ref.get_ref_ptr()));
|
|
|
|
} else {
|
|
|
|
#if defined(DEBUG_METHODS_ENABLED)
|
|
|
|
if (reference) {
|
|
|
|
ERR_PRINT("Reference object has 0 refcount in godot_variant_new_object - you lost it somewhere.");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(obj));
|
|
|
|
}
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Dictionary *dict = (Dictionary *)p_dict;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*dict));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
Array *arr = (Array *)p_arr;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*arr));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolByteArray *pba = (PoolByteArray *)p_pba;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*pba));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolIntArray *pia = (PoolIntArray *)p_pia;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*pia));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolRealArray *pra = (PoolRealArray *)p_pra;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*pra));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolStringArray *psa = (PoolStringArray *)p_psa;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*psa));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolVector2Array *pv2a = (PoolVector2Array *)p_pv2a;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*pv2a));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolVector3Array *pv3a = (PoolVector3Array *)p_pv3a;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*pv3a));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca) {
|
|
|
|
Variant *dest = (Variant *)r_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
PoolColorArray *pca = (PoolColorArray *)p_pca;
|
2017-04-17 19:42:11 +00:00
|
|
|
memnew_placement_custom(dest, Variant, Variant(*pca));
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
return self->operator bool();
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
return self->operator uint64_t();
|
2017-04-04 17:38:46 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
int64_t GDAPI godot_variant_as_int(const godot_variant *p_self) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
return self->operator int64_t();
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
double GDAPI godot_variant_as_real(const godot_variant *p_self) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
return self->operator double();
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_string GDAPI godot_variant_as_string(const godot_variant *p_self) {
|
|
|
|
godot_string raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
String *dest = (String *)&raw_dest;
|
|
|
|
memnew_placement(dest, String(self->operator String())); // operator = is overloaded by String
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self) {
|
|
|
|
godot_vector2 raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Vector2 *dest = (Vector2 *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self) {
|
|
|
|
godot_rect2 raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Rect2 *dest = (Rect2 *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self) {
|
|
|
|
godot_vector3 raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Vector3 *dest = (Vector3 *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self) {
|
|
|
|
godot_transform2d raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Transform2D *dest = (Transform2D *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self) {
|
|
|
|
godot_plane raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Plane *dest = (Plane *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) {
|
|
|
|
godot_quat raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Quat *dest = (Quat *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 02:09:00 +00:00
|
|
|
godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self) {
|
|
|
|
godot_aabb raw_dest;
|
2017-04-17 19:42:11 +00:00
|
|
|
const Variant *self = (const Variant *)p_self;
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB *dest = (AABB *)&raw_dest;
|
2017-04-17 19:42:11 +00:00
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self) {
|
|
|
|
godot_basis raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Basis *dest = (Basis *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self) {
|
|
|
|
godot_transform raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Transform *dest = (Transform *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_color GDAPI godot_variant_as_color(const godot_variant *p_self) {
|
|
|
|
godot_color raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Color *dest = (Color *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self) {
|
|
|
|
godot_node_path raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
NodePath *dest = (NodePath *)&raw_dest;
|
|
|
|
memnew_placement(dest, NodePath(self->operator NodePath())); // operator = is overloaded by NodePath
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self) {
|
|
|
|
godot_rid raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
RID *dest = (RID *)&raw_dest;
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Object *dest;
|
|
|
|
dest = *self;
|
|
|
|
return (godot_object *)dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self) {
|
|
|
|
godot_dictionary raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Dictionary *dest = (Dictionary *)&raw_dest;
|
|
|
|
memnew_placement(dest, Dictionary(self->operator Dictionary())); // operator = is overloaded by Dictionary
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_array GDAPI godot_variant_as_array(const godot_variant *p_self) {
|
|
|
|
godot_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
Array *dest = (Array *)&raw_dest;
|
|
|
|
memnew_placement(dest, Array(self->operator Array())); // operator = is overloaded by Array
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_byte_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolByteArray *dest = (PoolByteArray *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolByteArray(self->operator PoolByteArray())); // operator = is overloaded by PoolByteArray
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_int_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolIntArray *dest = (PoolIntArray *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolIntArray(self->operator PoolIntArray())); // operator = is overloaded by PoolIntArray
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_real_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolRealArray *dest = (PoolRealArray *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolRealArray(self->operator PoolRealArray())); // operator = is overloaded by PoolRealArray
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
2017-05-11 21:06:11 +00:00
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_string_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolStringArray *dest = (PoolStringArray *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolStringArray(self->operator PoolStringArray())); // operator = is overloaded by PoolStringArray
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
2017-05-11 21:06:11 +00:00
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_vector2_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolVector2Array *dest = (PoolVector2Array *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolVector2Array(self->operator PoolVector2Array())); // operator = is overloaded by PoolVector2Array
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_vector3_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolVector3Array *dest = (PoolVector3Array *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolVector3Array(self->operator PoolVector3Array())); // operator = is overloaded by PoolVector3Array
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self) {
|
|
|
|
godot_pool_color_array raw_dest;
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
PoolColorArray *dest = (PoolColorArray *)&raw_dest;
|
|
|
|
memnew_placement(dest, PoolColorArray(self->operator PoolColorArray())); // operator = is overloaded by PoolColorArray
|
|
|
|
*dest = *self;
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error) {
|
|
|
|
Variant *self = (Variant *)p_self;
|
|
|
|
String *method = (String *)p_method;
|
|
|
|
const Variant **args = (const Variant **)p_args;
|
|
|
|
godot_variant raw_dest;
|
|
|
|
Variant *dest = (Variant *)&raw_dest;
|
|
|
|
Variant::CallError error;
|
|
|
|
memnew_placement_custom(dest, Variant, Variant(self->call(*method, args, p_argcount, error)));
|
|
|
|
if (r_error) {
|
|
|
|
r_error->error = (godot_variant_call_error_error)error.error;
|
|
|
|
r_error->argument = error.argument;
|
|
|
|
r_error->expected = (godot_variant_type)error.expected;
|
2017-05-11 21:06:11 +00:00
|
|
|
}
|
2017-04-17 19:42:11 +00:00
|
|
|
return raw_dest;
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
const String *method = (const String *)p_method;
|
|
|
|
return self->has_method(*method);
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
const Variant *other = (const Variant *)p_other;
|
|
|
|
return self->operator==(*other);
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
const Variant *other = (const Variant *)p_other;
|
|
|
|
return self->operator<(*other);
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other) {
|
|
|
|
const Variant *self = (const Variant *)p_self;
|
|
|
|
const Variant *other = (const Variant *)p_other;
|
|
|
|
return self->hash_compare(*other);
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-09-18 18:02:47 +00:00
|
|
|
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self) {
|
2017-04-17 19:42:11 +00:00
|
|
|
const Variant *self = (const Variant *)p_self;
|
2017-09-18 18:02:47 +00:00
|
|
|
return self->booleanize();
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 19:42:11 +00:00
|
|
|
void GDAPI godot_variant_destroy(godot_variant *p_self) {
|
|
|
|
Variant *self = (Variant *)p_self;
|
|
|
|
self->~Variant();
|
2017-04-03 14:11:38 +00:00
|
|
|
}
|
|
|
|
|
2018-09-13 15:23:38 +00:00
|
|
|
// GDNative core 1.1
|
|
|
|
|
|
|
|
godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op) {
|
|
|
|
Variant::Operator op = (Variant::Operator)p_op;
|
|
|
|
godot_string raw_dest;
|
|
|
|
String *dest = (String *)&raw_dest;
|
|
|
|
memnew_placement(dest, String(Variant::get_operator_name(op))); // operator = is overloaded by String
|
|
|
|
return raw_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid) {
|
|
|
|
Variant::Operator op = (Variant::Operator)p_op;
|
|
|
|
const Variant *a = (const Variant *)p_a;
|
|
|
|
const Variant *b = (const Variant *)p_b;
|
|
|
|
Variant *ret = (Variant *)r_ret;
|
2019-05-22 07:10:06 +00:00
|
|
|
Variant::evaluate(op, *a, *b, *ret, *r_valid);
|
2018-09-13 15:23:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-03 14:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|