Uploaded image for project: 'Axis2-C'
  1. Axis2-C
  2. AXIS2C-1506

3 bugs in C code generation (invalid characters in c tokens, cyclic inclusion and uppercase-lowercase mismatch)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • code generation
    • Tested on Linux, but shall be present on all platforms

    Description

      I have encountered 3 bugs when trying to generate soap c-client code with the wsdl2c tool.

      I create a single issue because I have only one patch for all bugs.

      The first bug encountered is the presence of invalid characters in c tokens (in my case, the '-' character) when a type name containing an enumeration contains such invalid character. An example of schema that generates this bug is the following:
      <s:simpleType name="Temperature-Unit">
      <s:restriction base="s:string">
      <s:enumeration value="C"/>
      <s:enumeration value="F"/>
      <s:enumeration value="R"/>
      <s:enumeration value="r"/>
      <s:enumeration value="k"/>
      </s:restriction>
      </s:simpleType>
      I think that the solution to this problem is to change the C xml template filess in order to insert the property for which all invalid characters were replaced by '_'.

      The second problem arrises when generating code with one file per data type on very large projects : I did not identified which part of the schema was causing the trouble, but the #include directives are cyclic, which prevents the compilation of the code.
      I think that the solution to this problem is to change the C xml header template in order to declare the structure of each data type before performing inclusions.

      The third problem encountered arises when an enumeration type contains two different values that differ only by upper or lowercase characters. The generated C enum has all fields written in upper-case and so, both elements have the same name. The sample of wsdl schema written above contains such an error.
      In this case, the solution of the problem is not so trivial. A simple way to remove it is to keep the case (upper or lower) of the wsdl enumeration in the C structure. But this change would implies that new generated code will not be compatible with the previously one. I chose this way for solving the problem and so, I created a new property, called nu_id (nu stands for non-uppercase), which contains the original id (with removed invalid characters for c tokens) and I changed the C xml templates so that this new property is used for code generation.

      I don't see any way of joining files during the creation of an issue, but, when I will find a way to do so, I will join an example of wsdl file that generates the three problems as well as a patch that seems to correct all of them. If you don't find the attached files, fell free to contact me. I will send both files.

      I used the following command to generate the code :
      WSDL2C.sh -uri ../WSDL/ehealth-hubservices/WSDL/InterHubWebService-1_0.wsdl -u -o Generated/.

      I used the following command to compile the generated elements :
      gcc -c -combine -o ${OBJ_DIR}/axis2_stub_InterHubService.o -I${AXIS2C_HOME}/include src/*.c

      Best Regards,

      Brice André

      Attachments

        1. patch.diff
          7 kB
          Brice André
        2. ehealthxsd-hubservices-1-0-1.zip
          212 kB
          Brice André

        Activity

          People

            Unassigned Unassigned
            brice_andre Brice André
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: