If there is the 'ref' keyword, we should read and wrtie the argument.
Change-Id: I027cf6cc3101b474cc8ba07a7428a98d6566c488
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
std::string code;
for (const auto& param : decl.GetParameters()) {
auto& param_type = param->GetParameterType();
- if (param_type.GetDirection() != ParameterType::Direction::OUT)
+ if (param_type.GetDirection() == ParameterType::Direction::IN)
continue;
auto& type = param_type.GetBaseType();
std::string code;
for (const auto& param : decl.GetParameters()) {
auto& param_type = param->GetParameterType();
- if (param_type.GetDirection() != ParameterType::Direction::IN)
+ if (param_type.GetDirection() == ParameterType::Direction::OUT)
continue;
+ std::string arg = param->GetID();
+ if (param_type.GetDirection() == ParameterType::Direction::REF)
+ arg = "*" + arg;
+
auto& type = param_type.GetBaseType();
if (type.GetUserDefinedType() == BaseType::UserType::DELEGATE) {
code += ReplaceAll(CB_INTERFACE_METHOD_DELEGATE_UNIT_MAP_WRITE)
- .Change("<ARG>", param->GetID());
+ .Change("<ARG_NAME>", param->GetID())
+ .Change("<ARG>", arg);
} else if (type.GetUserDefinedType() == BaseType::UserType::ENUM) {
code += ReplaceAll(CB_INTERFACE_METHOD_ENUM_UNIT_MAP_WRITE)
.Change("<ARG_NAME>", param->GetID())
- .Change("<ARG>", param->GetID());
+ .Change("<ARG>", arg);
} else if (type.IsUserDefinedType() || type.GetMetaType() != nullptr) {
code += ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_WRITE)
.Change("<TYPE_NAME>", GetFullNameFromType(type, iface))
- .Change("<ARG>", param->GetID());
+ .Change("<ARG_NAME>", param->GetID())
+ .Change("<ARG>", arg);
code += GetPrivateSharingString(type, iface, "h->port", param->GetID());
} else if (type.ToString() == "bundle") {
code += ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_UNIT_MAP_WRITE)
- .Change("<ARG>", param->GetID());
+ .Change("<ARG_NAME>", param->GetID())
+ .Change("<ARG>", arg);
} else if (type.ToString() == "string") {
code += ReplaceAll(CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE)
- .Change("<ARG>", param->GetID());
+ .Change("<ARG_NAME>", param->GetID())
+ .Change("<ARG>", arg);
} else if (type.ToString() == "file") {
code += ReplaceAll(CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE)
- .Change("<ARG>", param->GetID());
+ .Change("<ARG_NAME>", param->GetID())
+ .Change("<ARG>", arg);
code += GetPrivateSharingString(type, iface, "h->port", param->GetID());
} else {
code += ReplaceAll(CB_INTERFACE_METHOD_BASE_UNIT_MAP_WRITE)
.Change("<TYPE_NAME>", GetFullNameFromType(type, iface))
.Change("<ARG_NAME>", param->GetID())
- .Change("<ARG>", param->GetID());
+ .Change("<ARG>", arg);
}
}
std::string code;
if (type.GetUserDefinedType() == BaseType::UserType::DELEGATE ||
type.GetUserDefinedType() == BaseType::UserType::STRUCTURE ||
- type.GetMetaType() != nullptr) {
+ type.GetMetaType() != nullptr || type.GetKeyType() != nullptr) {
code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_READ)
.Change("<TYPE_NAME>", GetFullNameFromType(type, iface))
.Change("<ARG_NAME>", arg_name)
return code;
}
+std::string CProxyBodyGenerator::GenMethodRefFree(
+ const Interface& iface, const BaseType& type, const std::string& arg) {
+ std::string code;
+ if (type.GetUserDefinedType() == BaseType::UserType::DELEGATE ||
+ type.GetUserDefinedType() == BaseType::UserType::STRUCTURE ||
+ type.GetMetaType() != nullptr || type.GetKeyType() != nullptr) {
+ code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_REF_FREE)
+ .Change("<PREFIX>", GetHandlePrefix())
+ .Change("<NAME>", GetFullNameFromType(type, iface))
+ .Change("<ARG>", arg);
+ } else if (type.ToString() == "bundle") {
+ code = ReplaceAll(CB_INTERFACE_METHOD_BUNDLE_REF_FREE)
+ .Change("<ARG>", arg);
+ } else if (type.ToString() == "string" || type.ToString() == "file") {
+ code = ReplaceAll(CB_INTERFACE_METHOD_STRING_REF_FREE)
+ .Change("<ARG>", arg);
+ }
+
+ return code;
+}
+
std::string CProxyBodyGenerator::GenMethodUnitMapRead(const Interface& iface,
const Declaration& decl) {
std::string code;
std::string parcel_read_code;
for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
- if (param_type.GetDirection() != ParameterType::Direction::OUT)
+ if (param_type.GetDirection() == ParameterType::Direction::IN)
continue;
auto& type = param_type.GetBaseType();
code += GenMethodUnitMapReadBase(iface, type, p->GetID(),
"new_" + p->GetID());
+ if (param_type.GetDirection() == ParameterType::Direction::REF)
+ code += GenMethodRefFree(iface, type, p->GetID());
+
code += ReplaceAll(CB_INTERFACE_METHOD_PARAM_SET, "<PARAM>",
p->GetID());
}
const std::string& arg);
std::string GenMethodUnitMapRead(const Interface& iface,
const Declaration& decl);
+ std::string GenMethodRefFree(const Interface& iface,
+ const BaseType& type, const std::string& arg);
void GenMethodBase(std::ofstream& stream, const Interface& iface,
const Declaration& decl);
void GenInterfaceMethodBase(std::ofstream& stream, const Interface& iface,
)__c_cb";
/**
+ * <ARG_NAME> The name of the argument.
* <TYPE_NAME> The type name of the argument.
* <ARG> The argument.
*/
constexpr const char CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_WRITE[] =
R"__c_cb(
-rpc_port_unit_map_write_<TYPE_NAME>(map_, "<ARG>", <ARG>);
+rpc_port_unit_map_write_<TYPE_NAME>(map_, "<ARG_NAME>", <ARG>);
)__c_cb";
/**
+ * <ARG_NAME> The name of the argument.
* <ARG> The argument.
*/
constexpr const char CB_INTERFACE_METHOD_DELEGATE_UNIT_MAP_WRITE[] =
R"__c_cb(
-rpc_port_unit_map_write_delegate(map_, "<ARG>", (rpc_port_delegate_h)<ARG>);
+rpc_port_unit_map_write_delegate(map_, "<ARG_NAME>", (rpc_port_delegate_h)<ARG>);
)__c_cb";
/**
+ * <ARG_NAME> The name of the argument.
* <ARG> The argument.
*/
constexpr const char CB_INTERFACE_METHOD_BUNDLE_UNIT_MAP_WRITE[] =
R"__c_cb(
-rpc_port_unit_map_write_bundle(map_, "<ARG>", <ARG>);
+rpc_port_unit_map_write_bundle(map_, "<ARG_NAME>", <ARG>);
)__c_cb";
/**
+ * <ARG_NAME> The name of the argument.
* <ARG> The argument.
*/
constexpr const char CB_INTERFACE_METHOD_STRING_UNIT_MAP_WRITE[] =
R"__c_cb(
-rpc_port_unit_map_write_string(map_, "<ARG>", <ARG>);
+rpc_port_unit_map_write_string(map_, "<ARG_NAME>", <ARG>);
)__c_cb";
/**
* <TYPE_NAME> The type name of the argument.
+ * <ARG_NAME> The name of the argument.
* <ARG> The argument.
*/
constexpr const char CB_INTERFACE_METHOD_BASE_UNIT_MAP_WRITE[] =
/**
* <TYPE_NAME> The type name of the argument.
+ * <ARG_NAME> The name of the argument.
* <ARG> The argument.
*/
constexpr const char CB_INTERFACE_METHOD_ENUM_UNIT_MAP_WRITE[] =
*<PARAM> = new_<PARAM>;
)__c_cb";
+/**
+ * <PREFIX> The prefix of the reference argument.
+ * <NAME> The name of the reference argument.
+ * <ARG> The argument.
+ */
+constexpr const char CB_INTERFACE_METHOD_USER_DEFINED_REF_FREE[] =
+R"__c_cb(
+<PREFIX>_<NAME>_destroy(*<ARG>);
+)__c_cb";
+
+/**
+ * <ARG> The argument.
+ */
+constexpr const char CB_INTERFACE_METHOD_BUNDLE_REF_FREE[] =
+R"__c_cb(
+bundle_free(*<ARG>);
+)__c_cb";
+
+/**
+ * <ARG> The argument.
+ */
+constexpr const char CB_INTERFACE_METHOD_STRING_REF_FREE[] =
+R"__c_cb(
+free(*<ARG>);
+)__c_cb";
+
/**
* <ARG> The argument.
*/
for (const auto& p : decl.GetParameters()) {
std::string parcel_read_code;
auto& param_type = p->GetParameterType();
- if (param_type.GetDirection() != ParameterType::Direction::IN)
+ if (param_type.GetDirection() == ParameterType::Direction::OUT)
continue;
auto& type = param_type.GetBaseType();
- if (type.GetUserDefinedType() == BaseType::UserType::DELEGATE){
+ if (type.GetUserDefinedType() == BaseType::UserType::DELEGATE) {
parcel_read_code = ReplaceAll(CB_INTERFACE_METHOD_DELEGATE_UNIT_MAP_READ)
.Change("<PREFIX>", GetHandlePrefix())
.Change("<TYPE_NAME>", GetFullNameFromType(type, iface))
.Change("<ARG_NAME>", p->GetID())
.Change("<ARG>", p->GetID());
} else if (type.GetUserDefinedType() == BaseType::UserType::STRUCTURE ||
- type.GetMetaType() != nullptr) {
+ type.GetMetaType() != nullptr ||
+ type.GetKeyType() != nullptr) {
parcel_read_code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_READ)
.Change("<TYPE_NAME>", GetFullNameFromType(type, iface))
.Change("<ARG_NAME>", p->GetID())
.Change("<ARG_NAME>", arg_name)
.Change("<ARG>", arg);
} else if (type.IsUserDefinedType() ||
- type.ToString() == "list" ||
- type.ToString() == "array") {
+ type.GetMetaType() != nullptr ||
+ type.GetKeyType() != nullptr) {
parcel_write_code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_UNIT_MAP_WRITE)
.Change("<TYPE_NAME>", GetFullNameFromType(type, iface))
.Change("<ARG_NAME>", arg_name)
auto& type = param_type.GetBaseType();
if (type.GetUserDefinedType() == BaseType::UserType::STRUCTURE ||
type.GetUserDefinedType() == BaseType::UserType::DELEGATE ||
- type.ToString() == "list" ||
- type.ToString() == "array") {
+ type.GetMetaType() != nullptr ||
+ type.GetKeyType() != nullptr) {
free_code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE,
"<PREFIX>", GetHandlePrefix());
free_code = ReplaceAll(free_code, "<NAME>",
auto& type = decl.GetType();
if (type.GetUserDefinedType() == BaseType::UserType::STRUCTURE ||
type.GetUserDefinedType() == BaseType::UserType::DELEGATE ||
- type.ToString() == "list" ||
- type.ToString() == "array") {
+ type.GetMetaType() != nullptr ||
+ type.GetKeyType() != nullptr) {
free_code = ReplaceAll(CB_INTERFACE_METHOD_USER_DEFINED_FREE,
"<PREFIX>", GetHandlePrefix());
free_code = ReplaceAll(free_code, "<NAME>",