summaryrefslogtreecommitdiffstats
path: root/include/core
diff options
context:
space:
mode:
authorNickolai Korshunov <n.a.korshunov@gmail.com>2018-04-25 11:40:49 +0300
committerNickolai Korshunov <n.a.korshunov@gmail.com>2018-04-25 11:40:49 +0300
commitef37d8d76e45a8249f34e66dfcc80954fecd5981 (patch)
tree2c155a6f9107b21474e9f1adcb0d4b752bb2e7bc /include/core
parent876715b610a52749e5cc7824122f892dd430ffab (diff)
parent68ba815bc5c9ffa9494511f9feb8ea36a95369d7 (diff)
downloadredot-cpp-ef37d8d76e45a8249f34e66dfcc80954fecd5981.tar.gz
Merge branch 'master' of https://github.com/GodotNativeTools/godot-cpp
Diffstat (limited to 'include/core')
-rw-r--r--include/core/Array.hpp6
-rw-r--r--include/core/Defs.hpp36
-rw-r--r--include/core/Dictionary.hpp5
-rw-r--r--include/core/Godot.hpp5
-rw-r--r--include/core/GodotGlobal.hpp6
-rw-r--r--include/core/NodePath.hpp2
-rw-r--r--include/core/PoolArrays.hpp14
-rw-r--r--include/core/String.hpp2
8 files changed, 69 insertions, 7 deletions
diff --git a/include/core/Array.hpp b/include/core/Array.hpp
index 2320568..ead3ba3 100644
--- a/include/core/Array.hpp
+++ b/include/core/Array.hpp
@@ -3,6 +3,7 @@
#include <gdnative/array.h>
+#include "Defs.hpp"
#include "String.hpp"
namespace godot {
@@ -39,6 +40,11 @@ public:
Array(const PoolColorArray& a);
+ template <class... Args>
+ static Array make(Args... args) {
+ return helpers::append_all(Array(), args...);
+ }
+
Variant& operator [](const int idx);
Variant operator [](const int idx) const;
diff --git a/include/core/Defs.hpp b/include/core/Defs.hpp
index 4b73cfa..245e32c 100644
--- a/include/core/Defs.hpp
+++ b/include/core/Defs.hpp
@@ -58,6 +58,42 @@ enum class Error {
ERR_WTF = ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
};
+ namespace helpers {
+ template <typename T, typename ValueT>
+ T append_all (T appendable, ValueT value) {
+ appendable.append(value);
+ return appendable;
+ }
+
+ template <typename T, typename ValueT, typename... Args>
+ T append_all (T appendable, ValueT value, Args... args) {
+ appendable.append(value);
+ return append_all(appendable, args...);
+ }
+
+ template <typename T>
+ T append_all (T appendable) {
+ return appendable;
+ }
+
+ template <typename KV, typename KeyT, typename ValueT>
+ KV add_all (KV kv, KeyT key, ValueT value) {
+ kv[key] = value;
+ return kv;
+ }
+
+ template <typename KV, typename KeyT, typename ValueT, typename... Args>
+ KV add_all (KV kv, KeyT key, ValueT value, Args... args) {
+ kv[key] = value;
+ return add_all(kv, args...);
+ }
+
+ template <typename KV>
+ KV add_all (KV kv) {
+ return kv;
+ }
+ }
+
}
#include <stdio.h>
diff --git a/include/core/Dictionary.hpp b/include/core/Dictionary.hpp
index ec496af..613d6ce 100644
--- a/include/core/Dictionary.hpp
+++ b/include/core/Dictionary.hpp
@@ -16,6 +16,11 @@ public:
Dictionary(const Dictionary & other);
Dictionary & operator=(const Dictionary & other);
+ template <class... Args>
+ static Dictionary make(Args... args) {
+ return helpers::add_all(Dictionary(), args...);
+ }
+
void clear();
bool empty() const;
diff --git a/include/core/Godot.hpp b/include/core/Godot.hpp
index f710658..4686c7f 100644
--- a/include/core/Godot.hpp
+++ b/include/core/Godot.hpp
@@ -484,6 +484,11 @@ void register_signal(String name, Dictionary args = Dictionary())
}
}
+template<class T, class... Args>
+void register_signal(String name, Args... varargs)
+{
+ register_signal<T>(name, Dictionary::make(varargs...));
+}
}
diff --git a/include/core/GodotGlobal.hpp b/include/core/GodotGlobal.hpp
index 7d28dba..a913359 100644
--- a/include/core/GodotGlobal.hpp
+++ b/include/core/GodotGlobal.hpp
@@ -3,6 +3,7 @@
#include <gdnative_api_struct.gen.h>
#include "String.hpp"
+#include "Array.hpp"
namespace godot {
@@ -20,6 +21,11 @@ public:
static void gdnative_init(godot_gdnative_init_options *o);
static void gdnative_terminate(godot_gdnative_terminate_options *o);
static void nativescript_init(void *handle);
+
+ template <class... Args>
+ static void print(const String& fmt, Args... values) {
+ print(fmt.format(Array::make(values...)));
+ }
};
diff --git a/include/core/NodePath.hpp b/include/core/NodePath.hpp
index 026414b..e9e60ac 100644
--- a/include/core/NodePath.hpp
+++ b/include/core/NodePath.hpp
@@ -36,6 +36,8 @@ public:
void operator =(const NodePath& other);
+ bool operator ==(const NodePath& other);
+
~NodePath();
};
diff --git a/include/core/PoolArrays.hpp b/include/core/PoolArrays.hpp
index 4d22fd7..eba7b9c 100644
--- a/include/core/PoolArrays.hpp
+++ b/include/core/PoolArrays.hpp
@@ -104,7 +104,7 @@ public:
void set(const int idx, const uint8_t data);
- uint8_t operator [](const int idx);
+ const uint8_t operator [](const int idx);
int size() const;
@@ -200,7 +200,7 @@ public:
void set(const int idx, const int data);
- int operator [](const int idx);
+ const int operator [](const int idx);
int size() const;
@@ -296,7 +296,7 @@ public:
void set(const int idx, const real_t data);
- real_t operator [](const int idx);
+ const real_t operator [](const int idx);
int size() const;
@@ -392,7 +392,7 @@ public:
void set(const int idx, const String& data);
- String operator [](const int idx);
+ const String operator [](const int idx);
int size() const;
@@ -489,7 +489,7 @@ public:
void set(const int idx, const Vector2& data);
- Vector2 operator [](const int idx);
+ const Vector2 operator [](const int idx);
int size() const;
@@ -585,7 +585,7 @@ public:
void set(const int idx, const Vector3& data);
- Vector3 operator [](const int idx);
+ const Vector3 operator [](const int idx);
int size() const;
@@ -681,7 +681,7 @@ public:
void set(const int idx, const Color& data);
- Color operator [](const int idx);
+ const Color operator [](const int idx);
int size() const;
diff --git a/include/core/String.hpp b/include/core/String.hpp
index de65f3c..7826fcb 100644
--- a/include/core/String.hpp
+++ b/include/core/String.hpp
@@ -81,6 +81,7 @@ public:
int find(String what, int from = 0) const;
int find_last(String what) const;
int findn(String what, int from = 0) const;
+ String format(Variant values) const;
String format(Variant values, String placeholder) const;
String get_base_dir() const;
String get_basename() const;
@@ -128,6 +129,7 @@ public:
String to_upper() const;
String xml_escape() const;
String xml_unescape() const;
+
};
String operator+(const char *a, const String &b);