summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
Diffstat (limited to 'idlc')
-rw-r--r--idlc/c_gen/c_proxy_body_gen.cc27
-rw-r--r--idlc/c_gen/c_proxy_body_gen.h7
-rw-r--r--idlc/c_gen/c_proxy_body_gen_cb.h38
-rw-r--r--idlc/c_gen/c_proxy_header_gen.cc13
-rw-r--r--idlc/c_gen/c_proxy_header_gen.h3
-rw-r--r--idlc/c_gen/c_proxy_header_gen_cb.h13
6 files changed, 68 insertions, 33 deletions
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[] =