Skip to content

How to map enum wrapped in a struct #146

Description

@ericwj

I am trying to map a series of enums which are declared and then used as follows:

namespace Lib {
    struct SomeEnumName {
        enum Enum {
            EUndefined,
            ...
        }
    }
    ...
    class SomeClass {
    public:
        SomeType* DoSomething(SomeEnumName::Enum value, ...) {
            ...
        }
    }
}

I am trying to map them like this:

<map enum="SomeEnumName::Enum" />

But I get these errors:

C:\Project\Mapping.xml(1,1): warning SG0019: Mapping rule [map enum:SomeEnumName::Enum] did not match any elements.
CppInterface [SomeClass]/Method SomeType* SomeClass::DoSomething([In] Enum type,[In] void* data) error : Unknown type found [Enum]

Are these enums represented in the C++ AST at all? How do I match on them such that first of all the method will be generated and second that some C# equivalent of the enumerations is created?

Next to that, the wrapping is usually in otherwise empty structs, probably because C++ enums are a broken concept as their constant members aren't scoped to the enum declaration. But it is silly to have enums be declared as nested in a struct, although it is valid C#. How do I match on them and change the C# such that these enums will be declared as SomeEnumName?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions