To make a reusable function, the functions are separated.
Change-Id: I0cc7252a84bd2e4316ddc30835088fb174c5cee3
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
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);
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,
}
}
-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)));
}
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)));
}
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,
}
)__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)
{
}
)__c_cb";
-const char CB_INTERFACE_DTOR[] =
+const char CB_INTERFACE_HANDLE_DTOR[] =
R"__c_cb(
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;
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");
const Interface& inf) {
GenInterfaceDeclaration(stream, inf);
GenInterfaceDelegators(stream, inf);
+ GenInterfaceCtor(stream, inf);
GenInterfaceConnect(stream, inf);
- GenInterfaceDisconnect(stream, inf);
+ GenInterfaceDtor(stream, inf);
GenInterfaceMethods(stream, inf);
}
}
}
+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));
}
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,
} 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[] =