mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Use type aliases for IntrusivePtr definitions
This commit is contained in:
parent
f6a251cdac
commit
ec9eff0bd5
180 changed files with 2026 additions and 1893 deletions
55
src/Scope.h
55
src/Scope.h
|
@ -13,18 +13,29 @@
|
|||
#include "TraverseTypes.h"
|
||||
|
||||
template <class T> class IntrusivePtr;
|
||||
class ListVal;
|
||||
|
||||
namespace zeek { class Type; }
|
||||
namespace zeek {
|
||||
class Type;
|
||||
using TypePtr = zeek::IntrusivePtr<zeek::Type>;
|
||||
}
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||
|
||||
namespace zeek::detail {
|
||||
class Attr;
|
||||
using AttrPtr = zeek::IntrusivePtr<Attr>;
|
||||
using IDPtr = zeek::IntrusivePtr<ID>;
|
||||
}
|
||||
|
||||
class Scope;
|
||||
using ScopePtr = zeek::IntrusivePtr<Scope>;
|
||||
|
||||
class Scope : public BroObj {
|
||||
public:
|
||||
explicit Scope(zeek::IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>> al);
|
||||
explicit Scope(zeek::detail::IDPtr id,
|
||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>> al);
|
||||
|
||||
const zeek::IntrusivePtr<zeek::detail::ID>& Find(std::string_view name) const;
|
||||
const zeek::detail::IDPtr& Find(std::string_view name) const;
|
||||
|
||||
template<typename N>
|
||||
[[deprecated("Remove in v4.1. Use Find().")]]
|
||||
|
@ -34,34 +45,34 @@ public:
|
|||
template<typename N, typename I>
|
||||
void Insert(N&& name, I&& id) { local[std::forward<N>(name)] = std::forward<I>(id); }
|
||||
|
||||
zeek::IntrusivePtr<zeek::detail::ID> Remove(std::string_view name);
|
||||
zeek::detail::IDPtr Remove(std::string_view name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetID().")]]
|
||||
zeek::detail::ID* ScopeID() const { return scope_id.get(); }
|
||||
|
||||
const zeek::IntrusivePtr<zeek::detail::ID>& GetID() const
|
||||
const zeek::detail::IDPtr& GetID() const
|
||||
{ return scope_id; }
|
||||
|
||||
const std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>>& Attrs() const
|
||||
const std::unique_ptr<std::vector<zeek::detail::AttrPtr>>& Attrs() const
|
||||
{ return attrs; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
||||
zeek::Type* ReturnType() const { return return_type.get(); }
|
||||
|
||||
const zeek::IntrusivePtr<zeek::Type>& GetReturnType() const
|
||||
const zeek::TypePtr& GetReturnType() const
|
||||
{ return return_type; }
|
||||
|
||||
size_t Length() const { return local.size(); }
|
||||
const auto& Vars() { return local; }
|
||||
|
||||
zeek::IntrusivePtr<zeek::detail::ID> GenerateTemporary(const char* name);
|
||||
zeek::detail::IDPtr GenerateTemporary(const char* name);
|
||||
|
||||
// Returns the list of variables needing initialization, and
|
||||
// removes it from this Scope.
|
||||
std::vector<zeek::IntrusivePtr<zeek::detail::ID>> GetInits();
|
||||
std::vector<zeek::detail::IDPtr> GetInits();
|
||||
|
||||
// Adds a variable to the list.
|
||||
void AddInit(zeek::IntrusivePtr<zeek::detail::ID> id)
|
||||
void AddInit(zeek::detail::IDPtr id)
|
||||
{ inits.emplace_back(std::move(id)); }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -69,33 +80,33 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const;
|
||||
|
||||
protected:
|
||||
zeek::IntrusivePtr<zeek::detail::ID> scope_id;
|
||||
std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>> attrs;
|
||||
zeek::IntrusivePtr<zeek::Type> return_type;
|
||||
std::map<std::string, zeek::IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||
std::vector<zeek::IntrusivePtr<zeek::detail::ID>> inits;
|
||||
zeek::detail::IDPtr scope_id;
|
||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>> attrs;
|
||||
zeek::TypePtr return_type;
|
||||
std::map<std::string, zeek::detail::IDPtr, std::less<>> local;
|
||||
std::vector<zeek::detail::IDPtr> inits;
|
||||
};
|
||||
|
||||
|
||||
extern bool in_debug;
|
||||
|
||||
// If no_global is true, don't search in the default "global" namespace.
|
||||
extern const zeek::IntrusivePtr<zeek::detail::ID>& lookup_ID(
|
||||
extern const zeek::detail::IDPtr& lookup_ID(
|
||||
const char* name, const char* module,
|
||||
bool no_global = false,
|
||||
bool same_module_only = false,
|
||||
bool check_export = true);
|
||||
|
||||
extern zeek::IntrusivePtr<zeek::detail::ID> install_ID(
|
||||
extern zeek::detail::IDPtr install_ID(
|
||||
const char* name, const char* module_name,
|
||||
bool is_global, bool is_export);
|
||||
|
||||
extern void push_scope(zeek::IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>> attrs);
|
||||
extern void push_scope(zeek::detail::IDPtr id,
|
||||
std::unique_ptr<std::vector<zeek::detail::AttrPtr>> attrs);
|
||||
extern void push_existing_scope(Scope* scope);
|
||||
|
||||
// Returns the one popped off.
|
||||
extern zeek::IntrusivePtr<Scope> pop_scope();
|
||||
extern ScopePtr pop_scope();
|
||||
extern Scope* current_scope();
|
||||
extern Scope* global_scope();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue