diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/NodePath.cpp | 12 | ||||
-rw-r--r-- | src/core/PoolArrays.cpp | 14 | ||||
-rw-r--r-- | src/core/String.cpp | 11 |
3 files changed, 27 insertions, 10 deletions
diff --git a/src/core/NodePath.cpp b/src/core/NodePath.cpp index 25ce882..b1fb9cc 100644 --- a/src/core/NodePath.cpp +++ b/src/core/NodePath.cpp @@ -17,7 +17,6 @@ NodePath::NodePath(const NodePath &other) { String from = other; godot::api->godot_node_path_new(&_node_path, (godot_string *) &from); - godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path); } NodePath::NodePath(const String &from) @@ -71,9 +70,18 @@ NodePath::operator String() const return *(String *) &str; } +bool NodePath::operator ==(const NodePath& other) +{ + return godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path); +} + void NodePath::operator =(const NodePath& other) { - godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path); + godot::api->godot_node_path_destroy(&_node_path); + + String other_string = (String) other; + + godot::api->godot_node_path_new(&_node_path, (godot_string *) &other_string); } NodePath::~NodePath() diff --git a/src/core/PoolArrays.cpp b/src/core/PoolArrays.cpp index d66de4c..8a6f9f8 100644 --- a/src/core/PoolArrays.cpp +++ b/src/core/PoolArrays.cpp @@ -86,7 +86,7 @@ void PoolByteArray::set(const int idx, const uint8_t data) godot::api->godot_pool_byte_array_set(&_godot_array, idx, data); } -uint8_t PoolByteArray::operator [](const int idx) +const uint8_t PoolByteArray::operator [](const int idx) { return godot::api->godot_pool_byte_array_get(&_godot_array, idx); } @@ -180,7 +180,7 @@ void PoolIntArray::set(const int idx, const int data) godot::api->godot_pool_int_array_set(&_godot_array, idx, data); } -int PoolIntArray::operator [](const int idx) +const int PoolIntArray::operator [](const int idx) { return godot::api->godot_pool_int_array_get(&_godot_array, idx); } @@ -273,7 +273,7 @@ void PoolRealArray::set(const int idx, const real_t data) godot::api->godot_pool_real_array_set(&_godot_array, idx, data); } -real_t PoolRealArray::operator [](const int idx) +const real_t PoolRealArray::operator [](const int idx) { return godot::api->godot_pool_real_array_get(&_godot_array, idx); } @@ -367,7 +367,7 @@ void PoolStringArray::set(const int idx, const String& data) godot::api->godot_pool_string_array_set(&_godot_array, idx, (godot_string *) &data); } -String PoolStringArray::operator [](const int idx) +const String PoolStringArray::operator [](const int idx) { String s; godot_string str = godot::api->godot_pool_string_array_get(&_godot_array, idx); @@ -465,7 +465,7 @@ void PoolVector2Array::set(const int idx, const Vector2& data) godot::api->godot_pool_vector2_array_set(&_godot_array, idx, (godot_vector2 *) &data); } -Vector2 PoolVector2Array::operator [](const int idx) +const Vector2 PoolVector2Array::operator [](const int idx) { Vector2 v; *(godot_vector2 *) &v = godot::api->godot_pool_vector2_array_get(&_godot_array, idx); @@ -561,7 +561,7 @@ void PoolVector3Array::set(const int idx, const Vector3& data) godot::api->godot_pool_vector3_array_set(&_godot_array, idx, (godot_vector3 *) &data); } -Vector3 PoolVector3Array::operator [](const int idx) +const Vector3 PoolVector3Array::operator [](const int idx) { Vector3 v; *(godot_vector3 *) &v = godot::api->godot_pool_vector3_array_get(&_godot_array, idx); @@ -656,7 +656,7 @@ void PoolColorArray::set(const int idx, const Color& data) godot::api->godot_pool_color_array_set(&_godot_array, idx, (godot_color *) &data); } -Color PoolColorArray::operator [](const int idx) +const Color PoolColorArray::operator [](const int idx) { Color v; *(godot_color *) &v = godot::api->godot_pool_color_array_get(&_godot_array, idx); diff --git a/src/core/String.cpp b/src/core/String.cpp index 3d822b1..737c040 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -267,13 +267,22 @@ int String::findn(String what, int from) const { return godot::api->godot_string_findn(&_godot_string, what._godot_string); } -String String::format(Variant values, String placeholder) const { +String String::format(Variant values) const { String new_string; new_string._godot_string = godot::api->godot_string_format(&_godot_string, (godot_variant *)&values); return new_string; } +String String::format(Variant values, String placeholder) const { + String new_string; + godot_char_string contents = godot::api->godot_string_utf8(&placeholder._godot_string); + new_string._godot_string = godot::api->godot_string_format_with_custom_placeholder(&_godot_string, (godot_variant *)&values, godot::api->godot_char_string_get_data(&contents)); + godot::api->godot_char_string_destroy(&contents); + + return new_string; +} + String String::get_base_dir() const { String new_string; new_string._godot_string = godot::api->godot_string_get_base_dir(&_godot_string); |