namespace tidl {
-Attribute::Attribute(std::string key, std::string value, unsigned line)
+Attribute::Attribute(std::string key, std::string value, unsigned int line)
: key_(std::move(key)), value_(std::move(value)), line_(line) {
}
return value_;
}
-const unsigned Attribute::GetLine() const {
+const unsigned int Attribute::GetLine() const {
return line_;
}
class Attribute {
public:
- Attribute(std::string key, std::string value, unsigned line);
+ Attribute(std::string key, std::string value, unsigned int line);
const std::string& GetKey() const;
const std::string& GetValue() const;
- const unsigned GetLine() const;
+ const unsigned int GetLine() const;
private:
std::string key_;
std::string value_;
- unsigned line_;
+ unsigned int line_;
};
class Attributes {
namespace tidl {
Block::Block(std::string id, Block::Type type,
- std::string comments, unsigned line)
+ std::string comments, unsigned int line)
: id_(std::move(id)), type_(type), comments_(std::move(comments)),
line_(line) {}
return type_;
}
-const unsigned Block::GetLine() const {
+const unsigned int Block::GetLine() const {
return line_;
}
};
Block(std::string id, Block::Type type, std::string comments,
- unsigned line);
+ unsigned int line);
virtual ~Block() = default;
const std::string& GetID() const;
const Block::Type& GetType() const;
- const unsigned GetLine() const;
+ const unsigned int GetLine() const;
const std::string& GetComments() const;
private:
std::string id_;
Block::Type type_;
std::string comments_;
- unsigned line_;
+ unsigned int line_;
};
} // namespace tidl
namespace tidl {
Declaration::Declaration(std::string id, std::unique_ptr<BaseType> ret_type,
- std::unique_ptr<Parameters> params, std::string comments, unsigned line,
- MethodType mtype)
+ std::unique_ptr<Parameters> params, std::string comments,
+ unsigned int line, MethodType mtype)
: id_(std::move(id)),
ret_type_(std::move(ret_type)),
params_(std::move(params)),
return *params_;
}
-const unsigned Declaration::GetLine() const {
+const unsigned int Declaration::GetLine() const {
return line_;
}
};
Declaration(std::string id, std::unique_ptr<BaseType> ret_type,
- std::unique_ptr<Parameters> params, std::string comments, unsigned line,
- MethodType mtype = MethodType::SYNC);
+ std::unique_ptr<Parameters> params, std::string comments,
+ unsigned int line, MethodType mtype = MethodType::SYNC);
const std::string& GetID() const;
const BaseType& GetType() const;
const Parameters& GetParameters() const;
MethodType GetMethodType() const { return mtype_; }
- const unsigned GetLine() const;
+ const unsigned int GetLine() const;
const std::string& GetComments() const;
private:
std::unique_ptr<BaseType> ret_type_;
std::unique_ptr<Parameters> params_;
std::string comments_;
- unsigned line_;
+ unsigned int line_;
MethodType mtype_;
};
namespace tidl {
Element::Element(std::string id, BaseType* type,
- std::string comments, unsigned line)
+ std::string comments, unsigned int line)
: id_(std::move(id)), type_(type), comments_(std::move(comments)),
line_(line) {}
return *type_;
}
-const unsigned Element::GetLine() const {
+const unsigned int Element::GetLine() const {
return line_;
}
class Element {
public:
Element(std::string id, BaseType* type,
- std::string comments, unsigned line);
+ std::string comments, unsigned int line);
const std::string& GetID() const;
const BaseType& GetType() const;
- const unsigned GetLine() const;
+ const unsigned int GetLine() const;
const std::string& GetComments() const;
private:
std::string id_;
std::unique_ptr<BaseType> type_;
std::string comments_;
- unsigned line_;
+ unsigned int line_;
};
class Elements {
namespace tidl {
-Parameter::Parameter(std::string id, ParameterType* type, unsigned line)
+Parameter::Parameter(std::string id, ParameterType* type, unsigned int line)
: type_(type), id_(std::move(id)), line_(line) {}
const std::string& Parameter::GetID() const {
return *type_;
}
-const unsigned Parameter::GetLine() const {
+const unsigned int Parameter::GetLine() const {
return line_;
}
class Parameter {
public:
- Parameter(std::string id, ParameterType* type, unsigned line);
+ Parameter(std::string id, ParameterType* type, unsigned int line);
const std::string& GetID() const;
const ParameterType& GetParameterType() const;
- const unsigned GetLine() const;
+ const unsigned int GetLine() const;
private:
std::unique_ptr<ParameterType> type_;
std::string id_;
- unsigned line_;
+ unsigned int line_;
};
class Parameters {
.Change("<BODY>", [&]() {
std::string str;
for (const auto& i : st.GetElements()) {
+ auto& type = i->GetType();
str += AddIndent(TAB_SIZE,
- ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
- str += Tab(1) + "param.Set" + i->GetID() + "(std::move("
- + i->GetID() + "));" + NLine(2);
+ ConvertTypeToDeserializer(type, i->GetID(), "h"));
+
+ str += Tab(1) + "param.Set" + i->GetID() + "(";
+ if (type.ToString() == "list" ||
+ type.ToString() == "array" ||
+ type.ToString() == "string" ||
+ type.ToString() == "bundle" ||
+ type.IsUserDefinedType())
+ str += "std::move(" + i->GetID() + ")";
+ else
+ str += i->GetID();
+
+ str += ");" + NLine(2);
}
str += Tab(1) + "return h;";
return str;
// Set tab
if (line.length() > 0)
- tab += std::move(Tab(tab_size));
+ tab += Tab(tab_size);
// Set tab for if statement or for loop or while loop
if (tab_once) {
return {};
std::string code = std::move(GenMethodResultParcelRead(decl));
- code += std::move(GenMethodOutParamParcelRead(decl));
+ code += GenMethodOutParamParcelRead(decl);
code = ReplaceAll(CB_METHOD_PARCEL_READ, "<PARCEL_READ>", code);
return code;
}
std::string code = std::move(method_handler_table);
code += NLine(1);
- code += std::move(attributes);
+ code += attributes;
return code;
}
return {};
std::string code = std::move(GenMethodHandlerResultParcelWrite(decl));
- code += std::move(GenMethodHandlerOutParamParcelWrite(decl));
+ code += GenMethodHandlerOutParamParcelWrite(decl);
code = ReplaceAll(CB_METHOD_HANDLER_PARCEL_WRITE, "<PARCEL_WRITE>", code);
return code;
}
stream << " ";
GenBrace(stream, 0, [&]() {
for (const auto& i : st.GetElements()) {
+ auto& type = i->GetType();
stream << AddIndent(TAB_SIZE,
- ConvertTypeToDeserializer(i->GetType(), i->GetID(), "h"));
- stream << Tab(1) << "param.Set" << i->GetID() << "(std::move("
- << i->GetID() << "));" << NLine(2);
+ ConvertTypeToDeserializer(type, i->GetID(), "h"));
+
+ stream << Tab(1) << "param.Set" << i->GetID() << "(";
+ if (type.ToString() == "list" ||
+ type.ToString() == "array" ||
+ type.ToString() == "string" ||
+ type.ToString() == "bundle" ||
+ type.IsUserDefinedType())
+ stream << "std::move(" << i->GetID() << ")";
+ else
+ stream << i->GetID();
+
+ stream << ");" << NLine(2);
}
stream << Tab(1) << "return h;" << NLine(1);
}, false);
}
TEST_F(AttributeTest, Attribute_GetLine) {
- unsigned line = __LINE__;
+ unsigned int line = __LINE__;
tidl::Attribute* attr = new tidl::Attribute("key", "value", line);
EXPECT_NE(attr, nullptr);
EXPECT_EQ(attr->GetLine(), line);
}
TEST_F(DeclarationTest, Declaration_GetLine) {
- unsigned line = __LINE__;
+ unsigned int line = __LINE__;
tidl::Declaration decl("test",
std::unique_ptr<tidl::BaseType>(new tidl::BaseType("int", "")),
std::move(params), "", line);
}
TEST_F(ElementTest, Element_GetLine) {
- unsigned line = __LINE__;
+ unsigned int line = __LINE__;
tidl::Element elm("test", new tidl::BaseType("int", ""), "", line);
EXPECT_EQ(elm.GetLine(), line);
}