Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2087)

Unified Diff: base/mac/scoped_typeref.h

Issue 1855483004: [iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing copy constructor from scoped_nsobject<subclass> to scoped_nsobject<class> Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/scoped_nsobject_unittest_arc.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/scoped_typeref.h
diff --git a/base/mac/scoped_typeref.h b/base/mac/scoped_typeref.h
index 11767186455e0aa859d0a7b9705372f472e868e2..b8d8a142625bb3f524786dae5078b6d95347149f 100644
--- a/base/mac/scoped_typeref.h
+++ b/base/mac/scoped_typeref.h
@@ -54,7 +54,7 @@ class ScopedTypeRef {
typedef T element_type;
explicit ScopedTypeRef(
- T object = Traits::InvalidValue(),
+ __unsafe_unretained T object = Traits::InvalidValue(),
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
: object_(object) {
if (object_ && policy == base::scoped_policy::RETAIN)
@@ -97,9 +97,9 @@ class ScopedTypeRef {
return &object_;
}
- void reset(T object = Traits::InvalidValue(),
+ void reset(__unsafe_unretained T object = Traits::InvalidValue(),
base::scoped_policy::OwnershipPolicy policy =
- base::scoped_policy::ASSUME) {
+ base::scoped_policy::ASSUME) {
if (object && policy == base::scoped_policy::RETAIN)
object = Traits::Retain(object);
if (object_)
@@ -107,24 +107,16 @@ class ScopedTypeRef {
object_ = object;
}
- bool operator==(T that) const {
- return object_ == that;
- }
+ bool operator==(__unsafe_unretained T that) const { return object_ == that; }
- bool operator!=(T that) const {
- return object_ != that;
- }
+ bool operator!=(__unsafe_unretained T that) const { return object_ != that; }
- operator T() const {
- return object_;
- }
+ operator T() const __attribute((ns_returns_not_retained)) { return object_; }
- T get() const {
- return object_;
- }
+ T get() const __attribute((ns_returns_not_retained)) { return object_; }
void swap(ScopedTypeRef& that) {
- T temp = that.object_;
+ __unsafe_unretained T temp = that.object_;
that.object_ = object_;
object_ = temp;
}
@@ -132,14 +124,14 @@ class ScopedTypeRef {
// ScopedTypeRef<>::release() is like std::unique_ptr<>::release. It is NOT
// a wrapper for Release(). To force a ScopedTypeRef<> object to call
// Release(), use ScopedTypeRef<>::reset().
- T release() WARN_UNUSED_RESULT {
- T temp = object_;
+ T release() __attribute((ns_returns_not_retained)) WARN_UNUSED_RESULT {
+ __unsafe_unretained T temp = object_;
object_ = Traits::InvalidValue();
return temp;
}
private:
- T object_;
+ __unsafe_unretained T object_;
};
} // namespace base
« no previous file with comments | « base/mac/scoped_nsobject_unittest_arc.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698