I created a pull request for this. It moves the code for creating the registry
from RawRegistry::create_registry() to the constructors of Registry and
TypeRegistry. Those constructors are now private and only called from an
`instance()` method (singleton pattern with a static variable in the method).
One downside is that previously, we collected errors and reported them in one
list rather than stop at the first error. This is now split into two such lists:
one for the type registry and one for the registry. This means that if the code
has multiple errors regarding the feature and type registry, the user will first
get a list of all errors in the type registry, and only sees the registry errors
after fixing the type errors.
On the positive side, we can now include errors in
the type registry that previously were not included in this report. For example,
registering an EnumType twice previously was assumed to never happen and led to
an abort, but it did happen (making us aware of this issue). Now it is included
in the list of errors for the type registry.
I'd say over all, the trade-off is
worth the cleaner design.
|