diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2018-06-19 14:52:18 +0900 |
---|---|---|
committer | HwanKyu Jhun <h.jhun@samsung.com> | 2018-06-25 05:32:48 +0000 |
commit | 9284203e1eb4c372eb426560fc85a8b1db4f4c35 (patch) | |
tree | 3cee1b1fddba4dc38b7ecf311183223ac8f2dcbc | |
parent | c3e81ca853a067d8a809a0ff708821876ee5e4c5 (diff) | |
download | tidl-9284203e1eb4c372eb426560fc85a8b1db4f4c35.tar.gz tidl-9284203e1eb4c372eb426560fc85a8b1db4f4c35.tar.bz2 tidl-9284203e1eb4c372eb426560fc85a8b1db4f4c35.zip |
Modify C proxy generator
To make a reusable function, the functions are separated.
Change-Id: I0cc7252a84bd2e4316ddc30835088fb174c5cee3
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rwxr-xr-x | README.md | 11 | ||||
-rw-r--r-- | idlc/c_gen/c_proxy_body_gen.cc | 27 | ||||
-rw-r--r-- | idlc/c_gen/c_proxy_body_gen.h | 7 | ||||
-rw-r--r-- | idlc/c_gen/c_proxy_body_gen_cb.h | 38 | ||||
-rw-r--r-- | idlc/c_gen/c_proxy_header_gen.cc | 13 | ||||
-rw-r--r-- | idlc/c_gen/c_proxy_header_gen.h | 3 | ||||
-rw-r--r-- | idlc/c_gen/c_proxy_header_gen_cb.h | 13 |
7 files changed, 75 insertions, 37 deletions
@@ -247,11 +247,14 @@ typedef struct { void (*rejected)(rpc_port_proxy_Runnable_h h, void* user_data); // Rejected event callback } rpc_port_proxy_Runnable_callback_s; -// Function for connecting service app -int rpc_port_proxy_Runnable_connect(const char* stub_appid,rpc_port_proxy_Runnable_callback_s* callback, void* user_data, rpc_port_proxy_Runnable_h* h); +// Function for creating Runnable proxy handle +int rpc_port_proxy_Runnable_create(const char* stub_appid,rpc_port_proxy_Runnable_callback_s* callback, void* user_data, rpc_port_proxy_Runnable_h* h); -// Function for disconnecting service app -int rpc_port_proxy_Runnable_disconnect(rpc_port_proxy_Runnable_h h); +// Function for connecting to service app +int rpc_port_proxy_Runnable_connect(rpc_port_proxy_Runnable_h h); + +// Function for destroying Runnable proxy handle +int rpc_port_proxy_Runnable_destroy(rpc_port_proxy_Runnable_h h); // Function from TIDL int rpc_port_proxy_Runnable_invoke_Run(rpc_port_proxy_Runnable_h h, rpc_port_Foo_h foo); diff --git a/idlc/c_gen/c_proxy_body_gen.cc b/idlc/c_gen/c_proxy_body_gen.cc index 4b78826..0f9bdea 100644 --- a/idlc/c_gen/c_proxy_body_gen.cc +++ b/idlc/c_gen/c_proxy_body_gen.cc @@ -70,10 +70,11 @@ void CProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& inf) { GenInterfaceOnRejectedEventCB(stream, inf); GenInterfaceOnReceivedEventCB(stream, inf); GenInterfaceMethods(stream, inf); - GenInterfaceConstructor(stream, inf); - GenInterfaceDestructor(stream, inf); + GenInterfaceHandleCtor(stream, inf); + GenInterfaceHandleDtor(stream, inf); + GenInterfaceCtor(stream, inf); GenInterfaceConnect(stream, inf); - GenInterfaceDisconnect(stream, inf); + GenInterfaceDtor(stream, inf); } void CProxyBodyGen::GenInterfaceDeclaration(std::ofstream& stream, @@ -365,15 +366,21 @@ void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream, } } -void CProxyBodyGen::GenInterfaceConstructor(std::ofstream& stream, - const Interface& inf) { - stream << SmartIndent(ReplaceAll(CB_INTERFACE_CTOR, "##", +void CProxyBodyGen::GenInterfaceHandleCtor(std::ofstream& stream, + const Interface& inf) { + stream << SmartIndent(ReplaceAll(CB_INTERFACE_HANDLE_CTOR, "##", GetInterfaceIdWithNamespace(inf))); } -void CProxyBodyGen::GenInterfaceDestructor(std::ofstream& stream, +void CProxyBodyGen::GenInterfaceHandleDtor(std::ofstream& stream, const Interface& inf) { - stream << SmartIndent(ReplaceAll(CB_INTERFACE_DTOR, "##", + stream << SmartIndent(ReplaceAll(CB_INTERFACE_HANDLE_DTOR, "##", + GetInterfaceIdWithNamespace(inf))); +} + +void CProxyBodyGen::GenInterfaceCtor(std::ofstream& stream, + const Interface& inf) { + stream << SmartIndent(ReplaceAll(CB_INTERFACE_CTOR, "##", GetInterfaceIdWithNamespace(inf))); } @@ -383,9 +390,9 @@ void CProxyBodyGen::GenInterfaceConnect(std::ofstream& stream, GetInterfaceIdWithNamespace(inf))); } -void CProxyBodyGen::GenInterfaceDisconnect(std::ofstream& stream, +void CProxyBodyGen::GenInterfaceDtor(std::ofstream& stream, const Interface& inf) { - stream << SmartIndent(ReplaceAll(CB_INTERFACE_DISCONNECT, "##", + stream << SmartIndent(ReplaceAll(CB_INTERFACE_DTOR, "##", GetInterfaceIdWithNamespace(inf))); } diff --git a/idlc/c_gen/c_proxy_body_gen.h b/idlc/c_gen/c_proxy_body_gen.h index a37d4fd..341b112 100644 --- a/idlc/c_gen/c_proxy_body_gen.h +++ b/idlc/c_gen/c_proxy_body_gen.h @@ -54,10 +54,11 @@ class CProxyBodyGen : public CBodyGeneratorBase { void GenInterfaceOnReceivedEventCB(std::ofstream& stream, const Interface& inf); void GenInterfaceMethods(std::ofstream& stream, const Interface& inf); - void GenInterfaceConstructor(std::ofstream& stream, const Interface& inf); - void GenInterfaceDestructor(std::ofstream& stream, const Interface& inf); + void GenInterfaceHandleCtor(std::ofstream& stream, const Interface& inf); + void GenInterfaceHandleDtor(std::ofstream& stream, const Interface& inf); + void GenInterfaceCtor(std::ofstream& stream, const Interface& inf); void GenInterfaceConnect(std::ofstream& stream, const Interface& inf); - void GenInterfaceDisconnect(std::ofstream& stream, const Interface& inf); + void GenInterfaceDtor(std::ofstream& stream, const Interface& inf); private: void GenInterfaceDelegator(std::ofstream& stream, const std::string& id, diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h index fd75454..2499fa7 100644 --- a/idlc/c_gen/c_proxy_body_gen_cb.h +++ b/idlc/c_gen/c_proxy_body_gen_cb.h @@ -294,7 +294,7 @@ $$ } )__c_cb"; -const char CB_INTERFACE_CTOR[] = +const char CB_INTERFACE_HANDLE_CTOR[] = R"__c_cb( static struct ##_s *__create_##(const char *stub_appid, rpc_port_proxy_##_callback_s *callback, void *user_data) { @@ -330,7 +330,7 @@ static struct ##_s *__create_##(const char *stub_appid, rpc_port_proxy_##_callba } )__c_cb"; -const char CB_INTERFACE_DTOR[] = +const char CB_INTERFACE_HANDLE_DTOR[] = R"__c_cb( static void __destroy_##(struct ##_s *h) { @@ -352,9 +352,9 @@ static void __destroy_##(struct ##_s *h) } )__c_cb"; -const char CB_INTERFACE_CONNECT[] = +const char CB_INTERFACE_CTOR[] = R"__c_cb( -int rpc_port_proxy_##_connect(const char *stub_appid, rpc_port_proxy_##_callback_s *callback, void *user_data, rpc_port_proxy_##_h *h) +int rpc_port_proxy_##_create(const char *stub_appid, rpc_port_proxy_##_callback_s *callback, void *user_data, rpc_port_proxy_##_h *h) { struct ##_s *handle; int r; @@ -396,22 +396,36 @@ int rpc_port_proxy_##_connect(const char *stub_appid, rpc_port_proxy_##_callback return r; } - r = rpc_port_proxy_connect(handle->proxy, stub_appid, "##"); - if (r != 0) { - _E("Failed to connect ##(%s)", stub_appid); - __destroy_##(handle); - return r; + *h = handle; + + return 0; +} +)__c_cb"; + +const char CB_INTERFACE_CONNECT[] = +R"__c_cb( +int rpc_port_proxy_##_connect(rpc_port_proxy_##_h h) +{ + int r; + + if (!h || !h->proxy) { + _E("Invalid parameter"); + return -1; } - *h = handle; + r = rpc_port_proxy_connect(h->proxy, h->stub_appid, "##"); + if (r != 0) { + _E("Failed to connect ##(%s)", h->stub_appid); + return r; + } return 0; } )__c_cb"; -const char CB_INTERFACE_DISCONNECT[] = +const char CB_INTERFACE_DTOR[] = R"__c_cb( -int rpc_port_proxy_##_disconnect(rpc_port_proxy_##_h h) +int rpc_port_proxy_##_destroy(rpc_port_proxy_##_h h) { if (!h) { _E("Invalid parameter"); diff --git a/idlc/c_gen/c_proxy_header_gen.cc b/idlc/c_gen/c_proxy_header_gen.cc index abedb2f..922de75 100644 --- a/idlc/c_gen/c_proxy_header_gen.cc +++ b/idlc/c_gen/c_proxy_header_gen.cc @@ -52,8 +52,9 @@ void CProxyHeaderGen::GenInterface(std::ofstream& stream, const Interface& inf) { GenInterfaceDeclaration(stream, inf); GenInterfaceDelegators(stream, inf); + GenInterfaceCtor(stream, inf); GenInterfaceConnect(stream, inf); - GenInterfaceDisconnect(stream, inf); + GenInterfaceDtor(stream, inf); GenInterfaceMethods(stream, inf); } @@ -145,15 +146,21 @@ void CProxyHeaderGen::GenInterfaceMethods(std::ofstream& stream, } } +void CProxyHeaderGen::GenInterfaceCtor(std::ofstream& stream, + const Interface& inf) { + stream << ReplaceAll(CB_INTERFACE_CTOR, "##", + GetInterfaceIdWithNamespace(inf)); +} + void CProxyHeaderGen::GenInterfaceConnect(std::ofstream& stream, const Interface& inf) { stream << ReplaceAll(CB_INTERFACE_CONNECT, "##", GetInterfaceIdWithNamespace(inf)); } -void CProxyHeaderGen::GenInterfaceDisconnect(std::ofstream& stream, +void CProxyHeaderGen::GenInterfaceDtor(std::ofstream& stream, const Interface& inf) { - stream << ReplaceAll(CB_INTERFACE_DISCONNECT, "##", + stream << ReplaceAll(CB_INTERFACE_DTOR, "##", GetInterfaceIdWithNamespace(inf)); } diff --git a/idlc/c_gen/c_proxy_header_gen.h b/idlc/c_gen/c_proxy_header_gen.h index 5957e96..04f3abf 100644 --- a/idlc/c_gen/c_proxy_header_gen.h +++ b/idlc/c_gen/c_proxy_header_gen.h @@ -40,8 +40,9 @@ class CProxyHeaderGen : public CHeaderGeneratorBase { void GenInterfaceDeclaration(std::ofstream& stream, const Interface& inf); void GenInterfaceDelegators(std::ofstream& stream, const Interface& inf); void GenInterfaceMethods(std::ofstream& stream, const Interface& inf); + void GenInterfaceCtor(std::ofstream& stream, const Interface& inf); void GenInterfaceConnect(std::ofstream& stream, const Interface& inf); - void GenInterfaceDisconnect(std::ofstream& stream, const Interface& inf); + void GenInterfaceDtor(std::ofstream& stream, const Interface& inf); private: void GenInterfaceDelegator(std::ofstream& stream, const std::string& id, diff --git a/idlc/c_gen/c_proxy_header_gen_cb.h b/idlc/c_gen/c_proxy_header_gen_cb.h index 631b808..0fd524b 100644 --- a/idlc/c_gen/c_proxy_header_gen_cb.h +++ b/idlc/c_gen/c_proxy_header_gen_cb.h @@ -28,16 +28,21 @@ typedef struct { } rpc_port_proxy_##_callback_s; )__c_cb"; -const char CB_INTERFACE_CONNECT[] = +const char CB_INTERFACE_CTOR[] = R"__c_cb( -int rpc_port_proxy_##_connect(const char *stub_appid, +int rpc_port_proxy_##_create(const char *stub_appid, rpc_port_proxy_##_callback_s *callback, void *user_data, rpc_port_proxy_##_h *h); )__c_cb"; -const char CB_INTERFACE_DISCONNECT[] = +const char CB_INTERFACE_CONNECT[] = +R"__c_cb( +int rpc_port_proxy_##_connect(rpc_port_proxy_##_h h); +)__c_cb"; + +const char CB_INTERFACE_DTOR[] = R"__c_cb( -int rpc_port_proxy_##_disconnect(rpc_port_proxy_##_h h); +int rpc_port_proxy_##_destroy(rpc_port_proxy_##_h h); )__c_cb"; const char CB_INTERFACE_METHODS[] = |