summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon Park <jh9216.park@samsung.com>2018-03-22 20:16:53 +0900
committerJunghoon Park <jh9216.park@samsung.com>2018-03-22 20:16:53 +0900
commitaefcd4c19f6138a45414daae1c1a2b6d4e15f4db (patch)
tree0114324a2527027fca1cb66e69d77933e6610b23
parentf0155ab787102718ca14df3caf9bd83225f3a869 (diff)
downloadtidl-aefcd4c19f6138a45414daae1c1a2b6d4e15f4db.tar.gz
tidl-aefcd4c19f6138a45414daae1c1a2b6d4e15f4db.tar.bz2
tidl-aefcd4c19f6138a45414daae1c1a2b6d4e15f4db.zip
Add user data in delegate object
Change-Id: I668baf7cf28b49c6dc3fc887a52b3d5b83f56495 Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r--idlc/c_gen/c_proxy_body_gen.cc11
-rw-r--r--idlc/c_gen/c_proxy_body_gen_cb.h10
-rw-r--r--idlc/c_gen/c_proxy_header_gen.cc22
-rw-r--r--idlc/c_gen/c_proxy_header_gen_cb.h5
4 files changed, 29 insertions, 19 deletions
diff --git a/idlc/c_gen/c_proxy_body_gen.cc b/idlc/c_gen/c_proxy_body_gen.cc
index c53b9f0..d7299fb 100644
--- a/idlc/c_gen/c_proxy_body_gen.cc
+++ b/idlc/c_gen/c_proxy_body_gen.cc
@@ -177,13 +177,10 @@ void CProxyBodyGen::GenInterfaceDelegatorInvoker(
},
[&]()->std::string {
std::string str;
- str += "handle->callback(";
- int cnt = 1;
+ str += "handle->callback(handle->user_data";
for (auto& i: decl.GetParameters().GetParams()) {
- if (cnt != 1)
- str += ", ";
+ str += ", ";
str += i->GetID();
- cnt++;
}
str += ");" + NLine(1);
return str;
@@ -303,9 +300,9 @@ void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream,
for (auto& p : i->GetParameters().GetParams()) {
str += ", ";
if (TypeIsDelegator(inf, p->GetParameterType().GetBaseType())) {
- str += inf.GetID() + "_" +
+ str += "rpc_port_" + inf.GetID() + "_" +
p->GetParameterType().GetBaseType().ToString() +
- " " + p->GetID();
+ "_h " + p->GetID();
} else {
str += GetParamTypeString(p->GetParameterType().GetDirection(),
p->GetParameterType().GetBaseType()) + p->GetID();
diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h
index 1abf199..08e3325 100644
--- a/idlc/c_gen/c_proxy_body_gen_cb.h
+++ b/idlc/c_gen/c_proxy_body_gen_cb.h
@@ -33,6 +33,7 @@ struct ##_s {
int id;
int seq_id;
## callback;
+ void *user_data;
};
)__c_cb";
@@ -70,7 +71,7 @@ static void __##_from(rpc_port_parcel_h parcel, void *data)
const char CB_DELEGATE_CTOR[] =
R"__c_cb(
-static struct ##_s *__create_##(## callback)
+rpc_port_##_h rpc_port_##_create(## callback, void *user_data)
{
struct ##_s *handle;
static int seq_num;
@@ -86,6 +87,7 @@ static struct ##_s *__create_##(## callback)
handle->id = $$_DELEGATE_$$;
handle->seq_id = seq_num++;
handle->callback = callback;
+ handle->user_data = user_data;
return handle;
}
@@ -375,11 +377,7 @@ int rpc_port_proxy_##_disconnect(rpc_port_proxy_##_h h)
const char CB_DELEGATE_BLOCK[] =
R"__c_cb(
do {
- struct ##_s *handle;
-
- handle = __create_##($$);
- if (!handle)
- break;
+ struct ##_s *handle = $$;
rpc_port_parcel_write(parcel, &handle->parcelable, handle);
h->delegates = g_list_append(h->delegates, handle);
diff --git a/idlc/c_gen/c_proxy_header_gen.cc b/idlc/c_gen/c_proxy_header_gen.cc
index caa7eb8..7da766b 100644
--- a/idlc/c_gen/c_proxy_header_gen.cc
+++ b/idlc/c_gen/c_proxy_header_gen.cc
@@ -69,6 +69,16 @@ void CProxyHeaderGen::GenInterfaceDelegators(std::ofstream& stream,
void CProxyHeaderGen::GenInterfaceDelegator(std::ofstream& stream,
const std::string& id,
const Declaration& decl) {
+ const char handle[] = "typedef struct $$_s *rpc_port_$$_h;";
+
+ stream << GenTemplateString(handle,
+ [&]()->std::string {
+ return id + "_" + decl.GetID();
+ },
+ [&]()->std::string {
+ return id + "_" + decl.GetID();
+ });
+
stream << GenTemplateString(CB_INTERFACE_DELEGATOR,
[&]()->std::string {
return GetReturnTypeString(decl.GetType());
@@ -78,17 +88,17 @@ void CProxyHeaderGen::GenInterfaceDelegator(std::ofstream& stream,
},
[&]()->std::string {
std::string str;
- int cnt = 1;
+ str += "void *user_data";
for (auto& p : decl.GetParameters().GetParams()) {
- if (cnt != 1)
- str += ", ";
+ str += ", ";
str += GetParamTypeString(p->GetParameterType().GetDirection(),
p->GetParameterType().GetBaseType()) + p->GetID();
- cnt++;
}
return str;
}
);
+
+ stream << ReplaceAll(CB_DELEGATE_CTOR, "##", id + "_" + decl.GetID());
}
void CProxyHeaderGen::GenInterfaceDeclaration(std::ofstream& stream,
@@ -114,9 +124,9 @@ void CProxyHeaderGen::GenInterfaceMethods(std::ofstream& stream,
for (auto& p : i->GetParameters().GetParams()) {
str += ", ";
if (TypeIsDelegator(inf, p->GetParameterType().GetBaseType())) {
- str += inf.GetID() + "_" +
+ str += "rpc_port_" + inf.GetID() + "_" +
p->GetParameterType().GetBaseType().ToString() +
- " " + p->GetID();
+ "_h " + p->GetID();
} else {
str += GetParamTypeString(p->GetParameterType().GetDirection(),
p->GetParameterType().GetBaseType()) + p->GetID();
diff --git a/idlc/c_gen/c_proxy_header_gen_cb.h b/idlc/c_gen/c_proxy_header_gen_cb.h
index 8569328..7306c2f 100644
--- a/idlc/c_gen/c_proxy_header_gen_cb.h
+++ b/idlc/c_gen/c_proxy_header_gen_cb.h
@@ -46,3 +46,8 @@ const char CB_INTERFACE_DELEGATOR[] =
R"__c_cb(
typedef $$(*$$)($$);
)__c_cb";
+
+const char CB_DELEGATE_CTOR[] =
+R"__c_cb(
+rpc_port_##_h rpc_port_##_create(## callback, void *user_data);
+)__c_cb";