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

Code generation issue with enumeration encapsulated in restriction type #234

Closed
raphaelcotty opened this issue Feb 5, 2021 · 4 comments
Closed

Comments

@raphaelcotty
Copy link
Contributor

The enumeration class uses encapsulate the enum using the enum name Type.
The class has a getter/setter getType type(0 and setType().
When this enum is encapsulated into a restriction type for example then the generated setter method generates code which tries to check the range generating this code.
Here the restriction length is 2:

rangeOk = rangeOk && (value.value().length() == 2);

The code doesn't compile because value doesn't have a value method.
Maybe adding a value method to the enumeration class returning a string?

@dfaure-kdab
Copy link
Member

The first step to get this fixed is to add a unittest, or extend an existing one, with enough WSDL to trigger the issue.

@raphaelcotty
Copy link
Contributor Author

Pull request added: #235

@dfaure-kdab
Copy link
Member

Thanks for the excellent unit test.

Clearly the restriction on length == 2 serves no purpose in this case, the base type already ensures that the string is a value enum value, and all enum values have a length of 2... but I assume you can't change the WSDL file, or that there are use cases where this might be useful (e.g. if some enum values had a different length, as a string...).

I added a stringValue() method and changed the range-check code to use that, in the case of enums ("restrictions").
It actually makes the generated code in the serialize() method cleaner, so I like it :)

dfaure-kdab added a commit that referenced this issue Feb 9, 2021
…234)

The existing unittest list_restriction didn't catch that things actually compiled.
So I removed it and extended the other unittests instead, to try and
test all cases (restriction on enum, restriction on string, restriction
on number of items in a list...)

The actual bugfix involves the addition of a stringValue() method for
enumeration types -- which also simplifies the serialize() code.
@dfaure-kdab
Copy link
Member

Fixed in commit 57e02fb

Thanks again for the unittest!

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

2 participants