interrogate: do not use MOVE in generated code, but use std::move

This commit is contained in:
rdb
2018-09-09 13:45:12 +02:00
parent 1a94e65b17
commit cb9e65720a
4 changed files with 6 additions and 7 deletions
+2 -3
View File
@@ -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 {
@@ -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 {
@@ -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 *&param 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;
}
@@ -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;
}