From 7fa7f7b9c5d5999a5c626a77b1a9b22da6f009b9 Mon Sep 17 00:00:00 2001 From: Karroffel Date: Sat, 18 Mar 2017 15:23:28 +0100 Subject: [PATCH] added operator overload for string --- binding_generator/src/main.rs | 8 +++++--- include/SConstruct | 4 +++- include/godot_cpp/Godot.hpp | 2 +- include/godot_cpp/core/String.cpp | 5 +++++ include/godot_cpp/core/String.hpp | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/binding_generator/src/main.rs b/binding_generator/src/main.rs index 1af7aaae..d426fa85 100644 --- a/binding_generator/src/main.rs +++ b/binding_generator/src/main.rs @@ -504,7 +504,8 @@ fn generate_icall_header(icalls: &HashSet<(String, Vec)>) -> String { contents = contents + return_type(ret) + " " + get_icall_name_ref((ret, args)).as_str() + "(godot_method_bind *mb, godot_object *inst"; for arg in args { contents = contents + ", "; - if !is_primitive(&arg) && is_core_type(&arg) { + // if !is_primitive(&arg) && is_core_type(&arg) { + if !is_primitive(&arg) { contents = contents + "const " + arg.as_str() + "&"; } else { contents = contents + "const " + arg.as_str() + ""; @@ -544,7 +545,8 @@ fn generate_icall_implementation(icalls: &HashSet<(String, Vec)>) -> Str let mut i = 0; for arg in args { contents = contents + ", "; - if !is_primitive(&arg) && is_core_type(&arg) { + // if !is_primitive(&arg) && is_core_type(&arg) { + if !is_primitive(&arg) { contents = contents + "const " + arg.as_str() + "&"; } else { contents = contents + "const " + arg.as_str() + ""; @@ -570,7 +572,7 @@ fn generate_icall_implementation(icalls: &HashSet<(String, Vec)>) -> Str } else if is_core_type(arg) { contents = contents + "(void *) &arg" + j.to_string().as_str(); } else { - contents = contents + "(void *) *(godot_object**) &arg" + j.to_string().as_str(); + contents = contents + "(void *) arg" + j.to_string().as_str() + ".__core_object"; } contents = contents + ",\n"; j = j + 1; diff --git a/include/SConstruct b/include/SConstruct index 1e8f7b90..158ac207 100644 --- a/include/SConstruct +++ b/include/SConstruct @@ -57,7 +57,9 @@ elif target == "bindings": env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN/\'']) env.Append(CPPPATH=['.', './godot', './godot_cpp']) - env.Append(LIBS=['godot_cpp_core', 'godot.windows.tools.64']) + if platform == "windows": + env.Append(LIBS=['godot.windows.tools.64']) + env.Append(LIBS=['godot_cpp_core']) env.Append(LIBPATH=["."]) env.Append(CPPFLAGS=['-D_GD_CPP_BINDING_IMPL']) diff --git a/include/godot_cpp/Godot.hpp b/include/godot_cpp/Godot.hpp index c3df7e46..bacfd646 100644 --- a/include/godot_cpp/Godot.hpp +++ b/include/godot_cpp/Godot.hpp @@ -173,7 +173,7 @@ struct _WrappedMethod1 { (obj->*(method->f))(*arg[0]); return v; - } + } }; diff --git a/include/godot_cpp/core/String.cpp b/include/godot_cpp/core/String.cpp index c3c78e4a..af83f2e6 100644 --- a/include/godot_cpp/core/String.cpp +++ b/include/godot_cpp/core/String.cpp @@ -66,6 +66,11 @@ int String::length() const return len; } +void String::operator =(const String &s) +{ + godot_string_copy_string(&_godot_string, &s._godot_string); +} + bool String::operator ==(const String &s) { return godot_string_operator_equal(&_godot_string, &s._godot_string); diff --git a/include/godot_cpp/core/String.hpp b/include/godot_cpp/core/String.hpp index ec142423..00790ae8 100644 --- a/include/godot_cpp/core/String.hpp +++ b/include/godot_cpp/core/String.hpp @@ -41,6 +41,8 @@ public: int length() const; + void operator =(const String &s); + bool operator ==(const String &s); bool operator !=(const String &s);