Finished core types (for now, looking at you, Image)

pull/7/head
Karroffel 2017-03-04 03:04:16 +01:00
parent 09332ee609
commit 8cbebc3e5d
9 changed files with 1440 additions and 5 deletions

201
include/godot/core/Array.h Normal file
View File

@ -0,0 +1,201 @@
#ifndef ARRAY_H
#define ARRAY_H
#include <godot/godot_array.h>
#include "Variant.h"
namespace godot {
class Array {
godot_array _godot_array;
public:
Array()
{
godot_array_new(&_godot_array);
}
Array(const PoolByteArray& a)
{
godot_array_new_pool_byte_array(&_godot_array, (godot_pool_byte_array *) &a);
}
Array(const PoolIntArray& a)
{
godot_array_new_pool_int_array(&_godot_array, (godot_pool_int_array *) &a);
}
Array(const PoolRealArray& a)
{
godot_array_new_pool_real_array(&_godot_array, (godot_pool_real_array *) &a);
}
Array(const PoolStringArray& a)
{
godot_array_new_pool_string_array(&_godot_array, (godot_pool_string_array *) &a);
}
Array(const PoolVector2Array& a)
{
godot_array_new_pool_vector2_array(&_godot_array, (godot_pool_vector2_array *) &a);
}
Array(const PoolVector3Array& a)
{
godot_array_new_pool_vector3_array(&_godot_array, (godot_pool_vector3_array *) &a);
}
Array(const PoolColorArray& a)
{
godot_array_new_pool_color_array(&_godot_array, (godot_pool_color_array *) &a);
}
Variant& operator [](const int idx)
{
godot_variant *v = godot_array_get(&_godot_array, idx);
return *(Variant *) v;
}
Variant operator [](const int idx) const
{
// Yes, I'm casting away the const... you can hate me now.
// since the result is
godot_variant *v = godot_array_get((godot_array *) &_godot_array, idx);
return *(Variant *) v;
}
void append(const Variant& v)
{
godot_array_append(&_godot_array, (godot_variant *) &v);
}
void clear()
{
godot_array_clear(&_godot_array);
}
int count(const Variant& v)
{
return godot_array_count(&_godot_array, (godot_variant *) &v);
}
bool empty() const
{
return godot_array_empty(&_godot_array);
}
void erase(const Variant& v)
{
godot_array_erase(&_godot_array, (godot_variant *) &v);
}
Variant front() const
{
godot_variant v = godot_array_front(&_godot_array);
return *(Variant *) &v;
}
Variant back() const
{
godot_variant v = godot_array_back(&_godot_array);
return *(Variant *) &v;
}
int find(const Variant& what, const int from = 0)
{
return godot_array_find(&_godot_array, (godot_variant *) &what, from);
}
int find_last(const Variant& what)
{
return godot_array_find_last(&_godot_array, (godot_variant *) &what);
}
bool has(const Variant& what) const
{
return godot_array_has(&_godot_array, (godot_variant *) &what);
}
uint32_t hash() const
{
return godot_array_hash(&_godot_array);
}
void insert(const int pos, const Variant& value)
{
godot_array_insert(&_godot_array, pos, (godot_variant *) &value);
}
void invert()
{
godot_array_invert(&_godot_array);
}
bool is_shared() const
{
return godot_array_is_shared(&_godot_array);
}
Variant pop_back()
{
godot_variant v = godot_array_pop_back(&_godot_array);
return *(Variant *) &v;
}
Variant pop_front()
{
godot_variant v = godot_array_pop_front(&_godot_array);
return *(Variant *) &v;
}
void push_back(const Variant& v)
{
godot_array_push_back(&_godot_array, (godot_variant *) &v);
}
void push_front(const Variant& v)
{
godot_array_push_front(&_godot_array, (godot_variant *) &v);
}
void remove(const int idx)
{
godot_array_remove(&_godot_array, idx);
}
int size() const
{
return godot_array_size(&_godot_array);
}
void resize(const int size)
{
godot_array_resize(&_godot_array, size);
}
int rfind(const Variant& what, const int from = -1)
{
return godot_array_rfind(&_godot_array, (godot_variant *) &what, from);
}
void sort()
{
godot_array_sort(&_godot_array);
}
void sort_custom(Object *obj, const String& func)
{
godot_array_sort_custom(&_godot_array, (godot_object *) obj, (godot_string *) &func);
}
~Array()
{
godot_array_destroy(&_godot_array);
}
};
}
#endif // ARRAY_H

View File

@ -1,16 +1,14 @@
#ifndef BASIS_H #ifndef BASIS_H
#define BASIS_H #define BASIS_H
#include "Defs.h"
#include "Vector3.h" #include "Vector3.h"
#include <algorithm> #include <algorithm>
typedef float real_t; // @Todo move this to a global Godot.h typedef float real_t; // @Todo move this to a global Godot.h
#define CMP_EPSILON 0.00001 // @Todo move this somewhere more global
#define CMP_EPSILON2 (CMP_EPSILON*CMP_EPSILON) // @Todo same as above
#define Math_PI 3.14159265358979323846 // I feel like I'm talking to myself
namespace godot { namespace godot {
@ -660,6 +658,43 @@ Basis::Basis(const Vector3& p_axis, real_t p_phi) {
} }
Basis::operator Quat() const {
ERR_FAIL_COND_V(is_rotation() == false, Quat());
real_t trace = elements[0][0] + elements[1][1] + elements[2][2];
real_t temp[4];
if (trace > 0.0)
{
real_t s = ::sqrt(trace + 1.0);
temp[3]=(s * 0.5);
s = 0.5 / s;
temp[0]=((elements[2][1] - elements[1][2]) * s);
temp[1]=((elements[0][2] - elements[2][0]) * s);
temp[2]=((elements[1][0] - elements[0][1]) * s);
}
else
{
int i = elements[0][0] < elements[1][1] ?
(elements[1][1] < elements[2][2] ? 2 : 1) :
(elements[0][0] < elements[2][2] ? 2 : 0);
int j = (i + 1) % 3;
int k = (i + 2) % 3;
real_t s = ::sqrt(elements[i][i] - elements[j][j] - elements[k][k] + 1.0);
temp[i] = s * 0.5;
s = 0.5 / s;
temp[3] = (elements[k][j] - elements[j][k]) * s;
temp[j] = (elements[j][i] + elements[i][j]) * s;
temp[k] = (elements[k][i] + elements[i][k]) * s;
}
return Quat(temp[0],temp[1],temp[2],temp[3]);
}

View File

@ -3,12 +3,15 @@
#include "Defs.h" #include "Defs.h"
#include "Array.h"
#include "Basis.h" #include "Basis.h"
#include "Color.h" #include "Color.h"
#include "Dictionary.h"
#include "Image.h" #include "Image.h"
#include "InputEvent.h" #include "InputEvent.h"
#include "NodePath.h" #include "NodePath.h"
#include "Plane.h" #include "Plane.h"
#include "PoolArrays.h"
#include "Quat.h" #include "Quat.h"
#include "Rect2.h" #include "Rect2.h"
#include "Rect3.h" #include "Rect3.h"
@ -16,8 +19,35 @@
#include "String.h" #include "String.h"
#include "Transform.h" #include "Transform.h"
#include "Transform2D.h" #include "Transform2D.h"
#include "Variant.h"
#include "Vector2.h" #include "Vector2.h"
#include "Vector3.h" #include "Vector3.h"
// This is ugly, sorry
// but those two casts need to be the last thing EVEEEEER
//
// if you can make it prettier feel free to open a Pull Request on
// https://github.com/GodotNativeTools/cpp_bindings
// or message someone on the IRC freenode #godotengine-devel
namespace godot {
Variant::operator Dictionary() const
{
godot_dictionary d = godot_variant_as_dictionary(&_godot_variant);
return *(Dictionary *) &d;
}
Variant::operator Array() const
{
godot_array s = godot_variant_as_array(&_godot_variant);
return *(Array *) &s;
}
}
#endif // CORETYPES_H #endif // CORETYPES_H

View File

@ -64,6 +64,16 @@ enum Error {
// @Todo as well as real_t // @Todo as well as real_t
#define CMP_EPSILON 0.00001 // @Todo move this somewhere more global
#define CMP_EPSILON2 (CMP_EPSILON*CMP_EPSILON) // @Todo same as above
#define Math_PI 3.14159265358979323846 // I feel like I'm talking to myself
#ifndef ERR_FAIL_COND_V
#define ERR_FAIL_COND_V(cond, ret) do { if (cond) { return ret; } } while(0)
#endif
#ifndef ERR_PRINT #ifndef ERR_PRINT
#define ERR_PRINT(msg) #define ERR_PRINT(msg)
#endif #endif

View File

@ -0,0 +1,98 @@
#ifndef DICTIONARY_H
#define DICTIONARY_H
#include "Variant.h"
#include "Array.h"
#include <godot/godot_dictionary.h>
namespace godot {
class Dictionary {
godot_dictionary _godot_dictionary;
public:
Dictionary()
{
godot_dictionary_new(&_godot_dictionary);
}
void clear()
{
godot_dictionary_clear(&_godot_dictionary);
}
bool empty() const
{
return godot_dictionary_empty(&_godot_dictionary);
}
void erase(const Variant& key)
{
godot_dictionary_erase(&_godot_dictionary, (godot_variant *) &key);
}
bool has(const Variant& key) const
{
return godot_dictionary_has(&_godot_dictionary, (godot_variant *) &key);
}
bool has_all(const Array& keys) const
{
return godot_dictionary_has_all(&_godot_dictionary, (godot_array *) &keys);
}
uint32_t hash() const
{
return godot_dictionary_hash(&_godot_dictionary);
}
Array keys() const
{
godot_array a = godot_dictionary_keys(&_godot_dictionary);
return *(Array *) &a;
}
int parse_json(const String& json)
{
return godot_dictionary_parse_json(&_godot_dictionary, (godot_string *) &json);
}
Variant &operator [](const Variant& key)
{
return *(Variant *) godot_dictionary_operator_index(&_godot_dictionary, (godot_variant *) &key);
}
const Variant &operator [](const Variant& key) const
{
// oops I did it again
return *(Variant *) godot_dictionary_operator_index((godot_dictionary *) &_godot_dictionary, (godot_variant *) &key);
}
int size() const
{
return godot_dictionary_size(&_godot_dictionary);
}
String to_json() const
{
godot_string s = godot_dictionary_to_json(&_godot_dictionary);
return *(String *) &s;
}
Array values() const
{
godot_array a = godot_dictionary_values(&_godot_dictionary);
return *(Array *) &a;
}
~Dictionary()
{
godot_dictionary_destroy(&_godot_dictionary);
}
};
}
#endif // DICTIONARY_H

View File

@ -2,6 +2,7 @@
#define INPUTEVENT_H #define INPUTEVENT_H
#include <cstdint> #include <cstdint>
#include <memory.h>
#include "String.h" #include "String.h"

View File

@ -0,0 +1,529 @@
#ifndef POOLARRAYS_H
#define POOLARRAYS_H
#include "Defs.h"
#include "String.h"
#include "Color.h"
#include "Vector2.h"
#include "Vector3.h"
#include <godot/godot_pool_arrays.h>
namespace godot {
class Array;
class PoolByteArray {
godot_pool_byte_array _godot_array;
public:
PoolByteArray()
{
godot_pool_byte_array_new(&_godot_array);
}
PoolByteArray(const Array& array)
{
godot_pool_byte_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const uint8_t data)
{
godot_pool_byte_array_append(&_godot_array, data);
}
void append_array(const PoolByteArray& array)
{
godot_pool_byte_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const uint8_t data)
{
return godot_pool_byte_array_insert(&_godot_array, idx, data);
}
void invert()
{
godot_pool_byte_array_invert(&_godot_array);
}
void push_back(const uint8_t data)
{
godot_pool_byte_array_push_back(&_godot_array, data);
}
void remove(const int idx)
{
godot_pool_byte_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_byte_array_resize(&_godot_array, size);
}
void set(const int idx, const uint8_t data)
{
godot_pool_byte_array_set(&_godot_array, idx, data);
}
uint8_t operator [](const int idx)
{
return godot_pool_byte_array_get(&_godot_array, idx);
}
int size()
{
return godot_pool_byte_array_size(&_godot_array);
}
~PoolByteArray()
{
godot_pool_byte_array_destroy(&_godot_array);
}
};
class PoolIntArray {
godot_pool_int_array _godot_array;
public:
PoolIntArray()
{
godot_pool_int_array_new(&_godot_array);
}
PoolIntArray(const Array& array)
{
godot_pool_int_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const int data)
{
godot_pool_int_array_append(&_godot_array, data);
}
void append_array(const PoolIntArray& array)
{
godot_pool_int_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const int data)
{
return godot_pool_int_array_insert(&_godot_array, idx, data);
}
void invert()
{
godot_pool_int_array_invert(&_godot_array);
}
void push_back(const int data)
{
godot_pool_int_array_push_back(&_godot_array, data);
}
void remove(const int idx)
{
godot_pool_int_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_int_array_resize(&_godot_array, size);
}
void set(const int idx, const int data)
{
godot_pool_int_array_set(&_godot_array, idx, data);
}
int operator [](const int idx)
{
return godot_pool_int_array_get(&_godot_array, idx);
}
int size()
{
return godot_pool_int_array_size(&_godot_array);
}
~PoolIntArray()
{
godot_pool_int_array_destroy(&_godot_array);
}
};
class PoolRealArray {
godot_pool_real_array _godot_array;
public:
PoolRealArray()
{
godot_pool_real_array_new(&_godot_array);
}
PoolRealArray(const Array& array)
{
godot_pool_real_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const real_t data)
{
godot_pool_real_array_append(&_godot_array, data);
}
void append_array(const PoolRealArray& array)
{
godot_pool_real_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const real_t data)
{
return godot_pool_real_array_insert(&_godot_array, idx, data);
}
void invert()
{
godot_pool_real_array_invert(&_godot_array);
}
void push_back(const real_t data)
{
godot_pool_real_array_push_back(&_godot_array, data);
}
void remove(const int idx)
{
godot_pool_real_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_real_array_resize(&_godot_array, size);
}
void set(const int idx, const real_t data)
{
godot_pool_real_array_set(&_godot_array, idx, data);
}
real_t operator [](const int idx)
{
return godot_pool_real_array_get(&_godot_array, idx);
}
int size()
{
return godot_pool_real_array_size(&_godot_array);
}
~PoolRealArray()
{
godot_pool_real_array_destroy(&_godot_array);
}
};
class PoolStringArray {
godot_pool_string_array _godot_array;
public:
PoolStringArray()
{
godot_pool_string_array_new(&_godot_array);
}
PoolStringArray(const Array& array)
{
godot_pool_string_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const String& data)
{
godot_pool_string_array_append(&_godot_array, (godot_string *) &data);
}
void append_array(const PoolStringArray& array)
{
godot_pool_string_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const String& data)
{
return godot_pool_string_array_insert(&_godot_array, idx, (godot_string *) &data);
}
void invert()
{
godot_pool_string_array_invert(&_godot_array);
}
void push_back(const String& data)
{
godot_pool_string_array_push_back(&_godot_array, (godot_string *) &data);
}
void remove(const int idx)
{
godot_pool_string_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_string_array_resize(&_godot_array, size);
}
void set(const int idx, const String& data)
{
godot_pool_string_array_set(&_godot_array, idx, (godot_string *) &data);
}
String operator [](const int idx)
{
String s;
godot_string str = godot_pool_string_array_get(&_godot_array, idx);
godot_string_copy_string((godot_string *) &s, &str);
godot_string_destroy(&str);
return s;
}
int size()
{
return godot_pool_string_array_size(&_godot_array);
}
~PoolStringArray()
{
godot_pool_string_array_destroy(&_godot_array);
}
};
class PoolVector2Array {
godot_pool_vector2_array _godot_array;
public:
PoolVector2Array()
{
godot_pool_vector2_array_new(&_godot_array);
}
PoolVector2Array(const Array& array)
{
godot_pool_vector2_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const Vector2& data)
{
godot_pool_vector2_array_append(&_godot_array, (godot_vector2 *) &data);
}
void append_array(const PoolVector2Array& array)
{
godot_pool_vector2_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const Vector2& data)
{
return godot_pool_vector2_array_insert(&_godot_array, idx, (godot_vector2 *) &data);
}
void invert()
{
godot_pool_vector2_array_invert(&_godot_array);
}
void push_back(const Vector2& data)
{
godot_pool_vector2_array_push_back(&_godot_array, (godot_vector2 *) &data);
}
void remove(const int idx)
{
godot_pool_vector2_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_vector2_array_resize(&_godot_array, size);
}
void set(const int idx, const Vector2& data)
{
godot_pool_vector2_array_set(&_godot_array, idx, (godot_vector2 *) &data);
}
Vector2 operator [](const int idx)
{
Vector2 v;
*(godot_vector2 *) &v = godot_pool_vector2_array_get(&_godot_array, idx);
return v;
}
int size()
{
return godot_pool_vector2_array_size(&_godot_array);
}
~PoolVector2Array()
{
godot_pool_vector2_array_destroy(&_godot_array);
}
};
class PoolVector3Array {
godot_pool_vector3_array _godot_array;
public:
PoolVector3Array()
{
godot_pool_vector3_array_new(&_godot_array);
}
PoolVector3Array(const Array& array)
{
godot_pool_vector3_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const Vector3& data)
{
godot_pool_vector3_array_append(&_godot_array, (godot_vector3 *) &data);
}
void append_array(const PoolVector3Array& array)
{
godot_pool_vector3_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const Vector3& data)
{
return godot_pool_vector3_array_insert(&_godot_array, idx, (godot_vector3 *) &data);
}
void invert()
{
godot_pool_vector3_array_invert(&_godot_array);
}
void push_back(const Vector3& data)
{
godot_pool_vector3_array_push_back(&_godot_array, (godot_vector3 *) &data);
}
void remove(const int idx)
{
godot_pool_vector3_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_vector3_array_resize(&_godot_array, size);
}
void set(const int idx, const Vector3& data)
{
godot_pool_vector3_array_set(&_godot_array, idx, (godot_vector3 *) &data);
}
Vector3 operator [](const int idx)
{
Vector3 v;
*(godot_vector3 *) &v = godot_pool_vector3_array_get(&_godot_array, idx);
return v;
}
int size()
{
return godot_pool_vector3_array_size(&_godot_array);
}
~PoolVector3Array()
{
godot_pool_vector3_array_destroy(&_godot_array);
}
};
class PoolColorArray {
godot_pool_color_array _godot_array;
public:
PoolColorArray()
{
godot_pool_color_array_new(&_godot_array);
}
PoolColorArray(const Array& array)
{
godot_pool_color_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void append(const Color& data)
{
godot_pool_color_array_append(&_godot_array, (godot_color *) &data);
}
void append_array(const PoolColorArray& array)
{
godot_pool_color_array_append_array(&_godot_array, &array._godot_array);
}
int insert(const int idx, const Color& data)
{
return godot_pool_color_array_insert(&_godot_array, idx, (godot_color *) &data);
}
void invert()
{
godot_pool_color_array_invert(&_godot_array);
}
void push_back(const Color& data)
{
godot_pool_color_array_push_back(&_godot_array, (godot_color *) &data);
}
void remove(const int idx)
{
godot_pool_color_array_remove(&_godot_array, idx);
}
void resize(const int size)
{
godot_pool_color_array_resize(&_godot_array, size);
}
void set(const int idx, const Color& data)
{
godot_pool_color_array_set(&_godot_array, idx, (godot_color *) &data);
}
Color operator [](const int idx)
{
Color v;
*(godot_color *) &v = godot_pool_color_array_get(&_godot_array, idx);
return v;
}
int size()
{
return godot_pool_color_array_size(&_godot_array);
}
~PoolColorArray()
{
godot_pool_color_array_destroy(&_godot_array);
}
};
}
#endif // POOLARRAYS_H

View File

@ -229,7 +229,7 @@ public:
} }
} }
inline Quat() {x=y=z=0; w=1; } Quat() {x=y=z=0; w=1; }
}; };
@ -251,6 +251,11 @@ void Quat::operator-=(const Quat& q) {
x -= q.x; y -= q.y; z -= q.z; w -= q.w; x -= q.x; y -= q.y; z -= q.z; w -= q.w;
} }
void Quat::operator*=(const Quat& q) {
x *= q.x; y *= q.y; z *= q.z; w *= q.w;
}
void Quat::operator*=(const real_t& s) { void Quat::operator*=(const real_t& s) {
x *= s; y *= s; z *= s; w *= s; x *= s; y *= s; z *= s; w *= s;
} }

View File

@ -0,0 +1,526 @@
#ifndef VARIANT_H
#define VARIANT_H
#include <godot/godot_variant.h>
#include "Defs.h"
#include "Basis.h"
#include "Color.h"
#include "Image.h"
#include "InputEvent.h"
#include "NodePath.h"
#include "Plane.h"
#include "PoolArrays.h"
#include "Quat.h"
#include "Rect2.h"
#include "Rect3.h"
#include "RID.h"
#include "String.h"
#include "Transform.h"
#include "Transform2D.h"
#include "Vector2.h"
#include "Vector3.h"
#include <iostream>
namespace godot {
class Dictionary;
class Array;
class Variant {
godot_variant _godot_variant;
public:
enum Type {
NIL,
// atomic types
BOOL,
INT,
REAL,
STRING,
// math types
VECTOR2, // 5
RECT2,
VECTOR3,
TRANSFORM2D,
PLANE,
QUAT, // 10
RECT3, //sorry naming convention fail :( not like it's used often
BASIS,
TRANSFORM,
// misc types
COLOR,
IMAGE, // 15
NODE_PATH,
_RID,
OBJECT,
INPUT_EVENT,
DICTIONARY, // 20
ARRAY,
// arrays
POOL_BYTE_ARRAY,
POOL_INT_ARRAY,
POOL_REAL_ARRAY,
POOL_STRING_ARRAY, // 25
POOL_VECTOR2_ARRAY,
POOL_VECTOR3_ARRAY,
POOL_COLOR_ARRAY,
VARIANT_MAX
};
Variant()
{
godot_variant_new_nil(&_godot_variant);
}
Variant(const Variant& v)
{
godot_variant_copy(&_godot_variant, &v._godot_variant);
}
Variant(bool p_bool)
{
godot_variant_new_bool(&_godot_variant, p_bool);
}
Variant(signed int p_int) // real one
{
godot_variant_new_int(&_godot_variant, p_int);
}
Variant(unsigned int p_int)
{
godot_variant_new_int(&_godot_variant, p_int);
}
Variant(signed short p_short) // real one
{
godot_variant_new_int(&_godot_variant, (int) p_short);
}
Variant(unsigned short p_short) : Variant((unsigned int) p_short) {}
Variant(signed char p_char) : Variant((signed int) p_char) {}// real one
Variant(unsigned char p_char) : Variant((unsigned int) p_char) {}
Variant(int64_t p_char) // real one
{
godot_variant_new_int(&_godot_variant, p_char);
}
Variant(uint64_t p_char)
{
godot_variant_new_int(&_godot_variant, p_char);
}
Variant(float p_float)
{
godot_variant_new_real(&_godot_variant, p_float);
}
Variant(double p_double)
{
godot_variant_new_real(&_godot_variant, p_double);
}
Variant(const String& p_string)
{
godot_variant_new_string(&_godot_variant, (godot_string *) &p_string);
}
Variant(const char * const p_cstring)
{
String s = String(p_cstring);
godot_variant_new_string(&_godot_variant, (godot_string *) &s);
}
Variant(const wchar_t * p_wstring)
{
String s = p_wstring;
godot_variant_new_string(&_godot_variant, (godot_string *) &s);
}
Variant(const Vector2& p_vector2)
{
godot_variant_new_vector2(&_godot_variant, (godot_vector2 *) &p_vector2);
}
Variant(const Rect2& p_rect2)
{
godot_variant_new_rect2(&_godot_variant, (godot_rect2 *) &p_rect2);
}
Variant(const Vector3& p_vector3)
{
godot_variant_new_vector3(&_godot_variant, (godot_vector3 *) &p_vector3);
}
Variant(const Plane& p_plane)
{
godot_variant_new_plane(&_godot_variant, (godot_plane *) &p_plane);
}
Variant(const Rect3& p_aabb)
{
godot_variant_new_rect3(&_godot_variant, (godot_rect3 *) &p_aabb);
}
Variant(const Quat& p_quat)
{
godot_variant_new_quat(&_godot_variant, (godot_quat *) &p_quat);
}
Variant(const Basis& p_transform)
{
godot_variant_new_basis(&_godot_variant, (godot_basis *) &p_transform);
}
Variant(const Transform2D& p_transform)
{
godot_variant_new_transform2d(&_godot_variant, (godot_transform2d *) &p_transform);
}
Variant(const Transform& p_transform)
{
godot_variant_new_transform(&_godot_variant, (godot_transform *) &p_transform);
}
Variant(const Color& p_color)
{
godot_variant_new_color(&_godot_variant, (godot_color *) &p_color);
}
Variant(const Image& p_image)
{
godot_variant_new_image(&_godot_variant, (godot_image *) &p_image);
}
Variant(const NodePath& p_path)
{
godot_variant_new_node_path(&_godot_variant, (godot_node_path *) &p_path);
}
Variant(const RID& p_rid)
{
godot_variant_new_rid(&_godot_variant, (godot_rid *) &p_rid);
}
Variant(const Object* p_object)
{
godot_variant_new_object(&_godot_variant, (godot_object *) p_object);
}
Variant(const InputEvent& p_input_event)
{
godot_variant_new_input_event(&_godot_variant, (godot_input_event *) &p_input_event);
}
Variant(const Dictionary& p_dictionary)
{
godot_variant_new_dictionary(&_godot_variant, (godot_dictionary *) &p_dictionary);
}
Variant(const Array& p_array)
{
godot_variant_new_array(&_godot_variant, (godot_array *) &p_array);
}
Variant(const PoolByteArray& p_raw_array)
{
godot_variant_new_pool_byte_array(&_godot_variant, (godot_pool_byte_array *) &p_raw_array);
}
Variant(const PoolIntArray& p_int_array)
{
godot_variant_new_pool_int_array(&_godot_variant, (godot_pool_int_array *) &p_int_array);
}
Variant(const PoolRealArray& p_real_array)
{
godot_variant_new_pool_real_array(&_godot_variant, (godot_pool_real_array *) &p_real_array);
}
Variant(const PoolStringArray& p_string_array)
{
godot_variant_new_pool_string_array(&_godot_variant, (godot_pool_string_array *) &p_string_array);
}
Variant(const PoolVector2Array& p_vector2_array)
{
godot_variant_new_pool_vector2_array(&_godot_variant, (godot_pool_vector2_array *) &p_vector2_array);
}
Variant(const PoolVector3Array& p_vector3_array)
{
godot_variant_new_pool_vector3_array(&_godot_variant, (godot_pool_vector3_array *) &p_vector3_array);
}
Variant(const PoolColorArray& p_color_array)
{
godot_variant_new_pool_color_array(&_godot_variant, (godot_pool_color_array *) &p_color_array);
}
Variant &operator =(const Variant& v)
{
godot_variant_copy(&_godot_variant, &v._godot_variant);
return *this;
}
operator bool() const
{
bool valid = false;
bool result = booleanize(valid);
return valid && result;
}
operator signed int() const
{
return godot_variant_as_int(&_godot_variant);
}
operator unsigned int() const // this is the real one
{
return godot_variant_as_int(&_godot_variant);
}
operator signed short() const
{
return godot_variant_as_int(&_godot_variant);
}
operator unsigned short() const
{
return godot_variant_as_int(&_godot_variant);
}
operator signed char() const
{
return godot_variant_as_int(&_godot_variant);
}
operator unsigned char() const
{
return godot_variant_as_int(&_godot_variant);
}
operator int64_t() const
{
return godot_variant_as_int(&_godot_variant);
}
operator uint64_t() const
{
return godot_variant_as_int(&_godot_variant);
}
operator wchar_t() const
{
return godot_variant_as_int(&_godot_variant);
}
operator float() const
{
return godot_variant_as_real(&_godot_variant);
}
operator double() const
{
return godot_variant_as_real(&_godot_variant);
}
operator String() const
{
godot_string s = godot_variant_as_string(&_godot_variant);
return *(String *) &s;
}
operator Vector2() const
{
godot_vector2 s = godot_variant_as_vector2(&_godot_variant);
return *(Vector2 *) &s;
}
operator Rect2() const
{
godot_rect2 s = godot_variant_as_rect2(&_godot_variant);
return *(Rect2 *) &s;
}
operator Vector3() const
{
godot_vector3 s = godot_variant_as_vector3(&_godot_variant);
return *(Vector3 *) &s;
}
operator Plane() const
{
godot_plane s = godot_variant_as_plane(&_godot_variant);
return *(Plane *) &s;
}
operator Rect3() const
{
godot_rect3 s = godot_variant_as_rect3(&_godot_variant);
return *(Rect3 *) &s;
}
operator Quat() const
{
godot_quat s = godot_variant_as_quat(&_godot_variant);
return *(Quat *) &s;
}
operator Basis() const
{
godot_basis s = godot_variant_as_basis(&_godot_variant);
return *(Basis *) &s;
}
operator Transform() const
{
godot_transform s = godot_variant_as_transform(&_godot_variant);
return *(Transform *) &s;
}
operator Transform2D() const
{
godot_transform2d s = godot_variant_as_transform2d(&_godot_variant);
return *(Transform2D *) &s;
}
operator Color() const
{
godot_color s = godot_variant_as_color(&_godot_variant);
return *(Color *) &s;
}
operator Image() const
{
godot_image s = godot_variant_as_image(&_godot_variant);
return *(Image *) &s;
}
operator NodePath() const
{
godot_node_path s = godot_variant_as_node_path(&_godot_variant);
return *(NodePath *) &s;
}
operator RID() const
{
godot_rid s = godot_variant_as_rid(&_godot_variant);
return *(RID *) &s;
}
operator InputEvent() const
{
godot_input_event s = godot_variant_as_input_event(&_godot_variant);
return *(InputEvent *) &s;
}
operator Object*() const
{
godot_object *s = godot_variant_as_object(&_godot_variant);
return (Object *) s;
}
operator Dictionary() const;
operator Array() const;
operator PoolByteArray() const
{
godot_pool_byte_array s = godot_variant_as_pool_byte_array(&_godot_variant);
return *(PoolByteArray *) &s;
}
operator PoolIntArray() const
{
godot_pool_int_array s = godot_variant_as_pool_int_array(&_godot_variant);
return *(PoolIntArray *) &s;
}
operator PoolRealArray() const
{
godot_pool_real_array s = godot_variant_as_pool_real_array(&_godot_variant);
return *(PoolRealArray *) &s;
}
operator PoolStringArray() const
{
godot_pool_string_array s = godot_variant_as_pool_string_array(&_godot_variant);
return *(PoolStringArray *) &s;
}
operator PoolVector2Array() const
{
godot_pool_vector2_array s = godot_variant_as_pool_vector2_array(&_godot_variant);
return *(PoolVector2Array *) &s;
}
operator PoolVector3Array() const
{
godot_pool_vector3_array s = godot_variant_as_pool_vector3_array(&_godot_variant);
return *(PoolVector3Array *) &s;
}
operator PoolColorArray() const
{
godot_pool_color_array s = godot_variant_as_pool_color_array(&_godot_variant);
return *(PoolColorArray *) &s;
}
Type get_type() const
{
return (Type) godot_variant_get_type(&_godot_variant);
}
Variant call(const String& method, const Variant **args, const int arg_count)
{
Variant v;
*(godot_variant *) &v = godot_variant_call(&_godot_variant, (godot_string *) &method, (const godot_variant **)args, arg_count);
return v;
}
bool has_method(const String& method)
{
return godot_variant_has_method(&_godot_variant, (godot_string *) &method);
}
bool operator ==(const Variant& b) const
{
return godot_variant_operator_equal(&_godot_variant, &b._godot_variant);
}
bool operator !=(const Variant& b) const
{
return !(*this == b);
}
bool operator <(const Variant& b) const
{
return godot_variant_operator_less(&_godot_variant, &b._godot_variant);
}
bool operator <=(const Variant& b) const
{
return (*this < b) || (*this == b);
}
bool operator >(const Variant& b) const
{
return !(*this <= b);
}
bool operator >=(const Variant& b) const
{
return !(*this < b);
}
bool hash_compare(const Variant& b) const
{
return godot_variant_hash_compare(&_godot_variant, &b._godot_variant);
}
bool booleanize(bool &valid) const
{
return godot_variant_booleanize(&_godot_variant, &valid);
}
~Variant()
{
godot_variant_destroy(&_godot_variant);
}
};
}
#endif // VARIANT_H