From: jh9216.park Date: Tue, 4 Oct 2022 03:04:04 +0000 (-0400) Subject: Move invocation parameters X-Git-Tag: accepted/tizen/7.0/unified/20221110.062448~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F50%2F282450%2F1;p=platform%2Fcore%2Fappfw%2Ftidl.git Move invocation parameters - Some parameters can be moved to improve performance Change-Id: Id80a74fded6b4188b23a2a4fa5fd274789ef743b Signed-off-by: jh9216.park --- diff --git a/idlc/gen/cpp_gen_base.cc b/idlc/gen/cpp_gen_base.cc index ee9f047..e14c663 100644 --- a/idlc/gen/cpp_gen_base.cc +++ b/idlc/gen/cpp_gen_base.cc @@ -718,4 +718,28 @@ void CppGeneratorBase::GenVersionDefinition(std::ofstream& stream) { stream << ReplaceAll(CB_VERSION_DEF, "[VERSION]", FULLVER); } +bool CppGeneratorBase::IsMovableType(const BaseType& type, + ParameterType::Direction dir) { + for (auto& i : GetDocument().GetBlocks()) { + if (i->GetType() != Block::TYPE_INTERFACE) + continue; + Interface& iface = static_cast(*i); + + if (IsDelegateType(iface, type)) + return true; + + if (dir != ParameterType::Direction::IN) + continue; + + if (type.ToString() == "string" || + type.ToString() == "file" || + type.ToString() == "bundle" || + type.GetMetaType() != nullptr || + type.IsUserDefinedType()) + return true; + } + + return false; +} + } // namespace tidl diff --git a/idlc/gen/cpp_gen_base.h b/idlc/gen/cpp_gen_base.h index 0d32993..8bf5c40 100644 --- a/idlc/gen/cpp_gen_base.h +++ b/idlc/gen/cpp_gen_base.h @@ -61,6 +61,7 @@ class CppGeneratorBase : public Generator { void GenLogTag(std::ofstream& stream, std::string id); void GenLogDefinition(std::ofstream& stream); void GenVersionDefinition(std::ofstream& stream); + bool IsMovableType(const BaseType& type, ParameterType::Direction dir); private: std::string GetSetter(const Element& ele); diff --git a/idlc/gen/cpp_stub_body_gen.cc b/idlc/gen/cpp_stub_body_gen.cc index 2c51d1f..4ac8013 100644 --- a/idlc/gen/cpp_stub_body_gen.cc +++ b/idlc/gen/cpp_stub_body_gen.cc @@ -205,7 +205,7 @@ void CppStubBodyGen::GenInvocation(std::ofstream& stream, if (pt.GetDirection() == ParameterType::Direction::OUT) { d += ConvertTypeToString(pt.GetBaseType()) + " " + v + ";\n"; } - if (IsDelegateType(pt.GetBaseType())) { + if (IsMovableType(pt.GetBaseType(), pt.GetDirection())) { m += "std::move("; m += v; m += ")"; diff --git a/tests/build_tests/tidl/Ex.tidl b/tests/build_tests/tidl/Ex.tidl index 8a33828..6ef0733 100644 --- a/tests/build_tests/tidl/Ex.tidl +++ b/tests/build_tests/tidl/Ex.tidl @@ -40,6 +40,8 @@ interface School { int Test4(out list st); int Test5(list st); int Test6(ref list st); + int Test7(string st); + int Test8(bundle st); /// /// Add class