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 7132fdf8959b2c0aeaa025532b81695146bf0c69..b1448e1bc54358a162d77cbef5850aafcdd6c786 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 76f55c7ceca79d924725dde99ce079f9f18a5591..69c88f9e72112d7c12eadbd8a7b681be4fe63332 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 db744e21de21ef81c106e4d162182a20a2100ddc..0bacac443352c26d885e2cd2f1aad3fb3e741d61 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 f8d982009303d3ef29fbdaf50c9482d814f5fae9..6755549454d29721ddd1d54cee475d0d7a5e2483 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 2359cef108bd9750bb30c9913e33837128102bda..3564967efa72f0da401467d721d4673ef89b9ef7 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 f16e733c9d5def173c8f1c7ab8a6a8c205b94bdd..49e37f0828418ea087cea4d173a080b5aa2941eb 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_