1 // Copyright 2022-present 650 Industries. All rights reserved. 2 3 #include "ObjectDeallocator.h" 4 #include "JSIUtils.h" 5 6 namespace expo::common { 7 8 void setDeallocator( 9 jsi::Runtime &runtime, 10 const std::shared_ptr<jsi::Object> &jsThis, 11 ObjectDeallocator::Block deallocatorBlock, 12 const std::string &key 13 ) { 14 std::shared_ptr<ObjectDeallocator> hostObjectPtr = std::make_shared<ObjectDeallocator>( 15 deallocatorBlock 16 ); 17 jsi::Object jsDeallocator = jsi::Object::createFromHostObject(runtime, hostObjectPtr); 18 jsThis->setProperty(runtime, key.c_str(), jsi::Value(runtime, jsDeallocator)); 19 } 20 21 } // namespace expo::common 22