mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Move IntrusivePtr and utility methods to the zeek namespace
This commit is contained in:
parent
4668378d91
commit
9364e6a5b7
255 changed files with 3761 additions and 3730 deletions
70
src/ID.cc
70
src/ID.cc
|
@ -19,24 +19,24 @@
|
|||
#include "zeekygen/ScriptInfo.h"
|
||||
#include "module_util.h"
|
||||
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::conn_id;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::endpoint;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::connection;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::fa_file;
|
||||
IntrusivePtr<zeek::RecordType> zeek::id::fa_metadata;
|
||||
IntrusivePtr<zeek::EnumType> zeek::id::transport_proto;
|
||||
IntrusivePtr<zeek::TableType> zeek::id::string_set;
|
||||
IntrusivePtr<zeek::TableType> zeek::id::string_array;
|
||||
IntrusivePtr<zeek::TableType> zeek::id::count_set;
|
||||
IntrusivePtr<zeek::VectorType> zeek::id::string_vec;
|
||||
IntrusivePtr<zeek::VectorType> zeek::id::index_vec;
|
||||
zeek::IntrusivePtr<zeek::RecordType> zeek::id::conn_id;
|
||||
zeek::IntrusivePtr<zeek::RecordType> zeek::id::endpoint;
|
||||
zeek::IntrusivePtr<zeek::RecordType> zeek::id::connection;
|
||||
zeek::IntrusivePtr<zeek::RecordType> zeek::id::fa_file;
|
||||
zeek::IntrusivePtr<zeek::RecordType> zeek::id::fa_metadata;
|
||||
zeek::IntrusivePtr<zeek::EnumType> zeek::id::transport_proto;
|
||||
zeek::IntrusivePtr<zeek::TableType> zeek::id::string_set;
|
||||
zeek::IntrusivePtr<zeek::TableType> zeek::id::string_array;
|
||||
zeek::IntrusivePtr<zeek::TableType> zeek::id::count_set;
|
||||
zeek::IntrusivePtr<zeek::VectorType> zeek::id::string_vec;
|
||||
zeek::IntrusivePtr<zeek::VectorType> zeek::id::index_vec;
|
||||
|
||||
const IntrusivePtr<zeek::detail::ID>& zeek::id::find(std::string_view name)
|
||||
const zeek::IntrusivePtr<zeek::detail::ID>& zeek::id::find(std::string_view name)
|
||||
{
|
||||
return global_scope()->Find(name);
|
||||
}
|
||||
|
||||
const IntrusivePtr<zeek::Type>& zeek::id::find_type(std::string_view name)
|
||||
const zeek::IntrusivePtr<zeek::Type>& zeek::id::find_type(std::string_view name)
|
||||
{
|
||||
auto id = global_scope()->Find(name);
|
||||
|
||||
|
@ -47,7 +47,7 @@ const IntrusivePtr<zeek::Type>& zeek::id::find_type(std::string_view name)
|
|||
return id->GetType();
|
||||
}
|
||||
|
||||
const IntrusivePtr<Val>& zeek::id::find_val(std::string_view name)
|
||||
const zeek::IntrusivePtr<Val>& zeek::id::find_val(std::string_view name)
|
||||
{
|
||||
auto id = global_scope()->Find(name);
|
||||
|
||||
|
@ -58,7 +58,7 @@ const IntrusivePtr<Val>& zeek::id::find_val(std::string_view name)
|
|||
return id->GetVal();
|
||||
}
|
||||
|
||||
const IntrusivePtr<Val>& zeek::id::find_const(std::string_view name)
|
||||
const zeek::IntrusivePtr<Val>& zeek::id::find_const(std::string_view name)
|
||||
{
|
||||
auto id = global_scope()->Find(name);
|
||||
|
||||
|
@ -73,7 +73,7 @@ const IntrusivePtr<Val>& zeek::id::find_const(std::string_view name)
|
|||
return id->GetVal();
|
||||
}
|
||||
|
||||
IntrusivePtr<Func> zeek::id::find_func(std::string_view name)
|
||||
zeek::IntrusivePtr<Func> zeek::id::find_func(std::string_view name)
|
||||
{
|
||||
const auto& v = zeek::id::find_val(name);
|
||||
|
||||
|
@ -130,7 +130,7 @@ std::string ID::ModuleName() const
|
|||
return extract_module_name(name);
|
||||
}
|
||||
|
||||
void ID::SetType(IntrusivePtr<zeek::Type> t)
|
||||
void ID::SetType(zeek::IntrusivePtr<zeek::Type> t)
|
||||
{
|
||||
type = std::move(t);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void ID::ClearVal()
|
|||
val = nullptr;
|
||||
}
|
||||
|
||||
void ID::SetVal(IntrusivePtr<Val> v)
|
||||
void ID::SetVal(zeek::IntrusivePtr<Val> v)
|
||||
{
|
||||
val = std::move(v);
|
||||
Modified();
|
||||
|
@ -169,7 +169,7 @@ void ID::SetVal(IntrusivePtr<Val> v)
|
|||
}
|
||||
}
|
||||
|
||||
void ID::SetVal(IntrusivePtr<Val> v, InitClass c)
|
||||
void ID::SetVal(zeek::IntrusivePtr<Val> v, InitClass c)
|
||||
{
|
||||
if ( c == INIT_NONE || c == INIT_FULL )
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ void ID::SetVal(IntrusivePtr<Val> v, InitClass c)
|
|||
}
|
||||
}
|
||||
|
||||
void ID::SetVal(IntrusivePtr<Expr> ev, InitClass c)
|
||||
void ID::SetVal(zeek::IntrusivePtr<Expr> ev, InitClass c)
|
||||
{
|
||||
const auto& a = attrs->Find(c == INIT_EXTRA ? ATTR_ADD_FUNC : ATTR_DEL_FUNC);
|
||||
|
||||
|
@ -222,7 +222,7 @@ bool ID::IsRedefinable() const
|
|||
return GetAttr(ATTR_REDEF) != nullptr;
|
||||
}
|
||||
|
||||
void ID::SetAttrs(IntrusivePtr<Attributes> a)
|
||||
void ID::SetAttrs(zeek::IntrusivePtr<Attributes> a)
|
||||
{
|
||||
attrs = nullptr;
|
||||
AddAttrs(std::move(a));
|
||||
|
@ -260,15 +260,15 @@ void ID::UpdateValAttrs()
|
|||
TypeDecl* fd = rt->FieldDecl(i);
|
||||
|
||||
if ( ! fd->attrs )
|
||||
fd->attrs = make_intrusive<Attributes>(rt->GetFieldType(i), true, IsGlobal());
|
||||
fd->attrs = zeek::make_intrusive<Attributes>(rt->GetFieldType(i), true, IsGlobal());
|
||||
|
||||
fd->attrs->AddAttr(make_intrusive<Attr>(ATTR_LOG));
|
||||
fd->attrs->AddAttr(zeek::make_intrusive<Attr>(ATTR_LOG));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const IntrusivePtr<Attr>& ID::GetAttr(AttrTag t) const
|
||||
const zeek::IntrusivePtr<Attr>& ID::GetAttr(AttrTag t) const
|
||||
{
|
||||
return attrs ? attrs->Find(t) : Attr::nil;
|
||||
}
|
||||
|
@ -278,13 +278,13 @@ bool ID::IsDeprecated() const
|
|||
return GetAttr(ATTR_DEPRECATED) != nullptr;
|
||||
}
|
||||
|
||||
void ID::MakeDeprecated(IntrusivePtr<Expr> deprecation)
|
||||
void ID::MakeDeprecated(zeek::IntrusivePtr<Expr> deprecation)
|
||||
{
|
||||
if ( IsDeprecated() )
|
||||
return;
|
||||
|
||||
std::vector<IntrusivePtr<Attr>> attrv{make_intrusive<Attr>(ATTR_DEPRECATED, std::move(deprecation))};
|
||||
AddAttrs(make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
|
||||
std::vector<zeek::IntrusivePtr<Attr>> attrv{zeek::make_intrusive<Attr>(ATTR_DEPRECATED, std::move(deprecation))};
|
||||
AddAttrs(zeek::make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
|
||||
}
|
||||
|
||||
std::string ID::GetDeprecationWarning() const
|
||||
|
@ -308,7 +308,7 @@ std::string ID::GetDeprecationWarning() const
|
|||
return fmt("deprecated (%s): %s", Name(), result.c_str());
|
||||
}
|
||||
|
||||
void ID::AddAttrs(IntrusivePtr<Attributes> a)
|
||||
void ID::AddAttrs(zeek::IntrusivePtr<Attributes> a)
|
||||
{
|
||||
if ( attrs )
|
||||
attrs->AddAttrs(a);
|
||||
|
@ -334,18 +334,18 @@ void ID::SetOption()
|
|||
// option implied redefinable
|
||||
if ( ! IsRedefinable() )
|
||||
{
|
||||
std::vector<IntrusivePtr<Attr>> attrv{make_intrusive<Attr>(ATTR_REDEF)};
|
||||
AddAttrs(make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
|
||||
std::vector<zeek::IntrusivePtr<Attr>> attrv{zeek::make_intrusive<Attr>(ATTR_REDEF)};
|
||||
AddAttrs(zeek::make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
|
||||
}
|
||||
}
|
||||
|
||||
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
||||
void ID::EvalFunc(zeek::IntrusivePtr<Expr> ef, zeek::IntrusivePtr<Expr> ev)
|
||||
{
|
||||
auto arg1 = make_intrusive<zeek::detail::ConstExpr>(val);
|
||||
auto args = make_intrusive<zeek::detail::ListExpr>();
|
||||
auto arg1 = zeek::make_intrusive<zeek::detail::ConstExpr>(val);
|
||||
auto args = zeek::make_intrusive<zeek::detail::ListExpr>();
|
||||
args->Append(std::move(arg1));
|
||||
args->Append(std::move(ev));
|
||||
auto ce = make_intrusive<CallExpr>(std::move(ef), std::move(args));
|
||||
auto ce = zeek::make_intrusive<CallExpr>(std::move(ef), std::move(args));
|
||||
SetVal(ce->Eval(nullptr));
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ void ID::UpdateValID()
|
|||
}
|
||||
#endif
|
||||
|
||||
void ID::AddOptionHandler(IntrusivePtr<Func> callback, int priority)
|
||||
void ID::AddOptionHandler(zeek::IntrusivePtr<Func> callback, int priority)
|
||||
{
|
||||
option_handlers.emplace(priority, std::move(callback));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue