diff --git a/src/Attr.cc b/src/Attr.cc index 3920e05fde..913e84620d 100644 --- a/src/Attr.cc +++ b/src/Attr.cc @@ -9,6 +9,8 @@ #include "IntrusivePtr.h" #include "threading/SerialTypes.h" +namespace zeek::detail { + const char* attr_name(attr_tag t) { static const char* attr_names[int(NUM_ATTRS)] = { @@ -23,18 +25,26 @@ const char* attr_name(attr_tag t) return attr_names[int(t)]; } -Attr::Attr(attr_tag t, IntrusivePtr e) +Attr::Attr(attr_tag t, IntrusivePtr e) : expr(std::move(e)) { tag = t; SetLocationInfo(&start_location, &end_location); } +Attr::Attr(::attr_tag t, IntrusivePtr e) : Attr(static_cast(t), e) + { + } + Attr::Attr(attr_tag t) : Attr(t, nullptr) { } +Attr::Attr(::attr_tag t) : Attr(static_cast(t)) + { + } + Attr::~Attr() = default; void Attr::SetAttrExpr(IntrusivePtr e) @@ -90,7 +100,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const d->Add("="); d->SP(); - if ( expr->Tag() == zeek::detail::EXPR_NAME ) + if ( expr->Tag() == EXPR_NAME ) { d->Add(":zeek:see:`"); expr->Describe(d); @@ -104,7 +114,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const d->Add("`"); } - else if ( expr->Tag() == zeek::detail::EXPR_CONST ) + else if ( expr->Tag() == EXPR_CONST ) { ODesc dd; dd.SetQuotes(true); @@ -233,6 +243,11 @@ const IntrusivePtr& Attributes::Find(attr_tag t) const return Attr::nil; } +Attr* Attributes::FindAttr(::attr_tag t) const + { + return FindAttr(static_cast(t)); + } + void Attributes::RemoveAttr(attr_tag t) { for ( auto it = attrs.begin(); it != attrs.end(); ) @@ -244,6 +259,11 @@ void Attributes::RemoveAttr(attr_tag t) } } +void Attributes::RemoveAttr(::attr_tag t) + { + RemoveAttr(static_cast(t)); + } + void Attributes::Describe(ODesc* d) const { if ( attrs.empty() ) @@ -663,3 +683,5 @@ bool Attributes::operator==(const Attributes& other) const return true; } + +} diff --git a/src/Attr.h b/src/Attr.h index 7e1fb62e17..828808b4b1 100644 --- a/src/Attr.h +++ b/src/Attr.h @@ -14,7 +14,7 @@ FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); // modify expressions or supply metadata on types, and the kind that // are extra metadata on every variable instance. -typedef enum { +enum [[deprecated("Remove in v4.1. Use zeek::detail::attr_tag instead.")]] attr_tag { ATTR_OPTIONAL, ATTR_DEFAULT, ATTR_REDEF, @@ -33,15 +33,45 @@ typedef enum { ATTR_TRACKED, // hidden attribute, tracked by NotifierRegistry ATTR_ON_CHANGE, // for table change tracking ATTR_DEPRECATED, -#define NUM_ATTRS (int(ATTR_DEPRECATED) + 1) -} attr_tag; + NUM_ATTRS // this item should always be last +}; + +namespace zeek::detail { + +enum attr_tag { + ATTR_OPTIONAL, + ATTR_DEFAULT, + ATTR_REDEF, + ATTR_ADD_FUNC, + ATTR_DEL_FUNC, + ATTR_EXPIRE_FUNC, + ATTR_EXPIRE_READ, + ATTR_EXPIRE_WRITE, + ATTR_EXPIRE_CREATE, + ATTR_RAW_OUTPUT, + ATTR_PRIORITY, + ATTR_GROUP, + ATTR_LOG, + ATTR_ERROR_HANDLER, + ATTR_TYPE_COLUMN, // for input framework + ATTR_TRACKED, // hidden attribute, tracked by NotifierRegistry + ATTR_ON_CHANGE, // for table change tracking + ATTR_DEPRECATED, + NUM_ATTRS // this item should always be last +}; class Attr final : public BroObj { public: - static inline const IntrusivePtr nil; + static inline const IntrusivePtr nil; Attr(attr_tag t, IntrusivePtr e); + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]] + Attr(::attr_tag t, IntrusivePtr e); + explicit Attr(attr_tag t); + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]] + explicit Attr(::attr_tag t); + ~Attr() override; attr_tag Tag() const { return tag; } @@ -75,7 +105,7 @@ protected: void AddTag(ODesc* d) const; attr_tag tag; - IntrusivePtr expr; + IntrusivePtr expr; }; // Manages a collection of attributes. @@ -97,10 +127,14 @@ public: [[deprecated("Remove in v4.1. Use Find().")]] Attr* FindAttr(attr_tag t) const; + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]] + Attr* FindAttr(::attr_tag t) const; const IntrusivePtr& Find(attr_tag t) const; void RemoveAttr(attr_tag t); + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]] + void RemoveAttr(::attr_tag t); void Describe(ODesc* d) const override; void DescribeReST(ODesc* d, bool shorten = false) const; @@ -118,3 +152,8 @@ protected: bool in_record; bool global_var; }; + +} + +using Attr [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attr; +using Attributes [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attributes; diff --git a/src/BroList.h b/src/BroList.h index fa30fa663f..410dd950d9 100644 --- a/src/BroList.h +++ b/src/BroList.h @@ -4,23 +4,23 @@ #include "List.h" +class Val; +using val_list = PList; + FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); -typedef PList expr_list; +using expr_list = PList; FORWARD_DECLARE_NAMESPACED(ID, zeek::detail); -typedef PList id_list; - -class Val; -typedef PList val_list; +using id_list = PList; FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); -typedef PList stmt_list; +using stmt_list = PList; class BroType; -typedef PList type_list; +using type_list = PList; -class Attr; -typedef PList attr_list; +FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail); +using attr_list = PList; class Timer; -typedef PList timer_list; +using timer_list = PList; diff --git a/src/CompHash.cc b/src/CompHash.cc index e8d2c5a681..aff8f65ac8 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -183,8 +183,8 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0, { auto rv_i = rv->GetField(i).get(); - Attributes* a = rt->FieldDecl(i)->attrs.get(); - bool optional = (a && a->Find(ATTR_OPTIONAL)); + zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get(); + bool optional = (a && a->Find(zeek::detail::ATTR_OPTIONAL)); if ( ! (rv_i || optional) ) return nullptr; @@ -514,8 +514,8 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v, for ( int i = 0; i < num_fields; ++i ) { - Attributes* a = rt->FieldDecl(i)->attrs.get(); - bool optional = (a && a->Find(ATTR_OPTIONAL)); + zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get(); + bool optional = (a && a->Find(zeek::detail::ATTR_OPTIONAL)); sz = SingleTypeKeySize(rt->GetFieldType(i).get(), rv ? rv->GetField(i).get() : nullptr, @@ -908,8 +908,8 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0, { IntrusivePtr v; - Attributes* a = rt->FieldDecl(i)->attrs.get(); - bool optional = (a && a->Find(ATTR_OPTIONAL)); + zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get(); + bool optional = (a && a->Find(zeek::detail::ATTR_OPTIONAL)); kp = RecoverOneVal(k, kp, k_end, rt->GetFieldType(i).get(), &v, optional); diff --git a/src/File.cc b/src/File.cc index a360fbf8a7..c27cd16773 100644 --- a/src/File.cc +++ b/src/File.cc @@ -257,7 +257,7 @@ void BroFile::Describe(ODesc* d) const d->Add("(no type)"); } -void BroFile::SetAttrs(Attributes* arg_attrs) +void BroFile::SetAttrs(zeek::detail::Attributes* arg_attrs) { if ( ! arg_attrs ) return; @@ -265,7 +265,7 @@ void BroFile::SetAttrs(Attributes* arg_attrs) attrs = arg_attrs; Ref(attrs); - if ( attrs->Find(ATTR_RAW_OUTPUT) ) + if ( attrs->Find(zeek::detail::ATTR_RAW_OUTPUT) ) EnableRawOutput(); } diff --git a/src/File.h b/src/File.h index ab7ac5a993..09093b85c8 100644 --- a/src/File.h +++ b/src/File.h @@ -16,11 +16,11 @@ #include "IntrusivePtr.h" #include "util.h" -class Attributes; class BroType; class RecordVal; FORWARD_DECLARE_NAMESPACED(PrintStmt, zeek::detail); +FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail); class BroFile final : public BroObj { public: @@ -61,7 +61,7 @@ public: RecordVal* Rotate(); // Set &raw_output attribute. - void SetAttrs(Attributes* attrs); + void SetAttrs(zeek::detail::Attributes* attrs); // Returns the current size of the file, after fresh stat'ing. double Size(); @@ -107,7 +107,7 @@ protected: IntrusivePtr t; char* name; char* access; - Attributes* attrs; + zeek::detail::Attributes* attrs; double open_time; bool is_open; // whether the file is open in a general sense bool buffered; diff --git a/src/Func.cc b/src/Func.cc index c2a498ceb5..d0d456ef38 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -844,16 +844,16 @@ bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call) // Gets a function's priority from its Scope's attributes. Errors if it sees any // problems. -static int get_func_priority(const std::vector>& attrs) +static int get_func_priority(const std::vector>& attrs) { int priority = 0; for ( const auto& a : attrs ) { - if ( a->Tag() == ATTR_DEPRECATED ) + if ( a->Tag() == zeek::detail::ATTR_DEPRECATED ) continue; - if ( a->Tag() != ATTR_PRIORITY ) + if ( a->Tag() != zeek::detail::ATTR_PRIORITY ) { a->Error("illegal attribute for function body"); continue; diff --git a/src/ID.cc b/src/ID.cc index 73bd2b50cb..a35118a562 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -337,6 +337,11 @@ void ID::RemoveAttr(attr_tag a) attrs->RemoveAttr(a); } +void ID::RemoveAttr(::attr_tag a) + { + RemoveAttr(static_cast(a)); + } + void ID::SetOption() { if ( is_option ) diff --git a/src/ID.h b/src/ID.h index 5da63d9a29..ff34218b54 100644 --- a/src/ID.h +++ b/src/ID.h @@ -20,13 +20,13 @@ class RecordType; class TableType; class VectorType; class EnumType; -class Attributes; enum [[deprecated("Remove in v4.1. Use zeek::detail::init_class instead.")]] init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, }; enum [[deprecated("Remove in v4.1. Use zeek::detail::IDScope instead.")]] IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL }; namespace zeek::detail { +class Attributes; class Expr; enum init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, }; @@ -116,6 +116,8 @@ public: void SetAttrs(IntrusivePtr attr); void AddAttrs(IntrusivePtr attr); void RemoveAttr(attr_tag a); + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag")]] + void RemoveAttr(::attr_tag a); void UpdateValAttrs(); const IntrusivePtr& GetAttrs() const @@ -125,10 +127,10 @@ public: Attributes* Attrs() const { return attrs.get(); } [[deprecated("Remove in 4.1. Use GetAttr().")]] - Attr* FindAttr(attr_tag t) const - { return GetAttr(t).get(); } + Attr* FindAttr(::attr_tag t) const + { return GetAttr(static_cast(t)).get(); } - const IntrusivePtr& GetAttr(attr_tag t) const; + const IntrusivePtr& GetAttr(zeek::detail::attr_tag t) const; bool IsDeprecated() const; diff --git a/src/Scope.cc b/src/Scope.cc index 008c43ff54..6872039fc8 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -16,7 +16,7 @@ static scope_list scopes; static Scope* top_scope; Scope::Scope(IntrusivePtr id, - std::unique_ptr>> al) + std::unique_ptr>> al) : scope_id(std::move(id)), attrs(std::move(al)) { return_type = nullptr; @@ -190,7 +190,7 @@ void push_existing_scope(Scope* scope) } void push_scope(IntrusivePtr id, - std::unique_ptr>> attrs) + std::unique_ptr>> attrs) { top_scope = new Scope(std::move(id), std::move(attrs)); scopes.push_back(top_scope); diff --git a/src/Scope.h b/src/Scope.h index 9ae4d5d976..6596f5ea64 100644 --- a/src/Scope.h +++ b/src/Scope.h @@ -21,7 +21,7 @@ FORWARD_DECLARE_NAMESPACED(ID, zeek::detail); class Scope : public BroObj { public: explicit Scope(IntrusivePtr id, - std::unique_ptr>> al); + std::unique_ptr>> al); const IntrusivePtr& Find(std::string_view name) const; @@ -41,7 +41,7 @@ public: const IntrusivePtr& GetID() const { return scope_id; } - const std::unique_ptr>>& Attrs() const + const std::unique_ptr>>& Attrs() const { return attrs; } [[deprecated("Remove in v4.1. Use GetReturnTrype().")]] @@ -69,7 +69,7 @@ public: protected: IntrusivePtr scope_id; - std::unique_ptr>> attrs; + std::unique_ptr>> attrs; IntrusivePtr return_type; std::map, std::less<>> local; std::vector> inits; @@ -88,7 +88,7 @@ extern IntrusivePtr install_ID(const char* name, const char* m bool is_global, bool is_export); extern void push_scope(IntrusivePtr id, - std::unique_ptr>> attrs); + std::unique_ptr>> attrs); extern void push_existing_scope(Scope* scope); // Returns the one popped off. diff --git a/src/Type.cc b/src/Type.cc index a6bbed2098..8c114c1df0 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -422,7 +422,7 @@ FuncType::FuncType(IntrusivePtr arg_args, { const TypeDecl* td = args->FieldDecl(i); - if ( td->attrs && td->attrs->Find(ATTR_DEFAULT) ) + if ( td->attrs && td->attrs->Find(zeek::detail::ATTR_DEFAULT) ) has_default_arg = true; else if ( has_default_arg ) @@ -608,7 +608,7 @@ std::optional FuncType::FindPrototype(const RecordType& arg } TypeDecl::TypeDecl(const char* i, IntrusivePtr t, - IntrusivePtr arg_attrs) + IntrusivePtr arg_attrs) : type(std::move(t)), attrs(std::move(arg_attrs)), id(i) @@ -687,7 +687,7 @@ IntrusivePtr RecordType::FieldDefault(int field) const if ( ! td->attrs ) return nullptr; - const auto& def_attr = td->attrs->Find(ATTR_DEFAULT); + const auto& def_attr = td->attrs->Find(zeek::detail::ATTR_DEFAULT); return def_attr ? def_attr->GetExpr()->Eval(nullptr) : nullptr; } @@ -807,7 +807,7 @@ IntrusivePtr RecordType::GetRecordFieldsVal(const RecordVal* rv) const if ( rv ) fv = rv->GetField(i); - bool logged = (fd->attrs && fd->GetAttr(ATTR_LOG) != nullptr); + bool logged = (fd->attrs && fd->GetAttr(zeek::detail::ATTR_LOG) != nullptr); auto nr = make_intrusive(record_field); @@ -832,7 +832,7 @@ const char* RecordType::AddFields(const type_decl_list& others, for ( const auto& td : others ) { - if ( ! td->GetAttr(ATTR_DEFAULT) && ! td->GetAttr(ATTR_OPTIONAL) ) + if ( ! td->GetAttr(zeek::detail::ATTR_DEFAULT) && ! td->GetAttr(zeek::detail::ATTR_OPTIONAL) ) return "extension field must be &optional or have &default"; } @@ -843,9 +843,9 @@ const char* RecordType::AddFields(const type_decl_list& others, if ( add_log_attr ) { if ( ! td->attrs ) - td->attrs = make_intrusive(td->type, true, false); + td->attrs = make_intrusive(td->type, true, false); - td->attrs->AddAttr(make_intrusive(ATTR_LOG)); + td->attrs->AddAttr(make_intrusive(zeek::detail::ATTR_LOG)); } types->push_back(td); @@ -993,7 +993,7 @@ string RecordType::GetFieldDeprecationWarning(int field, bool has_check) const if ( decl) { string result; - if ( const auto& deprecation = decl->GetAttr(ATTR_DEPRECATED) ) + if ( const auto& deprecation = decl->GetAttr(zeek::detail::ATTR_DEPRECATED) ) { auto expr = static_cast(deprecation->GetExpr().get()); if ( expr ) @@ -1559,7 +1559,7 @@ bool same_type(const BroType& arg_t1, const BroType& arg_t2, return false; } -bool same_attrs(const Attributes* a1, const Attributes* a2) +bool same_attrs(const zeek::detail::Attributes* a1, const zeek::detail::Attributes* a2) { if ( ! a1 ) return (a2 == nullptr); diff --git a/src/Type.h b/src/Type.h index 66100a65c8..cbc4a7878b 100644 --- a/src/Type.h +++ b/src/Type.h @@ -119,7 +119,6 @@ constexpr InternalTypeTag to_internal_type_tag(TypeTag tag) noexcept // Returns the name of the type. extern const char* type_name(TypeTag t); -class Attributes; class TypeList; class TableType; class SetType; @@ -135,6 +134,7 @@ class TableVal; FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); FORWARD_DECLARE_NAMESPACED(ListExpr, zeek::detail); +FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail); const int DOES_NOT_MATCH_INDEX = 0; const int MATCHES_INDEX_SCALAR = 1; @@ -564,21 +564,22 @@ protected: class TypeDecl final { public: TypeDecl() = default; - TypeDecl(const char* i, IntrusivePtr t, IntrusivePtr attrs = nullptr); + TypeDecl(const char* i, IntrusivePtr t, + IntrusivePtr attrs = nullptr); TypeDecl(const TypeDecl& other); ~TypeDecl(); [[deprecated("Remove in v4.1. Use GetAttr().")]] - const Attr* FindAttr(attr_tag a) const - { return attrs ? attrs->Find(a).get() : nullptr; } + const zeek::detail::Attr* FindAttr(::attr_tag a) const + { return attrs ? attrs->Find(static_cast(a)).get() : nullptr; } - const IntrusivePtr& GetAttr(attr_tag a) const - { return attrs ? attrs->Find(a) : Attr::nil; } + const IntrusivePtr& GetAttr(zeek::detail::attr_tag a) const + { return attrs ? attrs->Find(a) : zeek::detail::Attr::nil; } void DescribeReST(ODesc* d, bool roles_only = false) const; IntrusivePtr type; - IntrusivePtr attrs; + IntrusivePtr attrs; const char* id = nullptr; }; @@ -670,14 +671,19 @@ public: bool IsFieldDeprecated(int field) const { const TypeDecl* decl = FieldDecl(field); - return decl && decl->GetAttr(ATTR_DEPRECATED) != nullptr; + return decl && decl->GetAttr(zeek::detail::ATTR_DEPRECATED) != nullptr; } - bool FieldHasAttr(int field, attr_tag at) const + bool FieldHasAttr(int field, zeek::detail::attr_tag at) const { const TypeDecl* decl = FieldDecl(field); return decl && decl->GetAttr(at) != nullptr; } + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]] + bool FieldHasAttr(int field, ::attr_tag at) const + { + return FieldHasAttr(field, static_cast(at)); + } std::string GetFieldDeprecationWarning(int field, bool has_check) const; @@ -842,7 +848,7 @@ inline bool same_type(const BroType* t1, const IntrusivePtr& t2, { return same_type(*t1, *t2, is_init, match_record_field_names); } // True if the two attribute lists are equivalent. -extern bool same_attrs(const Attributes* a1, const Attributes* a2); +extern bool same_attrs(const zeek::detail::Attributes* a1, const zeek::detail::Attributes* a2); // Returns true if the record sub_rec can be promoted to the record // super_rec. diff --git a/src/Val.cc b/src/Val.cc index 9dc120028e..4ed394420d 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -588,7 +588,7 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val* { auto value = rval->GetFieldOrDefault(i); - if ( value && ( ! only_loggable || rt->FieldHasAttr(i, ATTR_LOG) ) ) + if ( value && ( ! only_loggable || rt->FieldHasAttr(i, zeek::detail::ATTR_LOG) ) ) { string key_str; auto field_name = rt->FieldName(i); @@ -1377,7 +1377,7 @@ static void find_nested_record_types(const IntrusivePtr& t, std::set t, IntrusivePtr a) : Val(t) +TableVal::TableVal(IntrusivePtr t, IntrusivePtr a) : Val(t) { Init(std::move(t)); SetAttrs(std::move(a)); @@ -1460,29 +1460,29 @@ int TableVal::RecursiveSize() const return n; } -void TableVal::SetAttrs(IntrusivePtr a) +void TableVal::SetAttrs(IntrusivePtr a) { attrs = std::move(a); if ( ! attrs ) return; - CheckExpireAttr(ATTR_EXPIRE_READ); - CheckExpireAttr(ATTR_EXPIRE_WRITE); - CheckExpireAttr(ATTR_EXPIRE_CREATE); + CheckExpireAttr(zeek::detail::ATTR_EXPIRE_READ); + CheckExpireAttr(zeek::detail::ATTR_EXPIRE_WRITE); + CheckExpireAttr(zeek::detail::ATTR_EXPIRE_CREATE); - const auto& ef = attrs->Find(ATTR_EXPIRE_FUNC); + const auto& ef = attrs->Find(zeek::detail::ATTR_EXPIRE_FUNC); if ( ef ) expire_func = ef->GetExpr(); - const auto& cf = attrs->Find(ATTR_ON_CHANGE); + const auto& cf = attrs->Find(zeek::detail::ATTR_ON_CHANGE); if ( cf ) change_func = cf->GetExpr(); } -void TableVal::CheckExpireAttr(attr_tag at) +void TableVal::CheckExpireAttr(zeek::detail::attr_tag at) { const auto& a = attrs->Find(at); @@ -1555,7 +1555,7 @@ bool TableVal::Assign(IntrusivePtr index, std::unique_ptr k, } // Keep old expiration time if necessary. - if ( old_entry_val && attrs && attrs->Find(ATTR_EXPIRE_CREATE) ) + if ( old_entry_val && attrs && attrs->Find(zeek::detail::ATTR_EXPIRE_CREATE) ) new_entry_val->SetExpireAccess(old_entry_val->ExpireAccessTime()); Modified(); @@ -1808,7 +1808,7 @@ bool TableVal::ExpandAndInit(IntrusivePtr index, IntrusivePtr new_val) IntrusivePtr TableVal::Default(const IntrusivePtr& index) { - const auto& def_attr = GetAttr(ATTR_DEFAULT); + const auto& def_attr = GetAttr(zeek::detail::ATTR_DEFAULT); if ( ! def_attr ) return nullptr; @@ -1897,7 +1897,7 @@ const IntrusivePtr& TableVal::Find(const IntrusivePtr& index) TableEntryVal* v = (TableEntryVal*) subnets->Lookup(index.get()); if ( v ) { - if ( attrs && attrs->Find(ATTR_EXPIRE_READ) ) + if ( attrs && attrs->Find(zeek::detail::ATTR_EXPIRE_READ) ) v->SetExpireAccess(network_time); if ( v->GetVal() ) @@ -1921,7 +1921,7 @@ const IntrusivePtr& TableVal::Find(const IntrusivePtr& index) if ( v ) { - if ( attrs && attrs->Find(ATTR_EXPIRE_READ) ) + if ( attrs && attrs->Find(zeek::detail::ATTR_EXPIRE_READ) ) v->SetExpireAccess(network_time); if ( v->GetVal() ) @@ -1993,7 +1993,7 @@ IntrusivePtr TableVal::LookupSubnetValues(const SubNetVal* search) if ( entry ) { - if ( attrs && attrs->Find(ATTR_EXPIRE_READ) ) + if ( attrs && attrs->Find(zeek::detail::ATTR_EXPIRE_READ) ) entry->SetExpireAccess(network_time); } } @@ -2195,9 +2195,9 @@ ListVal* TableVal::ConvertToPureList() const return ToPureListVal().release(); } -const IntrusivePtr& TableVal::GetAttr(attr_tag t) const +const IntrusivePtr& TableVal::GetAttr(zeek::detail::attr_tag t) const { - return attrs ? attrs->Find(t) : Attr::nil; + return attrs ? attrs->Find(t) : zeek::detail::Attr::nil; } void TableVal::Describe(ODesc* d) const @@ -2336,7 +2336,7 @@ void TableVal::InitDefaultFunc(Frame* f) if ( def_val ) return; - const auto& def_attr = GetAttr(ATTR_DEFAULT); + const auto& def_attr = GetAttr(zeek::detail::ATTR_DEFAULT); if ( ! def_attr ) return; @@ -2710,8 +2710,8 @@ RecordVal::RecordVal(IntrusivePtr t, bool init_fields) : Val(std::mo // by default). for ( int i = 0; i < n; ++i ) { - Attributes* a = rt->FieldDecl(i)->attrs.get(); - Attr* def_attr = a ? a->Find(ATTR_DEFAULT).get() : nullptr; + zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get(); + zeek::detail::Attr* def_attr = a ? a->Find(zeek::detail::ATTR_DEFAULT).get() : nullptr; auto def = def_attr ? def_attr->GetExpr()->Eval(nullptr) : nullptr; const auto& type = rt->FieldDecl(i)->type; @@ -2725,7 +2725,7 @@ RecordVal::RecordVal(IntrusivePtr t, bool init_fields) : Val(std::mo def = std::move(tmp); } - if ( ! def && ! (a && a->Find(ATTR_OPTIONAL)) ) + if ( ! def && ! (a && a->Find(zeek::detail::ATTR_OPTIONAL)) ) { TypeTag tag = type->Tag(); @@ -2878,7 +2878,7 @@ IntrusivePtr RecordVal::CoerceTo(IntrusivePtr t, for ( i = 0; i < ar_t->NumFields(); ++i ) if ( ! aggr->GetField(i) && - ! ar_t->FieldDecl(i)->GetAttr(ATTR_OPTIONAL) ) + ! ar_t->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) { char buf[512]; snprintf(buf, sizeof(buf), diff --git a/src/Val.h b/src/Val.h index 45aa98f626..30a0d213b9 100644 --- a/src/Val.h +++ b/src/Val.h @@ -758,7 +758,8 @@ class Frame; class TableVal final : public Val, public notifier::Modifiable { public: - explicit TableVal(IntrusivePtr t, IntrusivePtr attrs = nullptr); + explicit TableVal(IntrusivePtr t, IntrusivePtr attrs = nullptr); + [[deprecated("Remove in v4.1. Construct from IntrusivePtrs instead.")]] explicit TableVal(TableType* t, Attributes* attrs = nullptr) : TableVal({NewRef{}, t}, {NewRef{}, attrs}) @@ -943,18 +944,18 @@ public: [[deprecated("Remove in v4.1. Use ToPureListVal() instead.")]] ListVal* ConvertToPureList() const; // must be single index type - void SetAttrs(IntrusivePtr attrs); + void SetAttrs(IntrusivePtr attrs); [[deprecated("Remove in v4.1. Use GetAttr().")]] - Attr* FindAttr(attr_tag t) const - { return GetAttr(t).get(); } + Attr* FindAttr(::attr_tag t) const + { return GetAttr(static_cast(t)).get(); } - const IntrusivePtr& GetAttr(attr_tag t) const; + const IntrusivePtr& GetAttr(zeek::detail::attr_tag t) const; [[deprecated("Remove in v4.1. Use GetAttrs().")]] - Attributes* Attrs() { return attrs.get(); } + zeek::detail::Attributes* Attrs() { return attrs.get(); } - const IntrusivePtr& GetAttrs() const + const IntrusivePtr& GetAttrs() const { return attrs; } // Returns the size of the table. @@ -1020,7 +1021,9 @@ protected: ParseTimeTableState DumpTableState(); void RebuildTable(ParseTimeTableState ptts); - void CheckExpireAttr(attr_tag at); + void CheckExpireAttr(zeek::detail::attr_tag at); + [[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]] + void CheckExpireAttr(::attr_tag at); bool ExpandCompoundAndInit(ListVal* lv, int k, IntrusivePtr new_val); bool CheckAndAssign(IntrusivePtr index, IntrusivePtr new_val); @@ -1049,7 +1052,7 @@ protected: IntrusivePtr table_type; CompositeHash* table_hash; - IntrusivePtr attrs; + IntrusivePtr attrs; IntrusivePtr expire_time; IntrusivePtr expire_func; TableValTimer* timer; diff --git a/src/Var.cc b/src/Var.cc index bb8fda8975..3b75239350 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -17,6 +17,8 @@ #include "module_util.h" #include "ID.h" +using namespace zeek::detail; + static IntrusivePtr init_val(zeek::detail::Expr* init, const BroType* t, IntrusivePtr aggr) { @@ -31,7 +33,7 @@ static IntrusivePtr init_val(zeek::detail::Expr* init, const BroType* t, } static bool add_prototype(const IntrusivePtr& id, BroType* t, - std::vector>* attrs, + std::vector>* attrs, const IntrusivePtr& init) { if ( ! IsFunc(id->GetType()->Tag()) ) @@ -100,7 +102,7 @@ static bool add_prototype(const IntrusivePtr& id, BroType* t, if ( attrs ) for ( const auto& a : *attrs ) - if ( a->Tag() == ATTR_DEPRECATED ) + if ( a->Tag() == zeek::detail::ATTR_DEPRECATED ) deprecated = true; FuncType::Prototype p{deprecated, alt_args, std::move(offsets)}; @@ -111,7 +113,7 @@ static bool add_prototype(const IntrusivePtr& id, BroType* t, static void make_var(const IntrusivePtr& id, IntrusivePtr t, zeek::detail::init_class c, IntrusivePtr init, - std::unique_ptr>> attr, + std::unique_ptr>> attr, decl_type dt, bool do_init) { @@ -200,7 +202,7 @@ static void make_var(const IntrusivePtr& id, IntrusivePtrSetType(t); if ( attr ) - id->AddAttrs(make_intrusive(std::move(*attr), t, false, id->IsGlobal())); + id->AddAttrs(make_intrusive(std::move(*attr), t, false, id->IsGlobal())); if ( init ) { @@ -234,8 +236,8 @@ static void make_var(const IntrusivePtr& id, IntrusivePtrGetAttr(ATTR_ADD_FUNC)) || - (c == zeek::detail::INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) )) + if ( init && ((c == zeek::detail::INIT_EXTRA && id->GetAttr(zeek::detail::ATTR_ADD_FUNC)) || + (c == zeek::detail::INIT_REMOVE && id->GetAttr(zeek::detail::ATTR_DEL_FUNC)) )) // Just apply the function. id->SetVal(init, c); @@ -310,7 +312,7 @@ static void make_var(const IntrusivePtr& id, IntrusivePtr& id, IntrusivePtr t, zeek::detail::init_class c, IntrusivePtr init, - std::unique_ptr>> attr, + std::unique_ptr>> attr, decl_type dt) { make_var(id, std::move(t), c, std::move(init), std::move(attr), dt, true); @@ -318,7 +320,7 @@ void add_global(const IntrusivePtr& id, IntrusivePtr IntrusivePtr add_local(IntrusivePtr id, IntrusivePtr t, zeek::detail::init_class c, IntrusivePtr init, - std::unique_ptr>> attr, + std::unique_ptr>> attr, decl_type dt) { make_var(id, std::move(t), c, init, std::move(attr), dt, false); @@ -359,7 +361,7 @@ extern IntrusivePtr add_and_assign_local(IntrusivePtr t, - std::unique_ptr>> attr) + std::unique_ptr>> attr) { std::string new_type_name = id->Name(); std::string old_type_name = t->GetName(); @@ -384,7 +386,7 @@ void add_type(zeek::detail::ID* id, IntrusivePtr t, id->MakeType(); if ( attr ) - id->SetAttrs(make_intrusive(std::move(*attr), tnew, false, false)); + id->SetAttrs(make_intrusive(std::move(*attr), tnew, false, false)); } static void transfer_arg_defaults(RecordType* args, RecordType* recv) @@ -394,25 +396,26 @@ static void transfer_arg_defaults(RecordType* args, RecordType* recv) TypeDecl* args_i = args->FieldDecl(i); TypeDecl* recv_i = recv->FieldDecl(i); - const auto& def = args_i->attrs ? args_i->attrs->Find(ATTR_DEFAULT) : nullptr; + const auto& def = args_i->attrs ? args_i->attrs->Find(zeek::detail::ATTR_DEFAULT) : nullptr; if ( ! def ) continue; if ( ! recv_i->attrs ) { - std::vector> a{def}; - recv_i->attrs = make_intrusive(std::move(a), - recv_i->type, - true, false); + std::vector> a{def}; + recv_i->attrs = make_intrusive(std::move(a), + recv_i->type, + true, false); } - else if ( ! recv_i->attrs->Find(ATTR_DEFAULT) ) + else if ( ! recv_i->attrs->Find(zeek::detail::ATTR_DEFAULT) ) recv_i->attrs->AddAttr(def); } } -static Attr* find_attr(const std::vector>* al, attr_tag tag) +static zeek::detail::Attr* find_attr(const std::vector>* al, + zeek::detail::attr_tag tag) { if ( ! al ) return nullptr; @@ -462,7 +465,7 @@ static bool canonical_arg_types_match(const FuncType* decl, const FuncType* impl void begin_func(IntrusivePtr id, const char* module_name, function_flavor flavor, bool is_redef, IntrusivePtr t, - std::unique_ptr>> attrs) + std::unique_ptr>> attrs) { if ( flavor == FUNC_FLAVOR_EVENT ) { @@ -502,7 +505,7 @@ void begin_func(IntrusivePtr id, const char* module_name, { auto f = args->FieldDecl(i); - if ( f->attrs && f->attrs->Find(ATTR_DEFAULT) ) + if ( f->attrs && f->attrs->Find(zeek::detail::ATTR_DEFAULT) ) { reporter->PushLocation(args->GetLocationInfo()); reporter->Warning( @@ -579,8 +582,8 @@ void begin_func(IntrusivePtr id, const char* module_name, arg_id->SetOffset(prototype->offsets[i]); } - if ( Attr* depr_attr = find_attr(current_scope()->Attrs().get(), - ATTR_DEPRECATED) ) + if ( zeek::detail::Attr* depr_attr = find_attr(current_scope()->Attrs().get(), + zeek::detail::ATTR_DEPRECATED) ) current_scope()->GetID()->MakeDeprecated(depr_attr->GetExpr()); } diff --git a/src/Var.h b/src/Var.h index 696fdb7a29..f219277352 100644 --- a/src/Var.h +++ b/src/Var.h @@ -22,14 +22,14 @@ extern void add_global(const IntrusivePtr& id, IntrusivePtr t, zeek::detail::init_class c, IntrusivePtr init, - std::unique_ptr>> attr, + std::unique_ptr>> attr, decl_type dt); extern IntrusivePtr add_local(IntrusivePtr id, IntrusivePtr t, zeek::detail::init_class c, IntrusivePtr init, - std::unique_ptr>> attr, + std::unique_ptr>> attr, decl_type dt); extern IntrusivePtr add_and_assign_local(IntrusivePtr id, @@ -37,12 +37,12 @@ extern IntrusivePtr add_and_assign_local(IntrusivePtr val = nullptr); extern void add_type(zeek::detail::ID* id, IntrusivePtr t, - std::unique_ptr>> attr); + std::unique_ptr>> attr); extern void begin_func(IntrusivePtr id, const char* module_name, function_flavor flavor, bool is_redef, IntrusivePtr t, - std::unique_ptr>> attrs = nullptr); + std::unique_ptr>> attrs = nullptr); extern void end_func(IntrusivePtr body); diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 73474353c8..31ce39b1a4 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -884,7 +884,6 @@ bool Manager::UnrollRecordType(vector *fields, const RecordType *rec, { for ( int i = 0; i < rec->NumFields(); i++ ) { - if ( ! IsCompatibleType(rec->GetFieldType(i).get()) ) { string name = nameprepend + rec->FieldName(i); @@ -897,7 +896,7 @@ bool Manager::UnrollRecordType(vector *fields, const RecordType *rec, if ( ( rec->GetFieldType(i)->Tag() == TYPE_FILE || rec->GetFieldType(i)->Tag() == TYPE_FUNC || rec->GetFieldType(i)->Tag() == TYPE_OPAQUE ) && - rec->FieldDecl(i)->GetAttr(ATTR_OPTIONAL) ) + rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) { reporter->Info("Encountered incompatible type \"%s\" in type definition for field \"%s\" in ReaderFrontend. Ignoring optional field.", type_name(rec->GetFieldType(i)->Tag()), name.c_str()); continue; @@ -912,7 +911,7 @@ bool Manager::UnrollRecordType(vector *fields, const RecordType *rec, { string prep = nameprepend + rec->FieldName(i) + "."; - if ( rec->FieldDecl(i)->GetAttr(ATTR_OPTIONAL) ) + if ( rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) ) { reporter->Info("The input framework does not support optional record fields: \"%s\"", rec->FieldName(i)); return false; @@ -941,11 +940,11 @@ bool Manager::UnrollRecordType(vector *fields, const RecordType *rec, st = rec->GetFieldType(i)->AsVectorType()->Yield()->Tag(); else if ( ty == TYPE_PORT && - rec->FieldDecl(i)->GetAttr(ATTR_TYPE_COLUMN) ) + rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_TYPE_COLUMN) ) { // we have an annotation for the second column - c = rec->FieldDecl(i)->GetAttr(ATTR_TYPE_COLUMN)->GetExpr()->Eval(nullptr); + c = rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_TYPE_COLUMN)->GetExpr()->Eval(nullptr); assert(c); assert(c->GetType()->Tag() == TYPE_STRING); @@ -953,7 +952,7 @@ bool Manager::UnrollRecordType(vector *fields, const RecordType *rec, secondary = c->AsStringVal()->AsString()->CheckString(); } - if ( rec->FieldDecl(i)->GetAttr(ATTR_OPTIONAL ) ) + if ( rec->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL ) ) optional = true; Field* field = new Field(name.c_str(), secondary, ty, st, optional); @@ -1867,7 +1866,7 @@ RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *v // Hence -> assign null to the field, done. // Better check that it really is optional. Uou never know. - assert(request_type->FieldDecl(i)->GetAttr(ATTR_OPTIONAL)); + assert(request_type->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL)); } else { diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 434c25304f..25fa2b2f83 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -243,7 +243,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval) for ( int i = 0; i < columns->NumFields(); i++ ) { - if ( ! (columns->FieldDecl(i)->GetAttr(ATTR_LOG)) ) + if ( ! (columns->FieldDecl(i)->GetAttr(zeek::detail::ATTR_LOG)) ) continue; if ( ! threading::Value::IsCompatibleType(columns->GetFieldType(i).get()) ) @@ -411,7 +411,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, const auto& t = rtype->GetFieldType(i); // Ignore if &log not specified. - if ( ! rtype->FieldDecl(i)->GetAttr(ATTR_LOG) ) + if ( ! rtype->FieldDecl(i)->GetAttr(zeek::detail::ATTR_LOG) ) continue; list new_indices = indices; @@ -517,7 +517,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, else if ( t->Tag() == TYPE_VECTOR ) st = t->AsVectorType()->Yield()->Tag(); - bool optional = (bool)rtype->FieldDecl(i)->GetAttr(ATTR_OPTIONAL); + bool optional = (bool)rtype->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL); filter->fields[filter->num_fields - 1] = new threading::Field(new_path.c_str(), nullptr, t->Tag(), st, optional); } diff --git a/src/parse.y b/src/parse.y index 91361fe6db..5f80acfb5f 100644 --- a/src/parse.y +++ b/src/parse.y @@ -167,7 +167,7 @@ static void parser_redef_enum (zeek::detail::ID *id) } static void extend_record(zeek::detail::ID* id, std::unique_ptr fields, - std::unique_ptr>> attrs) + std::unique_ptr>> attrs) { std::set types = BroType::GetAliases(id->Name()); @@ -181,7 +181,7 @@ static void extend_record(zeek::detail::ID* id, std::unique_ptr if ( attrs ) for ( const auto& at : *attrs ) - if ( at->Tag() == ATTR_LOG ) + if ( at->Tag() == zeek::detail::ATTR_LOG ) { add_log_attr = true; break; @@ -199,14 +199,14 @@ static void extend_record(zeek::detail::ID* id, std::unique_ptr } } -static IntrusivePtr -make_attributes(std::vector>* attrs, +static IntrusivePtr +make_attributes(std::vector>* attrs, IntrusivePtr t, bool in_record, bool is_global) { if ( ! attrs ) return nullptr; - auto rval = make_intrusive(std::move(*attrs), std::move(t), + auto rval = make_intrusive(std::move(*attrs), std::move(t), in_record, is_global); delete attrs; return rval; @@ -249,9 +249,9 @@ static bool expr_is_table_type_name(const zeek::detail::Expr* expr) type_decl_list* type_decl_l; zeek::detail::Case* c_case; zeek::detail::case_list* case_l; - Attr* attr; - std::vector>* attr_l; - attr_tag attrtag; + zeek::detail::Attr* attr; + std::vector>* attr_l; + zeek::detail::attr_tag attrtag; } %% @@ -562,14 +562,14 @@ expr: opt_attr { // the ++in_init fixes up the parsing of "[x] = y" set_location(@1, @5); - std::unique_ptr>> attrs{$7}; + std::unique_ptr>> attrs{$7}; $$ = new zeek::detail::TableConstructorExpr({AdoptRef{}, $4}, std::move(attrs)); } | TOK_SET '(' opt_expr_list ')' opt_attr { set_location(@1, @4); - std::unique_ptr>> attrs{$5}; + std::unique_ptr>> attrs{$5}; $$ = new zeek::detail::SetConstructorExpr({AdoptRef{}, $3}, std::move(attrs)); } @@ -1083,7 +1083,7 @@ decl: { IntrusivePtr id{AdoptRef{}, $2}; add_global(id, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5}, - std::unique_ptr>>{$6}, + std::unique_ptr>>{$6}, VAR_REGULAR); zeekygen_mgr->Identifier(std::move(id)); } @@ -1092,7 +1092,7 @@ decl: { IntrusivePtr id{AdoptRef{}, $2}; add_global(id, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5}, - std::unique_ptr>>{$6}, + std::unique_ptr>>{$6}, VAR_OPTION); zeekygen_mgr->Identifier(std::move(id)); } @@ -1101,7 +1101,7 @@ decl: { IntrusivePtr id{AdoptRef{}, $2}; add_global(id, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5}, - std::unique_ptr>>{$6}, + std::unique_ptr>>{$6}, VAR_CONST); zeekygen_mgr->Identifier(std::move(id)); } @@ -1111,7 +1111,7 @@ decl: IntrusivePtr id{AdoptRef{}, $2}; IntrusivePtr init{AdoptRef{}, $5}; add_global(id, {AdoptRef{}, $3}, $4, init, - std::unique_ptr>>{$6}, + std::unique_ptr>>{$6}, VAR_REDEF); zeekygen_mgr->Redef(id.get(), ::filename, $4, std::move(init)); } @@ -1137,7 +1137,7 @@ decl: $3->Error("unknown identifier"); else extend_record($3, std::unique_ptr($8), - std::unique_ptr>>($11)); + std::unique_ptr>>($11)); } | TOK_TYPE global_id ':' @@ -1147,7 +1147,7 @@ decl: cur_decl_type_id = 0; IntrusivePtr id{AdoptRef{}, $2}; add_type(id.get(), {AdoptRef{}, $5}, - std::unique_ptr>>{$6}); + std::unique_ptr>>{$6}); zeekygen_mgr->Identifier(std::move(id)); } @@ -1181,7 +1181,7 @@ func_hdr: IntrusivePtr id{AdoptRef{}, $2}; begin_func(id, current_module.c_str(), FUNC_FLAVOR_FUNCTION, 0, {NewRef{}, $3}, - std::unique_ptr>>{$4}); + std::unique_ptr>>{$4}); $$ = $3; zeekygen_mgr->Identifier(std::move(id)); } @@ -1196,7 +1196,7 @@ func_hdr: begin_func({NewRef{}, $2}, current_module.c_str(), FUNC_FLAVOR_EVENT, 0, {NewRef{}, $3}, - std::unique_ptr>>{$4}); + std::unique_ptr>>{$4}); $$ = $3; } | TOK_HOOK def_global_id func_params opt_attr @@ -1205,14 +1205,14 @@ func_hdr: $3->SetYieldType(base_type(TYPE_BOOL)); begin_func({NewRef{}, $2}, current_module.c_str(), FUNC_FLAVOR_HOOK, 0, {NewRef{}, $3}, - std::unique_ptr>>{$4}); + std::unique_ptr>>{$4}); $$ = $3; } | TOK_REDEF TOK_EVENT event_id func_params opt_attr { begin_func({NewRef{}, $3}, current_module.c_str(), FUNC_FLAVOR_EVENT, 1, {NewRef{}, $4}, - std::unique_ptr>>{$5}); + std::unique_ptr>>{$5}); $$ = $4; } ; @@ -1347,48 +1347,50 @@ attr_list: { $1->emplace_back(AdoptRef{}, $2); } | attr { - $$ = new std::vector>; + $$ = new std::vector>; $$->emplace_back(AdoptRef{}, $1); } ; attr: TOK_ATTR_DEFAULT '=' expr - { $$ = new Attr(ATTR_DEFAULT, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_DEFAULT, {AdoptRef{}, $3}); } | TOK_ATTR_OPTIONAL - { $$ = new Attr(ATTR_OPTIONAL); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_OPTIONAL); } | TOK_ATTR_REDEF - { $$ = new Attr(ATTR_REDEF); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_REDEF); } | TOK_ATTR_ADD_FUNC '=' expr - { $$ = new Attr(ATTR_ADD_FUNC, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_ADD_FUNC, {AdoptRef{}, $3}); } | TOK_ATTR_DEL_FUNC '=' expr - { $$ = new Attr(ATTR_DEL_FUNC, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_DEL_FUNC, {AdoptRef{}, $3}); } | TOK_ATTR_ON_CHANGE '=' expr - { $$ = new Attr(ATTR_ON_CHANGE, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_ON_CHANGE, {AdoptRef{}, $3}); } | TOK_ATTR_EXPIRE_FUNC '=' expr - { $$ = new Attr(ATTR_EXPIRE_FUNC, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_EXPIRE_FUNC, {AdoptRef{}, $3}); } | TOK_ATTR_EXPIRE_CREATE '=' expr - { $$ = new Attr(ATTR_EXPIRE_CREATE, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_EXPIRE_CREATE, {AdoptRef{}, $3}); } | TOK_ATTR_EXPIRE_READ '=' expr - { $$ = new Attr(ATTR_EXPIRE_READ, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_EXPIRE_READ, {AdoptRef{}, $3}); } | TOK_ATTR_EXPIRE_WRITE '=' expr - { $$ = new Attr(ATTR_EXPIRE_WRITE, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_EXPIRE_WRITE, {AdoptRef{}, $3}); } | TOK_ATTR_RAW_OUTPUT - { $$ = new Attr(ATTR_RAW_OUTPUT); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_RAW_OUTPUT); } | TOK_ATTR_PRIORITY '=' expr - { $$ = new Attr(ATTR_PRIORITY, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_PRIORITY, {AdoptRef{}, $3}); } | TOK_ATTR_TYPE_COLUMN '=' expr - { $$ = new Attr(ATTR_TYPE_COLUMN, {AdoptRef{}, $3}); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_TYPE_COLUMN, {AdoptRef{}, $3}); } | TOK_ATTR_LOG - { $$ = new Attr(ATTR_LOG); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_LOG); } | TOK_ATTR_ERROR_HANDLER - { $$ = new Attr(ATTR_ERROR_HANDLER); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_ERROR_HANDLER); } | TOK_ATTR_DEPRECATED - { $$ = new Attr(ATTR_DEPRECATED); } + { $$ = new zeek::detail::Attr(zeek::detail::ATTR_DEPRECATED); } | TOK_ATTR_DEPRECATED '=' TOK_CONSTANT { if ( IsString($3->GetType()->Tag()) ) - $$ = new Attr(ATTR_DEPRECATED, make_intrusive(IntrusivePtr{AdoptRef{}, $3})); + $$ = new zeek::detail::Attr( + zeek::detail::ATTR_DEPRECATED, + make_intrusive(IntrusivePtr{AdoptRef{}, $3})); else { ODesc d; @@ -1396,7 +1398,7 @@ attr: Unref($3); reporter->Error("'&deprecated=%s' must use a string literal", d.Description()); - $$ = new Attr(ATTR_DEPRECATED); + $$ = new zeek::detail::Attr(zeek::detail::ATTR_DEPRECATED); } } ; @@ -1515,7 +1517,7 @@ stmt: set_location(@1, @7); $$ = add_local({AdoptRef{}, $2}, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5}, - std::unique_ptr>>{$6}, + std::unique_ptr>>{$6}, VAR_REGULAR).release(); if ( ! $8 ) brofiler.AddStmt($$); @@ -1526,7 +1528,7 @@ stmt: set_location(@1, @6); $$ = add_local({AdoptRef{}, $2}, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5}, - std::unique_ptr>>{$6}, + std::unique_ptr>>{$6}, VAR_CONST).release(); if ( ! $8 ) brofiler.AddStmt($$); diff --git a/src/zeekygen/ScriptInfo.cc b/src/zeekygen/ScriptInfo.cc index 4b630e6e6a..9104d42e2d 100644 --- a/src/zeekygen/ScriptInfo.cc +++ b/src/zeekygen/ScriptInfo.cc @@ -220,7 +220,7 @@ void ScriptInfo::DoInitPostScript() if ( id->IsConst() ) { - if ( id->GetAttr(ATTR_REDEF) ) + if ( id->GetAttr(zeek::detail::ATTR_REDEF) ) { DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a redef_option", id->Name(), name.c_str());