},
[&]()->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;
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();
int id;
int seq_id;
## callback;
+ void *user_data;
};
)__c_cb";
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;
handle->id = $$_DELEGATE_$$;
handle->seq_id = seq_num++;
handle->callback = callback;
+ handle->user_data = user_data;
return handle;
}
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);
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());
},
[&]()->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,
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();