diff options
| author | Karroffel <therzog@mail.de> | 2017-04-06 02:32:24 +0200 |
|---|---|---|
| committer | Karroffel <therzog@mail.de> | 2017-04-06 02:32:24 +0200 |
| commit | 5e3b01f0f136819b5628d4edec847eac2a4374a5 (patch) | |
| tree | 8673ea914db1407a5f13cbee2ae6d1ae12b63b5d /include/godot_cpp/core | |
| parent | 63c2b9d474784447d01cb4c90aabdfd3ab5e373c (diff) | |
| download | redot-cpp-5e3b01f0f136819b5628d4edec847eac2a4374a5.tar.gz | |
some NodePath fixes and better handling of Object type arguments
Diffstat (limited to 'include/godot_cpp/core')
| -rw-r--r-- | include/godot_cpp/core/NodePath.cpp | 19 | ||||
| -rw-r--r-- | include/godot_cpp/core/NodePath.hpp | 8 | ||||
| -rw-r--r-- | include/godot_cpp/core/String.cpp | 7 | ||||
| -rw-r--r-- | include/godot_cpp/core/String.hpp | 4 | ||||
| -rw-r--r-- | include/godot_cpp/core/Variant.cpp | 4 | ||||
| -rw-r--r-- | include/godot_cpp/core/Variant.hpp | 2 |
6 files changed, 42 insertions, 2 deletions
diff --git a/include/godot_cpp/core/NodePath.cpp b/include/godot_cpp/core/NodePath.cpp index 3dbfd4a..e5e784b 100644 --- a/include/godot_cpp/core/NodePath.cpp +++ b/include/godot_cpp/core/NodePath.cpp @@ -9,7 +9,15 @@ namespace godot { NodePath::NodePath() { + String from = ""; + godot_node_path_new(&_node_path, (godot_string *) &from); +} +NodePath::NodePath(const NodePath &other) +{ + String from = other; + godot_node_path_new(&_node_path, (godot_string *) &from); + godot_node_path_copy(&_node_path, &other._node_path); } NodePath::NodePath(const String &from) @@ -17,6 +25,12 @@ NodePath::NodePath(const String &from) godot_node_path_new(&_node_path, (godot_string *) &from); } +NodePath::NodePath(const char *contents) +{ + String from = contents; + godot_node_path_new(&_node_path, (godot_string *) &from); +} + String NodePath::get_name(const int idx) const { godot_string str = godot_node_path_get_name(&_node_path, idx); @@ -63,6 +77,11 @@ NodePath::operator String() const return *(String *) &str; } +void NodePath::operator =(const NodePath& other) +{ + godot_node_path_copy(&_node_path, &other._node_path); +} + NodePath::~NodePath() { godot_node_path_destroy(&_node_path); diff --git a/include/godot_cpp/core/NodePath.hpp b/include/godot_cpp/core/NodePath.hpp index c941ad0..3f75ca1 100644 --- a/include/godot_cpp/core/NodePath.hpp +++ b/include/godot_cpp/core/NodePath.hpp @@ -24,7 +24,11 @@ class GD_CPP_CORE_API NodePath public: NodePath(); - NodePath(const String &from); + NodePath(const NodePath &other); + + NodePath(const String& from); + + NodePath(const char *contents); String get_name(const int idx) const; @@ -42,6 +46,8 @@ public: operator String() const; + void operator =(const NodePath& other); + ~NodePath(); }; diff --git a/include/godot_cpp/core/String.cpp b/include/godot_cpp/core/String.cpp index af83f2e..9b344c7 100644 --- a/include/godot_cpp/core/String.cpp +++ b/include/godot_cpp/core/String.cpp @@ -1,5 +1,7 @@ #include "String.hpp" +#include "NodePath.hpp" + namespace godot { @@ -119,6 +121,11 @@ bool String::operator >=(const String &s) return !(*this < s); } +String::operator NodePath() const +{ + return NodePath(*this); +} + const wchar_t *String::c_string() const { return godot_string_c_str(&_godot_string); diff --git a/include/godot_cpp/core/String.hpp b/include/godot_cpp/core/String.hpp index 00790ae..1beaf21 100644 --- a/include/godot_cpp/core/String.hpp +++ b/include/godot_cpp/core/String.hpp @@ -15,6 +15,8 @@ namespace godot { +class NodePath; + class GD_CPP_CORE_API String { godot_string _godot_string; @@ -61,6 +63,8 @@ public: bool operator >=(const String &s); + operator NodePath() const; + const wchar_t *c_string() const; }; diff --git a/include/godot_cpp/core/Variant.cpp b/include/godot_cpp/core/Variant.cpp index 394d97d..6442bc2 100644 --- a/include/godot_cpp/core/Variant.cpp +++ b/include/godot_cpp/core/Variant.cpp @@ -385,6 +385,10 @@ Variant::operator PoolColorArray() const godot_pool_color_array s = godot_variant_as_pool_color_array(&_godot_variant); return *(PoolColorArray *) &s; } +Variant::operator Object*() const { + godot_object *o = godot_variant_as_object(&_godot_variant); + return (Object *) o; +} Variant::Type Variant::get_type() const { diff --git a/include/godot_cpp/core/Variant.hpp b/include/godot_cpp/core/Variant.hpp index 68e1210..baa1498 100644 --- a/include/godot_cpp/core/Variant.hpp +++ b/include/godot_cpp/core/Variant.hpp @@ -205,7 +205,7 @@ public: operator NodePath() const; operator RID() const; operator InputEvent() const; - operator Object() const; + operator Object*() const; operator Dictionary() const; operator Array() const; |
