some NodePath fixes and better handling of Object type arguments

This commit is contained in:
Karroffel
2017-04-06 02:32:24 +02:00
parent 63c2b9d474
commit 5e3b01f0f1
8 changed files with 93 additions and 13 deletions

View File

@@ -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);

View File

@@ -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();
};

View File

@@ -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);

View File

@@ -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;
};

View File

@@ -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
{

View File

@@ -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;