#include "CrossLang.hpp" namespace Tesses::CrossLang { TNative::TNative(void* ptr,std::function destroy) { this->ptr = ptr; this->destroyed=false; this->destroy = destroy; } bool TNative::GetDestroyed() { return this->destroyed; } void* TNative::GetPointer() { return this->ptr; } void TNative::Mark() { if(this->marked) return; this->marked=true; GC::Mark(this->other); } void TNative::Destroy() { if(this->destroyed) return; if(this->destroy != nullptr) { this->destroyed=true; this->destroy(this->ptr); } } TNative* TNative::Create(GCList& ls, void* ptr,std::function destroy) { TNative* native = new TNative(ptr,destroy); GC* gc = ls.GetGC(); ls.Add(native); gc->Watch(native); return native; } TNative* TNative::Create(GCList* ls, void* ptr,std::function destroy) { TNative* native = new TNative(ptr,destroy); GC* gc = ls->GetGC(); ls->Add(native); gc->Watch(native); return native; } TNative::~TNative() { this->Destroy(); } }