Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Yarp types names #2231

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

randaz81
Copy link
Member

This PR is not yet complete and its intended for discussion only.

I modified the yarp thrift generator to add additional stuff in the generated code of the yarp data types. This will allow a yarp data type to know the name (string) of its own type, and the message type version.

@update-docs
Copy link

update-docs bot commented Mar 13, 2020

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update the release notes by adding a file in doc/release/<target_branch>, based on your changes.

yarp_type_name = annotations.at("yarp.type.name");
}
else {
yarp_type_name = "yarp/"+name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced about this default value, I'd rather enable this only if specified by the user (at least for now), or everyone who defined some type in some other repo will have some "yarp" types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Better name? or just an empty string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string and do not add the type part if not defined

yarp_type_version = annotations.at("yarp.type.version");
}
else {
yarp_type_version = "1.0";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same about the default version, 1.0 is not a good value, since an unstable type with no annotation defined will have a stable version. I'd stick with enabling this part only if explicitly added by the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.0? or empty string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'd just leave it empty, and add the relative calls when generating the code only if it is defined


f_h_ << indent_h() << "//The name and the version for this message\n";
f_h_ << indent_h() << "static constexpr const char* typeName = \"" << yarp_type_name << "\";\n";
f_h_ << indent_h() << "static constexpr const char* typeVersion = \"" << "1.0" << "\";\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.0 shouldn't be hardcoded here

f_h_ << indent_h() << "yarp::os::Type getType() const;\n";
f_h_ << '\n';

f_cpp_ << indent_cpp() << "// Convert to a printable string\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems a copy-paste from somewhere else

f_cpp_ << indent_cpp() << "{\n";
indent_up_cpp();
{
f_cpp_ << indent_cpp() << " yarp::os::Type typ = yarp::os::Type::byNameOnWire(typeName);\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra space before yarp::os::Type (and 2 lines below before return) shouldn't be there

f_cpp_ << indent_cpp() << "{\n";
indent_up_cpp();
{
f_cpp_ << indent_cpp() << " yarp::os::Type typ = yarp::os::Type::byNameOnWire(typeName);\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarp::os::Type::byNameOnWire(typeName) is equivalent to yarp::os::Type::byName("yarp/bottle", typeName). We should definitely investigate what's the meaning of the first string, and if it is actually correct to use byNameOnWire, or it should be yarp::os::Type::byName(typeName, typeName)

@drdanz drdanz added Target: YARP v3.4.0 PR Type: Feat/Enh This PR adds some new feature or enhances some part of YARP labels Mar 13, 2020
{
unsigned int major = 0;
unsigned int minor = 0;
int ret = sscanf(mPriv->version.c_str(), "%u.%u", &major, &minor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drdanz drdanz marked this pull request as draft April 9, 2020 16:04
@CLAassistant
Copy link

CLAassistant commented Apr 20, 2020

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Tool - yarpidl_thrift PR Type: Feat/Enh This PR adds some new feature or enhances some part of YARP Target: YARP v4.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants