Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consistently use goEnumPrefix and fix bug generating enum default val…
…ue in wrapper union node. (#511) Consistently use goEnumPrefix and fix bug generating enum default value in wrapper union node. ### Background The recent union default value generation changes [removed a call to `enumDefaultValue`](https://github.com/openconfig/ygot/pull/496/files#diff-19ecb3e61250b63aaf93a11d7017203a90637b52bee811a021ab253b01c42748L275-L277) in order to use the *raw* default value string provided in the YANG file to look up the existence of the enum value in goyang's AST before accepting the default value as an enum type. The `yangDefaultValueToGo` function only processes these raw values for simplicity. However, this breaks generating typedef enums in wrapper union mode because a call to `enumDefaultValue` is required to make the output correct. ### This change What this change does is that during the processing of both inline and typedef enumerated values by `yangTypeToGoType`, `enumDefaultValue` is **not called** when populating `MappedType`'s `DefaultValue` field. This means that **all** enumerated values that subsequently get processed by `yangDefaultValueToGo`, which come after the call to `yangTypeToGoType`, will see the raw default value. Most importantly, `goLeafDefault`, a call that happens in wrapper-union mode, can now transform the raw default values for enums into their "cooked" versions without discriminating between inline and typedef enumerated values. This is what fixes this problem.
- Loading branch information