eProsima / Fast-DDS-Gen

Fast-DDS IDL code generator tool. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
77 stars 59 forks source link

fastddsgen generates invalid #ifndef header fence on IDL filename with "-" #298

Open okellogg opened 4 months ago

okellogg commented 4 months ago

For an IDL file named outer-middle-inner.idl with content

module outer {
   module middle {
      module inner {
         enum some_type { A, B, C };
      };
   };
};

fastddsgen generates the start of header file

#ifndef _FAST_DDS_GENERATED_OUTER-MIDDLE-INNER_H_
#define _FAST_DDS_GENERATED_OUTER-MIDDLE-INNER_H_

Notice that the dashes from the input filename are directly transferred to the header guard symbol. Looking at src/main/java/com/eprosima/fastdds/idl/grammar/Context.java function getHeaderGuardName,

            if (m_lastStructure.getHasScope())
            {
                return m_lastStructure.getScope().replaceAll("::", "_").toUpperCase() +
                       "_" + m_fileNameUpper.replaceAll("\\.", "_");
            }

IMHO it would be good to extend the pattern in the m_fileNameUpper.replaceAll to include "-".