Skip to content

Commit 08a3bdb

Browse files
committed
comments addressed
1 parent 7628738 commit 08a3bdb

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/idls/thrift/src/t_yarp_generator.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,15 +1847,15 @@ void t_yarp_generator::generate_struct(t_struct* tstruct)
18471847
yarp_type_name = annotations.at("yarp.type.name");
18481848
}
18491849
else {
1850-
yarp_type_name = "yarp/"+name;
1850+
yarp_type_name = "";
18511851
}
18521852

18531853
std::string yarp_type_version{};
18541854
if (annotations.find("yarp.type.version") != annotations.end()) {
18551855
yarp_type_version = annotations.at("yarp.type.version");
18561856
}
18571857
else {
1858-
yarp_type_version = "1.0";
1858+
yarp_type_version = "";
18591859
}
18601860

18611861
// Open header file
@@ -2247,7 +2247,7 @@ void t_yarp_generator::generate_struct_typeconstexpr(t_struct* tstruct, std::ost
22472247

22482248
f_h_ << indent_h() << "//The name and the version for this message\n";
22492249
f_h_ << indent_h() << "static constexpr const char* typeName = \"" << yarp_type_name << "\";\n";
2250-
f_h_ << indent_h() << "static constexpr const char* typeVersion = \"" << "1.0" << "\";\n";
2250+
f_h_ << indent_h() << "static constexpr const char* typeVersion = \"" << yarp_type_version << "\";\n";
22512251
f_h_ << '\n';
22522252

22532253
assert(indent_count_h() == 1);
@@ -2264,14 +2264,14 @@ void t_yarp_generator::generate_struct_gettype(t_struct* tstruct, std::ostringst
22642264
f_h_ << indent_h() << "yarp::os::Type getType() const;\n";
22652265
f_h_ << '\n';
22662266

2267-
f_cpp_ << indent_cpp() << "// Convert to a printable string\n";
2267+
f_cpp_ << indent_cpp() << "// Get the message type\n";
22682268
f_cpp_ << indent_cpp() << "yarp::os::Type " << name << "::getType() const\n";
22692269
f_cpp_ << indent_cpp() << "{\n";
22702270
indent_up_cpp();
22712271
{
2272-
f_cpp_ << indent_cpp() << " yarp::os::Type typ = yarp::os::Type::byNameOnWire(typeName);\n";
2272+
f_cpp_ << indent_cpp() << "yarp::os::Type typ = yarp::os::Type::byNameOnWire(typeName);\n";
22732273
f_cpp_ << indent_cpp() << "typ.setVersion(typeVersion);\n";
2274-
f_cpp_ << indent_cpp() << " return typ;\n";
2274+
f_cpp_ << indent_cpp() << "return typ;\n";
22752275
}
22762276
indent_down_cpp();
22772277
f_cpp_ << indent_cpp() << "}\n";

src/libYARP_os/src/yarp/os/Type.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,18 @@ std::string Type::getVersion() const
116116

117117
size_t Type::getMajorVersion() const
118118
{
119-
return 1;
119+
unsigned int major = 0;
120+
unsigned int minor = 0;
121+
int ret = sscanf(mPriv->version.c_str(),"%u.%u", &major, &minor);
122+
return major;
120123
}
121124

122125
size_t Type::getMinorVersion() const
123126
{
124-
return 1;
127+
unsigned int major = 0;
128+
unsigned int minor = 0;
129+
int ret = sscanf(mPriv->version.c_str(), "%u.%u", &major, &minor);
130+
return minor;
125131
}
126132

127133
Type& Type::operator=(const Type& rhs)
@@ -177,7 +183,11 @@ bool Type::hasVersion() const
177183

178184
bool Type::isValid() const
179185
{
186+
#if 0
187+
//this should be tested carefully, it could be a breaking change!
180188
return hasName() && hasVersion();
189+
#endif
190+
return hasName();
181191
}
182192

183193
std::string Type::toString() const

0 commit comments

Comments
 (0)