getEnumeratedTypes function

Iterable<EnumeratedType> getEnumeratedTypes(
  1. Root root
)

Return the enumerated types that must exist in the codec where the enumeration should be the key used in the buffer.

Implementation

Iterable<EnumeratedType> getEnumeratedTypes(Root root) sync* {
  int index = 0;

  for (final Enum customEnum in root.enums) {
    yield EnumeratedType(
      customEnum.name,
      index + minimumCodecFieldKey,
      CustomTypes.customEnum,
      associatedEnum: customEnum,
    );
    index += 1;
  }

  for (final Class customClass in root.classes) {
    yield EnumeratedType(
      customClass.name,
      index + minimumCodecFieldKey,
      CustomTypes.customClass,
      associatedClass: customClass,
    );
    index += 1;
  }
}