mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move IntrusivePtr and utility methods to the zeek namespace
This commit is contained in:
parent
4668378d91
commit
9364e6a5b7
255 changed files with 3761 additions and 3730 deletions
50
src/Scope.h
50
src/Scope.h
|
@ -21,10 +21,10 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
|||
|
||||
class Scope : public BroObj {
|
||||
public:
|
||||
explicit Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> al);
|
||||
explicit Scope(zeek::IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>> al);
|
||||
|
||||
const IntrusivePtr<zeek::detail::ID>& Find(std::string_view name) const;
|
||||
const zeek::IntrusivePtr<zeek::detail::ID>& Find(std::string_view name) const;
|
||||
|
||||
template<typename N>
|
||||
[[deprecated("Remove in v4.1. Use Find().")]]
|
||||
|
@ -34,34 +34,34 @@ public:
|
|||
template<typename N, typename I>
|
||||
void Insert(N&& name, I&& id) { local[std::forward<N>(name)] = std::forward<I>(id); }
|
||||
|
||||
IntrusivePtr<zeek::detail::ID> Remove(std::string_view name);
|
||||
zeek::IntrusivePtr<zeek::detail::ID> Remove(std::string_view name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetID().")]]
|
||||
zeek::detail::ID* ScopeID() const { return scope_id.get(); }
|
||||
|
||||
const IntrusivePtr<zeek::detail::ID>& GetID() const
|
||||
const zeek::IntrusivePtr<zeek::detail::ID>& GetID() const
|
||||
{ return scope_id; }
|
||||
|
||||
const std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>& Attrs() const
|
||||
const std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>>& Attrs() const
|
||||
{ return attrs; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
||||
zeek::Type* ReturnType() const { return return_type.get(); }
|
||||
|
||||
const IntrusivePtr<zeek::Type>& GetReturnType() const
|
||||
const zeek::IntrusivePtr<zeek::Type>& GetReturnType() const
|
||||
{ return return_type; }
|
||||
|
||||
size_t Length() const { return local.size(); }
|
||||
const auto& Vars() { return local; }
|
||||
|
||||
IntrusivePtr<zeek::detail::ID> GenerateTemporary(const char* name);
|
||||
zeek::IntrusivePtr<zeek::detail::ID> GenerateTemporary(const char* name);
|
||||
|
||||
// Returns the list of variables needing initialization, and
|
||||
// removes it from this Scope.
|
||||
std::vector<IntrusivePtr<zeek::detail::ID>> GetInits();
|
||||
std::vector<zeek::IntrusivePtr<zeek::detail::ID>> GetInits();
|
||||
|
||||
// Adds a variable to the list.
|
||||
void AddInit(IntrusivePtr<zeek::detail::ID> id)
|
||||
void AddInit(zeek::IntrusivePtr<zeek::detail::ID> id)
|
||||
{ inits.emplace_back(std::move(id)); }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -69,31 +69,33 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<zeek::detail::ID> scope_id;
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs;
|
||||
IntrusivePtr<zeek::Type> return_type;
|
||||
std::map<std::string, IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
extern bool in_debug;
|
||||
|
||||
// If no_global is true, don't search in the default "global" namespace.
|
||||
extern const IntrusivePtr<zeek::detail::ID>& lookup_ID(const char* name, const char* module,
|
||||
bool no_global = false,
|
||||
bool same_module_only = false,
|
||||
bool check_export = true);
|
||||
extern const zeek::IntrusivePtr<zeek::detail::ID>& lookup_ID(
|
||||
const char* name, const char* module,
|
||||
bool no_global = false,
|
||||
bool same_module_only = false,
|
||||
bool check_export = true);
|
||||
|
||||
extern IntrusivePtr<zeek::detail::ID> install_ID(const char* name, const char* module_name,
|
||||
bool is_global, bool is_export);
|
||||
extern zeek::IntrusivePtr<zeek::detail::ID> install_ID(
|
||||
const char* name, const char* module_name,
|
||||
bool is_global, bool is_export);
|
||||
|
||||
extern void push_scope(IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs);
|
||||
extern void push_scope(zeek::IntrusivePtr<zeek::detail::ID> id,
|
||||
std::unique_ptr<std::vector<zeek::IntrusivePtr<zeek::detail::Attr>>> attrs);
|
||||
extern void push_existing_scope(Scope* scope);
|
||||
|
||||
// Returns the one popped off.
|
||||
extern IntrusivePtr<Scope> pop_scope();
|
||||
extern zeek::IntrusivePtr<Scope> pop_scope();
|
||||
extern Scope* current_scope();
|
||||
extern Scope* global_scope();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue