Giter Club home page Giter Club logo

Comments (8)

TSC21 avatar TSC21 commented on August 12, 2024

@MiguelCompany @richiprosima any pointers are welcomed. Thanks!

from fast-dds-gen.

TSC21 avatar TSC21 commented on August 12, 2024

Another remark is that changing the scope is not enough as it is expected a naming with a structure like module.name::parent.name::struct.name_ (with an underscore in the end). So there's need to be a way of defining a custom name if defined globally.

from fast-dds-gen.

TSC21 avatar TSC21 commented on August 12, 2024

@LuisGP @richiware @MiguelCompany can any of view please give some suggestion here?

from fast-dds-gen.

LuisGP avatar LuisGP commented on August 12, 2024

Hello @TSC21

I don't know if we are going to have time to address this request, we are pretty busy at this moment. Maybe @MiguelCompany can consider it.

In the case we can't, I propose you to study the possibility to add a --ros2 parameter so the naming is directly generated in the ROS2 way. This parameter should simply put a boolean in the Context, which is globally accessible in the templates.
Another way would be to define --topic_name and --type_name parameters, as String in the Context and if defined, use them instead of the default naming.

I hope this throws a bit of light to you.

Best regards.

from fast-dds-gen.

TSC21 avatar TSC21 commented on August 12, 2024

Hello @TSC21

I don't know if we are going to have time to address this request, we are pretty busy at this moment. Maybe @MiguelCompany can consider it.

In the case we can't, I propose you to study the possibility to add a --ros2 parameter so the naming is directly generated in the ROS2 way. This parameter should simply put a boolean in the Context, which is globally accessible in the templates.
Another way would be to define --topic_name and --type_name parameters, as String in the Context and if defined, use them instead of the default naming.

I hope this throws a bit of light to you.

Best regards.

@LuisGP Thank you very much for your feedback! I actually took some time to investigate how everything connect but it certainly gets diffuse when you try to understand how the globals link to the each part of the template, and how to exactly pass that templates as globals and where. If you could give some pointers that would for sure help bring this further and I would take the implementation myself. Thanks!

from fast-dds-gen.

LuisGP avatar LuisGP commented on August 12, 2024

@LuisGP Thank you very much for your feedback! I actually took some time to investigate how everything connect but it certainly gets diffuse when you try to understand how the globals link to the each part of the template, and how to exactly pass that templates as globals and where. If you could give some pointers that would for sure help bring this further and I would take the implementation myself. Thanks!

@TSC21 I'll try to give you these points.
Fast-RTPS-Gen uses StringTemplate as templates for code generation. In the file src/main/java/com/eprosima/fastcdr/idl/generator/TypesGenerator.java you can see how from a StringTemplateGroup instance, StringTemplate instances are created.
Once you have a StringTemplate instance, you can add attributes to it, for example:

StringTemplate ifcst = stg_.getInstanceOf("interface");
ifcst.setAttribute("ctx", context);
ifcst.setAttribute("parent", ifc.getParent());
ifcst.setAttribute("interface", ifc);

Each attribute maps to a Java object, for example, ctx will map to the context.
The methods of these objects must follow a particular naming to be accessible:
It must start by is if it returns a boolean value, and get if it returns anything else. Once inside the template, these methods are accessed without that prefix, for example, the method context.isROS2() is used inside the template as ctx.ROS2.

I really hope this is enough to continue by yourself.

Best regards.

from fast-dds-gen.

TSC21 avatar TSC21 commented on August 12, 2024

@LuisGP Thank you very much for your feedback! I actually took some time to investigate how everything connect but it certainly gets diffuse when you try to understand how the globals link to the each part of the template, and how to exactly pass that templates as globals and where. If you could give some pointers that would for sure help bring this further and I would take the implementation myself. Thanks!

@TSC21 I'll try to give you these points.
Fast-RTPS-Gen uses StringTemplate as templates for code generation. In the file src/main/java/com/eprosima/fastcdr/idl/generator/TypesGenerator.java you can see how from a StringTemplateGroup instance, StringTemplate instances are created.
Once you have a StringTemplate instance, you can add attributes to it, for example:

StringTemplate ifcst = stg_.getInstanceOf("interface");
ifcst.setAttribute("ctx", context);
ifcst.setAttribute("parent", ifc.getParent());
ifcst.setAttribute("interface", ifc);

Each attribute maps to a Java object, for example, ctx will map to the context.
The methods of these objects must follow a particular naming to be accessible:
It must start by is if it returns a boolean value, and get if it returns anything else. Once inside the template, these methods are accessed without that prefix, for example, the method context.isROS2() is used inside the template as ctx.ROS2.

I really hope this is enough to continue by yourself.

Best regards.

@LuisGP thank you very much! I think the last thing I need to understand is the way of passing an argument given on the CLI to the StringTemplate. Maybe add it to the main TemplateGroup. And from there I have it available globally on all StringTemplates?

from fast-dds-gen.

LuisGP avatar LuisGP commented on August 12, 2024

I'd follow the same way of the already existing arguments in fastrtpsgen.java.
In your case, fastrtpsgen should parse the argument and pass it to the Context (in the constructor, for example). The Context should provide the isXXX method to allow the template to access to the XXX value.
As all templates include the context (if I'm not wrong), it should be directly available.

from fast-dds-gen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.