#include "Caches.h" #include "Constants.h" using namespace v8; namespace tns { Caches::Caches(Isolate* isolate, const int& isolateId) : isolate_(isolate), isolateId_(isolateId) { } Caches::~Caches() { this->Prototypes.clear(); this->ClassPrototypes.clear(); this->CtorFuncTemplates.clear(); this->CtorFuncs.clear(); this->ProtocolCtorFuncs.clear(); this->StructConstructorFunctions.clear(); this->PrimitiveInteropTypes.clear(); this->CFunctions.clear(); this->Instances.clear(); this->StructInstances.clear(); this->PointerInstances.clear(); this->cacheBoundObjects_.clear(); } void Caches::Remove(v8::Isolate* isolate) { auto cache = isolate->GetData(Constants::CACHES_ISOLATE_SLOT); isolate->SetData(Constants::CACHES_ISOLATE_SLOT, nullptr); if (cache != nullptr) { delete reinterpret_cast*>(cache); } } void Caches::SetContext(Local context) { this->context_ = std::make_shared>(this->isolate_, context); } Local Caches::GetContext() { return this->context_->Get(this->isolate_); } std::shared_ptr> Caches::Metadata = std::make_shared>(); std::shared_ptr>> Caches::Workers = std::make_shared>>(); }