5#ifndef FLUTTER_FML_PLATFORM_DARWIN_SCOPED_NSOBJECT_H_
6#define FLUTTER_FML_PLATFORM_DARWIN_SCOPED_NSOBJECT_H_
14#import <Foundation/NSObject.h>
16#include "flutter/fml/compiler_specific.h"
17#include "flutter/fml/macros.h"
18#include "flutter/fml/platform/darwin/scoped_typeref.h"
20#if !defined(__has_feature) || !__has_feature(objc_arc)
21@class NSAutoreleasePool;
56 __attribute((ns_returns_not_retained));
58 __attribute((ns_returns_not_retained));
66template <
typename NST>
71 static NST
Retain(__unsafe_unretained NST nst)
72 __attribute((ns_returns_not_retained)) {
75 static void Release(__unsafe_unretained NST nst) {
82template <
typename NST>
84 :
public ScopedTypeRef<NST, internal::ScopedNSProtocolTraits<NST>> {
88#if !defined(__has_feature) || !__has_feature(objc_arc)
96 scoped_policy::OwnershipPolicy::kRetain) {}
103 template <
typename NSR>
116#if !defined(__has_feature) || !__has_feature(objc_arc)
143 return p1 == p2.
get();
148 return p1 != p2.
get();
151template <
typename NST>
156#if !defined(__has_feature) || !__has_feature(objc_arc)
170 template <
typename NSR>
183#if !defined(__has_feature) || !__has_feature(objc_arc)
184 void reset(NST*
object = Traits::InvalidValue(),
190 void reset(NST*
object = Traits::InvalidValue()) {
195#if !defined(__has_feature) || !__has_feature(objc_arc)
196 static_assert(std::is_same<NST, NSAutoreleasePool>::value ==
false,
197 "Use ScopedNSAutoreleasePool instead");
207#if !defined(__has_feature) || !__has_feature(objc_arc)
221 template <
typename NSR>
234#if !defined(__has_feature) || !__has_feature(objc_arc)
235 void reset(
id object = Traits::InvalidValue(),
241 void reset(
id object = Traits::InvalidValue()) {
T get() const __attribute((ns_returns_not_retained))
ScopedTypeRef & operator=(const ScopedTypeRef< T, Traits > &that)
NST release() __attribute((ns_returns_not_retained))
void reset(__unsafe_unretained T object=Traits::InvalidValue(), fml::scoped_policy::OwnershipPolicy policy=fml::scoped_policy::kAssume)
void swap(ScopedTypeRef &that)
scoped_nsobject(id object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
scoped_nsobject(const scoped_nsobject< id > &that)
typename scoped_nsprotocol< id >::Traits Traits
void reset(id object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
scoped_nsobject(const scoped_nsobject< NSR > &that_as_subclass)
scoped_nsobject & operator=(const scoped_nsobject< id > &that)
scoped_nsobject(scoped_nsobject< id > &&that)
scoped_nsobject & operator=(const scoped_nsobject< NST > &that)
typename scoped_nsprotocol< NST * >::Traits Traits
scoped_nsobject(const scoped_nsobject< NST > &that)
void reset(NST *object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
scoped_nsobject(scoped_nsobject< NST > &&that)
scoped_nsobject(const scoped_nsobject< NSR > &that_as_subclass)
scoped_nsobject(NST *object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
scoped_nsprotocol & operator=(const scoped_nsprotocol< NST > &that)
scoped_nsprotocol(scoped_nsprotocol< NST > &&that)
scoped_nsprotocol(const scoped_nsprotocol< NSR > &that_as_subclass)
void reset(NST object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
scoped_nsprotocol(const scoped_nsprotocol< NST > &that)
scoped_nsprotocol(NST object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
internal::ScopedNSProtocolTraits< NST > Traits
NST autorelease() __attribute((ns_returns_not_retained))
void ScopedNSProtocolTraitsRelease(__unsafe_unretained id obj)
id ScopedNSProtocolTraitsAutoRelease(__unsafe_unretained id obj) __attribute((ns_returns_not_retained))
id ScopedNSProtocolTraitsRetain(__unsafe_unretained id obj) __attribute((ns_returns_not_retained))
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
void swap(scoped_nsprotocol< C > &p1, scoped_nsprotocol< C > &p2)
bool operator!=(C p1, const scoped_nsprotocol< C > &p2)
static void Release(__unsafe_unretained NST nst)
static NST InvalidValue() __attribute((ns_returns_not_retained))
static NST Retain(__unsafe_unretained NST nst) __attribute((ns_returns_not_retained))