mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Deprecate ID::FindAttr(), replace with GetAttr()
This commit is contained in:
parent
bee321711f
commit
5fc78a548c
4 changed files with 14 additions and 9 deletions
11
src/ID.cc
11
src/ID.cc
|
@ -217,7 +217,7 @@ void ID::SetVal(IntrusivePtr<Expr> ev, init_class c)
|
|||
|
||||
bool ID::IsRedefinable() const
|
||||
{
|
||||
return FindAttr(ATTR_REDEF) != nullptr;
|
||||
return GetAttr(ATTR_REDEF) != nullptr;
|
||||
}
|
||||
|
||||
void ID::SetAttrs(IntrusivePtr<Attributes> a)
|
||||
|
@ -266,14 +266,14 @@ void ID::UpdateValAttrs()
|
|||
}
|
||||
}
|
||||
|
||||
Attr* ID::FindAttr(attr_tag t) const
|
||||
const IntrusivePtr<Attr>& ID::GetAttr(attr_tag t) const
|
||||
{
|
||||
return attrs ? attrs->Find(t).get() : nullptr;
|
||||
return attrs ? attrs->Find(t) : Attr::nil;
|
||||
}
|
||||
|
||||
bool ID::IsDeprecated() const
|
||||
{
|
||||
return FindAttr(ATTR_DEPRECATED) != nullptr;
|
||||
return GetAttr(ATTR_DEPRECATED) != nullptr;
|
||||
}
|
||||
|
||||
void ID::MakeDeprecated(IntrusivePtr<Expr> deprecation)
|
||||
|
@ -288,7 +288,8 @@ void ID::MakeDeprecated(IntrusivePtr<Expr> deprecation)
|
|||
std::string ID::GetDeprecationWarning() const
|
||||
{
|
||||
std::string result;
|
||||
Attr* depr_attr = FindAttr(ATTR_DEPRECATED);
|
||||
const auto& depr_attr = GetAttr(ATTR_DEPRECATED);
|
||||
|
||||
if ( depr_attr )
|
||||
{
|
||||
auto expr = static_cast<ConstExpr*>(depr_attr->GetExpr().get());
|
||||
|
|
6
src/ID.h
6
src/ID.h
|
@ -109,7 +109,11 @@ public:
|
|||
[[deprecated("Remove in 4.1. Use GetAttrs().")]]
|
||||
Attributes* Attrs() const { return attrs.get(); }
|
||||
|
||||
Attr* FindAttr(attr_tag t) const;
|
||||
[[deprecated("Remove in 4.1. Use GetAttr().")]]
|
||||
Attr* FindAttr(attr_tag t) const
|
||||
{ return GetAttr(t).get(); }
|
||||
|
||||
const IntrusivePtr<Attr>& GetAttr(attr_tag t) const;
|
||||
|
||||
bool IsDeprecated() const;
|
||||
|
||||
|
|
|
@ -237,8 +237,8 @@ static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
|
|||
// intention clearly isn't to overwrite entire existing table val.
|
||||
c = INIT_EXTRA;
|
||||
|
||||
if ( init && ((c == INIT_EXTRA && id->FindAttr(ATTR_ADD_FUNC)) ||
|
||||
(c == INIT_REMOVE && id->FindAttr(ATTR_DEL_FUNC)) ))
|
||||
if ( init && ((c == INIT_EXTRA && id->GetAttr(ATTR_ADD_FUNC)) ||
|
||||
(c == INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) ))
|
||||
// Just apply the function.
|
||||
id->SetVal(init, c);
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ void ScriptInfo::DoInitPostScript()
|
|||
|
||||
if ( id->IsConst() )
|
||||
{
|
||||
if ( id->FindAttr(ATTR_REDEF) )
|
||||
if ( id->GetAttr(ATTR_REDEF) )
|
||||
{
|
||||
DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a redef_option",
|
||||
id->Name(), name.c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue