2017-03-04 02:04:16 +00:00
|
|
|
#ifndef VARIANT_H
|
|
|
|
#define VARIANT_H
|
|
|
|
|
2017-10-03 10:37:34 +00:00
|
|
|
#include <gdnative/variant.h>
|
2017-03-04 02:04:16 +00:00
|
|
|
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "Defs.hpp"
|
|
|
|
|
2017-11-23 11:50:05 +00:00
|
|
|
#include "AABB.hpp"
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "Basis.hpp"
|
|
|
|
#include "Color.hpp"
|
|
|
|
#include "NodePath.hpp"
|
|
|
|
#include "Plane.hpp"
|
|
|
|
#include "PoolArrays.hpp"
|
|
|
|
#include "Quat.hpp"
|
|
|
|
#include "RID.hpp"
|
2018-11-23 22:09:41 +00:00
|
|
|
#include "Rect2.hpp"
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "String.hpp"
|
|
|
|
#include "Transform.hpp"
|
2017-03-15 22:19:58 +00:00
|
|
|
#include "Transform2D.hpp"
|
2017-03-06 07:49:24 +00:00
|
|
|
#include "Vector2.hpp"
|
|
|
|
#include "Vector3.hpp"
|
2017-03-04 02:04:16 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
|
|
|
class Dictionary;
|
|
|
|
|
|
|
|
class Array;
|
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
class Variant {
|
2017-03-04 02:04:16 +00:00
|
|
|
godot_variant _godot_variant;
|
2018-11-23 22:09:41 +00:00
|
|
|
|
2017-03-04 02:04:16 +00:00
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
|
|
|
|
NIL,
|
|
|
|
|
|
|
|
// atomic types
|
|
|
|
BOOL,
|
|
|
|
INT,
|
|
|
|
REAL,
|
|
|
|
STRING,
|
|
|
|
|
|
|
|
// math types
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
VECTOR2, // 5
|
2017-03-04 02:04:16 +00:00
|
|
|
RECT2,
|
|
|
|
VECTOR3,
|
|
|
|
TRANSFORM2D,
|
|
|
|
PLANE,
|
2018-11-23 22:09:41 +00:00
|
|
|
QUAT, // 10
|
2017-03-04 02:04:16 +00:00
|
|
|
RECT3, //sorry naming convention fail :( not like it's used often
|
|
|
|
BASIS,
|
|
|
|
TRANSFORM,
|
|
|
|
|
|
|
|
// misc types
|
|
|
|
COLOR,
|
2018-11-23 22:09:41 +00:00
|
|
|
NODE_PATH, // 15
|
2017-03-04 02:04:16 +00:00
|
|
|
_RID,
|
|
|
|
OBJECT,
|
2017-05-23 21:03:57 +00:00
|
|
|
DICTIONARY,
|
2017-03-04 02:04:16 +00:00
|
|
|
ARRAY,
|
|
|
|
|
|
|
|
// arrays
|
2018-11-23 22:09:41 +00:00
|
|
|
POOL_BYTE_ARRAY, // 20
|
2017-03-04 02:04:16 +00:00
|
|
|
POOL_INT_ARRAY,
|
|
|
|
POOL_REAL_ARRAY,
|
2017-05-23 21:03:57 +00:00
|
|
|
POOL_STRING_ARRAY,
|
2017-03-04 02:04:16 +00:00
|
|
|
POOL_VECTOR2_ARRAY,
|
2018-11-23 22:09:41 +00:00
|
|
|
POOL_VECTOR3_ARRAY, // 25
|
2017-03-04 02:04:16 +00:00
|
|
|
POOL_COLOR_ARRAY,
|
|
|
|
|
|
|
|
VARIANT_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-11 19:34:20 +00:00
|
|
|
enum Operator {
|
|
|
|
|
|
|
|
//comparation
|
|
|
|
OP_EQUAL,
|
|
|
|
OP_NOT_EQUAL,
|
|
|
|
OP_LESS,
|
|
|
|
OP_LESS_EQUAL,
|
|
|
|
OP_GREATER,
|
|
|
|
OP_GREATER_EQUAL,
|
|
|
|
|
|
|
|
//mathematic
|
|
|
|
OP_ADD,
|
|
|
|
OP_SUBSTRACT,
|
|
|
|
OP_MULTIPLY,
|
|
|
|
OP_DIVIDE,
|
|
|
|
OP_NEGATE,
|
|
|
|
OP_POSITIVE,
|
|
|
|
OP_MODULE,
|
|
|
|
OP_STRING_CONCAT,
|
|
|
|
|
|
|
|
//bitwise
|
|
|
|
OP_SHIFT_LEFT,
|
|
|
|
OP_SHIFT_RIGHT,
|
|
|
|
OP_BIT_AND,
|
|
|
|
OP_BIT_OR,
|
|
|
|
OP_BIT_XOR,
|
|
|
|
OP_BIT_NEGATE,
|
|
|
|
|
|
|
|
//logic
|
|
|
|
OP_AND,
|
|
|
|
OP_OR,
|
|
|
|
OP_XOR,
|
|
|
|
OP_NOT,
|
|
|
|
|
|
|
|
//containment
|
|
|
|
OP_IN,
|
|
|
|
OP_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
Variant();
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Variant &v);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
Variant(bool p_bool);
|
|
|
|
|
|
|
|
Variant(signed int p_int);
|
|
|
|
|
|
|
|
Variant(unsigned int p_int);
|
|
|
|
|
|
|
|
Variant(signed short p_short);
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
inline Variant(unsigned short p_short) :
|
|
|
|
Variant((unsigned int)p_short) {}
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
inline Variant(signed char p_char) :
|
|
|
|
Variant((signed int)p_char) {}
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
inline Variant(unsigned char p_char) :
|
|
|
|
Variant((unsigned int)p_char) {}
|
2017-03-06 02:30:46 +00:00
|
|
|
Variant(int64_t p_char);
|
|
|
|
|
|
|
|
Variant(uint64_t p_char);
|
|
|
|
|
|
|
|
Variant(float p_float);
|
|
|
|
|
|
|
|
Variant(double p_double);
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const String &p_string);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const char *const p_cstring);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const wchar_t *p_wstring);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Vector2 &p_vector2);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Rect2 &p_rect2);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Vector3 &p_vector3);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Plane &p_plane);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const AABB &p_aabb);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Quat &p_quat);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Basis &p_transform);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Transform2D &p_transform);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Transform &p_transform);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Color &p_color);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const NodePath &p_path);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const RID &p_rid);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Object *p_object);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Dictionary &p_dictionary);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const Array &p_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolByteArray &p_raw_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolIntArray &p_int_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolRealArray &p_real_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolStringArray &p_string_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolVector2Array &p_vector2_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolVector3Array &p_vector3_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant(const PoolColorArray &p_color_array);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant &operator=(const Variant &v);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
|
|
|
operator bool() const;
|
|
|
|
operator signed int() const;
|
2018-11-23 22:09:41 +00:00
|
|
|
operator unsigned int() const;
|
2017-03-06 02:30:46 +00:00
|
|
|
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;
|
|
|
|
operator Vector2() const;
|
|
|
|
operator Rect2() const;
|
|
|
|
operator Vector3() const;
|
|
|
|
operator Plane() const;
|
2017-11-23 11:50:05 +00:00
|
|
|
operator AABB() const;
|
2017-03-06 02:30:46 +00:00
|
|
|
operator Quat() const;
|
|
|
|
operator Basis() const;
|
|
|
|
operator Transform() const;
|
|
|
|
operator Transform2D() const;
|
|
|
|
|
|
|
|
operator Color() const;
|
|
|
|
|
|
|
|
operator NodePath() const;
|
|
|
|
operator RID() const;
|
2018-11-23 22:09:41 +00:00
|
|
|
operator godot_object *() const;
|
2017-03-04 02:04:16 +00:00
|
|
|
|
|
|
|
operator Dictionary() const;
|
|
|
|
operator Array() const;
|
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
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;
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
Variant call(const String &method, const Variant **args, const int arg_count);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool has_method(const String &method);
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator==(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator!=(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator<(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator<=(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator>(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool operator>=(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
bool hash_compare(const Variant &b) const;
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2017-10-03 10:37:34 +00:00
|
|
|
bool booleanize() const;
|
2017-03-04 02:04:16 +00:00
|
|
|
|
2017-03-06 02:30:46 +00:00
|
|
|
~Variant();
|
2017-03-04 02:04:16 +00:00
|
|
|
};
|
|
|
|
|
2018-11-23 22:09:41 +00:00
|
|
|
} // namespace godot
|
2017-03-04 02:04:16 +00:00
|
|
|
|
|
|
|
#endif // VARIANT_H
|