Merge remote-tracking branch 'origin/topic/timw/266-namespaces'

Merge adjustments:

- Preserved original `base_type_no_ref` argument type as ::TypeTag
- Removed superfluous #pragma guard around deprecated TableVal ctor
- Clarify NEWS regarding MetaHook{Pre,Post} deprecations
- Simplify some `::zeek::` qualifications to just `zeek::`
- Prefixed FORWARD_DECLARE_NAMESPACED macro with ZEEK_

* origin/topic/timw/266-namespaces:
  Disable some deprecation diagnostics for GCC
  Rename BroType to Type
  Update NEWS
  Review cleanup
  Move Type types to zeek namespace
  Move Flare/Pipe from the bro namespace to zeek::detail
  Move Attr to the zeek::detail namespace
  Move Trigger into the zeek::detail namespace
  Move ID to the zeek::detail namespace
  Move Anon.h into zeek::detail namespace
  Mark all of the aliased classes in plugin/Plugin.h deprecated, and fix all of the plugins that were using them
  Move all of the base plugin classes into the zeek::plugin namespace
  Expr: move all classes into zeek::detail
  Stmt: move Stmt classes into zeek::detail namespace
  Add utility macro for creating namespaced aliases for classes
This commit is contained in:
Jon Siwek 2020-06-11 23:12:02 -07:00
commit d4f3cad7d1
256 changed files with 4277 additions and 3501 deletions

100
src/ID.h
View file

@ -14,23 +14,39 @@
#include <vector>
class Val;
class Expr;
class Func;
class BroType;
class RecordType;
class TableType;
class VectorType;
class EnumType;
class Attributes;
typedef enum { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, } init_class;
typedef enum { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL } IDScope;
namespace zeek { class Type; }
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(TableType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(EnumType, zeek);
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, };
enum IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
class ID final : public BroObj, public notifier::Modifiable {
public:
static inline const IntrusivePtr<ID> nil;
ID(const char* name, IDScope arg_scope, bool arg_is_export);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::IDScope")]]
ID(const char* name, ::IDScope arg_scope, bool arg_is_export);
#pragma GCC diagnostic pop
~ID() override;
const char* Name() const { return name; }
@ -43,14 +59,14 @@ public:
std::string ModuleName() const;
void SetType(IntrusivePtr<BroType> t);
void SetType(IntrusivePtr<Type> t);
[[deprecated("Remove in v4.1. Use GetType().")]]
BroType* Type() { return type.get(); }
zeek::Type* Type() { return type.get(); }
[[deprecated("Remove in v4.1. Use GetType().")]]
const BroType* Type() const { return type.get(); }
const zeek::Type* Type() const { return type.get(); }
const IntrusivePtr<BroType>& GetType() const
const IntrusivePtr<zeek::Type>& GetType() const
{ return type; }
template <class T>
@ -58,9 +74,9 @@ public:
{ return cast_intrusive<T>(type); }
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
BroType* AsType() { return is_type ? GetType().get() : nullptr; }
zeek::Type* AsType() { return is_type ? GetType().get() : nullptr; }
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
const BroType* AsType() const { return is_type ? GetType().get() : nullptr; }
const zeek::Type* AsType() const { return is_type ? GetType().get() : nullptr; }
bool IsType() const
{ return is_type; }
@ -72,6 +88,14 @@ public:
void SetVal(IntrusivePtr<Val> v, init_class c);
void SetVal(IntrusivePtr<Expr> ev, init_class c);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::init_class")]]
void SetVal(IntrusivePtr<Val> v, ::init_class c);
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::init_class")]]
void SetVal(IntrusivePtr<Expr> ev, ::init_class c);
#pragma GCC diagnostic pop
bool HasVal() const { return val != nullptr; }
[[deprecated("Remove in v4.1. Use GetVal().")]]
@ -101,6 +125,11 @@ public:
void SetAttrs(IntrusivePtr<Attributes> attr);
void AddAttrs(IntrusivePtr<Attributes> attr);
void RemoveAttr(attr_tag a);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag")]]
void RemoveAttr(::attr_tag a);
#pragma GCC diagnostic pop
void UpdateValAttrs();
const IntrusivePtr<Attributes>& GetAttrs() const
@ -109,11 +138,14 @@ public:
[[deprecated("Remove in 4.1. Use GetAttrs().")]]
Attributes* Attrs() const { return attrs.get(); }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[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(); }
#pragma GCC diagnostic pop
const IntrusivePtr<Attr>& GetAttr(attr_tag t) const;
const IntrusivePtr<zeek::detail::Attr>& GetAttr(zeek::detail::attr_tag t) const;
bool IsDeprecated() const;
@ -154,7 +186,7 @@ protected:
IDScope scope;
bool is_export;
bool infer_return_type;
IntrusivePtr<BroType> type;
IntrusivePtr<zeek::Type> type;
bool is_const, is_enum_const, is_type, is_option;
int offset;
IntrusivePtr<Val> val;
@ -164,6 +196,10 @@ protected:
};
}
using ID [[deprecated("Remove in v4.1. Use zeek::detail::ID instead.")]] = zeek::detail::ID;
namespace zeek::id {
/**
@ -172,7 +208,7 @@ namespace zeek::id {
* @return The identifier, which may reference a nil object if no such
* name exists.
*/
const IntrusivePtr<ID>& find(std::string_view name);
const IntrusivePtr<zeek::detail::ID>& find(std::string_view name);
/**
* Lookup an ID by its name and return its type. A fatal occurs if the ID
@ -180,7 +216,7 @@ const IntrusivePtr<ID>& find(std::string_view name);
* @param name The identifier name to lookup
* @return The type of the identifier.
*/
const IntrusivePtr<BroType>& find_type(std::string_view name);
const IntrusivePtr<zeek::Type>& find_type(std::string_view name);
/**
* Lookup an ID by its name and return its type (as cast to @c T).
@ -236,17 +272,17 @@ IntrusivePtr<T> find_const(std::string_view name)
*/
IntrusivePtr<Func> find_func(std::string_view name);
extern IntrusivePtr<RecordType> conn_id;
extern IntrusivePtr<RecordType> endpoint;
extern IntrusivePtr<RecordType> connection;
extern IntrusivePtr<RecordType> fa_file;
extern IntrusivePtr<RecordType> fa_metadata;
extern IntrusivePtr<EnumType> transport_proto;
extern IntrusivePtr<TableType> string_set;
extern IntrusivePtr<TableType> string_array;
extern IntrusivePtr<TableType> count_set;
extern IntrusivePtr<VectorType> string_vec;
extern IntrusivePtr<VectorType> index_vec;
extern IntrusivePtr<zeek::RecordType> conn_id;
extern IntrusivePtr<zeek::RecordType> endpoint;
extern IntrusivePtr<zeek::RecordType> connection;
extern IntrusivePtr<zeek::RecordType> fa_file;
extern IntrusivePtr<zeek::RecordType> fa_metadata;
extern IntrusivePtr<zeek::EnumType> transport_proto;
extern IntrusivePtr<zeek::TableType> string_set;
extern IntrusivePtr<zeek::TableType> string_array;
extern IntrusivePtr<zeek::TableType> count_set;
extern IntrusivePtr<zeek::VectorType> string_vec;
extern IntrusivePtr<zeek::VectorType> index_vec;
namespace detail {