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

View file

@ -26,7 +26,45 @@ namespace threading {
struct Field;
}
namespace plugin {
namespace plugin {
/**
* Hook types that a plugin may define. Each label maps to the corresponding
* virtual method in \a Plugin.
*/
enum [[deprecated("Remove in v4.1. Use the zeek::plugin::HookType instead.")]] HookType {
// Note: when changing this table, update hook_name() in Plugin.cc.
HOOK_LOAD_FILE, //< Activates Plugin::HookLoadFile().
HOOK_CALL_FUNCTION, //< Activates Plugin::HookCallFunction().
HOOK_QUEUE_EVENT, //< Activates Plugin::HookQueueEvent().
HOOK_DRAIN_EVENTS, //< Activates Plugin::HookDrainEvents()
HOOK_UPDATE_NETWORK_TIME, //< Activates Plugin::HookUpdateNetworkTime.
HOOK_BRO_OBJ_DTOR, //< Activates Plugin::HookBroObjDtor.
HOOK_SETUP_ANALYZER_TREE, //< Activates Plugin::HookAddToAnalyzerTree
HOOK_LOG_INIT, //< Activates Plugin::HookLogInit
HOOK_LOG_WRITE, //< Activates Plugin::HookLogWrite
HOOK_REPORTER, //< Activates Plugin::HookReporter
// Meta hooks.
META_HOOK_PRE, //< Activates Plugin::MetaHookPre().
META_HOOK_POST, //< Activates Plugin::MetaHookPost().
// End marker.
NUM_HOOKS,
};
/**
* Converts a hook type into a readable hook name.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use the version that takes zeek::plugin:HookType instead.")]]
extern const char* hook_name(::plugin::HookType h);
#pragma GCC diagnostic pop
}
namespace zeek::plugin {
class Manager;
class Component;
@ -60,25 +98,15 @@ enum HookType {
/**
* Converts a hook type into a readable hook name.
*/
extern const char* hook_name(HookType h);
extern const char* hook_name(zeek::plugin::HookType h);
/**
* Helper class to capture a plugin's version.
* */
struct VersionNumber {
int major; //< Major version number.
int minor; //< Minor version number.
int patch; //< Patch version number (available since Zeek 3.0).
/**
* Constructor.
*/
VersionNumber() {
// Major and minor versions are required.
major = minor = -1;
// Patch version is optional, and set to 0 if not manually set.
patch = 0;
}
int major = -1; //< Major version number.
int minor = -1; //< Minor version number.
int patch = 0; //< Patch version number (available since Zeek 3.0).
/**
* Returns true if the version is set to a non-negative value.
@ -91,14 +119,17 @@ struct VersionNumber {
*/
class Configuration {
public:
std::string name; //< The plugin's name, including a namespace. Mandatory.
std::string description; //< A short textual description of the plugin. Mandatory.
VersionNumber version; //< THe plugin's version. Optional.
std::string name = ""; //< The plugin's name, including a namespace. Mandatory.
std::string description= ""; //< A short textual description of the plugin. Mandatory.
VersionNumber version; //< THe plugin's version. Optional.
// We force this to inline so that the API version gets hardcoded
// into the external plugin. (Technically, it's not a "force", just a
// strong hint.). The attribute seems generally available.
inline Configuration() __attribute__((always_inline));
inline Configuration() __attribute__((always_inline))
{
bro_version = BRO_PLUGIN_BRO_VERSION;
}
/**
* One can assign BRO_PLUGIN_BRO_VERSION to this to catch
@ -110,13 +141,6 @@ private:
friend class Plugin;
};
inline Configuration::Configuration()
{
name = "";
description = "";
bro_version = BRO_PLUGIN_BRO_VERSION;
}
/**
* A class describing an item defined in \c *.bif file.
*/
@ -392,7 +416,7 @@ private:
std::string arg_string;
};
typedef std::list<HookArgument> HookArgumentList;
using HookArgumentList = std::list<HookArgument>;
/**
* Base class for all plugins.
@ -423,7 +447,7 @@ typedef std::list<HookArgument> HookArgumentList;
*/
class Plugin {
public:
typedef std::list<Component *> component_list;
typedef std::list<zeek::plugin::Component *> component_list;
typedef std::list<BifItem> bif_item_list;
typedef std::list<std::pair<HookType, int> > hook_list;
@ -538,7 +562,7 @@ public:
bool LoadBroFile(const std::string& file);
protected:
friend class Manager;
friend class zeek::plugin::Manager;
/**
* First-stage initialization of the plugin called early during Bro's
@ -568,7 +592,7 @@ protected:
*
* @param c The component. The method takes ownership.
*/
void AddComponent(Component* c);
void AddComponent(zeek::plugin::Component* c);
/**
* Calls the Initialize() function of all components.
@ -594,7 +618,7 @@ protected:
* highest to lowest. If two plugins specify the same priority, order
* is undefined.
*/
void EnableHook(HookType hook, int priority = 0);
void EnableHook(zeek::plugin::HookType hook, int priority = 0);
/**
* Disables a hook. Bro will no longer call the corresponding virtual
@ -602,7 +626,16 @@ protected:
*
* @param hook The hook to disable.
*/
void DisableHook(HookType hook);
void DisableHook(zeek::plugin::HookType hook);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use the version that takes zeek::plugin:HookType instead.")]]
void EnableHook(::plugin::HookType hook, int priority = 0);
[[deprecated("Remove in v4.1. Use the version that takes zeek::plugin:HookType instead.")]]
void DisableHook(::plugin::HookType hook);
#pragma GCC diagnostic pop
/**
* Returns a list of hooks that are currently enabled for the plugin,
@ -855,7 +888,13 @@ protected:
*
* args: A list of the hooks arguments.
*/
virtual void MetaHookPre(HookType hook, const HookArgumentList& args);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use the version that takes zeek::plugin:HookType instead.")]]
virtual void MetaHookPre(::plugin::HookType hook, const HookArgumentList& args);
#pragma GCC diagnostic pop
virtual void MetaHookPre(zeek::plugin::HookType hook, const HookArgumentList& args);
/**
* A meta hook called just after another hook got to execute. This
@ -870,7 +909,13 @@ protected:
* implementation for the hook, this will be the default result. If
* the hook doesn't yield a result, this will be of type VOID.
*/
virtual void MetaHookPost(HookType hook, const HookArgumentList& args, HookArgument result);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[[deprecated("Remove in v4.1. Use the version that takes zeek::plugin:HookType instead.")]]
virtual void MetaHookPost(::plugin::HookType hook, const HookArgumentList& args, HookArgument result);
#pragma GCC diagnostic pop
virtual void MetaHookPost(zeek::plugin::HookType hook, const HookArgumentList& args, HookArgument result);
private:
@ -925,3 +970,12 @@ private:
};
}
namespace plugin {
using VersionNumber [[deprecated("Remove in v4.1. Use zeek::plugin::VersionNumber instead")]] = zeek::plugin::VersionNumber;
using Configuration [[deprecated("Remove in v4.1. Use zeek::plugin::Configuration instead")]] = zeek::plugin::Configuration;
using BifItem [[deprecated("Remove in v4.1. Use zeek::plugin::BifItem instead")]] = zeek::plugin::BifItem;
using HookArgument [[deprecated("Remove in v4.1. Use zeek::plugin::HookArgument instead")]] = zeek::plugin::HookArgument;
using HookArgumentList [[deprecated("Remove in v4.1. Use zeek::plugin::HookArgumentList instead")]] = zeek::plugin::HookArgumentList;
using Plugin [[deprecated("Remove in v4.1. Use zeek::plugin::Plugin instead")]] = zeek::plugin::Plugin;
}