mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move Attr to the zeek::detail namespace
This commit is contained in:
parent
54233ce596
commit
60ed29c3b6
21 changed files with 249 additions and 168 deletions
28
src/Attr.cc
28
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<zeek::detail::Expr> e)
|
||||
Attr::Attr(attr_tag t, IntrusivePtr<Expr> e)
|
||||
: expr(std::move(e))
|
||||
{
|
||||
tag = t;
|
||||
SetLocationInfo(&start_location, &end_location);
|
||||
}
|
||||
|
||||
Attr::Attr(::attr_tag t, IntrusivePtr<Expr> e) : Attr(static_cast<attr_tag>(t), e)
|
||||
{
|
||||
}
|
||||
|
||||
Attr::Attr(attr_tag t)
|
||||
: Attr(t, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Attr::Attr(::attr_tag t) : Attr(static_cast<attr_tag>(t))
|
||||
{
|
||||
}
|
||||
|
||||
Attr::~Attr() = default;
|
||||
|
||||
void Attr::SetAttrExpr(IntrusivePtr<zeek::detail::Expr> 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<Attr>& Attributes::Find(attr_tag t) const
|
|||
return Attr::nil;
|
||||
}
|
||||
|
||||
Attr* Attributes::FindAttr(::attr_tag t) const
|
||||
{
|
||||
return FindAttr(static_cast<attr_tag>(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<attr_tag>(t));
|
||||
}
|
||||
|
||||
void Attributes::Describe(ODesc* d) const
|
||||
{
|
||||
if ( attrs.empty() )
|
||||
|
@ -663,3 +683,5 @@ bool Attributes::operator==(const Attributes& other) const
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
49
src/Attr.h
49
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<Attr> nil;
|
||||
static inline const IntrusivePtr<zeek::detail::Attr> nil;
|
||||
|
||||
Attr(attr_tag t, IntrusivePtr<zeek::detail::Expr> e);
|
||||
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]]
|
||||
Attr(::attr_tag t, IntrusivePtr<zeek::detail::Expr> 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<zeek::detail::Expr> expr;
|
||||
IntrusivePtr<Expr> 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<Attr>& 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;
|
||||
|
|
|
@ -4,23 +4,23 @@
|
|||
|
||||
#include "List.h"
|
||||
|
||||
class Val;
|
||||
using val_list = PList<Val>;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||
typedef PList<zeek::detail::Expr> expr_list;
|
||||
using expr_list = PList<zeek::detail::Expr>;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||
typedef PList<zeek::detail::ID> id_list;
|
||||
|
||||
class Val;
|
||||
typedef PList<Val> val_list;
|
||||
using id_list = PList<zeek::detail::ID>;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||
typedef PList<zeek::detail::Stmt> stmt_list;
|
||||
using stmt_list = PList<zeek::detail::Stmt>;
|
||||
|
||||
class BroType;
|
||||
typedef PList<BroType> type_list;
|
||||
using type_list = PList<BroType>;
|
||||
|
||||
class Attr;
|
||||
typedef PList<Attr> attr_list;
|
||||
FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
|
||||
using attr_list = PList<zeek::detail::Attr>;
|
||||
|
||||
class Timer;
|
||||
typedef PList<Timer, ListOrder::UNORDERED> timer_list;
|
||||
using timer_list = PList<Timer, ListOrder::UNORDERED>;
|
||||
|
|
|
@ -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<Val> 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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<BroType> 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;
|
||||
|
|
|
@ -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<IntrusivePtr<Attr>>& attrs)
|
||||
static int get_func_priority(const std::vector<IntrusivePtr<zeek::detail::Attr>>& 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;
|
||||
|
|
|
@ -337,6 +337,11 @@ void ID::RemoveAttr(attr_tag a)
|
|||
attrs->RemoveAttr(a);
|
||||
}
|
||||
|
||||
void ID::RemoveAttr(::attr_tag a)
|
||||
{
|
||||
RemoveAttr(static_cast<attr_tag>(a));
|
||||
}
|
||||
|
||||
void ID::SetOption()
|
||||
{
|
||||
if ( is_option )
|
||||
|
|
10
src/ID.h
10
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<Attributes> attr);
|
||||
void AddAttrs(IntrusivePtr<Attributes> 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<Attributes>& 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<zeek::detail::attr_tag>(t)).get(); }
|
||||
|
||||
const IntrusivePtr<Attr>& GetAttr(attr_tag t) const;
|
||||
const IntrusivePtr<zeek::detail::Attr>& GetAttr(zeek::detail::attr_tag t) const;
|
||||
|
||||
bool IsDeprecated() const;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ static scope_list scopes;
|
|||
static Scope* top_scope;
|
||||
|
||||
Scope::Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al)
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> 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<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||
{
|
||||
top_scope = new Scope(std::move(id), std::move(attrs));
|
||||
scopes.push_back(top_scope);
|
||||
|
|
|
@ -21,7 +21,7 @@ FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
|||
class Scope : public BroObj {
|
||||
public:
|
||||
explicit Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al);
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> al);
|
||||
|
||||
const IntrusivePtr<zeek::detail::ID>& Find(std::string_view name) const;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
const IntrusivePtr<zeek::detail::ID>& GetID() const
|
||||
{ return scope_id; }
|
||||
|
||||
const std::unique_ptr<std::vector<IntrusivePtr<Attr>>>& Attrs() const
|
||||
const std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>& Attrs() const
|
||||
{ return attrs; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
protected:
|
||||
IntrusivePtr<zeek::detail::ID> scope_id;
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs;
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs;
|
||||
IntrusivePtr<BroType> return_type;
|
||||
std::map<std::string, IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||
|
@ -88,7 +88,7 @@ extern IntrusivePtr<zeek::detail::ID> install_ID(const char* name, const char* m
|
|||
bool is_global, bool is_export);
|
||||
|
||||
extern void push_scope(IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs);
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs);
|
||||
extern void push_existing_scope(Scope* scope);
|
||||
|
||||
// Returns the one popped off.
|
||||
|
|
18
src/Type.cc
18
src/Type.cc
|
@ -422,7 +422,7 @@ FuncType::FuncType(IntrusivePtr<RecordType> 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::Prototype> FuncType::FindPrototype(const RecordType& arg
|
|||
}
|
||||
|
||||
TypeDecl::TypeDecl(const char* i, IntrusivePtr<BroType> t,
|
||||
IntrusivePtr<Attributes> arg_attrs)
|
||||
IntrusivePtr<zeek::detail::Attributes> arg_attrs)
|
||||
: type(std::move(t)),
|
||||
attrs(std::move(arg_attrs)),
|
||||
id(i)
|
||||
|
@ -687,7 +687,7 @@ IntrusivePtr<Val> 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<TableVal> 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<RecordVal>(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<Attributes>(td->type, true, false);
|
||||
td->attrs = make_intrusive<zeek::detail::Attributes>(td->type, true, false);
|
||||
|
||||
td->attrs->AddAttr(make_intrusive<Attr>(ATTR_LOG));
|
||||
td->attrs->AddAttr(make_intrusive<zeek::detail::Attr>(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<zeek::detail::ConstExpr*>(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);
|
||||
|
|
26
src/Type.h
26
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<BroType> t, IntrusivePtr<Attributes> attrs = nullptr);
|
||||
TypeDecl(const char* i, IntrusivePtr<BroType> t,
|
||||
IntrusivePtr<zeek::detail::Attributes> 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<zeek::detail::attr_tag>(a)).get() : nullptr; }
|
||||
|
||||
const IntrusivePtr<Attr>& GetAttr(attr_tag a) const
|
||||
{ return attrs ? attrs->Find(a) : Attr::nil; }
|
||||
const IntrusivePtr<zeek::detail::Attr>& 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<BroType> type;
|
||||
IntrusivePtr<Attributes> attrs;
|
||||
IntrusivePtr<zeek::detail::Attributes> 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<zeek::detail::attr_tag>(at));
|
||||
}
|
||||
|
||||
std::string GetFieldDeprecationWarning(int field, bool has_check) const;
|
||||
|
||||
|
@ -842,7 +848,7 @@ inline bool same_type(const BroType* t1, const IntrusivePtr<BroType>& 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.
|
||||
|
|
42
src/Val.cc
42
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<BroType>& t, std::set<Re
|
|||
}
|
||||
}
|
||||
|
||||
TableVal::TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> a) : Val(t)
|
||||
TableVal::TableVal(IntrusivePtr<TableType> t, IntrusivePtr<zeek::detail::Attributes> 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<Attributes> a)
|
||||
void TableVal::SetAttrs(IntrusivePtr<zeek::detail::Attributes> 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<Val> index, std::unique_ptr<HashKey> 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<Val> index, IntrusivePtr<Val> new_val)
|
|||
|
||||
IntrusivePtr<Val> TableVal::Default(const IntrusivePtr<Val>& 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<Val>& TableVal::Find(const IntrusivePtr<Val>& 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<Val>& TableVal::Find(const IntrusivePtr<Val>& 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> 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<Attr>& TableVal::GetAttr(attr_tag t) const
|
||||
const IntrusivePtr<zeek::detail::Attr>& 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<RecordType> 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<RecordType> 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> RecordVal::CoerceTo(IntrusivePtr<RecordType> 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),
|
||||
|
|
21
src/Val.h
21
src/Val.h
|
@ -758,7 +758,8 @@ class Frame;
|
|||
|
||||
class TableVal final : public Val, public notifier::Modifiable {
|
||||
public:
|
||||
explicit TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> attrs = nullptr);
|
||||
explicit TableVal(IntrusivePtr<TableType> t, IntrusivePtr<zeek::detail::Attributes> 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<Attributes> attrs);
|
||||
void SetAttrs(IntrusivePtr<zeek::detail::Attributes> 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<zeek::detail::attr_tag>(t)).get(); }
|
||||
|
||||
const IntrusivePtr<Attr>& GetAttr(attr_tag t) const;
|
||||
const IntrusivePtr<zeek::detail::Attr>& 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<Attributes>& GetAttrs() const
|
||||
const IntrusivePtr<zeek::detail::Attributes>& 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<Val> new_val);
|
||||
bool CheckAndAssign(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val);
|
||||
|
||||
|
@ -1049,7 +1052,7 @@ protected:
|
|||
|
||||
IntrusivePtr<TableType> table_type;
|
||||
CompositeHash* table_hash;
|
||||
IntrusivePtr<Attributes> attrs;
|
||||
IntrusivePtr<zeek::detail::Attributes> attrs;
|
||||
IntrusivePtr<zeek::detail::Expr> expire_time;
|
||||
IntrusivePtr<zeek::detail::Expr> expire_func;
|
||||
TableValTimer* timer;
|
||||
|
|
41
src/Var.cc
41
src/Var.cc
|
@ -17,6 +17,8 @@
|
|||
#include "module_util.h"
|
||||
#include "ID.h"
|
||||
|
||||
using namespace zeek::detail;
|
||||
|
||||
static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const BroType* t,
|
||||
IntrusivePtr<Val> aggr)
|
||||
{
|
||||
|
@ -31,7 +33,7 @@ static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const BroType* t,
|
|||
}
|
||||
|
||||
static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, BroType* t,
|
||||
std::vector<IntrusivePtr<Attr>>* attrs,
|
||||
std::vector<IntrusivePtr<zeek::detail::Attr>>* attrs,
|
||||
const IntrusivePtr<zeek::detail::Expr>& init)
|
||||
{
|
||||
if ( ! IsFunc(id->GetType()->Tag()) )
|
||||
|
@ -100,7 +102,7 @@ static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& 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<zeek::detail::ID>& id, BroType* t,
|
|||
static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt,
|
||||
bool do_init)
|
||||
{
|
||||
|
@ -200,7 +202,7 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
id->SetType(t);
|
||||
|
||||
if ( attr )
|
||||
id->AddAttrs(make_intrusive<Attributes>(std::move(*attr), t, false, id->IsGlobal()));
|
||||
id->AddAttrs(make_intrusive<zeek::detail::Attributes>(std::move(*attr), t, false, id->IsGlobal()));
|
||||
|
||||
if ( init )
|
||||
{
|
||||
|
@ -234,8 +236,8 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
// intention clearly isn't to overwrite entire existing table val.
|
||||
c = zeek::detail::INIT_EXTRA;
|
||||
|
||||
if ( init && ((c == zeek::detail::INIT_EXTRA && id->GetAttr(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<zeek::detail::ID>& id, IntrusivePtr<BroT
|
|||
|
||||
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
|
||||
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> 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<zeek::detail::ID>& id, IntrusivePtr<BroType>
|
|||
|
||||
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<BroType> t,
|
||||
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt)
|
||||
{
|
||||
make_var(id, std::move(t), c, init, std::move(attr), dt, false);
|
||||
|
@ -359,7 +361,7 @@ extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::
|
|||
}
|
||||
|
||||
void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr)
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> 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<BroType> t,
|
|||
id->MakeType();
|
||||
|
||||
if ( attr )
|
||||
id->SetAttrs(make_intrusive<Attributes>(std::move(*attr), tnew, false, false));
|
||||
id->SetAttrs(make_intrusive<zeek::detail::Attributes>(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<IntrusivePtr<Attr>> a{def};
|
||||
recv_i->attrs = make_intrusive<Attributes>(std::move(a),
|
||||
std::vector<IntrusivePtr<zeek::detail::Attr>> a{def};
|
||||
recv_i->attrs = make_intrusive<zeek::detail::Attributes>(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<IntrusivePtr<Attr>>* al, attr_tag tag)
|
||||
static zeek::detail::Attr* find_attr(const std::vector<IntrusivePtr<zeek::detail::Attr>>* 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<zeek::detail::ID> id, const char* module_name,
|
||||
function_flavor flavor, bool is_redef,
|
||||
IntrusivePtr<FuncType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||
{
|
||||
if ( flavor == FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
|
@ -502,7 +505,7 @@ void begin_func(IntrusivePtr<zeek::detail::ID> 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<zeek::detail::ID> 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());
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ extern void add_global(const IntrusivePtr<zeek::detail::ID>& id,
|
|||
IntrusivePtr<BroType> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt);
|
||||
|
||||
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id,
|
||||
IntrusivePtr<BroType> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt);
|
||||
|
||||
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::detail::ID> id,
|
||||
|
@ -37,12 +37,12 @@ extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::
|
|||
IntrusivePtr<Val> val = nullptr);
|
||||
|
||||
extern void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr);
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr);
|
||||
|
||||
extern void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
||||
function_flavor flavor, bool is_redef,
|
||||
IntrusivePtr<FuncType> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs = nullptr);
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs = nullptr);
|
||||
|
||||
extern void end_func(IntrusivePtr<zeek::detail::Stmt> body);
|
||||
|
||||
|
|
|
@ -884,7 +884,6 @@ bool Manager::UnrollRecordType(vector<Field*> *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<Field*> *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<Field*> *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<Field*> *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<Field*> *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
|
||||
{
|
||||
|
|
|
@ -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<int> 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);
|
||||
}
|
||||
|
|
84
src/parse.y
84
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<type_decl_list> fields,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||
{
|
||||
std::set<BroType*> types = BroType::GetAliases(id->Name());
|
||||
|
||||
|
@ -181,7 +181,7 @@ static void extend_record(zeek::detail::ID* id, std::unique_ptr<type_decl_list>
|
|||
|
||||
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<type_decl_list>
|
|||
}
|
||||
}
|
||||
|
||||
static IntrusivePtr<Attributes>
|
||||
make_attributes(std::vector<IntrusivePtr<Attr>>* attrs,
|
||||
static IntrusivePtr<zeek::detail::Attributes>
|
||||
make_attributes(std::vector<IntrusivePtr<zeek::detail::Attr>>* attrs,
|
||||
IntrusivePtr<BroType> t, bool in_record, bool is_global)
|
||||
{
|
||||
if ( ! attrs )
|
||||
return nullptr;
|
||||
|
||||
auto rval = make_intrusive<Attributes>(std::move(*attrs), std::move(t),
|
||||
auto rval = make_intrusive<zeek::detail::Attributes>(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<IntrusivePtr<Attr>>* attr_l;
|
||||
attr_tag attrtag;
|
||||
zeek::detail::Attr* attr;
|
||||
std::vector<IntrusivePtr<zeek::detail::Attr>>* 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<std::vector<IntrusivePtr<Attr>>> attrs{$7};
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> 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<std::vector<IntrusivePtr<Attr>>> attrs{$5};
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> 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<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$6},
|
||||
VAR_CONST);
|
||||
zeekygen_mgr->Identifier(std::move(id));
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ decl:
|
|||
IntrusivePtr id{AdoptRef{}, $2};
|
||||
IntrusivePtr<zeek::detail::Expr> init{AdoptRef{}, $5};
|
||||
add_global(id, {AdoptRef{}, $3}, $4, init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<type_decl_list>($8),
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>($11));
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>($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<std::vector<IntrusivePtr<Attr>>>{$6});
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$4});
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$4});
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$4});
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$5});
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$5});
|
||||
$$ = $4;
|
||||
}
|
||||
;
|
||||
|
@ -1347,48 +1347,50 @@ attr_list:
|
|||
{ $1->emplace_back(AdoptRef{}, $2); }
|
||||
| attr
|
||||
{
|
||||
$$ = new std::vector<IntrusivePtr<Attr>>;
|
||||
$$ = new std::vector<IntrusivePtr<zeek::detail::Attr>>;
|
||||
$$->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<zeek::detail::ConstExpr>(IntrusivePtr{AdoptRef{}, $3}));
|
||||
$$ = new zeek::detail::Attr(
|
||||
zeek::detail::ATTR_DEPRECATED,
|
||||
make_intrusive<zeek::detail::ConstExpr>(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<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$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<std::vector<IntrusivePtr<Attr>>>{$6},
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>{$6},
|
||||
VAR_CONST).release();
|
||||
if ( ! $8 )
|
||||
brofiler.AddStmt($$);
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue