Use type aliases for IntrusivePtr definitions

This commit is contained in:
Tim Wojtulewicz 2020-06-24 16:46:34 -04:00
parent f6a251cdac
commit ec9eff0bd5
180 changed files with 2026 additions and 1893 deletions

View file

@ -21,6 +21,19 @@ class BroFunc;
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Trigger, zeek::detail::trigger);
namespace zeek::detail {
using IDPtr = zeek::IntrusivePtr<ID>;
namespace trigger {
using TriggerPtr = zeek::IntrusivePtr<Trigger>;
}
}
using ValPtr = zeek::IntrusivePtr<Val>;
class Frame;
using FramePtr = zeek::IntrusivePtr<Frame>;
class Frame : public BroObj {
public:
/**
@ -43,7 +56,7 @@ public:
* @param n the index to get.
* @return the value at index *n* of the underlying array.
*/
const zeek::IntrusivePtr<Val>& GetElement(int n) const
const ValPtr& GetElement(int n) const
{ return frame[n].val; }
[[deprecated("Remove in v4.1. Use GetElement(int).")]]
@ -54,7 +67,7 @@ public:
* @param n the index to set
* @param v the value to set it to
*/
void SetElement(int n, zeek::IntrusivePtr<Val> v);
void SetElement(int n, ValPtr v);
[[deprecated("Remove in v4.1. Pass IntrusivePtr instead.")]]
void SetElement(int n, Val* v);
@ -66,8 +79,8 @@ public:
* @param id the ID to associate
* @param v the value to associate it with
*/
void SetElement(const zeek::detail::ID* id, zeek::IntrusivePtr<Val> v);
void SetElement(const zeek::IntrusivePtr<zeek::detail::ID>& id, zeek::IntrusivePtr<Val> v)
void SetElement(const zeek::detail::ID* id, ValPtr v);
void SetElement(const zeek::detail::IDPtr& id, ValPtr v)
{ SetElement(id.get(), std::move(v)); }
/**
@ -77,7 +90,7 @@ public:
* @param id the id who's value to retreive
* @return the value associated with *id*
*/
const zeek::IntrusivePtr<Val>& GetElementByID(const zeek::IntrusivePtr<zeek::detail::ID>& id) const
const ValPtr& GetElementByID(const zeek::detail::IDPtr& id) const
{ return GetElementByID(id.get()); }
[[deprecated("Remove in v4.1. Use GetElementByID().")]]
@ -195,7 +208,7 @@ public:
* and the second is the unserialized frame with reference count +1, or
* null if the serialization wasn't successful.
*/
static std::pair<bool, zeek::IntrusivePtr<Frame>> Unserialize(const broker::vector& data);
static std::pair<bool, FramePtr> Unserialize(const broker::vector& data);
/**
* Sets the IDs that the frame knows offsets for. These offsets will
@ -216,7 +229,7 @@ public:
// If the frame is run in the context of a trigger condition evaluation,
// the trigger needs to be registered.
void SetTrigger(zeek::IntrusivePtr<zeek::detail::trigger::Trigger> arg_trigger);
void SetTrigger(zeek::detail::trigger::TriggerPtr arg_trigger);
void ClearTrigger();
zeek::detail::trigger::Trigger* GetTrigger() const { return trigger.get(); }
@ -241,13 +254,13 @@ private:
using OffsetMap = std::unordered_map<std::string, int>;
struct Element {
zeek::IntrusivePtr<Val> val;
ValPtr val;
// Weak reference is used to prevent circular reference memory leaks
// in lambdas/closures.
bool weak_ref;
};
const zeek::IntrusivePtr<Val>& GetElementByID(const zeek::detail::ID* id) const;
const ValPtr& GetElementByID(const zeek::detail::ID* id) const;
/**
* Sets the element at index *n* of the underlying array to *v*, but does
@ -322,7 +335,7 @@ private:
/** The next statement to be evaluted in the context of this frame. */
zeek::detail::Stmt* next_stmt;
zeek::IntrusivePtr<zeek::detail::trigger::Trigger> trigger;
zeek::detail::trigger::TriggerPtr trigger;
const zeek::detail::CallExpr* call;
std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference;