Add some methods in ReplaceAll
- Add Repeat() method
- Add Remove() method
- Add Replace() method
- Example
constexpr const char CB_FUNCTION[] =
R"__rs_cb(
pub fn <FN_NAME>(&self, <PARAMS>) <RET>{
let p = Parcel::new();
let port = self.proxy.get_port(PortType::Main);
p.write_i32(MethodId::<METHOD_ID> as i32);
<SENDER_BODY*><ID>.write_parcel(&mut p);</SENDER_BODY*>
p.send(&port);
<SYNC?>let parcel_received = Parcel::from(&port);
<RECEIVER_BODY*><ID>.read_parcel(&mut parcel_received);</RECEIVER_BODY*>
<HAS_RETURN?>let mut __ret: <TYPE> = Default::default();
__ret.read_parcel(&mut parcel_received);
__ret</HAS_RETURN?></SYNC?>
}
)__rs_cb";
ret += ReplaceAll(::CB_FUNCTION)
.Replace("FN_NAME", i->GetID())
.Replace("PARAMS", GetParameters(i->GetParameters()))
.Replace("RET", GetRetExpr(*i))
.Replace("METHOD_ID", (*i).GetID())
.Repeat("SENDER_BODY", (*i).GetParameters(),
[](ReplaceAll* ra, const std::unique_ptr<tidl::Parameter>& i) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT)
return false;
ra->Replace("ID", i->GetID());
return true;
})
.Remove("SYNC", (*i).GetMethodType() == Declaration::MethodType::ASYNC)
.Repeat("RECEIVER_BODY", (*i).GetParameters(),
[](ReplaceAll* ra, const std::unique_ptr<tidl::Parameter>& i) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN)
return false;
ra->Replace("ID", i->GetID());
return true;
})
.Remove("HAS_RETURN", (*i).GetType().ToString() == "void" )
.Replace("TYPE", [&]() {
return ConvertTypeToString((*i).GetType());
});
Change-Id: Ic77369977767690181f192ebd6c21df802920ca6
Signed-off-by: jh9216.park <jh9216.park@samsung.com>