summaryrefslogtreecommitdiff
path: root/Menes
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-07 06:53:52 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-08 01:50:04 -0800
commitbf7c998c9b68756e925462bbfe1f9a699fc5055b (patch)
tree14f65a999df9ff282876450581034ce9a3fcd5d3 /Menes
parentdfdb9ae0d3bc3689c3ca7b59e92f45c1b3ecb28f (diff)
Automate set{Delegate,DataSource}:nil using _H<>.
Diffstat (limited to 'Menes')
-rw-r--r--Menes/ObjectHandle.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/Menes/ObjectHandle.h b/Menes/ObjectHandle.h
index 716e6f4..cd01509 100644
--- a/Menes/ObjectHandle.h
+++ b/Menes/ObjectHandle.h
@@ -40,7 +40,31 @@
#ifndef Menes_ObjectHandle_H
#define Menes_ObjectHandle_H
+template <typename Type_, unsigned Delegate_>
+struct MenesObjectHandle_;
+
template <typename Type_>
+struct MenesObjectHandle_<Type_, 0> {
+ static _finline void Execute(Type_ *value) {
+ }
+};
+
+template <typename Type_>
+struct MenesObjectHandle_<Type_, 1> {
+ static _finline void Execute(Type_ *value) {
+ [value setDelegate:nil];
+ }
+};
+
+template <typename Type_>
+struct MenesObjectHandle_<Type_, 2> {
+ static _finline void Execute(Type_ *value) {
+ [value setDelegate:nil];
+ [value setDataSource:nil];
+ }
+};
+
+template <typename Type_, unsigned Delegate_ = 0>
class MenesObjectHandle {
private:
Type_ *value_;
@@ -51,8 +75,10 @@ class MenesObjectHandle {
}
_finline void Clear_() {
- if (value_ != nil)
+ if (value_ != nil) {
+ MenesObjectHandle_<Type_, Delegate_>::Execute(value_);
CFRelease((CFTypeRef) value_);
+ }
}
public: