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

[21051] DynamicType to IDL serializer #4787

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

juanlofer-eprosima
Copy link
Contributor

@juanlofer-eprosima juanlofer-eprosima commented May 14, 2024

Description

After:

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • N/A Any new configuration API has an equivalent XML API (with the corresponding XSD extension)
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • New feature has been added to the versions.md file (if applicable).
  • New feature has been documented/Current behavior is correctly described in the documentation.
  • N/A Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
* Class that represents each of the Nodes that form a Tree, including the source and the leaves.
*/
template <typename Info>
class TreeNode : public Node<Info>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add tests for new container class.

std::string& output,
DynamicDataJsonFormat format) noexcept;

// TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do

DynamicDataJsonFormat format) noexcept;

// TODO
std::string generate_idl_schema(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Convert to a noexcept method, passing output by reference (both string and ostream overloads), and returning retcode (that would be a propagation of a DynamicType method return code in case of error).

return ss.str();
}

std::string generate_idl_schema(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rearrange methods implementations, by forward declarating all helper functions.

const auto ret = dyn_type->get_descriptor(type_descriptor);
if (ret != RETCODE_OK)
{
//throw utils::InconsistencyException("No Type Descriptor");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Propagate error codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And add log warnings.

Comment on lines +1230 to +1231
case TK_ENUM:
case TK_UNION:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Review implementation, some information is currently missing.

case TK_MAP:
return map_kind_to_str(dyn_type);

case TK_STRUCTURE:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missing inheritance case.

case TK_BYTE:
return "octet";

case TK_INT16:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add newly supported TK_INT8 and TK_UINT8 kinds.

return type_descriptor->element_type();
}

std::vector<uint32_t> container_size(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Return BoundSeq type.

std::stringstream ss;
ss << "sequence<" << type_kind_to_str(internal_type);

for (const auto& bound : this_sequence_size)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Review this logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compare bound with static_cast<uint32_t>(LENGTH_UNLIMITED) to cover the unbounded case.

@juanlofer-eprosima juanlofer-eprosima added this to the v3.0.0 milestone May 14, 2024
@juanlofer-eprosima juanlofer-eprosima changed the title DynamicType to IDL serializer [21051] DynamicType to IDL serializer May 20, 2024
@juanlofer-eprosima
Copy link
Contributor Author

Consider extending conversions to take annotations into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review PR that is ready to be reviewed to-do
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants