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:
Jon Siwek 2020-06-05 17:57:42 -07:00
parent ef6bd3ee39
commit 2893eea045
11 changed files with 66 additions and 36 deletions

View file

@ -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 {