From ebe9d9de6ab73af33581ea222d6bb9bc40469ed6 Mon Sep 17 00:00:00 2001 From: Karroffel Date: Sun, 18 Jun 2017 13:21:18 +0200 Subject: [PATCH] updated core to new GDNative interface --- include/core/Defs.hpp | 2 +- src/core/Array.cpp | 4 ++-- src/core/PoolArrays.cpp | 2 +- src/core/String.cpp | 12 ++++++------ src/core/Variant.cpp | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/core/Defs.hpp b/include/core/Defs.hpp index b2da2cc0..d3a87d8b 100644 --- a/include/core/Defs.hpp +++ b/include/core/Defs.hpp @@ -87,7 +87,7 @@ typedef float real_t; #ifndef ERR_PRINT -#define ERR_PRINT(msg) fprintf(stderr, "ERROR: %ls\n", (msg).c_string()) +#define ERR_PRINT(msg) fprintf(stderr, "ERROR: %s\n", (msg).c_string()) #endif #ifndef ERR_FAIL_INDEX_V diff --git a/src/core/Array.cpp b/src/core/Array.cpp index 4c80499c..bb388c4e 100644 --- a/src/core/Array.cpp +++ b/src/core/Array.cpp @@ -52,7 +52,7 @@ Array::Array(const PoolColorArray& a) Variant& Array::operator [](const int idx) { - godot_variant *v = godot_array_get(&_godot_array, idx); + godot_variant *v = godot_array_operator_index(&_godot_array, idx); return *(Variant *) v; } @@ -60,7 +60,7 @@ Variant Array::operator [](const int idx) const { // Yes, I'm casting away the const... you can hate me now. // since the result is - godot_variant *v = godot_array_get((godot_array *) &_godot_array, idx); + godot_variant *v = godot_array_operator_index((godot_array *) &_godot_array, idx); return *(Variant *) v; } diff --git a/src/core/PoolArrays.cpp b/src/core/PoolArrays.cpp index 27c4a58a..3e778142 100644 --- a/src/core/PoolArrays.cpp +++ b/src/core/PoolArrays.cpp @@ -268,7 +268,7 @@ String PoolStringArray::operator [](const int idx) { String s; godot_string str = godot_pool_string_array_get(&_godot_array, idx); - godot_string_copy_string((godot_string *) &s, &str); + godot_string_new_copy((godot_string *) &s, &str); godot_string_destroy(&str); return s; } diff --git a/src/core/String.cpp b/src/core/String.cpp index da0ca9e7..6d0dc563 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -33,8 +33,7 @@ String::String(const wchar_t c) String::String(const String& other) { - godot_string_new(&_godot_string); - godot_string_copy_string(&_godot_string, &other._godot_string); + godot_string_new_copy(&_godot_string, &other._godot_string); } String::~String() @@ -68,7 +67,8 @@ int String::length() const void String::operator =(const String &s) { - godot_string_copy_string(&_godot_string, &s._godot_string); + godot_string_destroy(&_godot_string); + godot_string_new_copy(&_godot_string, &s._godot_string); } bool String::operator ==(const String &s) @@ -83,15 +83,15 @@ bool String::operator !=(const String &s) String String::operator +(const String &s) { - String new_string; - godot_string_operator_plus(&new_string._godot_string, &_godot_string, &s._godot_string); + String new_string = *this; + godot_string_operator_plus(&new_string._godot_string, &s._godot_string); return new_string; } void String::operator +=(const String &s) { - godot_string_operator_plus(&_godot_string, &_godot_string, &s._godot_string); + godot_string_operator_plus(&_godot_string, &s._godot_string); } void String::operator +=(const wchar_t c) diff --git a/src/core/Variant.cpp b/src/core/Variant.cpp index 7a4d5754..1c6eef26 100644 --- a/src/core/Variant.cpp +++ b/src/core/Variant.cpp @@ -17,7 +17,7 @@ Variant::Variant() Variant::Variant(const Variant& v) { - godot_variant_copy(&_godot_variant, &v._godot_variant); + godot_variant_new_copy(&_godot_variant, &v._godot_variant); } Variant::Variant(bool p_bool) @@ -192,7 +192,7 @@ Variant::Variant(const PoolColorArray& p_color_array) Variant &Variant::operator =(const Variant& v) { - godot_variant_copy(&_godot_variant, &v._godot_variant); + godot_variant_new_copy(&_godot_variant, &v._godot_variant); return *this; }