return line_;
}
-void Attributes::Add(Attribute* attr) {
- attrs_.emplace_back(attr);
+void Attributes::Add(std::unique_ptr<Attribute> attr) {
+ attrs_.push_back(std::move(attr));
}
-const std::list<std::unique_ptr<Attribute>>& Attributes::GetAttrs() const {
- return attrs_;
-}
-
-bool Attributes::Exist(Attribute* attr) const {
+bool Attributes::Exist(const Attribute& attr) const {
for (auto& a : attrs_) {
- if (a->GetKey() == attr->GetKey() &&
- a->GetValue() == attr->GetValue())
+ if (a->GetKey() == attr.GetKey() &&
+ a->GetValue() == attr.GetValue())
return true;
}
return false;
}
+std::list<std::unique_ptr<Attribute>>::const_iterator
+Attributes::begin() const {
+ return attrs_.cbegin();
+}
+
+std::list<std::unique_ptr<Attribute>>::const_iterator Attributes::end() const {
+ return attrs_.cend();
+}
+
} // namespace tidl
class Attributes {
public:
- void Add(Attribute* attr);
- const std::list<std::unique_ptr<Attribute>>& GetAttrs() const;
- bool Exist(Attribute* attr) const;
+ void Add(std::unique_ptr<Attribute> attr);
+ bool Exist(const Attribute& attr) const;
+ std::list<std::unique_ptr<Attribute>>::const_iterator begin() const;
+ std::list<std::unique_ptr<Attribute>>::const_iterator end() const;
private:
std::list<std::unique_ptr<Attribute>> attrs_;
return comments_;
}
-void Declarations::Add(Declaration* decl) {
- decls_.emplace_back(decl);
+void Declarations::Add(std::unique_ptr<Declaration> decl) {
+ decls_.push_back(std::move(decl));
}
-const std::list<std::unique_ptr<Declaration>>& Declarations::GetDecls() const {
- return decls_;
-}
-
-bool Declarations::Exist(Declaration* decl) const {
+bool Declarations::Exist(const Declaration& decl) const {
for (auto& d : decls_) {
- if (d->GetID() == decl->GetID())
+ if (d->GetID() == decl.GetID())
return true;
}
return false;
}
+std::list<std::unique_ptr<Declaration>>::const_iterator
+Declarations::begin() const {
+ return decls_.cbegin();
+}
+
+std::list<std::unique_ptr<Declaration>>::const_iterator
+Declarations::end() const {
+ return decls_.cend();
+}
+
} // namespace tidl
class Declarations {
public:
- void Add(Declaration* decl);
- const std::list<std::unique_ptr<Declaration>>& GetDecls() const;
- bool Exist(Declaration* decl) const;
+ void Add(std::unique_ptr<Declaration> decl);
+ bool Exist(const Declaration& decl) const;
+ std::list<std::unique_ptr<Declaration>>::const_iterator begin() const;
+ std::list<std::unique_ptr<Declaration>>::const_iterator end() const;
private:
std::list<std::unique_ptr<Declaration>> decls_;
return comments_;
}
-void Elements::Add(Element* elm) {
- elms_.emplace_back(elm);
+void Elements::Add(std::unique_ptr<Element> elm) {
+ elms_.push_back(std::move(elm));
}
-const std::list<std::unique_ptr<Element>>& Elements::GetElms() const {
- return elms_;
-}
-
-bool Elements::Exist(Element* elm) const {
+bool Elements::Exist(const Element& elm) const {
for (auto& e : elms_) {
- if (e->GetID() == elm->GetID())
+ if (e->GetID() == elm.GetID())
return true;
}
return false;
}
+std::list<std::unique_ptr<Element>>::const_iterator
+Elements::begin() const {
+ return elms_.cbegin();
+}
+
+std::list<std::unique_ptr<Element>>::const_iterator Elements::end() const {
+ return elms_.cend();
+}
+
} // namespace tidl
class Elements {
public:
- void Add(Element* elm);
- const std::list<std::unique_ptr<Element>>& GetElms() const;
- bool Exist(Element* elm) const;
+ void Add(std::unique_ptr<Element> elm);
+ bool Exist(const Element& elm) const;
+ std::list<std::unique_ptr<Element>>::const_iterator begin() const;
+ std::list<std::unique_ptr<Element>>::const_iterator end() const;
private:
std::list<std::unique_ptr<Element>> elms_;
return line_;
}
-void Parameters::Add(Parameter* param) {
- params_.emplace_back(param);
+void Parameters::Add(std::unique_ptr<Parameter> param) {
+ params_.push_back(std::move(param));
}
-const std::list<std::unique_ptr<Parameter>>& Parameters::GetParams() const {
- return params_;
-}
-
-bool Parameters::Exist(Parameter* param) const {
+bool Parameters::Exist(const Parameter& param) const {
for (auto& p : params_) {
- if (p->GetID() == param->GetID())
+ if (p->GetID() == param.GetID())
return true;
}
return false;
}
+std::list<std::unique_ptr<Parameter>>::const_iterator
+Parameters::begin() const {
+ return params_.cbegin();
+}
+
+std::list<std::unique_ptr<Parameter>>::const_iterator Parameters::end() const {
+ return params_.cend();
+}
+
} // namespace tidl
class Parameters {
public:
- void Add(Parameter* param);
- const std::list<std::unique_ptr<Parameter>>& GetParams() const;
- bool Exist(Parameter* param) const;
+ void Add(std::unique_ptr<Parameter> param);
+ bool Exist(const Parameter& param) const;
bool Exist(std::string type_name) const;
+ std::list<std::unique_ptr<Parameter>>::const_iterator begin() const;
+ std::list<std::unique_ptr<Parameter>>::const_iterator end() const;
private:
std::list<std::unique_ptr<Parameter>> params_;
elements: element {
$$ = new (std::nothrow) tidl::Elements();
if ($$ != nullptr) {
- $$->Add($1);
+ $$->Add(std::unique_ptr<tidl::Element>($1));
}
}
| elements element {
$$ = $1;
if ($2 != nullptr) {
- if ($$->Exist($2)) {
+ if ($$->Exist(*$2)) {
ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
delete $2;
} else {
- $$->Add($2);
+ $$->Add(std::unique_ptr<tidl::Element>($2));
}
}
}
attributes: attribute {
$$ = new (std::nothrow) tidl::Attributes();
if ($$ != nullptr) {
- $$->Add($1);
+ $$->Add(std::unique_ptr<tidl::Attribute>($1));
}
}
| attributes T_COMMA attribute {
$$ = $1;
if ($3 != nullptr) {
- if ($$->Exist($3)) {
+ if ($$->Exist(*$3)) {
ps->ReportError("syntax error. \"Already Exist\".", $3->GetLine());
delete $3;
} else {
- $$->Add($3);
+ $$->Add(std::unique_ptr<tidl::Attribute>($3));
}
}
}
declarations: declaration {
$$ = new (std::nothrow) tidl::Declarations();
if ($$ != nullptr) {
- $$->Add($1);
+ $$->Add(std::unique_ptr<tidl::Declaration>($1));
}
}
| declarations declaration {
$$ = $1;
if ($2 != nullptr) {
- if ($$->Exist($2)) {
+ if ($$->Exist(*$2)) {
ps->ReportError("syntax error. \"Already Exists\".", $2->GetLine());
delete $2;
} else {
- $$->Add($2);
+ $$->Add(std::unique_ptr<tidl::Declaration>($2));
}
}
}
parameter_list: parameter {
$$ = new tidl::Parameters();
if ($1 != nullptr) {
- $$->Add($1);
+ $$->Add(std::unique_ptr<tidl::Parameter>($1));
}
}
| parameter_list T_COMMA parameter {
$$ = $1;
if ($3 != nullptr) {
- if ($$->Exist($3)) {
+ if ($$->Exist(*$3)) {
ps->ReportError("syntax error. \"Already Exists\".", $3->GetLine());
delete $3;
} else {
- $$->Add($3);
+ $$->Add(std::unique_ptr<tidl::Parameter>($3));
}
}
}
{
((*yyvalp).elms) = new (std::nothrow) tidl::Elements();
if (((*yyvalp).elms) != nullptr) {
- ((*yyvalp).elms)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm));
+ ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
}
}
#line 1343 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
{
((*yyvalp).elms) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm) != nullptr) {
- if (((*yyvalp).elms)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm))) {
+ if (((*yyvalp).elms)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm))) {
ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)->GetLine());
delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm);
} else {
- ((*yyvalp).elms)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm));
+ ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
}
}
}
{
((*yyvalp).attrs) = new (std::nothrow) tidl::Attributes();
if (((*yyvalp).attrs) != nullptr) {
- ((*yyvalp).attrs)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr));
+ ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
}
}
#line 1416 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
{
((*yyvalp).attrs) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.attrs);
if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr) != nullptr) {
- if (((*yyvalp).attrs)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr))) {
+ if (((*yyvalp).attrs)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr))) {
ps->ReportError("syntax error. \"Already Exist\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)->GetLine());
delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr);
} else {
- ((*yyvalp).attrs)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr));
+ ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
}
}
}
{
((*yyvalp).decls) = new (std::nothrow) tidl::Declarations();
if (((*yyvalp).decls) != nullptr) {
- ((*yyvalp).decls)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl));
+ ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
}
}
#line 1537 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
{
((*yyvalp).decls) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls);
if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl) != nullptr) {
- if (((*yyvalp).decls)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl))) {
+ if (((*yyvalp).decls)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl))) {
ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)->GetLine());
delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl);
} else {
- ((*yyvalp).decls)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl));
+ ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
}
}
}
{
((*yyvalp).params) = new tidl::Parameters();
if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
- ((*yyvalp).params)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param));
+ ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
}
}
#line 1683 "/home/gogo/work/tidl/idlc/ast/tidlc_y.cpp"
{
((*yyvalp).params) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params);
if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
- if (((*yyvalp).params)->Exist((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param))) {
+ if (((*yyvalp).params)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param))) {
ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)->GetLine());
delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param);
} else {
- ((*yyvalp).params)->Add((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param));
+ ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
}
}
}
for (auto& b : GetDocument().GetBlocks()) {
if (b->GetType() == Block::TYPE_STRUCTURE) {
auto& st = static_cast<const Structure&>(*b);
- for (auto& e : st.GetElements().GetElms()) {
+ for (const auto& e : st.GetElements()) {
auto& type = e->GetType();
AddStructureFromType(type);
}
} else {
auto& iface = static_cast<const Interface&>(*b);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& d : iface.GetDeclarations()) {
+ for (const auto& p : d->GetParameters()) {
auto& type = p->GetParameterType().GetBaseType();
if (IsDelegateType(iface, type))
continue;
// @see #CB_STRUCTURE_ARRAY_DEF
void CBodyGeneratorBase::GenStructureArrayDef(std::ofstream& stream,
const Structure& st) {
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto element_type = GetDataTypeString(type, false);
// @see #CB_STRUCTURE_ARRAY_BASE
void CBodyGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
const Structure& st) {
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type);
// @see #CB_STRUCTURE_LIST_BASE
void CBodyGeneratorBase::GenStructureListBase(std::ofstream& stream,
const Structure& st) {
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
std::string CBodyGeneratorBase::GenBaseElements(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
auto& type = elm->GetType();
auto param_type = GetDataTypeString(type, false);
code += param_type + elm->GetID() + ";";
std::string CBodyGeneratorBase::GenBaseElementsFree(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms())
+ for (const auto& elm : elms)
code += GenBaseElementFree(elm);
return RemoveLine(code);
// @see #CB_STRUCTURE_BASE_BASE_PARCEL_WRITE
std::string CBodyGeneratorBase::GenBaseParcelWrite(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
std::string parcel_write_code;
auto& type = elm->GetType();
if (type.IsUserDefinedType() ||
// @see #CB_STRUCTURE_BASE_BASE_PARCEL_READ
std::string CBodyGeneratorBase::GenBaseParcelRead(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
std::string parcel_read_code;
auto& type = elm->GetType();
if (type.IsUserDefinedType() ||
std::string CBodyGeneratorBase::GenBaseSetGet(const std::string& name,
const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
auto& type = elm->GetType();
auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT,
}
bool CBodyGeneratorBase::HasListFile(const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (IsProxy() && d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& p : d->GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
auto name = GetFullNameFromType(type, iface);
assert(t != nullptr);
std::string type_name = GetFullNameFromType(type);
- Element* elm = new Element(type_name, t, "", __LINE__);
+ auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
assert(elm != nullptr);
Elements* elms = new Elements();
assert(elms != nullptr);
- elms->Add(elm);
+ elms->Add(std::move(elm));
auto* st = new Structure(type_name, elms, "", __LINE__);
assert(st != nullptr);
assert(t != nullptr);
std::string type_name = GetFullNameFromType(type, iface);
- Element* elm = new Element(type_name, t, "", __LINE__);
+ auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
assert(elm != nullptr);
Elements* elms = new Elements();
assert(elms != nullptr);
- elms->Add(elm);
+ elms->Add(std::move(elm));
auto* st = new Structure(type_name, elms, "", __LINE__);
assert(st != nullptr);
for (auto& b : GetDocument().GetBlocks()) {
if (b->GetType() == Block::TYPE_STRUCTURE) {
auto& st = static_cast<const Structure&>(*b);
- for (auto& e : st.GetElements().GetElms()) {
+ for (const auto& e : st.GetElements()) {
auto& type = e->GetType();
AddStructureFromType(type);
}
} else {
auto& iface = static_cast<const Interface&>(*b);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& d : iface.GetDeclarations()) {
+ for (const auto& p : d->GetParameters()) {
auto& type = p->GetParameterType().GetBaseType();
if (IsDelegateType(iface, type))
continue;
// @see #CB_STRUCTURE_ARRAY_BASE
void CHeaderGeneratorBase::GenStructureArrayBase(std::ofstream& stream,
const Structure& st) {
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type);
// @see #CB_STRUCTURE_LIST_BASE
void CHeaderGeneratorBase::GenStructureListBase(std::ofstream& stream,
const Structure& st) {
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
str = ReplaceAll(str, "<NAME>", st.GetID());
stream << SmartIndent(str);
- for (auto& e : st.GetElements().GetElms()) {
+ for (const auto& e : st.GetElements()) {
auto& type = e->GetType();
auto param_type_in = GetParamTypeString(ParameterType::Direction::IN, type);
auto param_type_out = GetParamTypeString(ParameterType::Direction::OUT, type);
void CProxyBodyGen::GenInterfaceDef(std::ofstream& stream,
const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
const Interface& iface) {
GenInterfaceDelegateEnumBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenInterfaceMethodEnumBase(stream, iface);
GenInterfaceBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
const Interface& iface) {
unsigned int num = 1;
std::string enums;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
std::string CProxyBodyGen::GenDelegateArgsDecl(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
code += GetArgTypeString(type, iface) + p->GetID() + " = " +
std::string CProxyBodyGen::GenDelegateParcelRead(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string param_read_code;
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
const Declaration& decl, bool& has_free) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string param_free_code;
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CProxyBodyGen::GenDelegateCallbackArgs(const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams())
+ for (const auto& p : decl.GetParameters())
code += ", " + p->GetID();
return code;
void CProxyBodyGen::GenInterfaceDelegateTable(std::ofstream& stream,
const Interface& iface) {
std::string delegate_handlers;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
enums += GetHandlePrefix() + "_" + iface.GetID() + "_METHOD_CALLBACK_,";
enums += NLine(1);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CProxyBodyGen::GenMethodParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CProxyBodyGen::GenMethodParamsCheck(const Interface& iface,
const Declaration& decl) {
std::string params_check;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type) ||
std::string CProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::IN)
continue;
std::string CProxyBodyGen::GenMethodDelegateAppend(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type)) {
std::string CProxyBodyGen::GenMethodArgs(const Interface& iface,
const Declaration& decl) {
std::string args_code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::OUT)
continue;
const Declaration& decl) {
std::string code;
std::string parcel_read_code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::OUT)
continue;
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceHandle(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
void CProxyHeaderGen::GenInterface(std::ofstream& stream,
const Interface& iface) {
- for (auto& d: iface.GetDeclarations().GetDecls()) {
+ for (const auto& d: iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenInterfaceBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CProxyHeaderGen::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CProxyHeaderGen::GenMethodParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
method_enums += RemoveLine(method_enum);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CStubBodyGen::GenDelegateEnums(const Interface& iface) {
unsigned int num = 1;
std::string method_enums;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
void CStubBodyGen::GenInterfaceDef(std::ofstream& stream,
const Interface& iface) {
bool has_delegate = false;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
void CStubBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
bool has_delegate = false;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
has_delegate = true;
}
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CStubBodyGen::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CStubBodyGen::GenDelegateParamsCheck(const Interface& iface,
const Declaration& decl) {
std::string params_check;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type) ||
std::string CStubBodyGen::GenDelegateParcelWrite(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string parcel_write_code;
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CStubBodyGen::GenMethodHandlerArgsDecl(const Interface& iface,
const Declaration& decl) {
std::string args_decl;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
args_decl += GetArgTypeString(type, iface) + p->GetID() + " = " +
std::string CStubBodyGen::GenMethodHandlerParcelRead(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string parcel_read_code;
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::IN)
code = ReplaceAll(code, "<RES_SET>", "");
std::string args;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
args += ", ";
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::IN)
code = ReplaceAll(code, "<UPPERCASE_NAME>", name);
std::string parcel_write_code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() == ParameterType::Direction::IN)
continue;
const Declaration& decl) {
std::string free_code;
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type) ||
// @see #CB_INTERFACE_METHOD_HANDLER
std::string CStubBodyGen::GenMethodHandlers(const Interface& iface) {
std::string code;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
// @see #CB_INTERFACE_TRUSTED_SET
std::string CStubBodyGen::GenAccessControlSet(const Interface& iface) {
std::string code;
- for (auto& attr : iface.GetAttributes().GetAttrs()) {
+ for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "privilege") {
std::string privilege_add = ReplaceAll(CB_INTERFACE_PRIVILEGE_ADD, {
{ "<NAME>", iface.GetID() },
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceContextHandle(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceCallbackBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CStubHeaderGen::GenMethodParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
void CStubHeaderGen::GenInterface(std::ofstream& stream,
const Interface& iface) {
GenInterfaceContextBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
std::string CStubHeaderGen::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
// @see #CB_INTERFACE_METHOD_CALLBACK_DECL
std::string CStubHeaderGen::GenMethodCallbackDecls(const Interface& iface) {
std::string method_callback_decls;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
[&]()->std::string {
std::string str;
int n = 1;
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
if (n != 1)
str += ", ";
str += ConvertTypeToString(i->GetType()) + " " + i->GetID();
});
stream << NLine(1);
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
GenSetter(stream, *i);
GenGetter(stream, *i);
stream << NLine(1);
GenTemplate(variable, stream,
[&]()->std::string {
std::string str;
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
str += NLine(1) + Tab(1)
+ ConvertTypeToString(i->GetType()) + " "
+ i->GetID() + "_";
"##::##($$)\n" \
" : $$ {}";
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
std::pair<std::string, std::string> p;
p.first = ConvertTypeToString(i->GetType());
stream << " ";
GenBrace(stream, 0, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
stream << AddIndent(TAB_SIZE,
ConvertTypeToSerializer(i->GetType(),
"param.Get" + i->GetID() + "()", "h"));
stream << " ";
GenBrace(stream, 0, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
stream << AddIndent(TAB_SIZE,
ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
stream << Tab(1) << "param.Set" << i->GetID() << "(std::move("
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() == Block::TYPE_STRUCTURE) {
const Structure& st = static_cast<const Structure&>(*i);
- for (auto& j : st.GetElements().GetElms()) {
+ for (const auto& j : st.GetElements()) {
auto& t = j->GetType();
AddSerializerList(t);
}
} else if (i->GetType() == Block::TYPE_INTERFACE) {
const Interface& iface = static_cast<const Interface&>(*i);
- for (auto& j : iface.GetDeclarations().GetDecls()) {
+ for (const auto& j : iface.GetDeclarations()) {
auto& t = j->GetType();
AddSerializerList(t);
- for (auto& k : j->GetParameters().GetParams()) {
+ for (const auto& k : j->GetParameters()) {
auto& t1 = k->GetParameterType().GetBaseType();
AddSerializerList(t1);
}
int cnt = 2;
stream << Tab(2) << "__Result = 0," << NLine(1);
stream << Tab(2) << "__Callback = 1," << NLine(1);
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(2)
stream << Tab(1) << "enum class DelegateId : int ";
GenBrace(stream, TAB_SIZE, [&]() {
int cnt = 1;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
stream << Tab(2)
std::string CppGeneratorBase::GetParameters(const Parameters& ps) {
bool first = true;
std::string ret;
- for (auto& i : ps.GetParams()) {
+ for (const auto& i : ps) {
if (!first) {
ret += ", ";
}
const Interface& iface, bool is_proxy) {
stream << ReplaceAll(CB_CALLBACK_BASE, "##", iface.GetID());
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenBodyCallback(stream, iface, *i, is_proxy);
},
[&]()->std::string {
std::string m;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
m += AddIndent(TAB_SIZE,
GenPrivateSharingRequest(pt.GetBaseType(), i->GetID()));
[&]()->std::string {
int cnt = 1;
std::string ret;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
std::string v = "param" + std::to_string(cnt);
std::string c = ConvertTypeToDeserializer(
i->GetParameterType().GetBaseType(), v, "parcel");
cnt = 1;
ret += Tab(1) + "OnReceived(";
- for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+ for (auto i = decl.GetParameters().begin();
+ i != decl.GetParameters().end(); ++i) {
if (cnt != 1) {
ret += ", ";
}
}
stream << CB_CALLBACK_BASE_HEADER_BACK;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenHeaderCallback(stream, *i, is_proxy);
const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
<< decl.GetID() << "));" << NLine(1);
std::string m;
std::string l;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
auto parcel_read = [&]() -> std::string {
std::string code;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() ==
ParameterType::Direction::IN)
continue;
const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
const Interface& iface) {
stream << ReplaceAll(CB_CTOR_FRONT, "##", iface.GetID());
- for (auto& i : iface.GetAttributes().GetAttrs()) {
+ for (const auto& i : iface.GetAttributes()) {
if (i->GetKey() == "privilege") {
stream << Tab(1) << "rpc_port_stub_add_privilege(stub_, \""
<< i->GetValue() << "\");" << NLine(1);
stream << code;
}
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(2) << "case static_cast<int>(MethodId::"
int cnt = 1;
// Deserialize
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
cnt++;
continue;
}
m += "b->" + decl.GetID() + "(";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (cnt != 1) {
m += ", ";
}
cnt = 0;
m = "rpc_port_parcel_write_int32(" \
"result, static_cast<int>(MethodId::__Result));\n";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
cnt++;
if (pt.GetDirection() == ParameterType::Direction::IN)
stream << CB_SERVICE_BASE_FRONT;
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
if (!i->GetComments().empty())
stream << Tab(1) <<"public sealed class " << st.GetID() << NLine(1);
GenBrace(stream, TAB_SIZE, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
GenTemplate(CB_PROPERTY, stream,
[&]()->std::string {
return ConvertTypeToString(i->GetType());
stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
stream << Tab(4) << "h.Write"
stream << Tab(3) << "private static void Deserialize(Parcel h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
stream << Tab(4) << "var " << i->GetID() << " = "
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() == Block::TYPE_STRUCTURE) {
const Structure& st = static_cast<const Structure&>(*i);
- for (auto& j : st.GetElements().GetElms()) {
+ for (const auto& j : st.GetElements()) {
auto& t = j->GetType();
AddSerializerList(t);
}
} else if (i->GetType() == Block::TYPE_INTERFACE) {
const Interface& iface = static_cast<const Interface&>(*i);
- for (auto& j : iface.GetDeclarations().GetDecls()) {
+ for (const auto& j : iface.GetDeclarations()) {
auto& t = j->GetType();
AddSerializerList(t);
- for (auto& k : j->GetParameters().GetParams()) {
+ for (const auto& k : j->GetParameters()) {
auto& t1 = k->GetParameterType().GetBaseType();
AddSerializerList(t1);
}
int cnt = 2;
stream << Tab(4) << "__Result = 0," << NLine(1);
stream << Tab(4) << "__Callback = 1," << NLine(1);
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(4)
stream << Tab(3) << "private enum DelegateId : int" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
int cnt = 1;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
stream << Tab(4)
std::string CsGeneratorBase::GetParameters(const Parameters& ps) {
bool first = true;
std::string ret;
- for (auto& i : ps.GetParams()) {
+ for (const auto& i : ps) {
if (!first) {
ret += ", ";
}
const Interface& iface, bool is_proxy) {
stream << CB_CALLBACK_BASE;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenCallback(stream, *i, iface.GetID(), is_proxy);
<< NLine(1);
GenBrace(stream, TAB_SIZE * 4, [&]() {
int cnt = 1;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
std::string v = "param" + std::to_string(cnt);
std::string c = ConvertTypeToDeserializer(
i->GetParameterType().GetBaseType(), v, "parcel", true, id);
cnt = 1;
stream << Tab(5) << "Received?.Invoke(";
- for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+ for (auto i = decl.GetParameters().begin();
+ i != decl.GetParameters().end(); ++i) {
if (cnt != 1) {
stream << ", ";
}
},
[&]()->std::string {
std::string m;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
}
void CsProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
GenTemplate(CB_INVOCATION_PRE, stream,
[&]()->std::string {
std::string st;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
+ "p.WriteInt((int)MethodId." + decl.GetID() + ");" + NLine(1);
std::string m;
std::string l;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
st += NLine(1) + AddIndent(TAB_SIZE * 5, CB_INVOCATION_RECEIVE);
st += NLine(1);
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() ==
ParameterType::Direction::IN) {
continue;
void CsStubGen::GenDeclarations(std::ofstream& stream,
const Declarations& decls) {
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
if (!i->GetComments().empty())
void CsStubGen::GenReceivedEvent(std::ofstream& stream,
const Interface& iface) {
stream << CB_ON_RECEIVED_EVENT_FRONT;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(7) << "case MethodId." << i->GetID() << ":" << NLine(1);
int cnt = 1;
// Deserialize
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
cnt++;
continue;
}
m += "b." + decl.GetID() + "(";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (cnt != 1) {
m += ", ";
}
cnt = 0;
m = CB_INVOCATION_RESULT_PRE;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
cnt++;
if (pt.GetDirection() == ParameterType::Direction::IN)
return iface.GetID();
});
- for (auto& i : iface.GetAttributes().GetAttrs()) {
+ for (const auto& i : iface.GetAttributes()) {
if (i->GetKey() == "privilege") {
stream << Tab(4) << "AddPrivilege(\""
<< i->GetValue() << "\");" << NLine(1);
bool Generator::IsDelegateType(const Interface& inf,
const BaseType& type) {
- for (auto& i : inf.GetDeclarations().GetDecls()) {
+ for (const auto& i : inf.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
if (i->GetID() == type.ToString())
for (auto& b : GetDocument().GetBlocks()) {
if (b->GetType() == Block::TYPE_STRUCTURE) {
auto& st = static_cast<const Structure&>(*b);
- for (auto& e : st.GetElements().GetElms()) {
+ for (const auto& e : st.GetElements()) {
auto& type = e->GetType();
AddStructureFromType(type);
}
} else {
auto& iface = static_cast<const Interface&>(*b);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& d : iface.GetDeclarations()) {
+ for (const auto& p : d->GetParameters()) {
auto& type = p->GetParameterType().GetBaseType();
if (IsDelegateType(iface, type))
continue;
GetHandlePrefix());
code = ReplaceAll(code, "<NAME>", st.GetID());
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto element_type = GetDataTypeString(type, false);
code = ReplaceAll(code, "<ELEMENT_TYPE>", element_type);
GetHandlePrefix());
code = ReplaceAll(code, "<NAME>", st.GetID());
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
code = ReplaceAll(code, "<PARCEL_WRITE>", GenArrayParcelWrite(elm));
code = ReplaceAll(code, "<PARCEL_READ>", GenArrayParcelRead(elm));
GetHandlePrefix());
code = ReplaceAll(code, "<NAME>", st.GetID());
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
code = ReplaceAll(code, "<DATA_TYPE>", GetDataTypeString(type, true));
code = ReplaceAll(code, "<DATA_FREE>", GenListDataFree(elm));
std::string CCionBodyGeneratorBase::GenBaseElements(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
auto& type = elm->GetType();
auto param_type = GetDataTypeString(type, false);
code += param_type + elm->GetID() + ";";
std::string CCionBodyGeneratorBase::GenBaseElementsFree(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms())
+ for (const auto& elm : elms)
code += GenBaseElementFree(elm);
return RemoveLine(code);
// @see #CB_STRUCTURE_BASE_BASE_PARCEL_WRITE
std::string CCionBodyGeneratorBase::GenBaseParcelWrite(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
std::string parcel_write_code;
auto& type = elm->GetType();
if (type.IsUserDefinedType() ||
// @see #CB_STRUCTURE_BASE_BASE_PARCEL_READ
std::string CCionBodyGeneratorBase::GenBaseParcelRead(const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
std::string parcel_read_code;
auto& type = elm->GetType();
if (type.IsUserDefinedType() ||
std::string CCionBodyGeneratorBase::GenBaseSetGet(const std::string& name,
const Elements& elms) {
std::string code;
- for (auto& elm : elms.GetElms()) {
+ for (const auto& elm : elms) {
std::string set_get_code = ReplaceAll(CB_STRUCTURE_BASE_SET_GET,
"<PREFIX>", GetHandlePrefix());
set_get_code = ReplaceAll(set_get_code, "<NAME>", name);
bool CCionBodyGeneratorBase::HasListFile(const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (IsProxy() && d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& p : d->GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
auto name = GetFullNameFromType(type, iface);
}
bool CCionBodyGeneratorBase::HasFile(const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& d : iface.GetDeclarations()) {
+ for (const auto& p : d->GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
auto name = GetFullNameFromType(type, iface);
}
CCionBodyGeneratorBase::FileParamType CCionBodyGeneratorBase::HasFile(const Interface& iface, const Declaration& decl, bool is_proxy) {
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (is_proxy) {
if (param_type.GetDirection() != ParameterType::Direction::IN)
continue;
auto& iface = static_cast<const Interface&>(*i);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
param_type = HasFile(iface, *d, is_proxy);
if (param_type != NotExist)
break;
std::string CCionBodyGeneratorBase::GenSecurityString(const Interface& iface) {
std::string security_path;
- for (auto& attr : iface.GetAttributes().GetAttrs()) {
+ for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path")
security_path += ReplaceAll(CB_INTERFACE_SECURITY_CA, "<ARG>", attr->GetValue());
else if (attr->GetKey() == "cert_path")
assert(t != nullptr);
std::string type_name = GetFullNameFromType(type);
- Element* elm = new Element(type_name, t, "", __LINE__);
+ auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
assert(elm != nullptr);
Elements* elms = new Elements();
assert(elms != nullptr);
- elms->Add(elm);
+ elms->Add(std::move(elm));
auto* st = new Structure(type_name, elms, "", __LINE__);
assert(st != nullptr);
assert(t != nullptr);
std::string type_name = GetFullNameFromType(type, iface);
- Element* elm = new Element(type_name, t, "", __LINE__);
+ auto elm = std::unique_ptr<Element>(new Element(type_name, t, "", __LINE__));
assert(elm != nullptr);
Elements* elms = new Elements();
assert(elms != nullptr);
- elms->Add(elm);
+ elms->Add(std::move(elm));
auto* st = new Structure(type_name, elms, "", __LINE__);
assert(st != nullptr);
for (auto& b : GetDocument().GetBlocks()) {
if (b->GetType() == Block::TYPE_STRUCTURE) {
auto& st = static_cast<const Structure&>(*b);
- for (auto& e : st.GetElements().GetElms()) {
+ for (const auto& e : st.GetElements()) {
auto& type = e->GetType();
AddStructureFromType(type);
}
} else {
auto& iface = static_cast<const Interface&>(*b);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
- for (auto& p : d->GetParameters().GetParams()) {
+ for (const auto& d : iface.GetDeclarations()) {
+ for (const auto& p : d->GetParameters()) {
auto& type = p->GetParameterType().GetBaseType();
if (IsDelegateType(iface, type))
continue;
GetHandlePrefix());
str = ReplaceAll(str, "<NAME>", st.GetID());
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
str = ReplaceAll(str, "<PARAM_TYPE_IN>", param_type);
GetHandlePrefix());
str = ReplaceAll(str, "<NAME>", st.GetID());
- auto& elm = st.GetElements().GetElms().front();
+ auto& elm = *(st.GetElements().begin());
auto& type = elm->GetType();
auto param_type = GetParamTypeString(ParameterType::Direction::IN, type);
str = ReplaceAll(str, "<PARAM_TYPE_IN>", param_type);
str = ReplaceAll(str, "<NAME>", st.GetID());
stream << SmartIndent(str);
- for (auto& e : st.GetElements().GetElms()) {
+ for (const auto& e : st.GetElements()) {
str = ReplaceAll(CB_STRUCTURE_BASE_SET_GET, "<PREFIX>", GetHandlePrefix());
str = ReplaceAll(str, "<NAME>", st.GetID());
void CCionProxyBodyGen::GenInterfaceDef(std::ofstream& stream,
const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
void CCionProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
GenInterfaceDelegateEnumBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenInterfaceMethodEnumBase(stream, iface);
GenInterfaceBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
const Interface& iface) {
unsigned int num = 1;
std::string enums;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
std::string CCionProxyBodyGen::GenDelegateArgsDecl(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
code += GetArgTypeString(type, iface) + p->GetID() + " = " +
std::string CCionProxyBodyGen::GenDelegateParcelRead(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string param_read_code;
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CCionProxyBodyGen::GenDelegateArgsFree(const Interface& iface,
const Declaration& decl, bool& has_free) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string param_free_code;
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CCionProxyBodyGen::GenDelegateCallbackArgs(const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams())
+ for (const auto& p : decl.GetParameters())
code += ", " + p->GetID();
return code;
void CCionProxyBodyGen::GenInterfaceDelegateTable(std::ofstream& stream,
const Interface& iface) {
std::string delegate_handlers;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
enums += GetHandlePrefix() + "_" + iface.GetID() + "_METHOD_CALLBACK_,";
enums += NLine(1);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CCionProxyBodyGen::GenMethodParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CCionProxyBodyGen::GenMethodParamsCheck(const Interface& iface,
const Declaration& decl) {
std::string params_check;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type) ||
std::string CCionProxyBodyGen::GenMethodParcelWrite(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::IN)
continue;
std::string CCionProxyBodyGen::GenMethodDelegateAppend(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type)) {
std::string CCionProxyBodyGen::GenMethodArgs(const Interface& iface,
const Declaration& decl) {
std::string args_code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::OUT)
continue;
const Declaration& decl) {
std::string code;
std::string parcel_read_code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::OUT)
continue;
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceHandle(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
void CCionProxyHeaderGen::GenInterface(std::ofstream& stream,
const Interface& iface) {
- for (auto& d: iface.GetDeclarations().GetDecls()) {
+ for (const auto& d: iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenInterfaceBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CCionProxyHeaderGen::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CCionProxyHeaderGen::GenMethodParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
method_enum = ReplaceAll(method_enum, "<UPPERCASE_METHOD_NAME>", "CALLBACK_");
method_enums += RemoveLine(method_enum);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CCionStubBodyGen::GenDelegateEnums(const Interface& iface) {
unsigned int num = 1;
std::string method_enums;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
void CCionStubBodyGen::GenInterfaceDef(std::ofstream& stream,
const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
}
void CCionStubBodyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenInterfaceDelegateBase(stream, iface, *d);
}
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CCionStubBodyGen::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CCionStubBodyGen::GenDelegateParamsCheck(const Interface& iface,
const Declaration& decl) {
std::string params_check;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type) ||
std::string CCionStubBodyGen::GenDelegateParcelWrite(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string parcel_write_code;
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
std::string CCionStubBodyGen::GenMethodHandlerArgsDecl(const Interface& iface,
const Declaration& decl) {
std::string args_decl;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
args_decl += GetArgTypeString(type, iface) + p->GetID() + " = " +
std::string CCionStubBodyGen::GenMethodHandlerParcelRead(const Interface& iface,
const Declaration& decl) {
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
std::string parcel_read_code;
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::IN)
code = ReplaceAll(code, "<RES_SET>", "");
std::string args;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
args += ", ";
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() != ParameterType::Direction::IN)
name);
std::string parcel_write_code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (param_type.GetDirection() == ParameterType::Direction::IN)
continue;
const Declaration& decl) {
std::string free_code;
std::string code;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
if (IsDelegateType(iface, type) ||
// @see #CB_INTERFACE_METHOD_HANDLER
std::string CCionStubBodyGen::GenMethodHandlers(const Interface& iface) {
std::string code;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
continue;
auto& iface = static_cast<const Interface&>(*b);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenInterfaceDelegateHandle(stream, iface, *d);
auto& iface = static_cast<const Interface&>(*b);
GenInterfaceCallbackBase(stream, iface);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
std::string CCionStubHeaderGen::GenMethodParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
void CCionStubHeaderGen::GenInterface(std::ofstream& stream,
const Interface& iface) {
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
std::string CCionStubHeaderGen::GenDelegateParams(const Interface& iface,
const Declaration& decl) {
std::string params;
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
params += ", ";
auto& param_type = p->GetParameterType();
auto& type = param_type.GetBaseType();
// @see #CB_INTERFACE_METHOD_CALLBACK_DECL
std::string CCionStubHeaderGen::GenMethodCallbackDecls(const Interface& iface) {
std::string method_callback_decls;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
[&]()->std::string {
std::string str;
int n = 1;
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
if (n != 1)
str += ", ";
str += ConvertTypeToString(i->GetType()) + " " + i->GetID();
});
stream << NLine(1);
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
GenSetter(stream, *i);
GenGetter(stream, *i);
stream << NLine(1);
GenTemplate(variable, stream,
[&]()->std::string {
std::string str;
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
str += NLine(1) + Tab(1)
+ ConvertTypeToString(i->GetType()) + " "
+ i->GetID() + "_";
"##::##($$)\n" \
" : $$ {}";
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
std::pair<std::string, std::string> p;
p.first = ConvertTypeToString(i->GetType());
stream << " ";
GenBrace(stream, 0, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
stream << AddIndent(TAB_SIZE,
ConvertTypeToSerializer(i->GetType(),
"param.Get" + i->GetID() + "()", "h"));
stream << " ";
GenBrace(stream, 0, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
stream << AddIndent(TAB_SIZE,
ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
stream << Tab(1) << "param.Set" << i->GetID() << "(std::move("
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() == Block::TYPE_STRUCTURE) {
const Structure& st = static_cast<const Structure&>(*i);
- for (auto& j : st.GetElements().GetElms()) {
+ for (const auto& j : st.GetElements()) {
auto& t = j->GetType();
AddSerializerList(t);
}
} else if (i->GetType() == Block::TYPE_INTERFACE) {
const Interface& iface = static_cast<const Interface&>(*i);
- for (auto& j : iface.GetDeclarations().GetDecls()) {
+ for (const auto& j : iface.GetDeclarations()) {
auto& t = j->GetType();
AddSerializerList(t);
- for (auto& k : j->GetParameters().GetParams()) {
+ for (const auto& k : j->GetParameters()) {
auto& t1 = k->GetParameterType().GetBaseType();
AddSerializerList(t1);
}
int cnt = 2;
stream << Tab(2) << "__Result = 0," << NLine(1);
stream << Tab(2) << "__Callback = 1," << NLine(1);
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(2)
stream << Tab(1) << "enum class DelegateId : int ";
GenBrace(stream, TAB_SIZE, [&]() {
int cnt = 1;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
stream << Tab(2)
std::string CppCionGeneratorBase::GetParameters(const Parameters& ps) {
bool first = true;
std::string ret;
- for (auto& i : ps.GetParams()) {
+ for (const auto& i : ps) {
if (!first) {
ret += ", ";
}
const Interface& iface, bool is_proxy) {
stream << ReplaceAll(CB_CALLBACK_BASE, "##", iface.GetID());
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenBodyCallback(stream, iface, *i, is_proxy);
},
[&]()->std::string {
std::string m;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
m += AddIndent(TAB_SIZE,
GenPrivateSharingRequest(pt.GetBaseType(), i->GetID()));
[&]()->std::string {
int cnt = 1;
std::string ret;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
std::string v = "param" + std::to_string(cnt);
std::string c = ConvertTypeToDeserializer(
i->GetParameterType().GetBaseType(), v, "parcel");
cnt = 1;
ret += Tab(1) + "OnReceived(";
- for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+ for (auto i = decl.GetParameters().begin();
+ i != decl.GetParameters().end(); ++i) {
if (cnt != 1) {
ret += ", ";
}
}
stream << CB_CALLBACK_BASE_HEADER_BACK;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenHeaderCallback(stream, *i, is_proxy);
const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
<< decl.GetID() << "));" << NLine(1);
std::string m;
std::string l;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
}
stream << CB_INVOCATION_RECEIVE << NLine(1);
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN) {
continue;
}
}
std::string f;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
});
}
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE ||
i->GetMethodType() == Declaration::MethodType::ASYNC)
continue;
return iface.GetID();
});
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE ||
i->GetMethodType() == Declaration::MethodType::SYNC)
continue;
int cnt = 1;
// Deserialize
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
cnt++;
continue;
}
m += "b->" + decl.GetID() + "(";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (cnt != 1) {
m += ", ";
}
cnt = 0;
m = "rpc_port_parcel_write_int32(" \
"result, static_cast<int>(MethodId::__Result));\n";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
cnt++;
if (pt.GetDirection() == ParameterType::Direction::IN)
stream << CB_SERVICE_BASE_FRONT;
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
if (!i->GetComments().empty())
stream << Tab(1) <<"public sealed class " << st.GetID() << NLine(1);
GenBrace(stream, TAB_SIZE, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
GenTemplate(CB_PROPERTY, stream,
[&]()->std::string {
return ConvertTypeToString(i->GetType());
stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
stream << Tab(4) << "h.Write"
stream << Tab(3) << "private static void Deserialize(Parcel h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
stream << Tab(4) << "var " << i->GetID() << " = "
}
bool CsCionGeneratorBase::HasFile(const Interface& iface, const Declaration& decl, bool is_proxy) {
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (is_proxy) {
if (param_type.GetDirection() != ParameterType::Direction::IN)
void CsCionGeneratorBase::GenShareFile(std::ofstream& stream, const Interface& iface, bool is_proxy) {
bool hasFile = false;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
hasFile = HasFile(iface, *d, is_proxy);
if (hasFile == true)
break;
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() == Block::TYPE_STRUCTURE) {
const Structure& st = static_cast<const Structure&>(*i);
- for (auto& j : st.GetElements().GetElms()) {
+ for (const auto& j : st.GetElements()) {
auto& t = j->GetType();
AddSerializerList(t);
}
} else if (i->GetType() == Block::TYPE_INTERFACE) {
const Interface& iface = static_cast<const Interface&>(*i);
- for (auto& j : iface.GetDeclarations().GetDecls()) {
+ for (const auto& j : iface.GetDeclarations()) {
auto& t = j->GetType();
AddSerializerList(t);
- for (auto& k : j->GetParameters().GetParams()) {
+ for (const auto& k : j->GetParameters()) {
auto& t1 = k->GetParameterType().GetBaseType();
AddSerializerList(t1);
}
int cnt = 2;
stream << Tab(4) << "__Result = 0," << NLine(1);
stream << Tab(4) << "__Callback = 1," << NLine(1);
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(4)
stream << Tab(3) << "private enum DelegateId : int" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
int cnt = 1;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
stream << Tab(4)
std::string CsCionGeneratorBase::GetParameters(const Parameters& ps) {
bool first = true;
std::string ret;
- for (auto& i : ps.GetParams()) {
+ for (const auto& i : ps) {
if (!first) {
ret += ", ";
}
const Interface& iface, bool is_proxy) {
stream << CB_CALLBACK_BASE;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
GenCallback(stream, *i, iface.GetID(), is_proxy);
<< NLine(1);
GenBrace(stream, TAB_SIZE * 4, [&]() {
int cnt = 1;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
std::string v = "param" + std::to_string(cnt);
std::string c = ConvertTypeToDeserializer(
i->GetParameterType().GetBaseType(), v, "parcel", true, id);
cnt = 1;
stream << Tab(5) << "Received?.Invoke(";
- for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+ for (auto i = decl.GetParameters().begin();
+ i != decl.GetParameters().end(); ++i) {
if (cnt != 1) {
stream << ", ";
}
},
[&]()->std::string {
std::string m;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
}
},
[&]()->std::string {
std::string m;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if(HasFile(pt.GetBaseType()))
m += "_serverBase.TryShareFile(" + i->GetID() + ");\n";
bool securityCheck = false;
std::string m = "public $$(string serviceName) : base(serviceName, new SecurityInfo {";
- for (auto& attr : iface.GetAttributes().GetAttrs()) {
+ for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
m += "CaPath = \"" + attr->GetValue() + "\", ";
securityCheck = true;
void CsCionProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
+ "p.WriteInt((int)MethodId." + decl.GetID() + ");" + NLine(1);
std::string m;
std::string l;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
st += CB_SYNC_INVOCATION_MID;
}
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
return st;
}
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() ==
ParameterType::Direction::IN) {
continue;
void CsCionStubGen::GenDeclarations(std::ofstream& stream,
const Declarations& decls) {
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
if (!i->GetComments().empty())
void CsCionStubGen::GenReceivedSyncEvent(std::ofstream& stream,
const Interface& iface) {
stream << CB_ON_RECEIVED_SYNC_EVENT_FRONT;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::SYNC)
continue;
stream << Tab(7) << "case MethodId." << i->GetID() << ":" << NLine(1);
void CsCionStubGen::GenReceivedAsyncEvent(std::ofstream& stream,
const Interface& iface) {
stream << CB_ON_RECEIVED_ASYNC_EVENT_FRONT;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::ASYNC)
continue;
stream << Tab(6) << "case MethodId." << i->GetID() << ":" << NLine(1);
int cnt = 1;
// Deserialize
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
cnt++;
continue;
}
m += "b." + decl.GetID() + "(";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (cnt != 1) {
m += ", ";
}
// Serialize
cnt = 0;
m = CB_INVOCATION_RESULT_PRE;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
cnt++;
if (pt.GetDirection() == ParameterType::Direction::IN)
int cnt = 1;
// Deserialize
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) {
cnt++;
continue;
}
m += "b." + decl.GetID() + "(";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (cnt != 1) {
m += ", ";
}
bool securityCheck = false;
std::string m = "public $$(string serviceName, string displayName) : base(serviceName, displayName, new SecurityInfo {";
- for (auto& attr : iface.GetAttributes().GetAttrs()) {
+ for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
m += "CaPath = \"" + attr->GetValue() + "\", ";
securityCheck = true;
continue;
Interface& iface = static_cast<Interface&>(*i);
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
if (d->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
int cnt = 2;
stream << Tab(1) << "public static final int __RESULT = 0;" << NLine(2);
stream << Tab(1) << "public static final int __CALLBACK = 1;" << NLine(2);
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(1)
std::string JavaCionGeneratorBase::GetParameters(const Parameters& ps) {
bool first = true;
std::string ret;
- for (auto& i : ps.GetParams()) {
+ for (const auto& i : ps) {
if (!first) {
ret += ", ";
}
stream << Tab(1) << "private static void serialize(CionParcel h, "
<< st.GetID() << " param) ";
GenBrace(stream, TAB_SIZE * 1, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
stream << Tab(2) << "h.write"
stream << Tab(1) << "private static void deserialize(CionParcel h, "
<< st.GetID() << " param) ";
GenBrace(stream, TAB_SIZE * 1, [&]() {
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
stream << Tab(2) << ConvertTypeToString(t)
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() == Block::TYPE_STRUCTURE) {
const Structure& st = static_cast<const Structure&>(*i);
- for (auto& j : st.GetElements().GetElms()) {
+ for (const auto& j : st.GetElements()) {
auto& t = j->GetType();
AddSerializerList(t);
}
} else if (i->GetType() == Block::TYPE_INTERFACE) {
const Interface& iface = static_cast<const Interface&>(*i);
- for (auto& j : iface.GetDeclarations().GetDecls()) {
+ for (const auto& j : iface.GetDeclarations()) {
auto& t = j->GetType();
AddSerializerList(t);
- for (auto& k : j->GetParameters().GetParams()) {
+ for (const auto& k : j->GetParameters()) {
auto& t1 = k->GetParameterType().GetBaseType();
AddSerializerList(t1);
}
void JavaCionGeneratorBase::GenCallbacks(std::ofstream& stream,
const Interface& iface, bool is_proxy) {
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
if (is_proxy)
str = ReplaceAll(str, "<DELEGATOR_NAME>",decl.GetID());
std::string ser;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
ser += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
}
str = ReplaceAll(str, "<SERIALIZE>", ser);
std::string share;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if(HasFile(pt.GetBaseType()))
share += "_serverBase.shareFile(" + i->GetID() + ");\n";
const std::string& id) {
std::string str;
int cnt = 1;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
std::string v = "param" + std::to_string(cnt);
std::string c = ConvertTypeToDeserializer(
i->GetParameterType().GetBaseType(), v, "parcel", true, id);
cnt = 1;
str += Tab(3);
str += "onInvoked(";
- for (int i = 0; i < decl.GetParameters().GetParams().size(); i++) {
+ for (auto i = decl.GetParameters().begin();
+ i != decl.GetParameters().end(); ++i) {
if (cnt != 1) {
str += ", ";
}
void JavaCionGeneratorBase::GenDelegateId(std::ofstream& stream,
const Interface& iface) {
int cnt = 1;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
stream << Tab(1) << "private static final int __"
const Interface& iface, bool is_proxy) {
bool hasFile = false;
- for (auto& d : iface.GetDeclarations().GetDecls()) {
+ for (const auto& d : iface.GetDeclarations()) {
hasFile = HasFile(iface, *d, is_proxy);
if (hasFile == true)
break;
}
bool JavaCionGeneratorBase::HasFile(const Interface& iface, const Declaration& decl, bool is_proxy) {
- for (auto& p : decl.GetParameters().GetParams()) {
+ for (const auto& p : decl.GetParameters()) {
auto& param_type = p->GetParameterType();
if (is_proxy) {
if (param_type.GetDirection() != ParameterType::Direction::IN)
m += Tab(1) + "super(context, serviceName, new SecurityInfo(";
- for (auto& attr : iface.GetAttributes().GetAttrs()) {
+ for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
m += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
void JavaCionProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) {
auto& decls = iface.GetDeclarations();
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
+ "p.write(__" + decl.GetID() + ");" + NLine(1);
std::string m;
std::string l;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
st += CB_SYNC_INVOCATION_MID;
}
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT)
continue;
return st;
}
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (i->GetParameterType().GetDirection() ==
ParameterType::Direction::IN) {
continue;
GenTemplate(variable, stream,
[&]()->std::string {
std::string str;
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
str += NLine(1) + Tab(1) + "private ";
if (i->GetType().GetMetaType() == nullptr) {
str += ConvertTypeToString(i->GetType()) + " "
return str;
});
- for (auto& i : st.GetElements().GetElms()) {
+ for (const auto& i : st.GetElements()) {
GenSetter(stream, *i);
GenGetter(stream, *i);
stream << NLine(1);
void JavaCionStubGen::GenDeclarations(std::ofstream& stream,
const Declarations& decls) {
- for (auto& i : decls.GetDecls()) {
+ for (const auto& i : decls) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
if (!i->GetComments().empty())
void JavaCionStubGen::GenReceivedSyncEvent(std::ofstream& stream,
const Interface& iface) {
stream << CB_ON_RECEIVED_SYNC_EVENT_FRONT;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::SYNC)
continue;
stream << Tab(4) << "case __" << i->GetID() << ": ";
void JavaCionStubGen::GenReceivedAsyncEvent(std::ofstream& stream,
const Interface& iface) {
stream << CB_ON_RECEIVED_ASYNC_EVENT_FRONT;
- for (auto& i : iface.GetDeclarations().GetDecls()) {
+ for (const auto& i : iface.GetDeclarations()) {
if (i->GetMethodType() != Declaration::MethodType::ASYNC)
continue;
stream << Tab(4) << "case __" << i->GetID() << ": ";
// Serialize
int cnt = 0;
std::string m = CB_INVOCATION_RESULT_PRE;
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
auto& pt = i->GetParameterType();
cnt++;
if (pt.GetDirection() == ParameterType::Direction::IN)
int cnt = 1;
// Deserialize
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
std::string v = "param" + std::to_string(cnt);
auto& pt = i->GetParameterType();
if (pt.GetDirection() == ParameterType::Direction::OUT) {
}
m += "b." + decl.GetID() + "(";
- for (auto& i : decl.GetParameters().GetParams()) {
+ for (const auto& i : decl.GetParameters()) {
if (cnt != 1) {
m += ", ";
}
std::string m = "public $$(Context context, String serviceName, String displayName) {\n";
m += Tab(1) + "super(context, serviceName, displayName, new SecurityInfo(";
- for (auto& attr : iface.GetAttributes().GetAttrs()) {
+ for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
m += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
}
TEST_F(AttributesTest, Attributes_Add) {
- tidl::Attributes* attrs = new tidl::Attributes();
- EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("key", "value", __LINE__));
+ tidl::Attributes attrs;
+ attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+ "key", "value", __LINE__)));
bool flag = false;
- for (auto& attr : attrs->GetAttrs()) {
+ for (const auto& attr : attrs) {
if (attr->GetKey() == "key" &&
attr->GetValue() == "value")
flag = true;
}
EXPECT_EQ(flag, true);
- delete attrs;
}
-TEST_F(AttributesTest, Attributes_GetAttrs) {
- tidl::Attributes* attrs = new tidl::Attributes();
- EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("key1", "value1", __LINE__));
- attrs->Add(new tidl::Attribute("key2", "value2", __LINE__));
+TEST_F(AttributesTest, Attributes_range_for) {
+ tidl::Attributes attrs;
+ attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+ "key1", "value1", __LINE__)));
+ attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+ "key2", "value2", __LINE__)));
int count = 0;
- for (auto& attr : attrs->GetAttrs()) {
+ for (const auto& attr : attrs) {
if (attr->GetKey() == "key1" &&
attr->GetValue() == "value1")
count++;
count++;
}
EXPECT_EQ(count, 2);
- delete attrs;
}
TEST_F(AttributesTest, Attributes_Exist) {
- tidl::Attributes* attrs = new tidl::Attributes();
- EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("key", "value", __LINE__));
- tidl::Attribute* attr = new tidl::Attribute("key", "value", __LINE__);
- EXPECT_NE(attr, nullptr);
- EXPECT_EQ(attrs->Exist(attr), true);
- delete attr;
- delete attrs;
+ tidl::Attributes attrs;
+ attrs.Add(std::unique_ptr<tidl::Attribute>(new tidl::Attribute(
+ "key", "value", __LINE__)));
+ tidl::Attribute attr("key", "value", __LINE__);
+ EXPECT_EQ(attrs.Exist(attr), true);
}
virtual void SetUp() {
params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
- params->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
- params->Add(new tidl::Parameter("test2",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+ params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+ params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test2",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
}
virtual void TearDown() {}
};
TEST_F(DeclarationTest, Declaration_Constructor) {
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", __LINE__);
- EXPECT_NE(decl, nullptr);
- delete decl;
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+ __LINE__);
}
TEST_F(DeclarationTest, Declaration_GetID) {
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", __LINE__);
- EXPECT_NE(decl, nullptr);
- EXPECT_EQ(decl->GetID(), "test");
- delete decl;
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+ __LINE__);
+ EXPECT_EQ(decl.GetID(), "test");
}
TEST_F(DeclarationTest, Declaration_GetType) {
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", __LINE__);
- EXPECT_NE(decl, nullptr);
- EXPECT_EQ(decl->GetType().ToString(), "int");
- delete decl;
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+ __LINE__);
+ EXPECT_EQ(decl.GetType().ToString(), "int");
}
TEST_F(DeclarationTest, Declaration_GetParameters) {
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", __LINE__);
- EXPECT_NE(decl, nullptr);
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+ __LINE__);
int count = 0;
- for (auto& param : decl->GetParameters().GetParams()) {
+ for (const auto& param : decl.GetParameters()) {
if (param->GetID() == "test1" &&
param->GetParameterType().GetBaseType().ToString() == "int")
count++;
count++;
}
EXPECT_EQ(count, 2);
-
- delete decl;
}
TEST_F(DeclarationTest, Declaration_GetMethodType) {
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", __LINE__,
- tidl::Declaration::MethodType::DELEGATE);
- EXPECT_NE(decl, nullptr);
- EXPECT_EQ(decl->GetMethodType(), tidl::Declaration::MethodType::DELEGATE);
- delete decl;
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+ __LINE__, tidl::Declaration::MethodType::DELEGATE);
+ EXPECT_EQ(decl.GetMethodType(), tidl::Declaration::MethodType::DELEGATE);
}
TEST_F(DeclarationTest, Declaration_GetComments) {
std::string comments = "Test Declaration";
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, comments, __LINE__);
- EXPECT_NE(decl, nullptr);
- EXPECT_EQ(decl->GetComments(), comments);
- delete decl;
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params,
+ comments, __LINE__);
+ EXPECT_EQ(decl.GetComments(), comments);
}
TEST_F(DeclarationTest, Declaration_GetLine) {
unsigned line = __LINE__;
- tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", line);
- EXPECT_NE(decl, nullptr);
- EXPECT_EQ(decl->GetLine(), line);
- delete decl;
+ tidl::Declaration decl("test", new tidl::BaseType("int", ""), params, "",
+ line);
+ EXPECT_EQ(decl.GetLine(), line);
}
class DeclarationsTest : public testing::Test {
public:
- tidl::Declaration* decl;
-
virtual void SetUp() {}
virtual void TestDown() {}
- void PrepareDeclaration() {
+ std::unique_ptr<tidl::Declaration> PrepareDeclaration() {
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
- params->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
- params->Add(new tidl::Parameter("test2",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
- decl = new tidl::Declaration("test",
- new tidl::BaseType("int", ""), params, "", __LINE__);
+ params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+ params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test2",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+ auto decl = std::unique_ptr<tidl::Declaration>(new tidl::Declaration(
+ "test", new tidl::BaseType("int", ""), params, "", __LINE__));
EXPECT_NE(decl, nullptr);
+ return decl;
}
};
TEST_F(DeclarationsTest, Declarations_Constructor) {
- tidl::Declarations* decls = new tidl::Declarations();
- EXPECT_NE(decls, nullptr);
- delete decls;
+ tidl::Declarations decls;
}
TEST_F(DeclarationsTest, Declarations_Add) {
- tidl::Declarations* decls = new tidl::Declarations();
- EXPECT_NE(decls, nullptr);
- PrepareDeclaration();
- decls->Add(decl);
+ tidl::Declarations decls;
+ decls.Add(PrepareDeclaration());
bool flag = false;
- for (auto& d : decls->GetDecls()) {
+ for (const auto& d : decls) {
if (d->GetID() == "test")
flag = true;
}
EXPECT_EQ(flag, true);
- delete decls;
}
-TEST_F(DeclarationsTest, Declarations_GetDecls) {
- tidl::Declarations* decls = new tidl::Declarations();
- EXPECT_NE(decls, nullptr);
- PrepareDeclaration();
- decls->Add(decl);
+TEST_F(DeclarationsTest, Declarations_range_for) {
+ tidl::Declarations decls;
+ decls.Add(PrepareDeclaration());
bool flag = false;
- for (auto& d : decls->GetDecls()) {
+ for (auto& d : decls) {
if (d->GetID() == "test")
flag = true;
}
EXPECT_EQ(flag, true);
- delete decls;
}
TEST_F(DeclarationsTest, Declarations_Exist) {
- tidl::Declarations* decls = new tidl::Declarations();
- EXPECT_NE(decls, nullptr);
- PrepareDeclaration();
- decls->Add(decl);
+ tidl::Declarations decls;
+ decls.Add(PrepareDeclaration());
tidl::Parameters* testParams = new tidl::Parameters();
EXPECT_NE(testParams, nullptr);
- testParams->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
- tidl::Declaration* testDecl = new tidl::Declaration("test",
+ testParams->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+ tidl::Declaration testDecl("test",
new tidl::BaseType("int", ""), testParams, "", __LINE__);
- EXPECT_NE(testDecl, nullptr);
- EXPECT_EQ(decls->Exist(testDecl), true);
- delete testDecl;
- delete decls;
+ EXPECT_EQ(decls.Exist(testDecl), true);
}
};
TEST_F(ElementTest, Element_Contstructor) {
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", __LINE__);
- EXPECT_NE(elm, nullptr);
- delete elm;
+ tidl::Element elm("test", new tidl::BaseType("int", ""), "", __LINE__);
}
TEST_F(ElementTest, Element_GetID) {
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", __LINE__);
- EXPECT_NE(elm, nullptr);
- EXPECT_EQ(elm->GetID(), "test");
- delete elm;
+ tidl::Element elm("test", new tidl::BaseType("int", ""), "", __LINE__);
+ EXPECT_EQ(elm.GetID(), "test");
}
TEST_F(ElementTest, Element_GetType) {
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", __LINE__);
- EXPECT_NE(elm, nullptr);
- EXPECT_EQ(elm->GetType().ToString(), "int");
- delete elm;
+ tidl::Element elm("test", new tidl::BaseType("int", ""), "", __LINE__);
+ EXPECT_EQ(elm.GetType().ToString(), "int");
}
TEST_F(ElementTest, Element_GetLine) {
unsigned line = __LINE__;
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", line);
- EXPECT_NE(elm, nullptr);
- EXPECT_EQ(elm->GetLine(), line);
- delete elm;
+ tidl::Element elm("test", new tidl::BaseType("int", ""), "", line);
+ EXPECT_EQ(elm.GetLine(), line);
}
TEST_F(ElementTest, Element_GetComments) {
std::string comments = "Test comments";
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), comments, __LINE__);
- EXPECT_NE(elm, nullptr);
- EXPECT_EQ(elm->GetComments(), comments);
- delete elm;
+ tidl::Element elm("test", new tidl::BaseType("int", ""), comments, __LINE__);
+ EXPECT_EQ(elm.GetComments(), comments);
}
class ElementsTest : public testing::Test {
};
TEST_F(ElementsTest, Elements_Constructor) {
- tidl::Elements* elms = new tidl::Elements();
- EXPECT_NE(elms, nullptr);
- delete elms;
+ tidl::Elements elms();
}
TEST_F(ElementsTest, Elements_Add) {
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", __LINE__);
- EXPECT_NE(elm, nullptr);
- tidl::Elements* elms = new tidl::Elements();
- EXPECT_NE(elms, nullptr);
- elms->Add(elm);
+ tidl::Elements elms;
+ elms.Add(std::unique_ptr<tidl::Element>(
+ new tidl::Element("test", new tidl::BaseType("int", ""), "", __LINE__)));
bool flag = false;
- for (auto& elm : elms->GetElms()) {
+ for (const auto& elm : elms) {
if (elm->GetID() == "test" &&
elm->GetType().ToString() == "int")
flag = true;
}
EXPECT_EQ(flag, true);
- delete elms;
}
-TEST_F(ElementsTest, Elements_Getelms) {
- tidl::Elements* elms = new tidl::Elements();
- EXPECT_NE(elms, nullptr);
- elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
- "", __LINE__));
- elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
- "", __LINE__));
+TEST_F(ElementsTest, Elements_range_for) {
+ tidl::Elements elms;
+ elms.Add(std::unique_ptr<tidl::Element>(new tidl::Element(
+ "test1", new tidl::BaseType("int", ""), "", __LINE__)));
+ elms.Add(std::unique_ptr<tidl::Element>(new tidl::Element(
+ "test2", new tidl::BaseType("char *", ""), "", __LINE__)));
int count = 0;
- for (auto& elm : elms->GetElms()) {
+ for (auto& elm : elms) {
if (elm->GetID() == "test1" &&
elm->GetType().ToString() == "int")
count++;
count++;
}
EXPECT_EQ(count, 2);
- delete elms;
}
TEST_F(ElementsTest, Elements_Exist) {
- tidl::Element* elm = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", __LINE__);
- EXPECT_NE(elm, nullptr);
- tidl::Elements* elms = new tidl::Elements();
- EXPECT_NE(elms, nullptr);
- elms->Add(elm);
- tidl::Element* elm2 = new tidl::Element("test",
- new tidl::BaseType("int", ""), "", __LINE__);
- EXPECT_NE(elm, nullptr);
- EXPECT_EQ(elms->Exist(elm2), true);
- delete elm2;
- delete elms;
+ tidl::Elements elms;
+ elms.Add(std::unique_ptr<tidl::Element>(new tidl::Element("test",
+ new tidl::BaseType("int", ""), "", __LINE__)));
+ tidl::Element elm2("test", new tidl::BaseType("int", ""), "", __LINE__);
+ EXPECT_EQ(elms.Exist(elm2), true);
}
virtual void SetUp() {
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
- params->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
- params->Add(new tidl::Parameter("test2",
- new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
+ params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test1",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
+ params->Add(std::unique_ptr<tidl::Parameter>(new tidl::Parameter("test2",
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__)));
tidl::Declaration* decl = new tidl::Declaration("test",
new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
decls = new tidl::Declarations();
EXPECT_NE(decls, nullptr);
- decls->Add(decl);
+ decls->Add(std::unique_ptr<tidl::Declaration>(decl));
}
virtual void TearDown() {}
};
EXPECT_NE(interface, nullptr);
bool flag = false;
- for (auto& d : interface->GetDeclarations().GetDecls()) {
+ for (const auto& d : interface->GetDeclarations()) {
if (d->GetID() == "test")
flag = true;
}
virtual void SetUp() {
elms = new tidl::Elements();
EXPECT_NE(elms, nullptr);
- elms->Add(new tidl::Element("test1", new tidl::BaseType("int", ""),
- "", __LINE__));
- elms->Add(new tidl::Element("test2", new tidl::BaseType("char *", ""),
- "", __LINE__));
+ elms->Add(std::unique_ptr<tidl::Element>(new tidl::Element("test1",
+ new tidl::BaseType("int", ""), "", __LINE__)));
+ elms->Add(std::unique_ptr<tidl::Element>(new tidl::Element("test2",
+ new tidl::BaseType("char *", ""), "", __LINE__)));
}
virtual void TearDown() {}
};
EXPECT_NE(structure, nullptr);
int count = 0;
- for (auto& elm : elms->GetElms()) {
+ for (const auto& elm : *elms) {
if (elm->GetID() == "test1" &&
elm->GetType().ToString() == "int")
count++;