From: Hwankyu Jhun Date: Fri, 7 Sep 2018 09:16:52 +0000 (+0900) Subject: Add an exception handling X-Git-Tag: accepted/tizen/unified/20180910.172054~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71cebf63665b7dfa8a96c5207341258d1275b942;p=platform%2Fcore%2Fappfw%2Ftidl.git 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 --- 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[] =