gale320 / staff

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

Generate wsdl Type error #186

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.The file "device_doors" as follow:
namespace cspws
{
namespace csp
{
namespace device
{
struct DoorData
{
  enum Type
  {
    HOST = 0,
    ACCESS = 1,
    CHANNEL = 2
   };

   struct AccessState
  {
    enum Type
    {
      OPEN = 0,
      CLOSE = 1,
      LONG_TIME_NOT_CLOSE_GEN = 2,
      LONG_TIME_NOT_CLOSE_RES = 3,
      FORCE_OPEN_WARNING = 4,
      OPEN_BY_EXIT_BUTTON = 5,
      INVALID_AREA_WARNING = 6
    };
        Type type;
    unsigned int channel;
    AccessState():type(::cspws::csp::device::DoorData::AccessState::OPEN), channel(1)
    {
    }
   };
   unsigned long long id;  
   double time;  
   Type type;
   AccessState access_state;            
   DoorData():type(::cspws::csp::device::DoorData::CHANNEL)
  {
  }
};
2.staff_codegen -u -twsdl -cinclude device_doors.h
3.The Wsdl file as follow:
<complexType name="DoorData">
        <sequence>
          <element name="id" type="unsignedLong">
            <annotation><documentation>Door host id</documentation></annotation>
          </element>
          <element name="time" type="double">
            <annotation><documentation>Time</documentation></annotation>
          </element>
          <element name="type" type="ns_cspws_csp_device:DoorData.Type" default="::cspws::csp::device::DoorData::CHANNEL"/>
          <element name="access_state" type="ns_cspws_csp_device:DoorData.AccessState"/>
        </sequence>
      </complexType>

      <simpleType name="DoorData.Type">
        <restriction base="string">
          <enumeration value="0"/>
          <enumeration value="1"/>
          <enumeration value="2"/>
        </restriction>
      </simpleType>

      <complexType name="AccessState">
        <sequence>
          <element name="type" type="ns_cspws_csp_device:DoorData.AccessState.Type" default="::cspws::csp::device::DoorData::AccessState::OPEN"/>
          <element name="channel" type="unsignedInt" default="1"/>
        </sequence>
      </complexType>

      <simpleType name="DoorData.AccessState.Type">
        <restriction base="string">
          <enumeration value="0"/>
          <enumeration value="1"/>
          <enumeration value="2"/>
          <enumeration value="3"/>
          <enumeration value="4"/>
          <enumeration value="5"/>
          <enumeration value="6"/>
        </restriction>
      </simpleType>

What is the expected output? What do you see instead?
In the wsdl file, the line:
(1)<complexType name="AccessState"> shoudl be ==> 
<complexType name="DoorData.AccessState">.

(2) <element name="type" type="ns_cspws_csp_device:DoorData.AccessState.Type" 
default="::cspws::csp::device::DoorData::AccessState::OPEN"/>

should be ==>

<element name="type" type="ns_cspws_csp_device:DoorData.AccessState.Type" 
default="0"/>

What version of the product are you using? On what operating system?

r709, windows xp

Please provide any additional information below.

Original issue reported on code.google.com by bingqing...@gmail.com on 8 Sep 2012 at 8:18

GoogleCodeExporter commented 9 years ago
Agree there are several bugs in codegen:

- possibly invalid name of nested struct generated;
- invalid generating of default value of enums;
- enum names generation (what is your enum type, string or int?);

But there also a bug in your source (I suspect it was generated from wsdl by 
staff_codegen)

  struct AccessState
  {
//  ...
   AccessState access_state;            
// ...
};

Recursive structure declaration here.

Original comment by loentar on 18 Sep 2012 at 9:45

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

Original comment by loentar on 6 Nov 2012 at 7:08

GoogleCodeExporter commented 9 years ago
You must write value in "defaultValue" metacomment as is, i.e. in your case 
"OPEN"

Original comment by loentar on 6 Nov 2012 at 7:10