mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Improve Func.h inclusion
Now forward declares some Broker types since Broker/CAF headers generally slow things down and also Coverity Scan currently has a catastrophic error on some CAF headers. Also a few other changes to EventHandler/BifReturnVal to reduce number of places that depend on Func.h.
This commit is contained in:
parent
ef6bd3ee39
commit
2893eea045
11 changed files with 66 additions and 36 deletions
11
src/BifReturnVal.cc
Normal file
11
src/BifReturnVal.cc
Normal file
|
@ -0,0 +1,11 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "BifReturnVal.h"
|
||||
#include "Val.h"
|
||||
|
||||
BifReturnVal::BifReturnVal(std::nullptr_t) noexcept
|
||||
{}
|
||||
|
||||
BifReturnVal::BifReturnVal(Val* v) noexcept
|
||||
: rval(AdoptRef{}, v)
|
||||
{}
|
28
src/BifReturnVal.h
Normal file
28
src/BifReturnVal.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IntrusivePtr.h"
|
||||
|
||||
class Val;
|
||||
|
||||
/**
|
||||
* A simple wrapper class to use for the return value of BIFs so that
|
||||
* they may return either a Val* or IntrusivePtr<Val> (the former could
|
||||
* potentially be deprecated).
|
||||
*/
|
||||
class BifReturnVal {
|
||||
public:
|
||||
|
||||
template <typename T>
|
||||
BifReturnVal(IntrusivePtr<T> v) noexcept
|
||||
: rval(AdoptRef{}, v.release())
|
||||
{ }
|
||||
|
||||
BifReturnVal(std::nullptr_t) noexcept;
|
||||
|
||||
[[deprecated("Remove in v4.1. Return an IntrusivePtr instead.")]]
|
||||
BifReturnVal(Val* v) noexcept;
|
||||
|
||||
IntrusivePtr<Val> rval;
|
||||
};
|
|
@ -218,6 +218,7 @@ set(MAIN_SRCS
|
|||
Anon.cc
|
||||
Attr.cc
|
||||
Base64.cc
|
||||
BifReturnVal.cc
|
||||
Brofiler.cc
|
||||
BroString.cc
|
||||
CCL.cc
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "zeek-config.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
|
|
@ -44,6 +44,12 @@ const IntrusivePtr<FuncType>& EventHandler::GetType(bool check_export)
|
|||
return type;
|
||||
}
|
||||
|
||||
void EventHandler::SetFunc(IntrusivePtr<Func> f)
|
||||
{ local = std::move(f); }
|
||||
|
||||
void EventHandler::SetLocalHandler(Func* f)
|
||||
{ SetFunc({NewRef{}, f}); }
|
||||
|
||||
void EventHandler::Call(zeek::Args* vl, bool no_remote)
|
||||
{
|
||||
#ifdef PROFILE_BRO_FUNCTIONS
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
#include "BroList.h"
|
||||
#include "ZeekArgs.h"
|
||||
#include "Type.h"
|
||||
#include "Func.h"
|
||||
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
|
||||
class Func;
|
||||
|
||||
class EventHandler {
|
||||
public:
|
||||
explicit EventHandler(std::string name);
|
||||
|
@ -28,12 +29,10 @@ public:
|
|||
FuncType* FType(bool check_export = true)
|
||||
{ return GetType().get(); }
|
||||
|
||||
void SetFunc(IntrusivePtr<Func> f)
|
||||
{ local = std::move(f); }
|
||||
void SetFunc(IntrusivePtr<Func> f);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use SetFunc().")]]
|
||||
void SetLocalHandler(Func* f)
|
||||
{ SetFunc({NewRef{}, f}); }
|
||||
void SetLocalHandler(Func* f);
|
||||
|
||||
void AutoPublish(std::string topic)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "EventRegistry.h"
|
||||
#include "EventHandler.h"
|
||||
#include "Func.h"
|
||||
#include "RE.h"
|
||||
#include "Reporter.h"
|
||||
|
||||
|
|
|
@ -892,10 +892,3 @@ function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusiveP
|
|||
priority = (attrs ? get_func_priority(*attrs) : 0);
|
||||
this->body = std::move(body);
|
||||
}
|
||||
|
||||
BifReturnVal::BifReturnVal(std::nullptr_t) noexcept
|
||||
{ }
|
||||
|
||||
BifReturnVal::BifReturnVal(Val* v) noexcept
|
||||
: rval(AdoptRef{}, v)
|
||||
{ }
|
||||
|
|
35
src/Func.h
35
src/Func.h
|
@ -9,15 +9,13 @@
|
|||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
#include <broker/data.hh>
|
||||
#include <broker/expected.hh>
|
||||
|
||||
#include "BroList.h"
|
||||
#include "Obj.h"
|
||||
#include "IntrusivePtr.h"
|
||||
#include "Type.h" /* for function_flavor */
|
||||
#include "TraverseTypes.h"
|
||||
#include "ZeekArgs.h"
|
||||
#include "BifReturnVal.h"
|
||||
|
||||
class Val;
|
||||
class ListExpr;
|
||||
|
@ -28,6 +26,16 @@ class ID;
|
|||
class CallExpr;
|
||||
class Scope;
|
||||
|
||||
namespace caf {
|
||||
template <class> class expected;
|
||||
}
|
||||
|
||||
namespace broker {
|
||||
class data;
|
||||
using vector = std::vector<data>;
|
||||
using caf::expected;
|
||||
}
|
||||
|
||||
class Func : public BroObj {
|
||||
public:
|
||||
static inline const IntrusivePtr<Func> nil;
|
||||
|
@ -205,27 +213,6 @@ private:
|
|||
bool weak_closure_ref = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* A simple wrapper class to use for the return value of BIFs so that
|
||||
* they may return either a Val* or IntrusivePtr<Val> (the former could
|
||||
* potentially be deprecated).
|
||||
*/
|
||||
class BifReturnVal {
|
||||
public:
|
||||
|
||||
template <typename T>
|
||||
BifReturnVal(IntrusivePtr<T> v) noexcept
|
||||
: rval(AdoptRef{}, v.release())
|
||||
{ }
|
||||
|
||||
BifReturnVal(std::nullptr_t) noexcept;
|
||||
|
||||
[[deprecated("Remove in v4.1. Return an IntrusivePtr instead.")]]
|
||||
BifReturnVal(Val* v) noexcept;
|
||||
|
||||
IntrusivePtr<Val> rval;
|
||||
};
|
||||
|
||||
using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args);
|
||||
|
||||
class BuiltinFunc final : public Func {
|
||||
|
|
|
@ -7,3 +7,4 @@
|
|||
#include "Reporter.h"
|
||||
#include "ID.h"
|
||||
#include "EventRegistry.h"
|
||||
#include "BifReturnVal.h"
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "file_analysis/Manager.h"
|
||||
|
||||
#include <broker/error.hh>
|
||||
#include <broker/expected.hh>
|
||||
#include <broker/data.hh>
|
||||
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue