Move invocation parameters 50/282450/1
authorjh9216.park <jh9216.park@samsung.com>
Tue, 4 Oct 2022 03:04:04 +0000 (23:04 -0400)
committerjh9216.park <jh9216.park@samsung.com>
Tue, 4 Oct 2022 03:04:04 +0000 (23:04 -0400)
- Some parameters can be moved to improve performance

Change-Id: Id80a74fded6b4188b23a2a4fa5fd274789ef743b
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
idlc/gen/cpp_gen_base.cc
idlc/gen/cpp_gen_base.h
idlc/gen/cpp_stub_body_gen.cc
tests/build_tests/tidl/Ex.tidl

index ee9f047..e14c663 100644 (file)
@@ -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<Interface&>(*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
index 0d32993..8bf5c40 100644 (file)
@@ -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);
index 2c51d1f..4ac8013 100644 (file)
@@ -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 += ")";
index 8a33828..6ef0733 100644 (file)
@@ -40,6 +40,8 @@ interface School {
   int Test4(out list<StructTest> st);
   int Test5(list<StructTest> st);
   int Test6(ref list<StructTest> st);
+  int Test7(string st);
+  int Test8(bundle st);
 
   /// <summary>
   /// Add class