buuunch of stuff

This commit is contained in:
Karroffel
2017-03-06 08:49:24 +01:00
parent 92e1f553ec
commit 632c953e42
45 changed files with 474 additions and 533 deletions

View File

@@ -1,267 +0,0 @@
#ifndef GODOT_H
#define GODOT_H
#include <cstdlib>
#include <godot.h>
#include <godot_cpp/core/CoreTypes.h>
#include <godot_cpp/core/Variant.h>
namespace godot {
#define GODOT_CLASS(Name, Base) \
public: static char *___get_type_name() { return (char *) #Name; } \
static char *___get_base_type_name() { return (char *) #Base; } \
Name(godot_object *o) { __core_object = o; } \
private:
template<class A, class B>
A object_cast(B b)
{
A *a = (A*) &b;
return *a;
}
// instance and destroy funcs
template<class T>
void *_godot_class_instance_func(godot_object *p)
{
T *d = new T(p);
d->_init();
return d;
}
template<class T>
void _godot_class_destroy_func(godot_object *p, void *data)
{
T *d = (T *) data;
delete d;
}
template<class T>
void register_class()
{
godot_script_register(T::___get_type_name(), T::___get_base_type_name(), _godot_class_instance_func<T>, _godot_class_destroy_func<T>);
T::_register_methods();
}
// wrapped methods
template<class T, class R, class A0, class A1, class A2, class A3, class A4, R (T::*p)(A0, A1, A2, A3, A4)>
struct WrappedMethod5 {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
godot::Variant *v = (godot::Variant *) &_variant;
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
*v = (obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3], *arg[4]);
return _variant;
}
};
template<class T, class A0, class A1, class A2, class A3, class A4, void (T::*p)(A0, A1, A2, A3, A4)>
struct WrappedMethod5<T, void, A0, A1, A2, A3, A4, p> {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
(obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3], *arg[4]);
return _variant;
}
};
template<class T, class R, class A0, class A1, class A2, class A3, R (T::*p)(A0, A1, A2, A3)>
struct WrappedMethod4 {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
godot::Variant *v = (godot::Variant *) &_variant;
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
*v = (obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3]);
return _variant;
}
};
template<class T, class A0, class A1, class A2, class A3, void (T::*p)(A0, A1, A2, A3)>
struct WrappedMethod4<T, void, A0, A1, A2, A3, p> {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
(obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3]);
return _variant;
}
};
template<class T, class R, class A0, class A1, class A2, R (T::*p)(A0, A1, A2)>
struct WrappedMethod3 {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
godot::Variant *v = (godot::Variant *) &_variant;
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
*v = (obj->*p)(*arg[0], *arg[1], *arg[2]);
return _variant;
}
};
template<class T, class A0, class A1, class A2, void (T::*p)(A0, A1, A2)>
struct WrappedMethod3<T, void, A0, A1, A2, p> {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
(obj->*p)(*arg[0], *arg[1], *arg[2]);
return _variant;
}
};
template<class T, class R, class A0, class A1, R (T::*p)(A0, A1)>
struct WrappedMethod2 {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
godot::Variant *v = (godot::Variant *) &_variant;
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
*v = (obj->*p)(*arg[0], *arg[1]);
return _variant;
}
};
template<class T, class A0, class A1, void (T::*p)(A0, A1)>
struct WrappedMethod2<T, void, A0, A1, p> {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
(obj->*p)(*arg[0], *arg[1]);
return _variant;
}
};
template<class T, class R, class I, R (T::*p)(I)>
struct WrappedMethod1 {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
godot::Variant *v = (godot::Variant *) &_variant;
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
*v = (obj->*p)(*arg[0]);
return _variant;
}
};
template <class T, class I, void (T::*p)(I)>
struct WrappedMethod1<T, void, I, p> {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
T *obj = (T *) data;
godot::Variant **arg = (godot::Variant **) args;
(obj->*p)(*arg[0]);
return _variant;
}
};
template<class T, class R, R (T::*p)()>
struct WrappedMethod0 {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
godot::Variant *v = (godot::Variant *) &_variant;
T *obj = (T *) data;
*v = (obj->*p)();
return _variant;
}
};
template<class T, void (T::*p)()>
struct WrappedMethod0<T, void, p> {
static godot_variant wrapped_method(godot_object *_, void *data, int num_args, godot_variant **args)
{
godot_variant _variant;
godot_variant_new_nil(&_variant);
T *obj = (T *) data;
(obj->*p)();
return _variant;
}
};
// method registering
template<class T, class R, R (T::*p)()>
void register_method(char *name, godot_method_attributes attr = {}) {
godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod0<T, R, p>::wrapped_method);
}
template<class T, class R, class A0, R (T::*p)(A0)>
void register_method(char *name, godot_method_attributes attr = {}) {
godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod1<T, R, A0, p>::wrapped_method);
}
template<class T, class R, class A0, class A1, R (T::*p)(A0, A1)>
void register_method(char *name, godot_method_attributes attr = {}) {
godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod2<T, R, A0, A1, p>::wrapped_method);
}
template<class T, class R, class A0, class A1, class A2, R (T::*p)(A0, A1, A2)>
void register_method(char *name, godot_method_attributes attr = {}) {
godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod3<T, R, A0, A1, A2, p>::wrapped_method);
}
template<class T, class R, class A0, class A1, class A2, class A3, R (T::*p)(A0, A1, A2, A3)>
void register_method(char *name, godot_method_attributes attr = {}) {
godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod4<T, R, A0, A1, A2, A3, p>::wrapped_method);
}
template<class T, class R, class A0, class A1, class A2, class A3, class A4, R (T::*p)(A0, A1, A2, A3, A4)>
void register_method(char *name, godot_method_attributes attr = {}) {
godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod5<T, R, A0, A1, A2, A3, A4, p>::wrapped_method);
}
}
#endif // GODOT_H

View File

@@ -1,10 +1,10 @@
#include "Array.h"
#include "Array.hpp"
#include <cstdlib>
#include <godot/godot_array.h>
#include "Variant.h"
#include "Variant.hpp"
namespace godot {

View File

@@ -3,7 +3,7 @@
#include <godot/godot_array.h>
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -1,11 +1,11 @@
#include "Basis.h"
#include "Basis.hpp"
#include "Defs.h"
#include "Defs.hpp"
#include "Vector3.h"
#include "Vector3.hpp"
#include "Quat.h"
#include "Quat.hpp"
#include <algorithm>
@@ -597,7 +597,7 @@ Basis::Basis(const Vector3& p_euler) {
}
#include "Quat.h"
#include "Quat.hpp"
namespace godot {

View File

@@ -1,9 +1,9 @@
#ifndef BASIS_H
#define BASIS_H
#include "Defs.h"
#include "Defs.hpp"
#include "Vector3.h"
#include "Vector3.hpp"
namespace godot {

View File

@@ -1,10 +1,10 @@
#include "Color.h"
#include "Color.hpp"
#include <godot/godot_color.h>
#include <cmath>
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -5,7 +5,7 @@
#include <cmath>
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -1,27 +0,0 @@
#ifndef CORETYPES_H
#define CORETYPES_H
#include "Defs.h"
#include "Array.h"
#include "Basis.h"
#include "Color.h"
#include "Dictionary.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 "Variant.h"
#include "Vector2.h"
#include "Vector3.h"
#endif // CORETYPES_H

View File

@@ -0,0 +1,27 @@
#ifndef CORETYPES_H
#define CORETYPES_H
#include "Defs.hpp"
#include "Array.hpp"
#include "Basis.hpp"
#include "Color.hpp"
#include "Dictionary.hpp"
#include "Image.hpp"
#include "InputEvent.hpp"
#include "NodePath.hpp"
#include "Plane.hpp"
#include "PoolArrays.hpp"
#include "Quat.hpp"
#include "Rect2.hpp"
#include "Rect3.hpp"
#include "RID.hpp"
#include "String.hpp"
#include "Transform.hpp"
#include "Transform2D.hp"
#include "Variant.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#endif // CORETYPES_H

View File

@@ -1,8 +1,8 @@
#include "Dictionary.h"
#include "Dictionary.hpp"
#include "Variant.h"
#include "Variant.hpp"
#include "Array.h"
#include "Array.hpp"
#include <godot/godot_dictionary.h>

View File

@@ -1,9 +1,9 @@
#ifndef DICTIONARY_H
#define DICTIONARY_H
#include "Variant.h"
#include "Variant.hpp"
#include "Array.h"
#include "Array.hpp"
#include <godot/godot_dictionary.h>

View File

@@ -1,13 +1,13 @@
#include "Image.h"
#include "Image.hpp"
#include "Defs.h"
#include "Defs.hpp"
#include "Vector2.h"
#include "Rect2.h"
#include "Color.h"
#include "String.h"
#include "Vector2.hpp"
#include "Rect2.hpp"
#include "Color.hpp"
#include "String.hpp"
#include "PoolArrays.h"
#include "PoolArrays.hpp"
#include <godot/godot_image.h>

View File

@@ -1,12 +1,12 @@
#ifndef IMAGE_H
#define IMAGE_H
#include "Defs.h"
#include "Defs.hpp"
#include "Vector2.h"
#include "Rect2.h"
#include "Color.h"
#include "String.h"
#include "Vector2.hpp"
#include "Rect2.hpp"
#include "Color.hpp"
#include "String.hpp"
#include <godot/godot_image.h>

View File

@@ -1,14 +1,14 @@
#include "InputEvent.h"
#include "InputEvent.hpp"
#include <cstdint>
#include <memory.h>
#include "Vector2.h"
#include "Transform2D.h"
#include "Vector2.hpp"
#include "Transform2D.hp"
#include <cmath>
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -4,7 +4,7 @@
#include <cstdint>
#include <memory.h>
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -1,6 +1,6 @@
#include "NodePath.h"
#include "NodePath.hpp"
#include "String.h"
#include "String.hpp"
#include <godot/godot_node_path.h>

View File

@@ -1,7 +1,7 @@
#ifndef NODEPATH_H
#define NODEPATH_H
#include "String.h"
#include "String.hpp"
#include <godot/godot_node_path.h>

View File

@@ -1,6 +1,6 @@
#include "Plane.h"
#include "Plane.hpp"
#include "Vector3.h"
#include "Vector3.hpp"
#include <cmath>

View File

@@ -1,7 +1,7 @@
#ifndef PLANE_H
#define PLANE_H
#include "Vector3.h"
#include "Vector3.hpp"
#include <cmath>

View File

@@ -1,11 +1,11 @@
#include "PoolArrays.h"
#include "PoolArrays.hpp"
#include "Defs.h"
#include "Defs.hpp"
#include "String.h"
#include "Color.h"
#include "Vector2.h"
#include "Vector3.h"
#include "String.hpp"
#include "Color.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include <godot/godot_pool_arrays.h>

View File

@@ -1,12 +1,12 @@
#ifndef POOLARRAYS_H
#define POOLARRAYS_H
#include "Defs.h"
#include "Defs.hpp"
#include "String.h"
#include "Color.h"
#include "Vector2.h"
#include "Vector3.h"
#include "String.hpp"
#include "Color.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include <godot/godot_pool_arrays.h>

View File

@@ -1,13 +1,13 @@
#include "Quat.h"
#include "Quat.hpp"
#include <cmath>
#include "Defs.h"
#include "Defs.hpp"
#include "Vector3.h"
#include "Vector3.hpp"
#include "Basis.h"
#include "Basis.hpp"
namespace godot {

View File

@@ -3,7 +3,7 @@
#include <cmath>
#include "Vector3.h"
#include "Vector3.hpp"
// #include "Basis.h"

View File

@@ -1,4 +1,4 @@
#include "RID.h"
#include "RID.hpp"
#include <godot/godot_rid.h>

View File

@@ -11,6 +11,8 @@ class RID {
godot_rid _godot_rid;
public:
inline RID() {}
RID(Object *p);
int32_t get_rid() const;

View File

@@ -1,12 +1,12 @@
#include "Rect2.h"
#include "Rect2.hpp"
#include "Vector2.h"
#include "Vector2.hpp"
#include "String.h"
#include "String.hpp"
#include <cmath>
#include "Transform2D.h"
#include "Transform2D.hp"
namespace godot {

View File

@@ -1,7 +1,7 @@
#ifndef RECT2_H
#define RECT2_H
#include "Vector2.h"
#include "Vector2.hpp"
#include <cmath>

View File

@@ -1,8 +1,8 @@
#include "Rect3.h"
#include "Rect3.hpp"
#include "Vector3.h"
#include "Vector3.hpp"
#include "Plane.h"
#include "Plane.hpp"
#include <algorithm>

View File

@@ -1,9 +1,9 @@
#ifndef RECT3_H
#define RECT3_H
#include "Vector3.h"
#include "Vector3.hpp"
#include "Plane.h"
#include "Plane.hpp"
#include <cstdlib>

View File

@@ -1,4 +1,4 @@
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -1,11 +1,11 @@
#include "Transform.h"
#include "Transform.hpp"
#include "Basis.h"
#include "Basis.hpp"
#include "Plane.h"
#include "Rect3.h"
#include "Plane.hpp"
#include "Rect3.hpp"
#include "Quat.h"
#include "Quat.hpp"
namespace godot {

View File

@@ -1,10 +1,10 @@
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include "Basis.h"
#include "Basis.hpp"
#include "Plane.h"
#include "Rect3.h"
#include "Plane.hpp"
#include "Rect3.hpp"
namespace godot {

View File

@@ -1,10 +1,10 @@
#include "Transform2D.h"
#include "Transform2D.hp"
#include "Vector2.h"
#include "Vector2.hpp"
#include "String.h"
#include "String.hpp"
#include "Rect2.h"
#include "Rect2.hpp"
#include <algorithm>

View File

@@ -1,7 +1,7 @@
#ifndef TRANSFORM2D_H
#define TRANSFORM2D_H
#include "Vector2.h"
#include "Vector2.hpp"
namespace godot {

View File

@@ -1,10 +1,10 @@
#include "Variant.h"
#include "Variant.hpp"
#include <godot/godot_variant.h>
#include "Defs.h"
#include "Defs.hpp"
#include "CoreTypes.h"
#include "CoreTypes.hpp"
#include <iostream>

View File

@@ -3,24 +3,24 @@
#include <godot/godot_variant.h>
#include "Defs.h"
#include "Defs.hpp"
#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 "Basis.hpp"
#include "Color.hpp"
#include "Image.hpp"
#include "InputEvent.hpp"
#include "NodePath.hpp"
#include "Plane.hpp"
#include "PoolArrays.hpp"
#include "Quat.hpp"
#include "Rect2.hpp"
#include "Rect3.hpp"
#include "RID.hpp"
#include "String.hpp"
#include "Transform.hpp"
#include "Transform2D.hp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include <iostream>

View File

@@ -1,10 +1,10 @@
#include "Vector2.h"
#include "Vector2.hpp"
#include <cmath>
#include <godot/godot_vector2.h>
#include "String.h"
#include "String.hpp"
namespace godot {

View File

@@ -4,7 +4,7 @@
#include <godot/godot_vector2.h>
#include "Defs.h"
#include "Defs.hpp"
namespace godot {

View File

@@ -1,13 +1,13 @@
#include "Vector3.h"
#include "Vector3.hpp"
#include "String.h"
#include "String.hpp"
#include <stdlib.h>
#include <cmath>
#include "Basis.h"
#include "Basis.hpp"
namespace godot {

View File

@@ -1,9 +1,9 @@
#ifndef VECTOR3_H
#define VECTOR3_H
#include "Defs.h"
#include "Defs.hpp"
#include "String.h"
#include "String.hpp"
namespace godot {