summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2018-09-07 18:16:52 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2018-09-10 08:56:40 +0900
commit71cebf63665b7dfa8a96c5207341258d1275b942 (patch)
tree271a77a0d9e2331a32e1d264ff960b1c180311a8
parent33888057f919f08a51035310ad81d90ebf16d6b4 (diff)
downloadtidl-71cebf63665b7dfa8a96c5207341258d1275b942.tar.gz
tidl-71cebf63665b7dfa8a96c5207341258d1275b942.tar.bz2
tidl-71cebf63665b7dfa8a96c5207341258d1275b942.zip
Add an exception handling
Cpp Generator: - Adds an exception handling about rpc_port_parcel_send() C Generator: - Sets the result of rpc_port_parcel_send() Change-Id: I6ec3a0028ba1c83e50735717a97a1009d350939b Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--idlc/c_gen/c_proxy_body_gen.cc5
-rw-r--r--idlc/c_gen/c_proxy_body_gen_cb.h8
-rw-r--r--idlc/cpp_gen/cpp_proxy_body_gen_cb.h7
3 files changed, 17 insertions, 3 deletions
diff --git a/idlc/c_gen/c_proxy_body_gen.cc b/idlc/c_gen/c_proxy_body_gen.cc
index 0f9bdea..11aae75 100644
--- a/idlc/c_gen/c_proxy_body_gen.cc
+++ b/idlc/c_gen/c_proxy_body_gen.cc
@@ -450,8 +450,10 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
const Declaration& decl) {
const char setter[] = "$$($$, $$);\n";
std::string str;
- if (decl.GetMethodType() != Declaration::MethodType::SYNC)
+ if (decl.GetMethodType() != Declaration::MethodType::SYNC) {
+ str += "set_last_result(r);" + NLine(1);
return str;
+ }
str += GenTemplateString(CB_RECEIVE_BLOCK,
[&]()->std::string {
std::string s;
@@ -523,6 +525,7 @@ std::string CProxyBodyGen::GetMethodReadString(const Interface& inf,
return s;
});
if (GetReturnTypeString(decl.GetType()) != "void ") {
+ str += "set_last_result(r);" + NLine(1);
str += NLine(1);
str += "return ret;";
}
diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h
index 2499fa7..cd22b33 100644
--- a/idlc/c_gen/c_proxy_body_gen_cb.h
+++ b/idlc/c_gen/c_proxy_body_gen_cb.h
@@ -273,6 +273,7 @@ R"__c_cb(
$$rpc_port_proxy_##_invoke_$$(rpc_port_proxy_##_h h$$)
{
rpc_port_parcel_h parcel;
+ int r;
$$
if (!h$$) {
@@ -288,7 +289,12 @@ $$
rpc_port_parcel_create(&parcel);
rpc_port_parcel_write_int32(parcel, ##_METHOD_$$);
$$
- rpc_port_parcel_send(parcel, h->port);
+ r = rpc_port_parcel_send(parcel, h->port);
+ if (r != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. result(%d)", r);
+ r = RPC_PORT_ERROR_IO_ERROR;
+ }
+
rpc_port_parcel_destroy(parcel);
$$
}
diff --git a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
index 35347e3..b5dbefd 100644
--- a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
+++ b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
@@ -38,7 +38,12 @@ R"__cpp_cb( if (port_ == nullptr) {
const char CB_INVOCATION_MID[] =
R"__cpp_cb(
// Send
- rpc_port_parcel_send(p, port_);
+ int r = rpc_port_parcel_send(p, port_);
+ if (r != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. result(%d)", r);
+ rpc_port_parcel_destroy(p);
+ throw InvalidIOException();
+ }
)__cpp_cb";
const char CB_INVOCATION_RECEIVE[] =