{"float", "float"},
{"double", "double"},
{"bundle", "bundle"},
+ {"file", "string"},
};
}
[&]()->std::string {
if ((i->GetType().IsUserDefinedType() ||
i->GetType().ToString() == "string" ||
- i->GetType().ToString() == "bundle") ||
+ i->GetType().ToString() == "bundle" ||
+ i->GetType().ToString() == "file") ||
((i->GetType().ToString() == "list" ||
i->GetType().ToString() == "array") &&
(i->GetType().GetMetaType()->IsUserDefinedType() ||
i->GetType().GetMetaType()->ToString() == "list" ||
i->GetType().GetMetaType()->ToString() == "array" ||
i->GetType().GetMetaType()->ToString() == "string" ||
- i->GetType().GetMetaType()->ToString() == "bundle")))
+ i->GetType().GetMetaType()->ToString() == "bundle" ||
+ i->GetType().GetMetaType()->ToString() == "file")))
return "!h || !" + i->GetID();
return "!h";
i->GetType().GetMetaType()->ToString() == "list" ||
i->GetType().GetMetaType()->ToString() == "array" ||
i->GetType().GetMetaType()->ToString() == "string" ||
- i->GetType().GetMetaType()->ToString() == "bundle")
+ i->GetType().GetMetaType()->ToString() == "bundle" ||
+ i->GetType().GetMetaType()->ToString() == "file")
return GetParcelParamTypeString(*i->GetType().GetMetaType());
return ConvertTypeToString(ParameterType::Direction::IN,
return "&value->parcelable, value";
if (type.GetMetaType()->ToString() == "bundle")
return "value";
- if (type.GetMetaType()->ToString() == "string")
+ if (type.GetMetaType()->ToString() == "string"
+ || type.GetMetaType()->ToString() == "file")
return ReplaceAll(ternary_operation, "##", "value");
return "*value";
});
type.GetMetaType()->ToString() == "list" ||
type.GetMetaType()->ToString() == "array")
return "&h->" + id + "[i]->parcelable, h->" + id +"[i]";
- if (type.GetMetaType()->ToString() == "string")
+ if (type.GetMetaType()->ToString() == "string" ||
+ type.GetMetaType()->ToString() == "file")
return ReplaceAll(ternary_operation, "##", "h->" + id
+ "[i]");
return "h->" + id + "[i]";
return "&value->parcelable, value";
});
} else if (type.GetMetaType()->ToString() == "string" ||
- type.GetMetaType()->ToString() == "bundle") {
+ type.GetMetaType()->ToString() == "bundle"||
+ type.GetMetaType()->ToString() == "file") {
s += GenTemplateString(parcel,
[&]()->std::string {
return GetParcelReadFunctionString(*type.GetMetaType());
type.ToString() != "list" &&
type.ToString() != "array" &&
type.ToString() != "string" &&
- type.ToString() != "bundle")
+ type.ToString() != "bundle" &&
+ type.ToString() != "file")
return str;
if (type.ToString() == "list") {
type.GetMetaType()->ToString() != "list" &&
type.GetMetaType()->ToString() != "array" &&
type.GetMetaType()->ToString() != "string" &&
- type.GetMetaType()->ToString() != "bundle") {
+ type.GetMetaType()->ToString() != "bundle" &&
+ type.GetMetaType()->ToString() != "file") {
return GenTemplateString(CB_IF_STATEMENT,
[&]()->std::string {
return handle + id;
if (type.IsUserDefinedType() ||
type.ToString() == "string" ||
- type.ToString() == "bundle") {
+ type.ToString() == "bundle" ||
+ type.ToString() == "file") {
str += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
[&]()->std::string {
return "h->" + id;
if (type.GetMetaType()->IsUserDefinedType() ||
type.GetMetaType()->ToString() == "string" ||
type.GetMetaType()->ToString() == "bundle" ||
+ type.GetMetaType()->ToString() == "file" ||
type.GetMetaType()->ToString() == "list" ||
type.GetMetaType()->ToString() == "array") {
s += GetSetterString(*type.GetMetaType(), "value", id);
} else {
if (type.IsUserDefinedType() ||
type.ToString() == "string" ||
- type.ToString() == "bundle") {
+ type.ToString() == "bundle" ||
+ type.ToString() == "file") {
str += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
[&]()->std::string {
return "!h->" + id;
if (type.IsUserDefinedType() ||
type.ToString() == "string" ||
- type.ToString() == "bundle") {
+ type.ToString() == "bundle" ||
+ type.ToString() == "file") {
str += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
[&]()->std::string {
return "*" + id + " == NULL";
type.GetMetaType()->ToString() == "list" ||
type.GetMetaType()->ToString() == "array" ||
type.GetMetaType()->ToString() == "string" ||
- type.GetMetaType()->ToString() == "bundle")
+ type.GetMetaType()->ToString() == "bundle" ||
+ type.GetMetaType()->ToString() == "file")
return "value";
return "*value";
if (type.IsUserDefinedType() ||
type.ToString() == "string" ||
- type.ToString() == "bundle") {
+ type.ToString() == "bundle" ||
+ type.ToString() == "file") {
str += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
[&]()->std::string {
return "h->" + id;
type.GetMetaType()->ToString() == "list" ||
type.GetMetaType()->ToString() == "array" ||
type.GetMetaType()->ToString() == "string" ||
- type.GetMetaType()->ToString() == "bundle") {
+ type.GetMetaType()->ToString() == "bundle" ||
+ type.GetMetaType()->ToString() == "file") {
s += GetSetterString(*type.GetMetaType(),
"new_value", "value");
s += GenTemplateString(CB_IF_STATEMENT_WITH_BRACES,
"_destroy(" + value + ");";
} else if (type.ToString() == "bundle") {
str += "bundle_free(" + value + ");";
- } else if (type.ToString() == "string" || container_value) {
+ } else if (type.ToString() == "string" || type.ToString() == "file" || container_value) {
str += "free(" + value + ");";
}
type.ToString() == "array") {
str += GetHandlePrefix() + GetFullNameFromType(type) +
"_clone(" + rvalue + ", &" + lvalue +");" + NLine(1);
- } else if (type.ToString() == "string") {
+ } else if (type.ToString() == "string" || type.ToString() == "file") {
str += lvalue + " = strdup(" + rvalue + ");" + NLine(1);
} else if (type.ToString() == "bundle") {
str += lvalue + " = bundle_dup(" + rvalue + ");" + NLine(1);
{"char", "char "}, {"int", "int "}, {"short", "short "},
{"long", "long long "}, {"bool", "bool "}, {"string", "char *"},
{"list", "GList *"}, {"float", "float "}, {"double", "double "},
- {"bundle", "bundle *"}, {"void", "void "}
+ {"bundle", "bundle *"}, {"void", "void "}, {"file", "char *"}
};
}
}
}
- if (type.ToString() == "string") {
+ if (type.ToString() == "string" || type.ToString() == "file") {
if (direction == ParameterType::Direction::IN) {
if (!bconst)
return "char *";
type.ToString() == "array")
return GetHandlePrefix() + GetFullNameFromType(type) + "_h ";
- if (type.ToString() == "string")
+ if (type.ToString() == "string" || type.ToString() == "file")
return "char *";
if (type.ToString() == "bundle")
type.ToString() == "list" ||
type.ToString() == "array" ||
type.ToString() == "bundle" ||
- type.ToString() == "string")
+ type.ToString() == "string"||
+ type.ToString() == "file")
return "NULL";
if (type.ToString() == "bool")
return "false";
#include <dlog.h>
#include <rpc-port.h>
#include <rpc-port-parcel.h>
+#include <rpc-port-internal.h>
)__c_cb";
#endif // IDLC_C_GEN_C_GEN_BASE_CB_H_
}
void CProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& inf) {
+ GenInterfaceFileSharing(stream, inf);
GenInterfaceEnumerations(stream, inf);
GenInterfaceDeclaration(stream, inf);
GenInterfaceDelegators(stream, inf);
GenInterfaceDtor(stream, inf);
}
+void CProxyBodyGen::GenInterfaceFileSharing(std::ofstream& stream,
+ const Interface& inf) {
+
+ for (auto& i : inf.GetDeclarations().GetDecls()) {
+ for (auto& p : i->GetParameters().GetParams()) {
+ if ((p->GetParameterType().GetBaseType().ToString() == "list" ||
+ p->GetParameterType().GetBaseType().ToString() == "array") &&
+ p->GetParameterType().GetBaseType().GetMetaType()->ToString() == "file") {
+ if (p->GetParameterType().GetBaseType().ToString() == "array") {
+ stream << SmartIndent(std::string(CB_FILE_ARRAY_SHARING));
+ } else {
+ stream << SmartIndent(std::string(CB_FILE_LIST_SHARING));
+ }
+ }
+ }
+ }
+}
+
+
void CProxyBodyGen::GenInterfaceDeclaration(std::ofstream& stream,
const Interface& inf) {
stream << SmartIndent(ReplaceAll(CB_INTERFACE_STRUCT, "##",
for (auto& i : inf.GetDeclarations().GetDecls()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
+
stream << SmartIndent(GenTemplateString(
ReplaceAll(CB_INTERFACE_METHODS, "##",
GetInterfaceIdWithNamespace(inf)),
return "";
},
[&]()->std::string {
+ for (auto& p : i->GetParameters().GetParams()) {
+ if (p->GetParameterType().GetDirection() ==
+ ParameterType::Direction::IN &&
+ p->GetParameterType().GetBaseType().ToString() == "file") {
+ return ReplaceAll(CB_PRIVATE_SHARING_BLOCK, "##",
+ p->GetID());
+ }
+
+ if ((p->GetParameterType().GetBaseType().ToString() == "list" ||
+ p->GetParameterType().GetBaseType().ToString() == "array") &&
+ p->GetParameterType().GetBaseType().GetMetaType()->ToString() == "file") {
+ if (p->GetParameterType().GetBaseType().ToString() == "array") {
+
+ return ReplaceAll(CB_ARRAY_PRIVATE_SHARING_BLOCK, "##",
+ p->GetID());
+ } else {
+ return ReplaceAll(CB_LIST_PRIVATE_SHARING_BLOCK, "##",
+ p->GetID());
+ }
+ }
+ }
+ return "";
+ },
+ [&]()->std::string {
return i->GetID();
},
[&]()->std::string {
return "&" + p->GetID() + "->parcelable, " + p->GetID();
} else if (p->GetParameterType().GetDirection()
== ParameterType::Direction::REF) {
- if (p->GetParameterType().GetBaseType().ToString() == "string")
+ if (p->GetParameterType().GetBaseType().ToString() == "string"
+ || p->GetParameterType().GetBaseType().ToString() == "file")
return ReplaceAll(ternary_operation, "##", "*" + p->GetID());
return "*" + p->GetID();
- } else if (p->GetParameterType().GetBaseType().ToString() ==
- "string") {
+ } else if (p->GetParameterType().GetBaseType().ToString() == "string"
+ || p->GetParameterType().GetBaseType().ToString() == "file") {
return ReplaceAll(ternary_operation, "##", p->GetID());
}
return p->GetID();
private:
void GenInterface(std::ofstream& stream, const Interface& inf);
+ void GenInterfaceFileSharing(std::ofstream& stream, const Interface& st);
void GenInterfaceDeclaration(std::ofstream& stream, const Interface& inf);
void GenInterfaceDelegators(std::ofstream& stream, const Interface& inf);
void GenInterfaceDelegatorTable(std::ofstream& stream, const Interface& inf);
};
)__c_cb";
+const char CB_FILE_LIST_SHARING[] =
+R"__c_cb(
+int __file_list_set_private_sharing(rpc_port_h port, GList *list_files) {
+ const char **arr = calloc(g_list_length(list_files), sizeof(char*));
+ GList *iter;
+ int idx = 0;
+ int r = 0;
+ iter = list_files;
+ while (iter) {
+ char *value = iter->data;
+ if (!value) {
+ _W("Warning: value is NULL");
+ continue;
+ }
+ arr[idx++] = value;
+ iter = g_list_next(iter);
+ }
+ if (idx > 0)
+ r = rpc_port_set_private_sharing_array(port, arr, idx);
+ return r;
+}
+)__c_cb";
+
+const char CB_FILE_ARRAY_SHARING[] =
+R"__c_cb(
+int __file_array_set_private_sharing(rpc_port_h port,
+ const char **files, int files_size) {
+ return rpc_port_set_private_sharing_array(port, files, files_size);
+}
+)__c_cb";
+
const char CB_DELEGATE_STRUCT[] =
R"__c_cb(
struct ##_s {
_E("Not connected");
return$$;
}
-
+$$
rpc_port_parcel_create(&parcel);
rpc_port_parcel_write_int32(parcel, ##_METHOD_$$);
$$
g_rec_mutex_unlock(&h->mutex);
)__c_cb";
+const char CB_LIST_PRIVATE_SHARING_BLOCK[] =
+R"__c_cb(
+ r = __file_list_set_private_sharing(h->port, ##->list_files);
+ if (r != RPC_PORT_ERROR_NONE) {
+ _E("Fail to set private sharing");
+ return ret;
+ }
+)__c_cb";
+
+const char CB_ARRAY_PRIVATE_SHARING_BLOCK[] =
+R"__c_cb(
+ r = __file_array_set_private_sharing(h->port,
+ (const char **)##->array_files, ##->array_files_size);
+ if (r != RPC_PORT_ERROR_NONE) {
+ _E("Fail to set private sharing");
+ return ret;
+ }
+)__c_cb";
+
+const char CB_PRIVATE_SHARING_BLOCK[] =
+R"__c_cb(
+ r = rpc_port_set_private_sharing(h->port, ##);
+ if (r != RPC_PORT_ERROR_NONE) {
+ _E("Fail to set private sharing");
+ return ret;
+ }
+)__c_cb";
+
#endif // IDLC_C_GEN_C_PROXY_BODY_GEN_CB_H_
if (t.IsUserDefinedType() || t.ToString() == "list" ||
t.ToString() == "array")
return "&" + i->GetID() + "->parcelable, " + i->GetID();
- else if (t.ToString() == "string")
+ else if (t.ToString() == "string" || t.ToString() == "file")
return ReplaceAll(ternary_operation, "##", i->GetID());
return i->GetID();
});
decl.GetType().ToString() == "list" ||
decl.GetType().ToString() == "array")
return "&ret->parcelable, ret";
- else if (decl.GetType().ToString() == "string")
+ else if (decl.GetType().ToString() == "string" ||
+ decl.GetType().ToString() == "file")
return ReplaceAll(ternary_operation, "##", "ret");
return "ret";
});
if (t.IsUserDefinedType() || t.ToString() == "list" ||
t.ToString() == "array")
return "&" + i->GetID() + "->parcelable, " + i->GetID();
- else if (t.ToString() == "string")
+ else if (t.ToString() == "string" || t.ToString() == "file")
return ReplaceAll(ternary_operation, "##", i->GetID());
return i->GetID();
});
+ std::string(" std::vector<const char*> v;\n")
+ std::string(" std::string name = i.GetFileName();\n")
+ std::string(" v.push_back(name.c_str());\n")
- + std::string(" int r = rpc_port_set_private_sharing(port_, v.data(), v.size());\n")
+ + std::string(" int r = rpc_port_set_private_sharing_array(port_, v.data(), v.size());\n")
+ std::string(" if (r != RPC_PORT_ERROR_NONE) {\n")
+ std::string(" _E(\"Failed to set private sharing\");\n")
+ std::string(" throw InvalidIOException();\n")
ret += "std::vector<const char*> v;\n"
+ std::string("std::string name = " + id + ".GetFileName();\n")
+ std::string("v.push_back(name.c_str());\n")
- + std::string("int r = rpc_port_set_private_sharing(port_, v.data(), v.size());\n")
+ + std::string("int r = rpc_port_set_private_sharing_array(port_, v.data(), v.size());\n")
+ std::string("if (r != RPC_PORT_ERROR_NONE) {\n")
+ std::string(" _E(\"Failed to set private sharing\");\n")
+ std::string(" throw InvalidIOException();\n")
int GetStudent(in string c_name, in string s_name, out Student student);
string GetName(out string name);
int SetName(in string name);
- int ShareFile(file myFile);
- int ShareFilesList(list<file> myFile);
- int ShareFilesArray(array<file> myFile);
}