From acb5e5dd26d305d1c22d58352d9f4a5a4ff4bfc0 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Fri, 3 Dec 2021 11:35:15 -0700 Subject: [PATCH] Remove separate Tag types, note breaking change in NEWS --- NEWS | 11 +++ src/RuleAction.h | 2 +- src/analyzer/Analyzer.h | 2 +- src/analyzer/Tag.h | 152 -------------------------------------- src/file_analysis/File.h | 2 +- src/file_analysis/Tag.h | 152 -------------------------------------- src/input/Manager.h | 2 +- src/input/Tag.h | 152 -------------------------------------- src/logging/Tag.h | 152 -------------------------------------- src/packet_analysis/Tag.h | 152 -------------------------------------- src/zeek-setup.cc | 2 +- 11 files changed, 16 insertions(+), 765 deletions(-) delete mode 100644 src/analyzer/Tag.h delete mode 100644 src/file_analysis/Tag.h delete mode 100644 src/input/Tag.h delete mode 100644 src/logging/Tag.h delete mode 100644 src/packet_analysis/Tag.h diff --git a/NEWS b/NEWS index dd3c9b377c..8f1ac4555b 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,17 @@ release. For an exhaustive list of changes, see the ``CHANGES`` file Zeek 4.2.0 ========== +Breaking Changes +---------------- + +- The existing ``Tag`` types in C++ (``zeek::Analyzer::Tag``, etc) have been merged + into a single type called ``zeek::Tag``. This is a breaking change, and may result + in plugins failing to build where they were relying on those types being different + for function overloading and such. We attempted to include deprecated versions of + the old types, but were unable to do so because of changes to return types from a + number of methods. With this change, any uses of the `zeek::*::Tag` types will + need to be replaced by `zeek::Tag`. + New Functionality ----------------- diff --git a/src/RuleAction.h b/src/RuleAction.h index c9d1b45db8..938904d4fb 100644 --- a/src/RuleAction.h +++ b/src/RuleAction.h @@ -3,7 +3,7 @@ #include // for u_char #include -#include "zeek/analyzer/Tag.h" +#include "zeek/Tag.h" namespace zeek::detail { diff --git a/src/analyzer/Analyzer.h b/src/analyzer/Analyzer.h index 7bdfa0fbed..3d84632374 100644 --- a/src/analyzer/Analyzer.h +++ b/src/analyzer/Analyzer.h @@ -11,8 +11,8 @@ #include "zeek/EventHandler.h" #include "zeek/IntrusivePtr.h" #include "zeek/Obj.h" +#include "zeek/Tag.h" #include "zeek/Timer.h" -#include "zeek/analyzer/Tag.h" namespace zeek { diff --git a/src/analyzer/Tag.h b/src/analyzer/Tag.h deleted file mode 100644 index 6316381dc2..0000000000 --- a/src/analyzer/Tag.h +++ /dev/null @@ -1,152 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#pragma once - -#include "zeek/zeek-config.h" - -#include - -#include "zeek/Tag.h" -#include "zeek/Val.h" - -namespace zeek::analyzer - { - -/** - * This class implements a wrapper around zeek::Tag , presenting the same interface as that - * member object. It previously implemented a full tag object for this type of plugin - * component, but that functionality was merged into zeek::Tag and the separate tag types were - * deprecated. This class will eventually be removed per the Zeek deprecation policy. - */ -class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag - { -public: - /** - * Type for the component's main type. - */ - using type_t = zeek::Tag::type_t; - - /** - * Type for the component's subtype. - */ - using subtype_t = zeek::Tag::subtype_t; - - /** - * Returns the tag's main type. - */ - zeek::Tag::type_t Type() const { return tag.Type(); } - - /** - * Returns the tag's subtype. - */ - zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); } - - /** - * Default constructor. This initializes the tag with an error value - * that will make \c operator \c bool return false. - */ - Tag() : tag() { } - - /** - * Constructor. - * - * @param etype the script-layer enum type associated with the tag. - * - * @param type The main type. Note that the manager class manages the - * the value space internally, so noone else should assign main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) - : tag(etype, type, subtype) - { - } - - /** - * Constructor. - * - * @param type The main type. Note that the component's Manager - * manages the value space internally, so noone else should assign - * any main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { } - - /** - * Constructor. - * - * @param val An enum value of script type \c Analyzer::Tag. - */ - explicit Tag(EnumValPtr val) : tag(val) { } - - /* - * Copy constructor. - */ - Tag(const Tag& other) : tag(other.tag) { } - - /** - * Destructor. - */ - ~Tag() { } - - /** - * Assignment operator. - */ - Tag& operator=(const Tag& other) - { - tag = other.tag; - return *this; - } - - /** - * Move assignment operator. - */ - Tag& operator=(Tag&& other) noexcept - { - tag = other.tag; - return *this; - } - - /** - * Compares two tags for equality. - */ - bool operator==(const Tag& other) const { return tag == other.tag; } - - /** - * Compares two tags for inequality. - */ - bool operator!=(const Tag& other) const { return tag != other.tag; } - - /** - * Compares two tags for less-than relationship. - */ - bool operator<(const Tag& other) const { return tag < other.tag; } - - /** - * Returns the numerical values for main and subtype inside a string - * suitable for printing. This is primarily for debugging. - */ - std::string AsString() const { return tag.AsString(); } - - /** - * Returns the script-layer enum that corresponds to this tag. - * The returned value does not have its ref-count increased. - * - * @param etype the script-layer enum type associated with the tag. - */ - const EnumValPtr& AsVal() const { return tag.AsVal(); } - - /** - * Returns false if the tag represents an error value rather than a - * legal component type. - */ - explicit operator bool() const { return static_cast(tag); } - -private: - zeek::Tag tag; - }; - - } // namespace zeek::analyzer diff --git a/src/file_analysis/File.h b/src/file_analysis/File.h index db8e20f025..da87e6a963 100644 --- a/src/file_analysis/File.h +++ b/src/file_analysis/File.h @@ -6,11 +6,11 @@ #include #include +#include "zeek/Tag.h" #include "zeek/WeirdState.h" #include "zeek/ZeekArgs.h" #include "zeek/ZeekList.h" // for ValPList #include "zeek/ZeekString.h" -#include "zeek/analyzer/Tag.h" #include "zeek/file_analysis/AnalyzerSet.h" namespace zeek diff --git a/src/file_analysis/Tag.h b/src/file_analysis/Tag.h deleted file mode 100644 index 5f21276a0a..0000000000 --- a/src/file_analysis/Tag.h +++ /dev/null @@ -1,152 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#pragma once - -#include "zeek/zeek-config.h" - -#include - -#include "zeek/Tag.h" -#include "zeek/Val.h" - -namespace zeek::file_analysis - { - -/** - * This class implements a wrapper around zeek::Tag , presenting the same interface as that - * member object. It previously implemented a full tag object for this type of plugin - * component, but that functionality was merged into zeek::Tag and the separate tag types were - * deprecated. This class will eventually be removed per the Zeek deprecation policy. - */ -class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag - { -public: - /** - * Type for the component's main type. - */ - using type_t = zeek::Tag::type_t; - - /** - * Type for the component's subtype. - */ - using subtype_t = zeek::Tag::subtype_t; - - /** - * Returns the tag's main type. - */ - zeek::Tag::type_t Type() const { return tag.Type(); } - - /** - * Returns the tag's subtype. - */ - zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); } - - /** - * Default constructor. This initializes the tag with an error value - * that will make \c operator \c bool return false. - */ - Tag() : tag() { } - - /** - * Constructor. - * - * @param etype the script-layer enum type associated with the tag. - * - * @param type The main type. Note that the manager class manages the - * the value space internally, so noone else should assign main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) - : tag(etype, type, subtype) - { - } - - /** - * Constructor. - * - * @param type The main type. Note that the component's Manager - * manages the value space internally, so noone else should assign - * any main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { } - - /** - * Constructor. - * - * @param val An enum value of script type \c Files::Tag. - */ - explicit Tag(EnumValPtr val) : tag(val) { } - - /* - * Copy constructor. - */ - Tag(const Tag& other) : tag(other.tag) { } - - /** - * Destructor. - */ - ~Tag() { } - - /** - * Assignment operator. - */ - Tag& operator=(const Tag& other) - { - tag = other.tag; - return *this; - } - - /** - * Move assignment operator. - */ - Tag& operator=(Tag&& other) noexcept - { - tag = other.tag; - return *this; - } - - /** - * Compares two tags for equality. - */ - bool operator==(const Tag& other) const { return tag == other.tag; } - - /** - * Compares two tags for inequality. - */ - bool operator!=(const Tag& other) const { return tag != other.tag; } - - /** - * Compares two tags for less-than relationship. - */ - bool operator<(const Tag& other) const { return tag < other.tag; } - - /** - * Returns the numerical values for main and subtype inside a string - * suitable for printing. This is primarily for debugging. - */ - std::string AsString() const { return tag.AsString(); } - - /** - * Returns the script-layer enum that corresponds to this tag. - * The returned value does not have its ref-count increased. - * - * @param etype the script-layer enum type associated with the tag. - */ - const EnumValPtr& AsVal() const { return tag.AsVal(); } - - /** - * Returns false if the tag represents an error value rather than a - * legal component type. - */ - explicit operator bool() const { return static_cast(tag); } - -private: - zeek::Tag tag; - }; - - } // namespace zeek::file_analysis diff --git a/src/input/Manager.h b/src/input/Manager.h index 1c0b34d55b..2928b4f23d 100644 --- a/src/input/Manager.h +++ b/src/input/Manager.h @@ -7,8 +7,8 @@ #include #include "zeek/EventHandler.h" +#include "zeek/Tag.h" #include "zeek/input/Component.h" -#include "zeek/input/Tag.h" #include "zeek/plugin/ComponentManager.h" #include "zeek/threading/SerialTypes.h" diff --git a/src/input/Tag.h b/src/input/Tag.h deleted file mode 100644 index 290728560b..0000000000 --- a/src/input/Tag.h +++ /dev/null @@ -1,152 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#pragma once - -#include "zeek/zeek-config.h" - -#include - -#include "zeek/Tag.h" -#include "zeek/Val.h" - -namespace zeek::input - { - -/** - * This class implements a wrapper around zeek::Tag , presenting the same interface as that - * member object. It previously implemented a full tag object for this type of plugin - * component, but that functionality was merged into zeek::Tag and the separate tag types were - * deprecated. This class will eventually be removed per the Zeek deprecation policy. - */ -class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag - { -public: - /** - * Type for the component's main type. - */ - using type_t = zeek::Tag::type_t; - - /** - * Type for the component's subtype. - */ - using subtype_t = zeek::Tag::subtype_t; - - /** - * Returns the tag's main type. - */ - zeek::Tag::type_t Type() const { return tag.Type(); } - - /** - * Returns the tag's subtype. - */ - zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); } - - /** - * Default constructor. This initializes the tag with an error value - * that will make \c operator \c bool return false. - */ - Tag() : tag() { } - - /** - * Constructor. - * - * @param etype the script-layer enum type associated with the tag. - * - * @param type The main type. Note that the manager class manages the - * the value space internally, so noone else should assign main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) - : tag(etype, type, subtype) - { - } - - /** - * Constructor. - * - * @param type The main type. Note that the component's Manager - * manages the value space internally, so noone else should assign - * any main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { } - - /** - * Constructor. - * - * @param val An enum value of script type \c Input::Tag. - */ - explicit Tag(EnumValPtr val) : tag(val) { } - - /* - * Copy constructor. - */ - Tag(const Tag& other) : tag(other.tag) { } - - /** - * Destructor. - */ - ~Tag() { } - - /** - * Assignment operator. - */ - Tag& operator=(const Tag& other) - { - tag = other.tag; - return *this; - } - - /** - * Move assignment operator. - */ - Tag& operator=(Tag&& other) noexcept - { - tag = other.tag; - return *this; - } - - /** - * Compares two tags for equality. - */ - bool operator==(const Tag& other) const { return tag == other.tag; } - - /** - * Compares two tags for inequality. - */ - bool operator!=(const Tag& other) const { return tag != other.tag; } - - /** - * Compares two tags for less-than relationship. - */ - bool operator<(const Tag& other) const { return tag < other.tag; } - - /** - * Returns the numerical values for main and subtype inside a string - * suitable for printing. This is primarily for debugging. - */ - std::string AsString() const { return tag.AsString(); } - - /** - * Returns the script-layer enum that corresponds to this tag. - * The returned value does not have its ref-count increased. - * - * @param etype the script-layer enum type associated with the tag. - */ - const EnumValPtr& AsVal() const { return tag.AsVal(); } - - /** - * Returns false if the tag represents an error value rather than a - * legal component type. - */ - explicit operator bool() const { return static_cast(tag); } - -private: - zeek::Tag tag; - }; - - } // namespace zeek::input diff --git a/src/logging/Tag.h b/src/logging/Tag.h deleted file mode 100644 index ae8e17d7bb..0000000000 --- a/src/logging/Tag.h +++ /dev/null @@ -1,152 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#pragma once - -#include "zeek/zeek-config.h" - -#include - -#include "zeek/Tag.h" -#include "zeek/Val.h" - -namespace zeek::logging - { - -/** - * This class implements a wrapper around zeek::Tag , presenting the same interface as that - * member object. It previously implemented a full tag object for this type of plugin - * component, but that functionality was merged into zeek::Tag and the separate tag types were - * deprecated. This class will eventually be removed per the Zeek deprecation policy. - */ -class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag - { -public: - /** - * Type for the component's main type. - */ - using type_t = zeek::Tag::type_t; - - /** - * Type for the component's subtype. - */ - using subtype_t = zeek::Tag::subtype_t; - - /** - * Returns the tag's main type. - */ - zeek::Tag::type_t Type() const { return tag.Type(); } - - /** - * Returns the tag's subtype. - */ - zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); } - - /** - * Default constructor. This initializes the tag with an error value - * that will make \c operator \c bool return false. - */ - Tag() : tag() { } - - /** - * Constructor. - * - * @param etype the script-layer enum type associated with the tag. - * - * @param type The main type. Note that the manager class manages the - * the value space internally, so noone else should assign main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) - : tag(etype, type, subtype) - { - } - - /** - * Constructor. - * - * @param type The main type. Note that the \a logging::Manager - * manages the value space internally, so noone else should assign - * any main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { } - - /** - * Constructor. - * - * @param val An enum value of script type \c Logger::Tag. - */ - explicit Tag(EnumValPtr val) : tag(val) { } - - /* - * Copy constructor. - */ - Tag(const Tag& other) : tag(other.tag) { } - - /** - * Destructor. - */ - ~Tag() { } - - /** - * Assignment operator. - */ - Tag& operator=(const Tag& other) - { - tag = other.tag; - return *this; - } - - /** - * Move assignment operator. - */ - Tag& operator=(Tag&& other) noexcept - { - tag = other.tag; - return *this; - } - - /** - * Compares two tags for equality. - */ - bool operator==(const Tag& other) const { return tag == other.tag; } - - /** - * Compares two tags for inequality. - */ - bool operator!=(const Tag& other) const { return tag != other.tag; } - - /** - * Compares two tags for less-than relationship. - */ - bool operator<(const Tag& other) const { return tag < other.tag; } - - /** - * Returns the numerical values for main and subtype inside a string - * suitable for printing. This is primarily for debugging. - */ - std::string AsString() const { return tag.AsString(); } - - /** - * Returns the script-layer enum that corresponds to this tag. - * The returned value does not have its ref-count increased. - * - * @param etype the script-layer enum type associated with the tag. - */ - const EnumValPtr& AsVal() const { return tag.AsVal(); } - - /** - * Returns false if the tag represents an error value rather than a - * legal component type. - */ - explicit operator bool() const { return static_cast(tag); } - -private: - zeek::Tag tag; - }; - - } // namespace zeek::logging diff --git a/src/packet_analysis/Tag.h b/src/packet_analysis/Tag.h deleted file mode 100644 index ffbdfee105..0000000000 --- a/src/packet_analysis/Tag.h +++ /dev/null @@ -1,152 +0,0 @@ -// See the file "COPYING" in the main distribution directory for copyright. - -#pragma once - -#include "zeek/zeek-config.h" - -#include - -#include "zeek/Tag.h" -#include "zeek/Val.h" - -namespace zeek::packet_analysis - { - -/** - * This class implements a wrapper around zeek::Tag , presenting the same interface as that - * member object. It previously implemented a full tag object for this type of plugin - * component, but that functionality was merged into zeek::Tag and the separate tag types were - * deprecated. This class will eventually be removed per the Zeek deprecation policy. - */ -class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag - { -public: - /** - * Type for the component's main type. - */ - using type_t = zeek::Tag::type_t; - - /** - * Type for the component's subtype. - */ - using subtype_t = zeek::Tag::subtype_t; - - /** - * Returns the tag's main type. - */ - zeek::Tag::type_t Type() const { return tag.Type(); } - - /** - * Returns the tag's subtype. - */ - zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); } - - /** - * Default constructor. This initializes the tag with an error value - * that will make \c operator \c bool return false. - */ - Tag() : tag() { } - - /** - * Constructor. - * - * @param etype the script-layer enum type associated with the tag. - * - * @param type The main type. Note that the manager class manages the - * the value space internally, so noone else should assign main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) - : tag(etype, type, subtype) - { - } - - /** - * Constructor. - * - * @param type The main type. Note that the component's Manager - * manages the value space internally, so noone else should assign - * any main types. - * - * @param subtype The sub type, which is left to a component for - * interpretation. By default it's set to zero. - */ - explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { } - - /** - * Constructor. - * - * @param val An enum value of script type \c PacketAnalyzer::Tag. - */ - explicit Tag(EnumValPtr val) : tag(val) { } - - /* - * Copy constructor. - */ - Tag(const Tag& other) : tag(other.tag) { } - - /** - * Destructor. - */ - ~Tag() { } - - /** - * Assignment operator. - */ - Tag& operator=(const Tag& other) - { - tag = other.tag; - return *this; - } - - /** - * Move assignment operator. - */ - Tag& operator=(Tag&& other) noexcept - { - tag = other.tag; - return *this; - } - - /** - * Compares two tags for equality. - */ - bool operator==(const Tag& other) const { return tag == other.tag; } - - /** - * Compares two tags for inequality. - */ - bool operator!=(const Tag& other) const { return tag != other.tag; } - - /** - * Compares two tags for less-than relationship. - */ - bool operator<(const Tag& other) const { return tag < other.tag; } - - /** - * Returns the numerical values for main and subtype inside a string - * suitable for printing. This is primarily for debugging. - */ - std::string AsString() const { return tag.AsString(); } - - /** - * Returns the script-layer enum that corresponds to this tag. - * The returned value does not have its ref-count increased. - * - * @param etype the script-layer enum type associated with the tag. - */ - const EnumValPtr& AsVal() const { return tag.AsVal(); } - - /** - * Returns false if the tag represents an error value rather than a - * legal component type. - */ - explicit operator bool() const { return static_cast(tag); } - -private: - zeek::Tag tag; - }; - - } // namespace zeek::packet_analysis diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 5b2c6de914..8867ab548e 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -41,12 +41,12 @@ #include "zeek/ScriptCoverageManager.h" #include "zeek/Stats.h" #include "zeek/Stmt.h" +#include "zeek/Tag.h" #include "zeek/Timer.h" #include "zeek/Traverse.h" #include "zeek/Trigger.h" #include "zeek/Var.h" #include "zeek/analyzer/Manager.h" -#include "zeek/analyzer/Tag.h" #include "zeek/binpac_zeek.h" #include "zeek/broker/Manager.h" #include "zeek/file_analysis/Manager.h"