GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/src/cppgc_helpers-inl.h at main · trentm/node Expand file tree/ Copy pathcppgc_helpers-inl.hMore file actions 69 lines (57 loc) · 2.28 KB / Copy pathcppgc_helpers-inl.hFile metadata and controls69 lines (57 loc) · 2.28 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 #ifndef SRC_CPPGC_HELPERS_INL_H_ #define SRC_CPPGC_HELPERS_INL_H_ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "cppgc_helpers.h" #include "env-inl.h" namespace node { template <typename T> void CppgcMixin::Wrap(T* ptr, Realm* realm, v8::Local<v8::Object> obj) { CHECK_GE(obj->InternalFieldCount(), T::kInternalFieldCount); ptr->realm_ = realm; v8::Isolate* isolate = realm->isolate(); ptr->traced_reference_ = v8::TracedReference<v8::Object>(isolate, obj); // Note that ptr must be of concrete type T in Wrap. auto* wrappable = static_cast<v8::Object::Wrappable*>(ptr); v8::Object::Wrap<v8::CppHeapPointerTag::kDefaultTag>(isolate, obj, wrappable); // Keep the layout consistent with BaseObjects. obj->SetAlignedPointerInInternalField( kEmbedderType, realm->isolate_data()->embedder_id_for_cppgc(), EmbedderDataTag::kEmbedderType); obj->SetAlignedPointerInInternalField(kSlot, ptr, EmbedderDataTag::kDefault); realm->TrackCppgcWrapper(ptr); } template <typename T> void CppgcMixin::Wrap(T* ptr, Environment* env, v8::Local<v8::Object> obj) { Wrap(ptr, env->principal_realm(), obj); } template <typename T> T* CppgcMixin::Unwrap(v8::Local<v8::Object> obj) { // We are not using v8::Object::Unwrap currently because that requires // access to isolate which the ASSIGN_OR_RETURN_UNWRAP macro that we'll shim // with ASSIGN_OR_RETURN_UNWRAP_GC doesn't take, and we also want a // signature consistent with BaseObject::Unwrap() to avoid churn. Since // cppgc-managed objects share the same layout as BaseObjects, just unwrap // from the pointer in the internal field, which should be valid as long as // the object is still alive. if (obj->InternalFieldCount() != T::kInternalFieldCount) { return nullptr; } T* ptr = static_cast<T*>(obj->GetAlignedPointerFromInternalField( T::kSlot, EmbedderDataTag::kDefault)); return ptr; } v8::Local<v8::Object> CppgcMixin::object() const { return traced_reference_.Get(realm_->isolate()); } Environment* CppgcMixin::env() const { return realm_->env(); } CppgcMixin::~CppgcMixin() { if (realm_ != nullptr) { realm_->set_should_purge_empty_cppgc_wrappers(true); } } } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #endif // SRC_CPPGC_HELPERS_INL_H_ |
| You are visitor 01402792 — 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. |