From cb9e65720a27ca654ba1c8fc4f10d01f1cde78b5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 9 Sep 2018 13:45:12 +0200 Subject: [PATCH] interrogate: do not use MOVE in generated code, but use std::move --- dtool/src/interrogate/functionRemap.cxx | 5 ++--- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 4 ++-- dtool/src/interrogate/parameterRemapConcreteToPointer.cxx | 2 +- dtool/src/interrogate/parameterRemapReferenceToPointer.cxx | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index e7a2f828d9..9836a23bfc 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -254,14 +254,13 @@ call_function(ostream &out, int indent_level, bool convert_result, &parser); out << " = " << call << ";\n"; - // MOVE() expands to std::move() when we are compiling with a compiler - // that supports rvalue references. It basically turns an lvalue into + // Use of the C++11 std::move function basically turns an lvalue into // an rvalue, allowing a move constructor to be called instead of a // copy constructor (since we won't be using the return value any // more), which is usually more efficient if it exists. If it // doesn't, it shouldn't do any harm. string new_str = - _return_type->prepare_return_expr(out, indent_level, "MOVE(result)"); + _return_type->prepare_return_expr(out, indent_level, "std::move(result)"); return_expr = _return_type->get_return_expr(new_str); } else { diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5752fe126b..8d2b0f2288 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -5491,7 +5491,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // Use move constructor when available for functions that take an // actual PointerTo. This eliminates an unref()ref() pair. - pexpr_string = "MOVE(" + param_name + "_this)"; + pexpr_string = "std::move(" + param_name + "_this)"; } else { // This is a move-assignable type, such as TypeHandle or LVecBase4. @@ -6156,7 +6156,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "return true;\n"; } else if (TypeManager::is_reference_count(remap->_cpptype)) { - indent(out, indent_level) << "coerced = MOVE(" << return_expr << ");\n"; + indent(out, indent_level) << "coerced = std::move(" << return_expr << ");\n"; indent(out, indent_level) << "return true;\n"; } else { diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx index f5e7c35b39..9f217076cb 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx @@ -40,7 +40,7 @@ pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? - out << "MOVE(" << variable_name.substr(1) << ")"; + out << "std::move(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx index 6c8e8b05a9..4e8d1fad90 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx @@ -42,7 +42,7 @@ pass_parameter(std::ostream &out, const std::string &variable_name) { // this parameter is an rvalue reference, but CPPParser can't know that, // and it might have an overload that takes an rvalue reference. It // shouldn't hurt either way. - out << "MOVE(" << variable_name.substr(1) << ")"; + out << "std::move(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; }