Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to map enum wrapped in a struct #146

Open
ericwj opened this issue Aug 16, 2019 · 4 comments
Open

How to map enum wrapped in a struct #146

ericwj opened this issue Aug 16, 2019 · 4 comments

Comments

@ericwj
Copy link

ericwj commented Aug 16, 2019

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?

@jkoritzinsky
Copy link
Member

Currently I don't think enums nested in structs are currently parsed into the C++ AST. I'll try to take a look at supporting nested types in the C++ AST.

Once it's supported, the rule that you'll likely want is <map enum="SomeEnumName::Enum" name="SomeEnumName" />.

@ericwj
Copy link
Author

ericwj commented Aug 17, 2019

Doesn't the same hold for namespaces?

I get Mapping rule [remove method:Lib::SomeClass::DoSomething] did not match any elements. if I try to <remove method="Lib::SomeClass::DoSomething"/>. Removing Lib:: has it match, but it is ambiguous.

@elliotsayes
Copy link

@jkoritzinsky is there any plan to fix this, what would be involved? Currently this is holding up my project.

@jkoritzinsky
Copy link
Member

I’m very busy with work at the moment so I don’t know when I’ll get this done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants