COVESA / capicxx-core-tools

Common API C++ core tools
Mozilla Public License 2.0
135 stars 106 forks source link

Example E03Methods - suspicious error enumeration #69

Closed srl100 closed 5 months ago

srl100 commented 6 months ago

When running the commonapi-core-generator on the .fidl code in CommonAPI-Examples/E03Methods/README the generated header file includes some suspicious code for the error enumeration.

Input:

package commonapi.examples

interface E03Methods {

    version { major 1 minor 2 }

    method foo {
        in {
            Int32 x1
            String x2
        }
        out {
            Int32 y1
            String y2
        }
        error {
            stdErrorTypeEnum
        }
    }

    broadcast myStatus {
        out {
            Int32 myCurrentValue
        }
    }

    enumeration stdErrorTypeEnum {
        NO_FAULT
        MY_FAULT
    }
}

Generated E03Methods.hpp: ...

    struct stdErrorTypeEnum : CommonAPI::Enumeration< uint8_t> {
        enum Literal : uint8_t {
            NO_FAULT = 0,
            MY_FAULT = 1
        };

...

    struct fooError : CommonAPI::Enumeration< uint8_t> {
        enum Literal : uint8_t {
            stdErrorTypeEnum = 0
        };

...

I don't really know what I am expecting here, but I am surprised that there are two enum lists defined here - from the FIDL it looks like fooError should somehow refer to stdErrorTypeEnum rather than (re?)define it with a value of 0.

E03_fidl.txt E03Methods_hpp.txt

srl100 commented 5 months ago

Could not recreate this problem.