Modified C Generator 22/189222/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 14 Sep 2018 09:39:47 +0000 (18:39 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Mon, 17 Sep 2018 00:52:33 +0000 (00:52 +0000)
- Adds delegator dtor

Change-Id: I69f55d3735676d0b180dea7973d11e260916f334
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/c_gen/c_proxy_body_gen.cc
idlc/c_gen/c_proxy_body_gen.h
idlc/c_gen/c_proxy_body_gen_cb.h
idlc/c_gen/c_proxy_header_gen.cc
idlc/c_gen/c_proxy_header_gen_cb.h

index 76aed88870c7a0dae09c042de34090749ac2f70b..85c7f1196c4ac3bc5677fad7d21b794fcf31d703 100644 (file)
@@ -99,6 +99,7 @@ void CProxyBodyGen::GenInterfaceDelegator(std::ofstream& stream,
   GenInterfaceDelegatorSerializer(stream, id, decl);
   GenInterfaceDelegatorDeserializer(stream, id, decl);
   GenInterfaceDelegatorConstructor(stream, id, decl);
+  GenInterfaceDelegatorDestructor(stream, id, decl);
   GenInterfaceDelegatorDisposer(stream, id, decl);
   GenInterfaceDelegatorInvoker(stream, id, decl);
 }
@@ -208,6 +209,12 @@ void CProxyBodyGen::GenInterfaceDelegatorInvoker(
         }));
 }
 
+void CProxyBodyGen::GenInterfaceDelegatorDestructor(
+    std::ofstream& stream, const std::string& id, const Declaration& decl) {
+  stream << SmartIndent(ReplaceAll(
+      CB_DELEGATE_DTOR, "##", id + "_" + decl.GetID()));
+}
+
 void CProxyBodyGen::GenInterfaceDelegatorTable(std::ofstream& stream,
                                                const Interface& inf) {
   const char block[] =
index 341b112988951ee8b574bb58c9e1b5a68626fc27..04dd55e7879eb9c904473021105229b996d06c86 100644 (file)
@@ -81,6 +81,9 @@ class CProxyBodyGen : public CBodyGeneratorBase {
   void GenInterfaceDelegatorInvoker(std::ofstream& stream,
                                     const std::string& id,
                                     const Declaration& decl);
+  void GenInterfaceDelegatorDestructor(std::ofstream& stream,
+                                       const std::string& id,
+                                       const Declaration& decl);
 
  private:
   std::string GetMethodWriteString(const Interface& inf,
index cd22b33d384869e82d516af5f307675a162d95a0..95a87149e9b2aca46a4c231f2e2bc7ab2065de4c 100644 (file)
@@ -130,6 +130,21 @@ int rpc_port_proxy_##_dispose(rpc_port_proxy_$$_h proxy, rpc_port_##_h delegate)
 }
 )__c_cb";
 
+const char CB_DELEGATE_DTOR[] =
+R"__c_cb(
+int rpc_port_proxy_##_destroy(rpc_port_##_h delegate)
+{
+    if (!delegate) {
+        _E("Invalid parameter");
+        return -1;
+    }
+
+    free(delegate);
+
+    return 0;
+}
+)__c_cb";
+
 const char CB_DELEGATE_INVOKER[] =
 R"__c_cb(
 static void __$$_delegate_$$(GList **list, rpc_port_parcel_h parcel, int seq_id, int id)
index 922de759c3597d3f55ab8e6a1622a5622c6a2b0d..0ca669c56dfc91ca9194600065c78ea3bf2d9bc0 100644 (file)
@@ -101,6 +101,7 @@ void CProxyHeaderGen::GenInterfaceDelegator(std::ofstream& stream,
       });
 
   stream << ReplaceAll(CB_DELEGATE_CTOR, "##", id + "_" + decl.GetID());
+  stream << ReplaceAll(CB_DELEGATE_DTOR, "##", id + "_" + decl.GetID());
   stream << GenTemplateString(
       ReplaceAll(CB_DELEGATE_DISPOSER, "##", id + "_" + decl.GetID()),
       [&]()->std::string {
index 0fd524b134f117969abb2b519049227673747373..4fe6dafe850cd4fa7a459dbd35e3f604ba0b7981 100644 (file)
@@ -65,4 +65,9 @@ R"__c_cb(
 int rpc_port_proxy_##_dispose(rpc_port_proxy_$$_h proxy, rpc_port_##_h delegate);
 )__c_cb";
 
+const char CB_DELEGATE_DTOR[] =
+R"__c_cb(
+int rpc_port_##_destroy(rpc_port_##_h delegate);
+)__c_cb";
+
 #endif  // IDLC_C_GEN_C_PROXY_HEADER_GEN_CB_H_