Merge remote-tracking branch 'origin/topic/jsiwek/type-alias-introspection'

* origin/topic/jsiwek/type-alias-introspection:
  Add enum_names() BIF to return names of an enum type's values
  Add type_aliases() BIF for introspecting type-names of types/values
  Change Type::type_aliases map to store IntrusivePtr
  Fix lookup_ID() BIF to return enum values
This commit is contained in:
Jon Siwek 2020-11-12 14:30:32 -08:00
commit aab99b743d
12 changed files with 301 additions and 13 deletions

View file

@ -1348,13 +1348,11 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
if ( vals.find(val) == vals.end() )
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
set<Type*> types = Type::GetAliases(GetName());
set<Type*>::const_iterator it;
const auto& types = Type::Aliases(GetName());
for ( it = types.begin(); it != types.end(); ++it )
if ( *it != this )
(*it)->AsEnumType()->AddNameInternal(module_name, name, val,
is_export);
for ( const auto& t : types )
if ( t.get() != this )
t->AsEnumType()->AddNameInternal(module_name, name, val, is_export);
}
void EnumType::AddNameInternal(const string& module_name, const char* name,