5#ifndef FLUTTER_FML_PLATFORM_DARWIN_SCOPED_TYPEREF_H_
6#define FLUTTER_FML_PLATFORM_DARWIN_SCOPED_TYPEREF_H_
8#include "flutter/fml/compiler_specific.h"
9#include "flutter/fml/platform/darwin/scoped_policy.h"
50template <
typename T,
typename Traits = ScopedTypeRefTraits<T>>
56 __unsafe_unretained
T object = Traits::InvalidValue(),
60 object_ = Traits::Retain(object_);
67 object_ = Traits::Retain(object_);
72 template <
typename R,
typename RTraits>
74 : object_(that_as_subclass.
get()) {
76 object_ = Traits::Retain(object_);
82 that.object_ = Traits::InvalidValue();
87 Traits::Release(object_);
104 void reset(__unsafe_unretained
T object = Traits::InvalidValue(),
108 object = Traits::Retain(
object);
111 Traits::Release(object_);
116 bool operator==(__unsafe_unretained
T that)
const {
return object_ == that; }
118 bool operator!=(__unsafe_unretained
T that)
const {
return object_ != that; }
121 operator T() const __attribute((ns_returns_not_retained)) {
return object_; }
123 T get() const __attribute((ns_returns_not_retained)) {
return object_; }
126 __unsafe_unretained
T temp = that.object_;
127 that.object_ = object_;
135 [[nodiscard]]
T release() __attribute((ns_returns_not_retained)) {
136 __unsafe_unretained
T temp = object_;
137 object_ = Traits::InvalidValue();
142 __unsafe_unretained
T object_;
T get() const __attribute((ns_returns_not_retained))
ScopedTypeRef(__unsafe_unretained T object=Traits::InvalidValue(), fml::scoped_policy::OwnershipPolicy policy=fml::scoped_policy::kAssume)
ScopedTypeRef & operator=(const ScopedTypeRef< T, Traits > &that)
T release() __attribute((ns_returns_not_retained))
void reset(__unsafe_unretained T object=Traits::InvalidValue(), fml::scoped_policy::OwnershipPolicy policy=fml::scoped_policy::kAssume)
bool operator==(__unsafe_unretained T that) const
void swap(ScopedTypeRef &that)
bool operator!=(__unsafe_unretained T that) const
ScopedTypeRef(const ScopedTypeRef< R, RTraits > &that_as_subclass)
ScopedTypeRef(const ScopedTypeRef< T, Traits > &that)
ScopedTypeRef(ScopedTypeRef< T, Traits > &&that)
#define FML_DCHECK(condition)