use new interface for associating attributes with constructors

This commit is contained in:
Vern Paxson 2022-03-11 14:21:59 -08:00 committed by Tim Wojtulewicz
parent 96f52b0e11
commit 0bbbd84c9d

View file

@ -248,13 +248,9 @@ void ID::UpdateValAttrs()
if ( ! attrs ) if ( ! attrs )
return; return;
if ( val && val->GetType()->Tag() == TYPE_TABLE ) auto tag = GetType()->Tag();
val->AsTableVal()->SetAttrs(attrs);
if ( val && val->GetType()->Tag() == TYPE_FILE ) if ( tag == TYPE_FUNC )
val->AsFile()->SetAttrs(attrs.get());
if ( GetType()->Tag() == TYPE_FUNC )
{ {
const auto& attr = attrs->Find(ATTR_ERROR_HANDLER); const auto& attr = attrs->Find(ATTR_ERROR_HANDLER);
@ -262,7 +258,7 @@ void ID::UpdateValAttrs()
event_registry->SetErrorHandler(Name()); event_registry->SetErrorHandler(Name());
} }
if ( GetType()->Tag() == TYPE_RECORD ) if ( tag == TYPE_RECORD )
{ {
const auto& attr = attrs->Find(ATTR_LOG); const auto& attr = attrs->Find(ATTR_LOG);
@ -281,6 +277,17 @@ void ID::UpdateValAttrs()
} }
} }
} }
if ( ! val )
return;
auto vtag = val->GetType()->Tag();
if ( vtag == TYPE_TABLE )
val->AsTableVal()->SetAttrs(attrs);
else if ( vtag == TYPE_FILE )
val->AsFile()->SetAttrs(attrs.get());
} }
const AttrPtr& ID::GetAttr(AttrTag t) const const AttrPtr& ID::GetAttr(AttrTag t) const