From: Hwankyu Jhun Date: Fri, 24 Aug 2018 10:13:44 +0000 (+0900) Subject: Fixed C Generator X-Git-Tag: accepted/tizen/unified/20180831.061821~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F187584%2F1;p=platform%2Fcore%2Fappfw%2Ftidl.git Fixed C Generator Adds client number getter: - rpc_port_stub__client_number() Change-Id: I6676d81d110c00f038eb7bfc1f70d9eea8601ff8 Signed-off-by: Hwankyu Jhun --- diff --git a/idlc/c_gen/c_stub_body_gen.cc b/idlc/c_gen/c_stub_body_gen.cc index 7132fdf..b1448e1 100644 --- a/idlc/c_gen/c_stub_body_gen.cc +++ b/idlc/c_gen/c_stub_body_gen.cc @@ -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 diff --git a/idlc/c_gen/c_stub_body_gen.h b/idlc/c_gen/c_stub_body_gen.h index 76f55c7..69c88f9 100644 --- a/idlc/c_gen/c_stub_body_gen.h +++ b/idlc/c_gen/c_stub_body_gen.h @@ -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, diff --git a/idlc/c_gen/c_stub_body_gen_cb.h b/idlc/c_gen/c_stub_body_gen_cb.h index db744e2..0bacac4 100644 --- a/idlc/c_gen/c_stub_body_gen_cb.h +++ b/idlc/c_gen/c_stub_body_gen_cb.h @@ -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; diff --git a/idlc/c_gen/c_stub_header_gen.cc b/idlc/c_gen/c_stub_header_gen.cc index f8d9820..6755549 100644 --- a/idlc/c_gen/c_stub_header_gen.cc +++ b/idlc/c_gen/c_stub_header_gen.cc @@ -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 diff --git a/idlc/c_gen/c_stub_header_gen.h b/idlc/c_gen/c_stub_header_gen.h index 2359cef..3564967 100644 --- a/idlc/c_gen/c_stub_header_gen.h +++ b/idlc/c_gen/c_stub_header_gen.h @@ -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, diff --git a/idlc/c_gen/c_stub_header_gen_cb.h b/idlc/c_gen/c_stub_header_gen_cb.h index f16e733..49e37f0 100644 --- a/idlc/c_gen/c_stub_header_gen_cb.h +++ b/idlc/c_gen/c_stub_header_gen_cb.h @@ -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_