2023-05-23 19:01:39 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* Variant.hpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VARIANT_H
|
|
|
|
#define VARIANT_H
|
|
|
|
|
2023-05-31 13:28:14 +02:00
|
|
|
#include <gdn/variant.h>
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
#include "Defs.hpp"
|
|
|
|
|
|
|
|
#include "AABB.hpp"
|
|
|
|
#include "Basis.hpp"
|
|
|
|
#include "Color.hpp"
|
|
|
|
#include "NodePath.hpp"
|
|
|
|
#include "Plane.hpp"
|
|
|
|
#include "PoolArrays.hpp"
|
|
|
|
#include "Quat.hpp"
|
|
|
|
#include "RID.hpp"
|
|
|
|
#include "Rect2.hpp"
|
|
|
|
#include "String.hpp"
|
|
|
|
#include "Transform.hpp"
|
|
|
|
#include "Transform2D.hpp"
|
|
|
|
#include "Vector2.hpp"
|
|
|
|
#include "Vector3.hpp"
|
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
|
|
|
class Dictionary;
|
|
|
|
|
|
|
|
class Array;
|
|
|
|
|
|
|
|
class Variant {
|
2023-05-31 13:31:45 +02:00
|
|
|
pandemonium_variant _pandemonium_variant;
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
friend class Array;
|
2023-05-31 13:31:45 +02:00
|
|
|
inline explicit Variant(pandemonium_variant v) {
|
|
|
|
_pandemonium_variant = v;
|
2023-05-23 19:01:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
|
|
|
|
NIL,
|
|
|
|
|
|
|
|
// atomic types
|
|
|
|
BOOL,
|
|
|
|
INT,
|
|
|
|
REAL,
|
|
|
|
STRING,
|
|
|
|
|
|
|
|
// math types
|
2023-05-31 14:29:51 +02:00
|
|
|
RECT2, // 5
|
|
|
|
RECT2I,
|
|
|
|
VECTOR2,
|
|
|
|
VECTOR2I,
|
2023-05-23 19:01:39 +02:00
|
|
|
VECTOR3,
|
2023-05-31 14:29:51 +02:00
|
|
|
VECTOR3I, // 10
|
|
|
|
VECTOR4,
|
|
|
|
VECTOR4I,
|
|
|
|
|
2023-05-23 19:01:39 +02:00
|
|
|
PLANE,
|
2023-05-31 14:29:51 +02:00
|
|
|
QUATERNION,
|
|
|
|
AABB, // 15
|
2023-05-23 19:01:39 +02:00
|
|
|
BASIS,
|
|
|
|
TRANSFORM,
|
2023-05-31 14:29:51 +02:00
|
|
|
TRANSFORM2D,
|
|
|
|
PROJECTION,
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
// misc types
|
2023-05-31 14:29:51 +02:00
|
|
|
COLOR, // 20
|
|
|
|
NODE_PATH,
|
|
|
|
RID,
|
2023-05-23 19:01:39 +02:00
|
|
|
OBJECT,
|
2023-05-31 14:29:51 +02:00
|
|
|
STRING_NAME,
|
|
|
|
DICTIONARY, // 25
|
2023-05-23 19:01:39 +02:00
|
|
|
ARRAY,
|
|
|
|
|
|
|
|
// arrays
|
2023-05-31 14:29:51 +02:00
|
|
|
POOL_BYTE_ARRAY,
|
2023-05-23 19:01:39 +02:00
|
|
|
POOL_INT_ARRAY,
|
|
|
|
POOL_REAL_ARRAY,
|
2023-05-31 14:29:51 +02:00
|
|
|
POOL_STRING_ARRAY, // 30
|
2023-05-23 19:01:39 +02:00
|
|
|
POOL_VECTOR2_ARRAY,
|
2023-05-31 14:29:51 +02:00
|
|
|
POOL_VECTOR2I_ARRAY,
|
|
|
|
POOL_VECTOR3_ARRAY,
|
|
|
|
POOL_VECTOR3I_ARRAY,
|
|
|
|
POOL_VECTOR4_ARRAY, // 35
|
|
|
|
POOL_VECTOR4I_ARRAY,
|
2023-05-23 19:01:39 +02:00
|
|
|
POOL_COLOR_ARRAY,
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
VARIANT_MAX // 38
|
2023-05-23 19:01:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Operator {
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
// comparation
|
2023-05-23 19:01:39 +02:00
|
|
|
OP_EQUAL,
|
|
|
|
OP_NOT_EQUAL,
|
|
|
|
OP_LESS,
|
|
|
|
OP_LESS_EQUAL,
|
|
|
|
OP_GREATER,
|
|
|
|
OP_GREATER_EQUAL,
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
// mathematic
|
2023-05-23 19:01:39 +02:00
|
|
|
OP_ADD,
|
|
|
|
OP_SUBSTRACT,
|
|
|
|
OP_MULTIPLY,
|
|
|
|
OP_DIVIDE,
|
|
|
|
OP_NEGATE,
|
|
|
|
OP_POSITIVE,
|
|
|
|
OP_MODULE,
|
|
|
|
OP_STRING_CONCAT,
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
// bitwise
|
2023-05-23 19:01:39 +02:00
|
|
|
OP_SHIFT_LEFT,
|
|
|
|
OP_SHIFT_RIGHT,
|
|
|
|
OP_BIT_AND,
|
|
|
|
OP_BIT_OR,
|
|
|
|
OP_BIT_XOR,
|
|
|
|
OP_BIT_NEGATE,
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
// logic
|
2023-05-23 19:01:39 +02:00
|
|
|
OP_AND,
|
|
|
|
OP_OR,
|
|
|
|
OP_XOR,
|
|
|
|
OP_NOT,
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
// containment
|
2023-05-23 19:01:39 +02:00
|
|
|
OP_IN,
|
|
|
|
OP_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
Variant();
|
|
|
|
|
|
|
|
Variant(const Variant &v);
|
|
|
|
|
|
|
|
Variant(bool p_bool);
|
|
|
|
|
|
|
|
Variant(signed int p_int);
|
|
|
|
|
|
|
|
Variant(unsigned int p_int);
|
|
|
|
|
|
|
|
Variant(signed short p_short);
|
|
|
|
|
|
|
|
inline Variant(unsigned short p_short) :
|
|
|
|
Variant((unsigned int)p_short) {}
|
|
|
|
|
|
|
|
inline Variant(signed char p_char) :
|
|
|
|
Variant((signed int)p_char) {}
|
|
|
|
|
|
|
|
inline Variant(unsigned char p_char) :
|
|
|
|
Variant((unsigned int)p_char) {}
|
|
|
|
Variant(int64_t p_char);
|
|
|
|
|
|
|
|
Variant(uint64_t p_char);
|
|
|
|
|
|
|
|
Variant(float p_float);
|
|
|
|
|
|
|
|
Variant(double p_double);
|
|
|
|
|
|
|
|
Variant(const String &p_string);
|
2023-05-31 14:29:51 +02:00
|
|
|
Variant(const StringName &p_string);
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
Variant(const char *const p_cstring);
|
|
|
|
|
|
|
|
Variant(const wchar_t *p_wstring);
|
|
|
|
|
|
|
|
Variant(const Vector2 &p_vector2);
|
|
|
|
|
|
|
|
Variant(const Rect2 &p_rect2);
|
|
|
|
|
|
|
|
Variant(const Vector3 &p_vector3);
|
|
|
|
|
|
|
|
Variant(const Plane &p_plane);
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
Variant(const ::AABB &p_aabb);
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
Variant(const Quat &p_quat);
|
|
|
|
|
|
|
|
Variant(const Basis &p_transform);
|
|
|
|
|
|
|
|
Variant(const Transform2D &p_transform);
|
|
|
|
|
|
|
|
Variant(const Transform &p_transform);
|
|
|
|
|
|
|
|
Variant(const Color &p_color);
|
|
|
|
|
|
|
|
Variant(const NodePath &p_path);
|
|
|
|
|
2023-05-31 14:29:51 +02:00
|
|
|
Variant(const ::RID &p_rid);
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
Variant(const Object *p_object);
|
|
|
|
|
|
|
|
Variant(const Dictionary &p_dictionary);
|
|
|
|
|
|
|
|
Variant(const Array &p_array);
|
|
|
|
|
|
|
|
Variant(const PoolByteArray &p_raw_array);
|
|
|
|
|
|
|
|
Variant(const PoolIntArray &p_int_array);
|
|
|
|
|
|
|
|
Variant(const PoolRealArray &p_real_array);
|
|
|
|
|
|
|
|
Variant(const PoolStringArray &p_string_array);
|
|
|
|
|
|
|
|
Variant(const PoolVector2Array &p_vector2_array);
|
|
|
|
|
|
|
|
Variant(const PoolVector3Array &p_vector3_array);
|
|
|
|
|
|
|
|
Variant(const PoolColorArray &p_color_array);
|
|
|
|
|
|
|
|
Variant &operator=(const Variant &v);
|
|
|
|
|
|
|
|
operator bool() const;
|
|
|
|
operator signed int() const;
|
|
|
|
operator unsigned int() const;
|
|
|
|
operator signed short() const;
|
|
|
|
operator unsigned short() const;
|
|
|
|
operator signed char() const;
|
|
|
|
operator unsigned char() const;
|
|
|
|
operator int64_t() const;
|
|
|
|
operator uint64_t() const;
|
|
|
|
|
|
|
|
operator wchar_t() const;
|
|
|
|
|
|
|
|
operator float() const;
|
|
|
|
|
|
|
|
operator double() const;
|
|
|
|
operator String() const;
|
2023-05-31 14:29:51 +02:00
|
|
|
operator StringName() const;
|
2023-05-23 19:01:39 +02:00
|
|
|
operator Vector2() const;
|
|
|
|
operator Rect2() const;
|
|
|
|
operator Vector3() const;
|
|
|
|
operator Plane() const;
|
2023-05-31 14:29:51 +02:00
|
|
|
operator ::AABB() const;
|
2023-05-23 19:01:39 +02:00
|
|
|
operator Quat() const;
|
|
|
|
operator Basis() const;
|
|
|
|
operator Transform() const;
|
|
|
|
operator Transform2D() const;
|
|
|
|
|
|
|
|
operator Color() const;
|
|
|
|
|
|
|
|
operator NodePath() const;
|
2023-05-31 14:29:51 +02:00
|
|
|
operator ::RID() const;
|
2023-05-31 13:31:45 +02:00
|
|
|
operator pandemonium_object *() const;
|
2023-05-23 19:01:39 +02:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
operator T *() const { return static_cast<T *>(T::___get_from_variant(*this)); }
|
|
|
|
|
|
|
|
operator Dictionary() const;
|
|
|
|
operator Array() const;
|
|
|
|
|
|
|
|
operator PoolByteArray() const;
|
|
|
|
operator PoolIntArray() const;
|
|
|
|
operator PoolRealArray() const;
|
|
|
|
operator PoolStringArray() const;
|
|
|
|
operator PoolVector2Array() const;
|
|
|
|
operator PoolVector3Array() const;
|
|
|
|
operator PoolColorArray() const;
|
|
|
|
|
|
|
|
Type get_type() const;
|
|
|
|
|
|
|
|
Variant call(const String &method, const Variant **args, const int arg_count);
|
|
|
|
|
|
|
|
bool has_method(const String &method);
|
|
|
|
|
|
|
|
bool operator==(const Variant &b) const;
|
|
|
|
|
|
|
|
bool operator!=(const Variant &b) const;
|
|
|
|
|
|
|
|
bool operator<(const Variant &b) const;
|
|
|
|
|
|
|
|
bool operator<=(const Variant &b) const;
|
|
|
|
|
|
|
|
bool operator>(const Variant &b) const;
|
|
|
|
|
|
|
|
bool operator>=(const Variant &b) const;
|
|
|
|
|
|
|
|
bool hash_compare(const Variant &b) const;
|
|
|
|
|
|
|
|
bool booleanize() const;
|
|
|
|
|
|
|
|
~Variant();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace godot
|
|
|
|
|
|
|
|
#endif // VARIANT_H
|