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

[14671] Fix generated code for bounded strings #119

Merged
merged 8 commits into from
Jul 1, 2022
Merged

Conversation

MiguelCompany
Copy link
Member

This PR changes the generated code for bounded strings, so eprosima::fastrtps::fixed_string<N> is used instead of std::string

Depends on eProsima/IDL-Parser#53

@MiguelCompany MiguelCompany changed the title Fix generated code for bounded strings [14671] Fix generated code for bounded strings May 25, 2022
Copy link
Member

@richiware richiware left a comment

Choose a reason for hiding this comment

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

Next IDL test file is not compiling due to array and sequence of bounded strings:

module hola
{
    struct S
    {
        string sn;
        string<10> sb;
    };
};

    struct S
    {
        hola::S st;
        string sn;
        string<10> sb;
        string sna[10];
        string<10> sba[10];
        sequence<string, 10> sns;
        sequence<string<10>, 10> sbs;
    };

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@MiguelCompany
Copy link
Member Author

@richiware I think I fixed the (de)serialization of collections of bounded strings

Copy link
Member

@richiware richiware left a comment

Choose a reason for hiding this comment

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

coverage_basic.idl test from fastddsgen is failing. The output:

2022-06-30T14:03:18.840+0200 [DEBUG] [TestEventLogger]     >>> COVERAGE_BASIC TEST: GENERATE...
2022-06-30T14:03:18.840+0200 [DEBUG] [TestEventLogger]     Executing command: java -jar share/fastddsgen/java/fastddsgen.jar -replace -example CMake -test -d build/test/integration/idls/coverage_basic thirdparty/idl-parser/test/idls/coverage_basic.idl
2022-06-30T14:03:19.702+0200 [DEBUG] [TestEventLogger]     Loading templates...
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]     Processing the file thirdparty/idl-parser/test/idls/coverage_basic.idl...
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]     Exception in thread "main" java.lang.StackOverflowError
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.703+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.704+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.705+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.705+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.705+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.705+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.705+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.706+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.706+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.706+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.706+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.706+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.707+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.707+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.707+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.707+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.707+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.708+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.708+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.708+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.708+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.708+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)
2022-06-30T14:03:19.708+0200 [DEBUG] [TestEventLogger]          at org.antlr.stringtemplate.StringTemplate.getAttributeRenderer(StringTemplate.java:1045)

@richiware
Copy link
Member

I was investigating and the error is caused by a recursive map. This was fixed already in master branch. Could you rebase?

@richiware
Copy link
Member

I test it again from scratch. The map problem goes away. But coverage_basic.idl still failing.

2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]     In file included from /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx:29:
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.h:2840:21: error: ISO C++ forbids declaration of '_my_large_wstring' with no type [-fpermissive]
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]      2840 |             const & _my_large_wstring);
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]           |                     ^~~~~~~~~~~~~~~~~
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.h:2847:5: error: expected identifier before '&&' token
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]      2847 |     && _my_large_wstring);
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]           |     ^~
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.h:2853:37: error: ISO C++ forbids declaration of 'my_large_wstring' with no type [-fpermissive]
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]      2853 |     eProsima_user_DllExport const & my_large_wstring() const;
2022-06-30T23:25:23.839+0200 [DEBUG] [TestEventLogger]           |                                     ^~~~~~~~~~~~~~~~
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.h:2859:31: error: ISO C++ forbids declaration of 'my_large_wstring' with no type [-fpermissive]
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]      2859 |     eProsima_user_DllExport & my_large_wstring();
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]           |                               ^~~~~~~~~~~~~~~~
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.h:2920:6: error: 'm_my_large_wstring' does not name a type
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]      2920 |      m_my_large_wstring;
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]           |      ^~~~~~~~~~~~~~~~~~
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx: In copy constructor 'LargeWStringStruct::LargeWStringStruct(const LargeWStringStruct&)':
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx:2866:5: error: 'm_my_large_wstring' was not declared in this scope; did you mean 'my_large_wstring'?
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]      2866 |     m_my_large_wstring = x.m_my_large_wstring;
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]           |     ^~~~~~~~~~~~~~~~~~
2022-06-30T23:25:23.840+0200 [DEBUG] [TestEventLogger]           |     my_large_wstring
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx:2866:28: error: 'const class LargeWStringStruct' has no member named 'm_my_large_wstring'; did you mean 'my_large_wstring'?
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]      2866 |     m_my_large_wstring = x.m_my_large_wstring;
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]           |                            ^~~~~~~~~~~~~~~~~~
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]           |                            my_large_wstring
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx: In constructor 'LargeWStringStruct::LargeWStringStruct(LargeWStringStruct&&)':
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx:2872:5: error: 'm_my_large_wstring' was not declared in this scope; did you mean 'my_large_wstring'?
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]      2872 |     m_my_large_wstring = std::move(x.m_my_large_wstring);
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]           |     ^~~~~~~~~~~~~~~~~~
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]           |     my_large_wstring
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_basic/coverage_basic.cxx:2872:38: error: 'class LargeWStringStruct' has no member named 'm_my_large_wstring'; did you mean 'my_large_wstring'?
2022-06-30T23:25:23.841+0200 [DEBUG] [TestEventLogger]      2872 |     m_my_large_wstring = std::move(x.m_my_large_wstring);

The idl part which provokes this is:

struct LargeWStringStruct
{
    wstring<41925> my_large_wstring;
};

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@MiguelCompany
Copy link
Member Author

@richiware I think i fixed the wstring issue. I checked with the following idl:

struct LargeWStringStruct
{
    wstring<41925> my_large_wstring;
};

module hola
{
    struct S
    {
        string sn;
        string<10> sb;
        wstring wn;
        wstring<10> wb;
    };
};

struct S
{
    hola::S st;
    string sn;
    string<10> sb;
    string sna[10];
    string<10> sba[10];
    sequence<string, 10> sns;
    sequence<string<10>, 10> sbs;
    wstring wn;
    wstring<10> wb;
    wstring wna[10];
    wstring<10> wba[10];
    sequence<wstring, 10> wns;
    sequence<wstring<10>, 10> wbs;
};

@richiware
Copy link
Member

richiware commented Jul 1, 2022

Next test also fails:

 /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_complex/coverage_complex.cxx: In member function 'void ComplexStruct::serialize(eprosima::fastcdr::Cdr&) const':
2022-07-01T10:29:54.867+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_complex/coverage_complex.cxx:1387:26: error: 'const struct std::array<eprosima::fastrtps::fixed_string<75>, 5>' has no member named 'c_str'
2022-07-01T10:29:54.867+0200 [DEBUG] [TestEventLogger]      1387 |             scdr << item.c_str();
2022-07-01T10:29:54.867+0200 [DEBUG] [TestEventLogger]           |                          ^~~~~
2022-07-01T10:29:54.867+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_complex/coverage_complex.cxx: In member function 'void ComplexStruct::deserialize(eprosima::fastcdr::Cdr&)':
2022-07-01T10:29:54.867+0200 [DEBUG] [TestEventLogger]     /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_complex/coverage_complex.cxx:1449:28: error: no match for 'operator=' (operand types are 'std::array<eprosima::fastrtps::fixed_string<75>, 5>' and 'const char*')
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]      1449 |             item = s.c_str();
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]           |                            ^
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     In file included from /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_complex/coverage_complex.h:29,
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]                      from /home/ricardo/workspace/eprosima/fastrtpsgen/build/test/integration/idls/coverage_complex/coverage_complex.cxx:29:
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     /usr/include/c++/11/array:95:12: note: candidate: 'std::array<eprosima::fastrtps::fixed_string<75>, 5>& std::array<eprosima::fastrtps::fixed_string<75>, 5>::operator=(const std::array<eprosima::fastrtps::fixed_string<75>, 5>&)'
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]        95 |     struct array
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]           |            ^~~~~
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     /usr/include/c++/11/array:95:12: note:   no known conversion for argument 1 from 'const char*' to 'const std::array<eprosima::fastrtps::fixed_string<75>, 5>&'
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     /usr/include/c++/11/array:95:12: note: candidate: 'std::array<eprosima::fastrtps::fixed_string<75>, 5>& std::array<eprosima::fastrtps::fixed_string<75>, 5>::operator=(std::array<eprosima::fastrtps::fixed_string<75>, 5>&&)'
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     /usr/include/c++/11/array:95:12: note:   no known conversion for argument 1 from 'const char*' to 'std::array<eprosima::fastrtps::fixed_string<75>, 5>&&'
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     make[2]: *** [CMakeFiles/coverage_complex_lib.dir/build.make:76: CMakeFiles/coverage_complex_lib.dir/coverage_complex.cxx.o] Error 1
2022-07-01T10:29:54.868+0200 [DEBUG] [TestEventLogger]     make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/coverage_complex_lib.dir/all] Error 2

Here the IDL file for testing:

https://raw.githubusercontent.com/eProsima/IDL-Parser/master/test/idls/coverage_complex.idl

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@richiware richiware merged commit d507813 into master Jul 1, 2022
@richiware richiware deleted the bugfix/14652 branch July 1, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants