GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: add iteration over all base objects to Environment · nodejs/node@d42dbde

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • env-inl.h
    • env.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,22 @@ bool Environment::CleanupHookCallback::Equal::operator()(
809809
return a.fn_ == b.fn_ && a.arg_ == b.arg_;
810810
}
811811

812+
BaseObject* Environment::CleanupHookCallback::GetBaseObject() const {
813+
if (fn_ == BaseObject::DeleteMe)
814+
return static_cast<BaseObject*>(arg_);
815+
else
816+
return nullptr;
817+
}
818+
819+
template <typename T>
820+
void Environment::ForEachBaseObject(T&& iterator) {
821+
for (const auto& hook : cleanup_hooks_) {
822+
BaseObject* obj = hook.GetBaseObject();
823+
if (obj != nullptr)
824+
iterator(obj);
825+
}
826+
}
827+
812828
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
813829
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
814830
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,8 @@ class Environment {
976976
inline bool operator()(const CleanupHookCallback& a,
977977
const CleanupHookCallback& b) const;
978978
};
979+
980+
inline BaseObject* GetBaseObject() const;
979981
};
980982

981983
// Use an unordered_set, so that we have efficient insertion and removal.
@@ -988,6 +990,9 @@ class Environment {
988990
v8::Local<v8::Promise> promise,
989991
v8::Local<v8::Value> parent);
990992

993+
template <typename T>
994+
void ForEachBaseObject(T&& iterator);
995+
991996
#define V(PropertyName, TypeName) Persistent<TypeName> PropertyName ## _;
992997
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
993998
#undef V

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.