.Change("<TYPE>", st.GetID())
.Change("<BODY>", [&]() {
std::string ret;
- std::string type_str;
for (const auto& i : st.GetElements()) {
- auto& t = i->GetType();
- if (t.IsEnumType())
- type_str = "int";
- else
- type_str = GetTypeString(t);
-
- ret += Tab(4) + "map.Write(\"" + i->GetID() +
- "\", \"" + type_str + "\"" + ", param." +
- i->GetID() + ");" + NLine(1);
+ ret += Tab(4) + "map.Write(\"" + i->GetID() +
+ "\", param." + i->GetID() + ");" + NLine(1);
}
return ret;
}));
std::string ret;
std::string type_str;
for (const auto& i : st.GetElements()) {
- auto& t = i->GetType();
- if (t.IsEnumType())
- type_str = "int";
- else
- type_str = GetTypeString(t);
-
- ret += Tab(4) + "map.Read(\"" + i->GetID() + "\", \"" +
- type_str + "\"" + ", out param." + i->GetID() + ");" +
+ ret += Tab(4) + "map.Read(\"" + i->GetID() +
+ "\", out param." + i->GetID() + ");" +
NLine(1);
}
return ret;
std::string CsGeneratorBase::GenListWrite(const BaseType& type,
const std::string& type_str) {
std::string ret;
- std::string type_string;
- if (type.ToString() == "map") {
- if (type.GetValueType()->IsEnumType())
- type_string = "int";
- else
- type_string = ConvertTypeToString(*type.GetValueType());
- ret = ReplaceAll(CB_LIST_MAP_WRITE)
- .Change("<KEY_TYPE>", ConvertTypeToString(*type.GetKeyType()))
- .Change("<VALUE_TYPE>", type_string);
+ if (type.ToString() == "map") {
+ ret = CB_LIST_MAP_WRITE;
} else if (type.ToString() == "set") {
- ret = ReplaceAll(CB_LIST_SET_WRITE)
- .Change("<VALUE_TYPE>", ConvertTypeToString(*type.GetMetaType()));
- } else if (type.GetMetaType()->IsEnumType()) {
- ret = ReplaceAll(CB_LIST_WRITE).Change("<VALUE_TYPE>", std::string("int"));
+ ret = CB_LIST_SET_WRITE;
} else {
- ret = ReplaceAll(CB_LIST_WRITE)
- .Change("<VALUE_TYPE>", ConvertTypeToString(*type.GetMetaType()));
+ ret = CB_LIST_WRITE;
}
return ret;
if (type.GetValueType()->IsEnumType()) {
ret = ReplaceAll(CB_LIST_MAP_READ)
.Change("<KEY_TYPE>", ConvertTypeToString(*type.GetKeyType()))
- .Change("<TYPE_STRING>", std::string("int"))
.Change("<VALUE_TYPE>", type.GetValueType()->ToString());
} else {
ret =
ReplaceAll(CB_LIST_MAP_READ)
.Change("<KEY_TYPE>", ConvertTypeToString(*type.GetKeyType()))
- .Change("<TYPE_STRING>", ConvertTypeToString(*type.GetKeyType()))
.Change("<VALUE_TYPE>",
ConvertTypeToString(*type.GetValueType()));
}
list_method = "Last";
ret = ReplaceAll(CB_LIST_READ)
- .Change("<TYPE_STRING>", std::string("int"))
.Change("<LIST_METHOD>", list_method)
.Change("<VALUE_TYPE>", type.GetMetaType()->ToString());
} else {
list_method = "Last";
ret = ReplaceAll(CB_LIST_READ)
- .Change("<TYPE_STRING>", ConvertTypeToString(*type.GetMetaType()))
.Change("<LIST_METHOD>", list_method)
.Change("<VALUE_TYPE>", ConvertTypeToString(*type.GetMetaType()));
}
}
}
- std::string type_str;
-
- if (type.GetUserDefinedType() == BaseType::UserType::ENUM)
- type_str = "int";
- else
- type_str = GetTypeString(type);
- ret += map + ".Read(" + "\"" + param_id + "\", \"" + type_str + "\", out ";
+ ret += map + ".Read(" + "\"" + param_id + "\", out ";
if (IsDelegateType(type)) {
ret += "CallbackBase del_" + gen_id + ");\n";
ret +=
std::string CsGeneratorBase::ConvertTypeToSerializer(std::string gen_id,
std::string param_id,
- std::string param_type,
std::string map) {
- return map + ".Write(\"" + param_id + "\", \"" + param_type + "\", " +
- gen_id + ");\n";
-}
-std::string CsGeneratorBase::ConvertTypeToSerializer(std::string gen_id,
- std::string param_id,
- const BaseType& type,
- std::string map) {
- if (type.GetUserDefinedType() == BaseType::UserType::ENUM)
- return ConvertTypeToSerializer(gen_id, param_id, "int", map);
- else
- return ConvertTypeToSerializer(gen_id, param_id, GetTypeString(type), map);
+ return map + ".Write(\"" + param_id + "\", " + gen_id + ");\n";
}
std::string CsGeneratorBase::Tab(int cnt) {
for (const auto& iter : types) {
auto& type_str = iter.first;
auto& base_type = iter.second;
+
+ std::string unit_type;
+ if (base_type.IsEnumType())
+ unit_type = "int";
+ else
+ unit_type = GetTypeString(base_type);
+
code +=
ReplaceAll(CB_UNITMAP_READ_READ_BASE)
.Change("<PARAM_TYPE>", GenUnitMapParamType(base_type, type_str))
.Change("<PARAM_INIT>",
GenUnitMapParamInit(iface, base_type, type_str))
+ .Change("<UNIT_TYPE>", unit_type)
.Change("<UINT_READ>",
GenUnitMaUintRead(iface, base_type, type_str));
code +=
ReplaceAll(CB_UNITMAP_READ_WRITE_BASE)
.Change("<PARAM_TYPE>", GenUnitMapParamType(base_type, type_str))
+ .Change("<UNIT_TYPE>", unit_type)
.Change("<UINT_WRITE>", GenUnitMaUintWrite(iface, base_type));
}
[&]() -> std::string {
std::string m;
for (const auto& i : decl.GetParameters()) {
- m += ConvertTypeToSerializer(
- i->GetID(), i->GetID(),
- GetTypeString(i->GetParameterType().GetBaseType()), "map");
+ m += ConvertTypeToSerializer(i->GetID(), i->GetID(), "map");
}
return AddIndent(TAB_SIZE * 6, m);
});
bool make_new_type = true,
const std::string iface_id = "");
std::string ConvertTypeToSerializer(std::string gen_id, std::string param_id,
- const BaseType& type, std::string map);
- std::string ConvertTypeToSerializer(std::string gen_id, std::string param_id,
- std::string param_type, std::string map);
+ std::string map);
std::string ConvertTypeToParcelType(const std::string& key);
std::string GetParameters(const Parameters& ps);
std::string Tab(int cnt);
private static void Serialize(Parcel h, RemoteException param)
{
UnitMap map = new UnitMap();
- map.Write("cause", "int", param.Cause);
- map.Write("message", "string", param.Message);
+ map.Write("cause", param.Cause);
+ map.Write("message", param.Message);
map.Serialize(h);
}
{
UnitMap map = new UnitMap();
map.Deserialize(h);
- map.Read("cause", "int", out int cause);
+ map.Read("cause", out int cause);
param.Cause = cause;
- map.Read("message", "string", out string message);
+ map.Read("message", out string message);
param.Message = message;
}
)__cs_cb";
const char CB_UNITMAP_READ_READ_BASE[] =
R"__cs_cb(
-internal void Read(string name, string type, out <PARAM_TYPE> value)
+internal void Read(string name, out <PARAM_TYPE> value)
{
<PARAM_INIT>
if (map.ContainsKey(name) == false)
}
Unit unit = map[name];
- if (unit.type != type)
+ if (unit.type != "<UNIT_TYPE>")
{
- Tizen.Log.Error("RPC_PORT", "type is not " + type + " : " + unit.type);
+ Tizen.Log.Error("RPC_PORT", "type is not <UNIT_TYPE> : " + unit.type);
return;
}
<UINT_READ>
const char CB_UNITMAP_READ_WRITE_BASE[] =
R"__cs_cb(
-internal void Write(string name, string type, <PARAM_TYPE> value)
+internal void Write(string name, <PARAM_TYPE> value)
{
Unit unit = new Unit();
unit.name = name;
- unit.type = type;
+ unit.type = "<UNIT_TYPE>";
<UINT_WRITE>
map[name] = unit;
}
internal static void Serialize(Parcel h, CallbackBase param)
{
UnitMap map = new UnitMap();
- map.Write("id", "int", param.Id);
- map.Write("seq_id", "int", param.SeqId);
- map.Write("once", "bool", param.Once);
+ map.Write("id", param.Id);
+ map.Write("seq_id", param.SeqId);
+ map.Write("once", param.Once);
map.Serialize(h);
}
{
UnitMap map = new UnitMap();
map.Deserialize(h);
- map.Read("id", "int", out param.Id);
- map.Read("seq_id", "int", out param.SeqId);
- map.Read("once", "bool", out param.Once);
+ map.Read("id", out param.Id);
+ map.Read("seq_id", out param.SeqId);
+ map.Read("once", out param.Once);
}
}
{
UnitMap map = new UnitMap();
- map.Write("[METHOD]", "int", (int)MethodId.__Callback);
- map.Write("delegate", "delegate", this);
+ map.Write("[METHOD]", (int)MethodId.__Callback);
+ map.Write("delegate", this);
$$
map.Serialize(p);
)__cs_cb";
constexpr const char CB_LIST_MAP_WRITE[] =
-R"__cs_cb( map.Write("key-" + index.ToString(), "<KEY_TYPE>", i.Key);
- map.Write("value-" + index.ToString(), "<VALUE_TYPE>", i.Value);)__cs_cb";
+R"__cs_cb( map.Write("key-" + index.ToString(), i.Key);
+ map.Write("value-" + index.ToString(), i.Value);)__cs_cb";
constexpr const char CB_LIST_SET_WRITE[] =
-R"__cs_cb( map.Write("key-" + index.ToString(), "<VALUE_TYPE>", i);)__cs_cb";
+R"__cs_cb( map.Write("key-" + index.ToString(), i);)__cs_cb";
constexpr const char CB_LIST_WRITE[] =
-R"__cs_cb( map.Write(index.ToString(), "<VALUE_TYPE>", i);)__cs_cb";
+R"__cs_cb( map.Write(index.ToString(), i);)__cs_cb";
constexpr const char CB_LIST_MAP_READ[] =
-R"__cs_cb( map.Read("key-" + index.ToString(), "<KEY_TYPE>", out <KEY_TYPE> key);
- map.Read("value-" + index.ToString(), "<TYPE_STRING>", out <VALUE_TYPE> value);
+R"__cs_cb( map.Read("key-" + index.ToString(), out <KEY_TYPE> key);
+ map.Read("value-" + index.ToString(), out <VALUE_TYPE> value);
param[key] = value;)__cs_cb";
constexpr const char CB_LIST_SET_READ[] =
-R"__cs_cb( map.Read("key-" + index.ToString(), "<VALUE_TYPE>", out <VALUE_TYPE> value);
+R"__cs_cb( map.Read("key-" + index.ToString(), out <VALUE_TYPE> value);
param.Add(value);)__cs_cb";
constexpr const char CB_LIST_READ[] =
-R"__cs_cb( map.Read("key-" + index.ToString(), "<TYPE_STRING>", out <VALUE_TYPE> value);
+R"__cs_cb( map.Read("key-" + index.ToString(), out <VALUE_TYPE> value);
param.Add<LIST_METHOD>(value);)__cs_cb";
const char CB_LIST_SERIALIZER[] =
private static void Serialize(Parcel h, <TYPE> param)
{
UnitMap map = new UnitMap();
- map.Write("<LENGTH_NAME>", "int", param.Count & int.MaxValue);
+ map.Write("<LENGTH_NAME>", param.Count & int.MaxValue);
int index = 0;
foreach (var i in param)
{
{
UnitMap map = new UnitMap();
map.Deserialize(h);
- map.Read("<LENGTH_NAME>", "int", out int length);
+ map.Read("<LENGTH_NAME>", out int length);
for (int index = 0; index < length; index++)
{
<READ_LIST>
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
- m += Tab(5) + ConvertTypeToSerializer(
- i->GetID(), i->GetID(),
- GetTypeString(i->GetParameterType().GetBaseType()), "map");
+ m += Tab(5) + ConvertTypeToSerializer(i->GetID(), i->GetID(), "map");
}
return m;
m += Tab(5) + NLine(1) + "UnitMap map = new UnitMap();" + NLine(1);
m += ConvertTypeToSerializer("(int)MethodId." + decl.GetID(), "[METHOD]",
- "int", "map");
+ "map");
for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
- m += ConvertTypeToSerializer(i->GetID(), i->GetID(), pt.GetBaseType(),
- "map");
+ m += ConvertTypeToSerializer(i->GetID(), i->GetID(), "map");
if (IsDelegateType(pt.GetBaseType())) {
l += "_delegateList.Add(" + i->GetID() + ");\n";
private void ProcessReceivedEvent(UnitMap map)
{
CallbackBase cb;
- map.Read("delegate", "delegate", out cb);
+ map.Read("delegate", out cb);
foreach (var i in _delegateList)
{
map.Deserialize(parcelReceived);
int cmd;
- map.Read("[METHOD]", "int", out cmd);
+ map.Read("[METHOD]", out cmd);
if (cmd != (int)MethodId.__Callback)
{
const char CB_INVOCATION_REMOTE_EXCEPTION[] =
R"__cs_cb( if (mapReceived.ContainsName("[REMOTE_EXCEPTION]"))
{
- mapReceived.Read("[REMOTE_EXCEPTION]", "remote_exception", out RemoteException exception);
+ mapReceived.Read("[REMOTE_EXCEPTION]", out RemoteException exception);
throw exception;
}
)__cs_cb";
stream << CB_ON_RECEIVED_EVENT_BACK;
}
+
+std::string CsStubGen::GetWriteOutParam(const Declaration& decl) {
+ int cnt = 0;
+ std::string code;
+
+ for (const auto& i : decl.GetParameters()) {
+ auto& pt = i->GetParameterType();
+ cnt++;
+ if (pt.GetDirection() == ParameterType::Direction::IN)
+ continue;
+
+ code += ConvertTypeToSerializer("param" + std::to_string(cnt),
+ i->GetID(), "result_map");
+ }
+
+ return code;
+}
+
std::string CsStubGen::GetInvocationMethod(const Declaration& decl) {
std::string code;
if (decl.GetType().ToString() != "void") {
- code = ReplaceAll(CB_INVOCATION_REMOTE_EXCEPTION)
- .Change("<SYNC_INVOCATION>", GetInvocationMethodParam(decl, true))
- .Change("<WRITE_RESULT>",
- ConvertTypeToSerializer("retVal", "[RESULT]",
- GetTypeString(decl.GetType()),
- "result_map"));
+ code =
+ ReplaceAll(CB_INVOCATION_REMOTE_EXCEPTION)
+ .Change("<SYNC_INVOCATION>", GetInvocationMethodParam(decl, true))
+ .Change("<WRITE_RESULT>", ConvertTypeToSerializer(
+ "retVal", "[RESULT]", "result_map"))
+ .Change("<WRITE_OUT_PARAM>", GetWriteOutParam(decl));
} else {
code = NLine(1) + GetInvocationMethodParam(decl, false);
}
cnt = 0;
m = CB_INVOCATION_RESULT_PRE;
- for (const auto& i : decl.GetParameters()) {
- auto& pt = i->GetParameterType();
- cnt++;
- if (pt.GetDirection() == ParameterType::Direction::IN)
- continue;
-
- m += ConvertTypeToSerializer("param" + std::to_string(cnt), i->GetID(),
- GetTypeString(pt.GetBaseType()), "result_map");
- }
-
m += "result_map.Serialize(result);\n";
m += "result.Send(port);\n";
stream << AddIndent(TAB_SIZE * 9, m);
void GenDisposable(std::ofstream& stream, const Interface& iface);
std::string GetInvocationMethodParam(const Declaration& decl, bool hasRet);
std::string GetInvocationMethod(const Declaration& decl);
+ std::string GetWriteOutParam(const Declaration& decl);
};
} // namespace version2
UnitMap map = new UnitMap();
map.Deserialize(p);
- map.Read("[METHOD]", "int", out cmd);
+ map.Read("[METHOD]", out cmd);
switch ((MethodId)cmd)
{
if (b._is_app && CheckPrivilege((MethodId)cmd, b) == false)
{
RemoteException ex = new RemoteException("Permission denied", (int)Tizen.Internals.Errors.ErrorCode.PermissionDenied);
- result_map.Write("[REMOTE_EXCEPTION]", "remote_exception", ex);
+ result_map.Write("[REMOTE_EXCEPTION]", ex);
} else {
<INVOCATION>
}
{
<SYNC_INVOCATION>
<WRITE_RESULT>
+ <WRITE_OUT_PARAM>
} catch (RemoteException ex)
{
- result_map.Write("[REMOTE_EXCEPTION]", "remote_exception", ex);
+ result_map.Write("[REMOTE_EXCEPTION]", ex);
})__cs_cb";
constexpr const char CB_INVOCATION_RESULT_PRE[] =
resultHeader.SetTag(_tidlVersion);
resultHeader.SetSequenceNumber(header.GetSequenceNumber());
-result_map.Write("[METHOD]", "int", (int)MethodId.__Result);
+result_map.Write("[METHOD]", (int)MethodId.__Result);
)__cs_cb";
#endif // IDLC_CS_GEN_VERSION2_CS_STUB_GENRATOR_CB_H_
\ No newline at end of file