.Repeat("UNIT_MAP_READ_WRITE", unit_types_,
[&](auto& r, const auto& i) {
auto& param_type = i.second;
- r.Replace("TYPE", std::to_string(GetHashCode(
- GetFullNameFromType(param_type))))
+ r.Replace("TYPE",
+ GetHashCodeStr(GetFullNameFromType(param_type)))
.Replace("TYPE_STR", GetFullNameFromType(param_type))
.Replace("PARAM_TYPE",
ConvertTypeToString(param_type, true));
std::string CppGroupBodyGenerator::GenInterface(const Interface& iface) {
return std::string(
ReplaceAll(CB_INTERFACE)
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
.Repeat("IMPL_DISPATCH_FUNC_INIT", iface.GetDeclarations(),
[&](auto& r, const auto& i) {
r.Replace("NAME", i->GetID())
[&](auto& r, const auto& i) {
auto& type = i->GetParameterType().GetBaseType();
r.Replace("TYPE", ConvertTypeToString(type))
- .Replace("HASH_NAME",
- std::to_string(GetHashCode(i->GetID())))
+ .Replace("HASH_NAME", GetHashCodeStr(i->GetID()))
.Replace("NAME", i->GetID());
return true;
})
std::string code;
for (auto& decl : iface.GetDeclarations()) {
code += ReplaceAll(CB_INTERFACE_METHOD)
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
.Replace("CLS_NAME", iface.GetID())
.Replace("PARAMS", GetParameters(decl->GetParameters()))
.Repeat("SERIALIZE", decl->GetParameters(),
[&](auto& r, const auto& i) {
- r.Replace("HASH_NAME",
- std::to_string(GetHashCode(i->GetID())))
+ r.Replace("HASH_NAME", GetHashCodeStr(i->GetID()))
.Replace("NAME", i->GetID());
return true;
})
}
std::string CppProxyBodyGenerator::GenInterface(const Interface& iface) {
- return std::string(
- ReplaceAll(CB_INTERFACE_BASE)
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
- .Replace("HASH_DELEGATE", std::to_string(GetHashCode("delegate")))
- .Replace("CLS_NAME", iface.GetID())
- .Replace("ENUMS", GenEnumerations(iface.GetEnums()))
- .Replace("CALLBACKS", GenInterfaceCallbacks(iface))
- .Replace("METHODS", GenInterfaceMethods(iface)));
+ return std::string(ReplaceAll(CB_INTERFACE_BASE)
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
+ .Replace("HASH_DELEGATE", "delegate"_hash)
+ .Replace("CLS_NAME", iface.GetID())
+ .Replace("ENUMS", GenEnumerations(iface.GetEnums()))
+ .Replace("CALLBACKS", GenInterfaceCallbacks(iface))
+ .Replace("METHODS", GenInterfaceMethods(iface)));
}
std::string CppProxyBodyGenerator::GenInterfaceCallbacks(
.Repeat("MAP_READ", decl->GetParameters(),
[&](auto& r, const auto& i) {
auto& type = i->GetParameterType().GetBaseType();
- r.Replace("HASH_NAME",
- std::to_string(GetHashCode(i->GetID())))
+ r.Replace("HASH_NAME", GetHashCodeStr(i->GetID()))
.Replace("TYPE", ConvertTypeToString(type))
.Replace("NAME", i->GetID());
return true;
[&](auto& r, const auto& i) {
return GenInterfaceMethodSerialize(r, i);
})
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
.Replace("IFACE_NAME", iface.GetID())
.Replace("NAME", decl.GetID())
.Replace("PARAMS", GetParameters(decl.GetParameters())));
ParameterType::Direction::IN)
return false;
- r.Replace("HASH_DNAME",
- std::to_string(GetHashCode(i->GetID())))
+ r.Replace("HASH_DNAME", GetHashCodeStr(i->GetID()))
.Replace("DNAME", i->GetID());
return true;
})
- .Replace("HASH_REMOTE_EXCEPTION",
- std::to_string(GetHashCode("[REMOTE_EXCEPTION]")))
- .Replace("HASH_RESULT", std::to_string(GetHashCode("[RESULT]")))
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
+ .Replace("HASH_REMOTE_EXCEPTION", "[REMOTE_EXCEPTION]"_hash)
+ .Replace("HASH_RESULT", "[RESULT]"_hash)
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
.Replace("RETURN_TYPE", ConvertTypeToString(decl.GetType()))
.Replace("SET_INIT_VALUE", GetSettingInitValue(decl.GetType()))
.Replace("IFACE_NAME", iface.GetID())
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT)
return false;
- r.Replace("HASH_SNAME", std::to_string(GetHashCode(i->GetID())))
+ r.Replace("HASH_SNAME", GetHashCodeStr(i->GetID()))
.Replace("SNAME", i->GetID());
return true;
}
return attr->GetKey() == "trusted" &&
attr->GetValue() == "true";
}) == iface.GetAttributes().end())
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
.Replace("CLS_NAME", iface.GetID())
.Replace("CALLBACKS", GenInterfaceCallbacks(iface))
.Replace("IMPL_SERVICE_BASE_THREAD_MEMBER_INIT",
for (const auto& decl : iface.GetDeclarations()) {
if (decl->GetMethodType() != Declaration::MethodType::DELEGATE) continue;
- code +=
- ReplaceAll(CB_INTERFACE_CALLBACK)
- .Repeat("SERIALIZE", decl->GetParameters(),
- [&](auto& r, const auto& i) {
- r.Replace("HASH_NAME",
- std::to_string(GetHashCode(i->GetID())))
- .Replace("NAME", i->GetID());
- return true;
- })
- .Repeat("PRIVATE_SHARINGS", decl->GetParameters(),
- [&](auto& r, const auto& i) {
- r.Replace("PRIVATE_SHARING", GenPrivateSharing(*i));
- return true;
- })
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
- .Replace("HASH_DELEGATE", std::to_string(GetHashCode("delegate")))
- .Replace("IFACE_NAME", iface.GetID())
- .Replace("CLS_NAME", decl->GetID())
- .Replace("PARAMS", GetParameters(decl->GetParameters()));
+ code += ReplaceAll(CB_INTERFACE_CALLBACK)
+ .Repeat("SERIALIZE", decl->GetParameters(),
+ [&](auto& r, const auto& i) {
+ r.Replace("HASH_NAME", GetHashCodeStr(i->GetID()))
+ .Replace("NAME", i->GetID());
+ return true;
+ })
+ .Repeat("PRIVATE_SHARINGS", decl->GetParameters(),
+ [&](auto& r, const auto& i) {
+ r.Replace("PRIVATE_SHARING", GenPrivateSharing(*i));
+ return true;
+ })
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
+ .Replace("HASH_DELEGATE", "delegate"_hash)
+ .Replace("IFACE_NAME", iface.GetID())
+ .Replace("CLS_NAME", decl->GetID())
+ .Replace("PARAMS", GetParameters(decl->GetParameters()));
code += NLine(1);
}
ParameterType::Direction::IN)
return false;
- r.Replace("HASH_NAME",
- std::to_string(GetHashCode(i->GetID())))
+ r.Replace("HASH_NAME", GetHashCodeStr(i->GetID()))
.Replace("NAME", i->GetID());
return true;
})
r.Replace("PRIVATE_SHARING", GenPrivateSharing(*i));
return true;
})
- .Replace("HASH_REMOTE_EXCEPTION",
- std::to_string(GetHashCode("[REMOTE_EXCEPTION]")))
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
- .Replace("HASH_RESULT", std::to_string(GetHashCode("[RESULT]")))
+ .Replace("HASH_REMOTE_EXCEPTION", "[REMOTE_EXCEPTION]"_hash)
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
+ .Replace("HASH_RESULT", "[RESULT]"_hash)
.Replace("IFACE_NAME", iface.GetID())
.Replace("NAME", decl.GetID())
.Replace("PARAMS", params)
ParameterType::Direction::OUT)
continue;
- code += RemoveLine(std::string(
- ReplaceAll(CB_INTERFACE_SERVICE_BASE_UNIT_MAP_READ)
- .Replace("HASH_NAME", std::to_string(GetHashCode(param->GetID())))
- .Replace("TYPE", ConvertTypeToString(type))
- .Replace("NAME", param->GetID())));
+ code += RemoveLine(
+ std::string(ReplaceAll(CB_INTERFACE_SERVICE_BASE_UNIT_MAP_READ)
+ .Replace("HASH_NAME", GetHashCodeStr(param->GetID()))
+ .Replace("TYPE", ConvertTypeToString(type))
+ .Replace("NAME", param->GetID())));
}
return RemoveLine(code);
})
.ReplaceBlock("META_PARCELS",
[&](ReplaceAll& ra) { return SetMetaParcelBlock(ra); })
- .Replace("HASH_CHAR", std::to_string(GetHashCode("char")))
- .Replace("HASH_SHORT", std::to_string(GetHashCode("short")))
- .Replace("HASH_INT", std::to_string(GetHashCode("int")))
- .Replace("HASH_LONG", std::to_string(GetHashCode("long")))
- .Replace("HASH_FLOAT", std::to_string(GetHashCode("float")))
- .Replace("HASH_DOUBLE", std::to_string(GetHashCode("double")))
- .Replace("HASH_BOOL", std::to_string(GetHashCode("bool")))
- .Replace("HASH_STRING", std::to_string(GetHashCode("string")))
- .Replace("HASH_REMOTE_EXCEPTION",
- std::to_string(GetHashCode("remote_exception")))
- .Replace("HASH_BUNDLE", std::to_string(GetHashCode("bundle")))
+ .Replace("HASH_CHAR", "char"_hash)
+ .Replace("HASH_SHORT", "short"_hash)
+ .Replace("HASH_INT", "int"_hash)
+ .Replace("HASH_LONG", "long"_hash)
+ .Replace("HASH_FLOAT", "float"_hash)
+ .Replace("HASH_DOUBLE", "double"_hash)
+ .Replace("HASH_BOOL", "bool"_hash)
+ .Replace("HASH_STRING", "string"_hash)
+ .Replace("HASH_REMOTE_EXCEPTION", "remote_exception"_hash)
+ .Replace("HASH_BUNDLE", "bundle"_hash)
.Out(stream);
stream.close();
}
ConvertTypeToString(e->GetType(), i, false));
return true;
})
- .Replace("HASH_UNIT_TYPE",
- std::to_string(GetHashCode(GetStructTypeString(st))))
+ .Replace("HASH_UNIT_TYPE", GetHashCodeStr(GetStructTypeString(st)))
.Replace("UNIT_TYPE", GetStructTypeString(st));
return true;
}
target.Replace("TYPE", ConvertTypeToString(type, nullptr, false))
.Replace("TYPE_ID", GetFullNameFromType(type))
- .Replace("HASH_TYPE_ID",
- std::to_string(GetHashCode(GetFullNameFromType(type))))
+ .Replace("HASH_TYPE_ID", GetHashCodeStr(GetFullNameFromType(type)))
.RemoveAll("LIST", type.ToString() != "list")
.RemoveAll("ARRAY", type.ToString() != "array")
.RemoveAll("SET", type.ToString() != "set")
ReplaceAll(::CB_GROUP_MAIN)
.Replace("VERSION", std::string(FULLVER))
.Repeat("STRUCTS", GetDocument().GetBlocks(),
- [&](ReplaceAll& ra, const std::shared_ptr<Block>& i) {
- return SetStructs(ra, i);
- })
+ [&](ReplaceAll& ra, const std::shared_ptr<Block>& i) {
+ return SetStructs(ra, i);
+ })
.ReplaceBlock("MODULE_BLOCK", [&](ReplaceAll& ra) { SetModules(ra); })
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
.Out(stream);
stream.close();
}
int m_cnt = 2;
int d_cnt = 1;
- ra.Repeat("MODULES", GetDocument().GetBlocks(),
+ ra.Repeat(
+ "MODULES", GetDocument().GetBlocks(),
[&](ReplaceAll& ra, const std::shared_ptr<Block>& i) {
- if (i->GetType() != Block::TYPE_INTERFACE)
- return false;
- Interface& iface = static_cast<Interface&>(*i);
- ra.Replace("MOD_NAME", PascalToSnake(iface.GetID()))
- .Repeat("METHOD_ID", iface.GetDeclarations(),
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d){
- return SetMethodIDs(ra, d, m_cnt);
- })
- .Repeat("DELEGATE_ID", iface.GetDeclarations(),
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d){
- return SetDelegateIDs(ra, d, d_cnt);
- })
- .ReplaceBlock("DELEGATE_BLOCK", [&](ReplaceAll& ra) {
- SetDelegateBlock(ra, iface);
- })
- .Repeat("ENUM", iface.GetEnums(),
- [&](ReplaceAll& ra, const std::unique_ptr<Enum>& e) {
- return SetEnum(ra, e);
- })
- .ReplaceBlock("INTERFACE_BLOCK", [&](ReplaceAll& ra) {
- SetInterfaceBlock(ra, iface);
- });
- return true;
- });
+ if (i->GetType() != Block::TYPE_INTERFACE) return false;
+ Interface& iface = static_cast<Interface&>(*i);
+ ra.Replace("MOD_NAME", PascalToSnake(iface.GetID()))
+ .Repeat("METHOD_ID", iface.GetDeclarations(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
+ return SetMethodIDs(ra, d, m_cnt);
+ })
+ .Repeat("DELEGATE_ID", iface.GetDeclarations(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
+ return SetDelegateIDs(ra, d, d_cnt);
+ })
+ .ReplaceBlock("DELEGATE_BLOCK",
+ [&](ReplaceAll& ra) { SetDelegateBlock(ra, iface); })
+ .Repeat("ENUM", iface.GetEnums(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Enum>& e) {
+ return SetEnum(ra, e);
+ })
+ .ReplaceBlock("INTERFACE_BLOCK", [&](ReplaceAll& ra) {
+ SetInterfaceBlock(ra, iface);
+ });
+ return true;
+ });
}
bool RsGroupGen::SetMethodIDs(ReplaceAll& ra,
- const std::unique_ptr<Declaration>& d, int& cnt) {
- if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
- return false;
+ const std::unique_ptr<Declaration>& d, int& cnt) {
+ if (d->GetMethodType() == Declaration::MethodType::DELEGATE) return false;
ra.Replace("ID", SnakeToPascal(d->GetID()))
- .Replace("COUNT", std::to_string(cnt++));
+ .Replace("COUNT", std::to_string(cnt++));
return true;
}
bool RsGroupGen::SetDelegateIDs(ReplaceAll& ra,
- const std::unique_ptr<Declaration>& d, int& cnt) {
- if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
- return false;
+ const std::unique_ptr<Declaration>& d,
+ int& cnt) {
+ if (d->GetMethodType() != Declaration::MethodType::DELEGATE) return false;
ra.Replace("ID", SnakeToPascal(d->GetID()))
- .Replace("COUNT", std::to_string(cnt++));
+ .Replace("COUNT", std::to_string(cnt++));
return true;
}
-
void RsGroupGen::SetDelegateBlock(ReplaceAll& ra, const Interface& iface) {
auto& decls = iface.GetDeclarations();
ra.Repeat("DELEGATES", decls,
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& i) {
- if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
- return false;
- ra.Replace("TYPES", GetParameters(i->GetParameters(), true))
- .Repeat("REPLY_BODY", i->GetParameters(),
- [&](ReplaceAll& ra, const std::unique_ptr<tidl::Parameter>& p) {
- ra.Replace("ID", p->GetID());
- return true;
- })
- .Replace("METHOD_NAME", SnakeToPascal(i->GetID()))
- .Replace("METHOD_ORG_NAME", i->GetID());
- return true;
- });
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& i) {
+ if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
+ return false;
+ ra.Replace("TYPES", GetParameters(i->GetParameters(), true))
+ .Repeat("REPLY_BODY", i->GetParameters(),
+ [&](ReplaceAll& ra,
+ const std::unique_ptr<tidl::Parameter>& p) {
+ ra.Replace("ID", p->GetID());
+ return true;
+ })
+ .Replace("METHOD_NAME", SnakeToPascal(i->GetID()))
+ .Replace("METHOD_ORG_NAME", i->GetID());
+ return true;
+ });
}
void RsGroupGen::SetInterfaceBlock(ReplaceAll& ra, const Interface& iface) {
ra.Repeat("ENUM", iface.GetEnums(),
- [&](ReplaceAll& ra, const std::unique_ptr<Enum>& e) {
- return SetEnum(ra, e);
- });
+ [&](ReplaceAll& ra, const std::unique_ptr<Enum>& e) {
+ return SetEnum(ra, e);
+ });
ra.Replace("IFACE_NAME", SnakeToPascal(iface.GetID()))
- .Repeat("METHODS_PROTO", iface.GetDeclarations(),
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d){
- return SetMethod(ra, d);
- })
- .Repeat("METHODS", iface.GetDeclarations(),
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d){
- return SetMethod(ra, d);
- })
- .Repeat("DISPATCHES", iface.GetDeclarations(),
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
- if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
- return false;
-
- ra.Replace("ID", d->GetID())
- .Replace("SNAKE_ID", PascalToSnake(d->GetID()));
- return true;
- })
- .Repeat("PRIVILEGES", iface.GetDeclarations(),
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
- if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
- return false;
-
- std::vector<std::string> privileges;
- for (auto& attr : d->GetAttributes()) {
- if (attr->GetKey() != "privilege")
- continue;
-
- privileges.push_back(attr->GetValue());
- }
- if (privileges.empty())
- return false;
-
- ra.Repeat("PRIVILEGE", privileges,
- [&](ReplaceAll& ra, const std::string& priv) {
- ra.Replace("ID", priv);
- return true;
- })
- .Replace("METHOD", SnakeToPascal(d->GetID()));
- return true;
- });
+ .Repeat("METHODS_PROTO", iface.GetDeclarations(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
+ return SetMethod(ra, d);
+ })
+ .Repeat("METHODS", iface.GetDeclarations(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
+ return SetMethod(ra, d);
+ })
+ .Repeat("DISPATCHES", iface.GetDeclarations(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
+ if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
+ return false;
+
+ ra.Replace("ID", d->GetID())
+ .Replace("SNAKE_ID", PascalToSnake(d->GetID()));
+ return true;
+ })
+ .Repeat("PRIVILEGES", iface.GetDeclarations(),
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
+ if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
+ return false;
+
+ std::vector<std::string> privileges;
+ for (auto& attr : d->GetAttributes()) {
+ if (attr->GetKey() != "privilege") continue;
+
+ privileges.push_back(attr->GetValue());
+ }
+ if (privileges.empty()) return false;
+
+ ra.Repeat("PRIVILEGE", privileges,
+ [&](ReplaceAll& ra, const std::string& priv) {
+ ra.Replace("ID", priv);
+ return true;
+ })
+ .Replace("METHOD", SnakeToPascal(d->GetID()));
+ return true;
+ });
}
-bool RsGroupGen::SetMethod(ReplaceAll& ra, const std::unique_ptr<Declaration>& d) {
- if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
- return false;
+bool RsGroupGen::SetMethod(ReplaceAll& ra,
+ const std::unique_ptr<Declaration>& d) {
+ if (d->GetMethodType() == Declaration::MethodType::DELEGATE) return false;
if (!d->GetComments().empty())
ra.Replace("COMMENTS", AddIndent(2 * TAB_SIZE, d->GetComments()));
if (p->GetParameterType().GetBaseType().IsDelegateType())
return false;
ra.Replace("ID", p->GetID())
- .Replace("HASH_ID", std::to_string(GetHashCode(p->GetID())))
- .Replace("TYPE", ConvertTypeToString(
- p->GetParameterType().GetBaseType()));
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()))
+ .Replace("TYPE", ConvertTypeToString(
+ p->GetParameterType().GetBaseType()));
return true;
})
.Repeat("DELEGATER_RECEIVER_BODY", (*d).GetParameters(),
if (!p->GetParameterType().GetBaseType().IsDelegateType())
return false;
ra.Replace("ID", p->GetID())
- .Replace("HASH_ID", std::to_string(GetHashCode(p->GetID())))
- .Replace("TYPE", ConvertTypeToString(
- p->GetParameterType().GetBaseType()));
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()))
+ .Replace("TYPE", ConvertTypeToString(
+ p->GetParameterType().GetBaseType()));
return true;
})
.Repeat("RETURNS", (*d).GetParameters(),
[&](ReplaceAll& ra, const std::unique_ptr<tidl::Parameter>& p) {
- if (p->GetParameterType().GetDirection() == ParameterType::Direction::IN ||
+ if (p->GetParameterType().GetDirection() ==
+ ParameterType::Direction::IN ||
p->GetParameterType().GetBaseType().IsDelegateType())
return false;
}
void RsGroupGen::SetFile(ReplaceAll& ra,
- const std::unique_ptr<tidl::Parameter>& i) {
+ const std::unique_ptr<tidl::Parameter>& i) {
std::string type = GetFullNameFromType(i->GetParameterType().GetBaseType());
ra.Remove("FILE", type != "file")
- .Remove("FILESLIST", type != "list_file")
- .Remove("FILESARRAY", type != "array_file");
+ .Remove("FILESLIST", type != "list_file")
+ .Remove("FILESARRAY", type != "array_file");
}
bool RsGroupGen::SetSenderBody(ReplaceAll& ra,
- const std::unique_ptr<tidl::Parameter>& i) {
+ const std::unique_ptr<tidl::Parameter>& i) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT)
return false;
SetFile(ra, i);
- ra.Replace("ID", i->GetID())
- .Replace("HASH_ID", std::to_string(GetHashCode(i->GetID())));
+ ra.Replace("ID", i->GetID()).Replace("HASH_ID", GetHashCodeStr(i->GetID()));
return true;
}
bool RsGroupGen::SetReceiverBody(ReplaceAll& ra,
- const std::unique_ptr<tidl::Parameter>& i) {
+ const std::unique_ptr<tidl::Parameter>& i) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN)
- return false;
+ return false;
ra.Replace("ID", i->GetID());
return true;
}
std::string RsGroupGen::GetRetExpr(const Declaration& decl) {
- if (decl.GetType().ToString() == "void")
- return "";
+ if (decl.GetType().ToString() == "void") return "";
return "-> " + ConvertTypeToString(decl.GetType());
}
})
.ReplaceBlock("MODULE_BLOCK", [&](ReplaceAll& ra) { SetModules(ra); })
.Remove("BUNDLE_HEADER_BLOCK", RsGeneratorBase::HasBundle() != true)
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
- .Replace("HASH_REMOTE_EXCEPTION",
- std::to_string(GetHashCode("[REMOTE_EXCEPTION]")))
- .Replace("HASH_RESULT", std::to_string(GetHashCode("[RESULT]")))
- .Replace("HASH_DELEGATE", std::to_string(GetHashCode("delegate")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
+ .Replace("HASH_REMOTE_EXCEPTION", "[REMOTE_EXCEPTION]"_hash)
+ .Replace("HASH_RESULT", "[RESULT]"_hash)
+ .Replace("HASH_DELEGATE", "delegate"_hash)
.Out(stream);
stream.close();
}
"RECEIVER_BODY", i->GetParameters(),
[&](ReplaceAll& ra, const std::unique_ptr<tidl::Parameter>& p) {
ra.Replace("ID", p->GetID())
- .Replace("HASH_ID",
- std::to_string(GetHashCode(p->GetID())))
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()))
.Replace("TYPE",
ConvertTypeToString(
p->GetParameterType().GetBaseType()));
return SetRegDelegaters(ra, i);
})
.Remove("HAS_RETURN", (*d).GetType().ToString() == "void")
- .Replace("HASH_RESULT", std::to_string(GetHashCode("[RESULT]")))
+ .Replace("HASH_RESULT", "[RESULT]"_hash)
.Replace("TYPE", [&]() { return ConvertTypeToString((*d).GetType()); });
return true;
}
return "";
return "&";
})
- .Replace("HASH_ID", std::to_string(GetHashCode(i->GetID())));
+ .Replace("HASH_ID", GetHashCodeStr(i->GetID()));
return true;
}
const std::unique_ptr<tidl::Parameter>& i) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN)
return false;
- ra.Replace("ID", i->GetID())
- .Replace("HASH_ID", std::to_string(GetHashCode(i->GetID())));
+ ra.Replace("ID", i->GetID()).Replace("HASH_ID", GetHashCodeStr(i->GetID()));
return true;
}
})
.ReplaceBlock("MODULE_BLOCK", [&](ReplaceAll& ra) { SetModules(ra); })
.Remove("BUNDLE_HEADER_BLOCK", RsGeneratorBase::HasBundle() != true)
- .Replace("HASH_METHOD", std::to_string(GetHashCode("[METHOD]")))
- .Replace("HASH_REMOTE_EXCEPTION",
- std::to_string(GetHashCode("[REMOTE_EXCEPTION]")))
- .Replace("HASH_RESULT", std::to_string(GetHashCode("[RESULT]")))
- .Replace("HASH_DELEGATE", std::to_string(GetHashCode("delegate")))
+ .Replace("HASH_METHOD", "[METHOD]"_hash)
+ .Replace("HASH_REMOTE_EXCEPTION", "[REMOTE_EXCEPTION]"_hash)
+ .Replace("HASH_RESULT", "[RESULT]"_hash)
+ .Replace("HASH_DELEGATE", "delegate"_hash)
.Out(stream);
stream.close();
}
void RsStubGen::SetDelegateBlock(ReplaceAll& ra, const Interface& iface) {
auto& decls = iface.GetDeclarations();
- ra.Repeat(
- "DELEGATES", decls,
- [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& i) {
- if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
- return false;
- ra.Replace("TYPES", GetParameters(i->GetParameters(), true))
- .Repeat(
- "REPLY_BODY", i->GetParameters(),
- [&](ReplaceAll& ra, const std::unique_ptr<tidl::Parameter>& p) {
- ra.Replace("ID", p->GetID())
- .Replace("HASH_ID",
- std::to_string(GetHashCode(p->GetID())));
- return true;
- })
- .Replace("METHOD_NAME", SnakeToPascal(i->GetID()))
- .Replace("METHOD_ORG_NAME", i->GetID());
- return true;
- });
+ ra.Repeat("DELEGATES", decls,
+ [&](ReplaceAll& ra, const std::unique_ptr<Declaration>& i) {
+ if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
+ return false;
+ ra.Replace("TYPES", GetParameters(i->GetParameters(), true))
+ .Repeat("REPLY_BODY", i->GetParameters(),
+ [&](ReplaceAll& ra,
+ const std::unique_ptr<tidl::Parameter>& p) {
+ ra.Replace("ID", p->GetID())
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()));
+ return true;
+ })
+ .Replace("METHOD_NAME", SnakeToPascal(i->GetID()))
+ .Replace("METHOD_ORG_NAME", i->GetID());
+ return true;
+ });
}
void RsStubGen::SetInterfaceBlock(ReplaceAll& ra, const Interface& iface) {
ra.Remove("IS_OUT_DIR", p->GetParameterType().GetDirection() ==
ParameterType::Direction::OUT)
.Replace("ID", p->GetID())
- .Replace("HASH_ID", std::to_string(GetHashCode(p->GetID())))
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()))
.Replace("TYPE", ConvertTypeToString(
p->GetParameterType().GetBaseType()));
return true;
if (!p->GetParameterType().GetBaseType().IsDelegateType())
return false;
ra.Replace("ID", p->GetID())
- .Replace("HASH_ID", std::to_string(GetHashCode(p->GetID())))
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()))
.Replace("TYPE", ConvertTypeToString(
p->GetParameterType().GetBaseType()));
return true;
return false;
ra.Replace("ID", p->GetID())
- .Replace("HASH_ID",
- std::to_string(GetHashCode(p->GetID())));
+ .Replace("HASH_ID", GetHashCodeStr(p->GetID()));
return true;
})
.Replace("IDS", GetParameterIDsWithDir((*d).GetParameters()))