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 generator updates and fix for a union with a discriminator referencing an enum type. #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ckenna
Copy link
Contributor

@ckenna ckenna commented May 19, 2018

The QAPI has changed again. More fields have been added since April 23.

This also exposed a bug in the way that CpuInfoFast was being generated. The bug has to do with the way Java names are generated when there is a union with a discriminator referencing an enum type. So there's a commit in here to handle that case.

Also, this added more parameters to some options, so I had to go and fix some tests to add the new parameters.

If a union uses a field as a discriminator but that field is defined as
an enum type, then we have to reference it by name differently. This is
because enum names have a different conversion from a QAPI name to a
Java name. Sometimes, this name cannot easily be derived from the known
information so far.

Concretely, the following bug introduced this:
1. The type "SysEmuTarget" is defined as an enum. One of its values is
   "x86_64".
2. The type "CpuInfoFast" uses a field of the above type as a
   discriminator.
3. In Java generated code, it was trying to reference SysEmuType.x8664.
   This type did not exist in the enum. It only has "x86_64".

Now we save all enum fields and check if a union is referencing an
enum explicitly. If it is, then we use the enum name for that field.
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

Successfully merging this pull request may close these issues.

1 participant