Fixed C Generator 84/187584/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 24 Aug 2018 10:13:44 +0000 (19:13 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 24 Aug 2018 10:13:44 +0000 (19:13 +0900)
Adds client number getter:
 - rpc_port_stub_<interface>_client_number()

Change-Id: I6676d81d110c00f038eb7bfc1f70d9eea8601ff8
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/c_gen/c_stub_body_gen.cc
idlc/c_gen/c_stub_body_gen.h
idlc/c_gen/c_stub_body_gen_cb.h
idlc/c_gen/c_stub_header_gen.cc
idlc/c_gen/c_stub_header_gen.h
idlc/c_gen/c_stub_header_gen_cb.h

index 7132fdf..b1448e1 100644 (file)
@@ -62,6 +62,7 @@ void CStubBodyGen::GenInterface(std::ofstream& stream, const Interface& inf) {
   GenInterfaceAddPrivileges(stream, inf);
   GenInterfaceRegister(stream, inf);
   GenInterfaceUnregister(stream, inf);
+  GenInterfaceClientNumberGetter(stream, inf);
 }
 
 void CStubBodyGen::GenInterfaceMethods(std::ofstream& stream,
@@ -562,4 +563,10 @@ void CStubBodyGen::GenInterfaceAddPrivileges(std::ofstream& stream,
         }));
 }
 
+void CStubBodyGen::GenInterfaceClientNumberGetter(std::ofstream& stream,
+                                                  const Interface& inf) {
+  stream << SmartIndent(ReplaceAll(CB_INTERFACE_CLIENT_NUMBER_GETTER, "##",
+      GetInterfaceIdWithNamespace(inf)));
+}
+
 }  // namespace tidl
index 76f55c7..69c88f9 100644 (file)
@@ -50,6 +50,8 @@ class CStubBodyGen : public CBodyGeneratorBase {
   void GenInterfaceDelegators(std::ofstream& stream, const Interface& inf);
   void GenInterfaceContext(std::ofstream& stream, const Interface& inf);
   void GenInterfaceAddPrivileges(std::ofstream& stream, const Interface& inf);
+  void GenInterfaceClientNumberGetter(std::ofstream& stream,
+                                      const Interface& inf);
 
  private:
   void GenInterfaceContextDeclaration(std::ofstream& stream,
index db744e2..0bacac4 100644 (file)
@@ -207,6 +207,26 @@ int rpc_port_stub_##_unregister(void)
 }
 )__c_cb";
 
+const char CB_INTERFACE_CLIENT_NUMBER_GETTER[] =
+R"__c_cb(
+int rpc_port_stub_##_get_client_number(unsigned int *n)
+{
+       if (!n) {
+               _E("Invalid parameter");
+               return -1;
+       }
+
+       if (!__##_stub) {
+               _E("## Stub is not ready");
+               return -1;
+       }
+
+       *n = g_list_length(__##_contexts);
+
+       return 0;
+}
+)__c_cb";
+
 const char CB_GLOBALS[] =
 R"__c_cb(
 static rpc_port_stub_h __##_stub;
index f8d9820..6755549 100644 (file)
@@ -55,6 +55,7 @@ void CStubHeaderGen::GenInterface(std::ofstream& stream,
   GenInterfaceDeclaration(stream, inf);
   GenInterfaceRegister(stream, inf);
   GenInterfaceUnregister(stream, inf);
+  GenInterfaceClientNumberGetter(stream, inf);
 }
 
 void CStubHeaderGen::GenInterfaceDeclaration(std::ofstream& stream,
@@ -194,4 +195,10 @@ void CStubHeaderGen::GenInterfaceUnregister(std::ofstream& stream,
       GetInterfaceIdWithNamespace(inf));
 }
 
+void CStubHeaderGen::GenInterfaceClientNumberGetter(std::ofstream& stream,
+                                                    const Interface& inf) {
+  stream << ReplaceAll(CB_INTERFACE_CLIENT_NUMBER_GETTER, "##",
+      GetInterfaceIdWithNamespace(inf));
+}
+
 }  // namespace tidl
index 2359cef..3564967 100644 (file)
@@ -40,6 +40,8 @@ class CStubHeaderGen : public CHeaderGeneratorBase {
   void GenInterfaceDelegators(std::ofstream& stream, const Interface& inf);
   void GenInterfaceRegister(std::ofstream& stream, const Interface& inf);
   void GenInterfaceUnregister(std::ofstream& stream, const Interface& inf);
+  void GenInterfaceClientNumberGetter(std::ofstream& stream,
+                                       const Interface& inf);
 
  private:
   void GenInterfaceContextDeclaration(std::ofstream& stream,
index f16e733..49e37f0 100644 (file)
@@ -79,4 +79,9 @@ R"__c_cb(
 int rpc_port_stub_##_unregister(void);
 )__c_cb";
 
+const char CB_INTERFACE_CLIENT_NUMBER_GETTER[] =
+R"__c_cb(
+int rpc_port_stub_##_get_client_number(unsigned int *n);
+)__c_cb";
+
 #endif  // IDLC_C_GEN_C_STUB_HEADER_GEN_CB_H_