Comments (8)
@MiguelCompany @richiprosima any pointers are welcomed. Thanks!
from fast-dds-gen.
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.
@LuisGP @richiware @MiguelCompany can any of view please give some suggestion here?
from fast-dds-gen.
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.
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, asString
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 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.
@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 usesStringTemplate
as templates for code generation. In the filesrc/main/java/com/eprosima/fastcdr/idl/generator/TypesGenerator.java
you can see how from aStringTemplateGroup
instance,StringTemplate
instances are created.
Once you have aStringTemplate
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 thecontext
.
The methods of these objects must follow a particular naming to be accessible:
It must start byis
if it returns a boolean value, andget
if it returns anything else. Once inside the template, these methods are accessed without that prefix, for example, the methodcontext.isROS2()
is used inside the template asctx.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.
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)
- bitset implementation HOT 2
- Use virtual or override, not both HOT 2
- C++: Incorrect C++ includes generated for IDLs which include enum-only IDLs HOT 1
- How to define enumeration with int value in IDL? HOT 1
- fastddsgen template asks for headers which doesn't exist or which are misplaced in the install process HOT 1
- fastddsgen -d [19844] HOT 2
- undefined reference to `performance_test::msg::FastDDSGen::PointCloud4m::PointCloud4m() HOT 2
- Generated xxxCdrAux.hpp has data type casting issue for large recursive data structure
- fastddsgen.bat .\HelloWorld.idl Error HOT 1
- Cannot generate python bindings for map data type
- allow modern enum class/scoped enums with type specifier and assigning values HOT 1
- fastddsgen generates invalid #ifndef header fence on IDL filename with "-"
- comparing floating point types in generator equality operator
- Include error with CMake example - <fastcdr/cdr/fixed_size_string.hpp> HOT 3
- FastDDSGen detects IDL file changes HOT 1
- Failures with multiple consecutive directory separators
- On Windows, using a GCC preprocessor does not work
- [XTypes/PL_CDR2] Member header issue for sequences with an inner type of 2 bytes length (short, unsigned short)
- Can I convert UMAA IDL files to code using Fast-DDS-Gen?(Windows or Linux) HOT 1
- Why don't 1-byte data types call cdr_alignment for byte alignment? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-dds-gen.