QUSIR / staff

Automatically exported from code.google.com/p/staff
Apache License 2.0
0 stars 0 forks source link

Duplicated enum values due to punctuation character in "xsd:enumeration" #169

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add the following "xsi:enumeration" to a WSDL file
        ...
        <xsd:simpleType name="ruleType">
                <xsd:restriction base="xsd:string">
                        ...
                        <xsd:enumeration value="+L1"/>
                        <xsd:enumeration value="-L1"/>
                        ...
                </xsd:restriction>
        </xsd:simpleType>
        ...
2. Run "staff_codegen -pwsdl" on that WSDL file.
3. Compile the generated code.

What is the expected output? What do you see instead?
Expect to generate unique enum values, but instead, generate the following 
duplicated enum values.
  // *baseType: string
  // *renamed: true
  enum ruleType
  {
    ...
    // *value: +L1
    ruleType__L1,
    // *value: -L1
    ruleType__L1,
    ...
  };

What version of the product are you using? On what operating system?
win32 binary axis2/c-1.6.0 and staff-2.0.0-a1-r670 built with vs2005 
On Windows

Please provide any additional information below.
Currently, the implementation of "bool FixId(std::string& sName, bool 
bIgnoreBool = false)" in "staff/tools/codegenparser/src/tools.cpp" will always 
convert the punctuation character to an underscore character. This won't work 
in situations similar to above.
gSOAP handles punctuation character in "xsd:enumeration" by converting the 
punctuation character into an integral value using hexadecimal base format like 
the following code. 
      std::ostringstream os;
      os << std::showbase << std::hex << static_cast<int>(sId[nPos]);
      sId.replace(nPos, 1, os.str());
Therefore, it will generate enum values like the following.
  // *baseType: string
  // *renamed: true
  enum ruleType
  {
    ...
    // *value: +L1
    ruleType__0x2bL1,
    // *value: -L1
    ruleType__0x2dL1,
    ...
  };
You might want to consider this for the fix.

Original issue reported on code.google.com by kenn...@gmail.com on 6 Jun 2012 at 6:09

GoogleCodeExporter commented 9 years ago
Accepted. Thanks for such detailed info and for suggestion.

Original comment by loentar on 6 Jun 2012 at 6:21

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r678.

Original comment by loentar on 6 Jun 2012 at 9:47