#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); } } bool TNativeObject::ToBool() { return true; } bool TNativeObject::Equals(std::shared_ptr gc, TObject right) { if (std::holds_alternative(right)) { return this == std::get(right).obj; } return false; } TNative *TNative::Create(GCList &ls, void *ptr, std::function destroy) { return ls.Create(ptr, destroy); } TNative *TNative::Create(GCList *ls, void *ptr, std::function destroy) { return ls->Create(ptr, destroy); } TNative::~TNative() { this->Destroy(); } } // namespace Tesses::CrossLang