openweave / openweave-wdlc

This package makes available the Weave Data Language (WDL) compiler (WDLC). WDL is Weave's publish and subscribe schema language. The WDLC compiler can be used to compile (i.e., validate and code generate) schema written against the WDL specification.
https://openweave.io/
Apache License 2.0
2 stars 8 forks source link

Multiple references to the same Command Response generates multiple similar enum definitions #9

Open mrjerryjohns opened 5 years ago

mrjerryjohns commented 5 years ago

When there are multiple command requests referencing the same command response definition, it seems to cause WDLC to emit multiple similar definitions of the parameter list enumeration for the response.

E.g:

  message TestARequest {
    option (wdl.message_type) = COMMAND;
    option (wdl.command) = {
      id: 0x05,
      completion_event: "Response"
    };

    int32 a = 1;
  }

  message TestBRequest {
    option (wdl.message_type) = COMMAND;
    option (wdl.command) = {
      id: 0x06,
      completion_event: "Response"
    };

    int32 b = 1;
  }

  message Response {
    option (wdl.message_type) = RESPONSE_EVENT;

    int32 resp = 1;
  }

Generated C++ device code:

enum TestARequestParameters {
    kTestARequestParameter_A = 1,
};

enum TestBRequestParameters {
    kTestBRequestParameter_B = 1,
};

enum ResponseParameters {
    kResponseParameter_Resp = 1,
};

enum ResponseParameters {
    kResponseParameter_Resp = 1,
};