summaryrefslogtreecommitdiff
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
parentdfdb9ae0d3bc3689c3ca7b59e92f45c1b3ecb28f (diff)
Automate set{Delegate,DataSource}:nil using _H<>.
-rw-r--r--CyteKit/TableViewCell.h4
-rw-r--r--CyteKit/WebViewController.h6
-rw-r--r--CyteKit/WebViewController.mm8
-rw-r--r--Menes/ObjectHandle.h28
-rw-r--r--MobileCydia.mm43
5 files changed, 46 insertions, 43 deletions
diff --git a/CyteKit/TableViewCell.h b/CyteKit/TableViewCell.h
index 27fd650..719b16b 100644
--- a/CyteKit/TableViewCell.h
+++ b/CyteKit/TableViewCell.h
@@ -44,7 +44,7 @@
#include <UIKit/UIKit.h>
-#include <CydiaSubstrate/CydiaSubstrate.h>
+#include <Menes/ObjectHandle.h>
@protocol CyteTableViewCellDelegate
- (void) drawContentRect:(CGRect)rect;
@@ -57,7 +57,7 @@
@end
@interface CYTableViewCell : UITableViewCell {
- _H<CyteTableViewCellContentView> content_;
+ _H<CyteTableViewCellContentView, 1> content_;
bool highlighted_;
}
diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h
index 0954b38..76bdd82 100644
--- a/CyteKit/WebViewController.h
+++ b/CyteKit/WebViewController.h
@@ -46,7 +46,7 @@
#include <UIKit/UIKit.h>
#include <MessageUI/MessageUI.h>
-#include <CydiaSubstrate/CydiaSubstrate.h>
+#include <Menes/ObjectHandle.h>
@class IndirectDelegate;
@@ -62,11 +62,11 @@
MFMailComposeViewControllerDelegate,
UIWebViewDelegate
> {
- _transient CyteWebView *webview_;
+ _H<CyteWebView, 1> webview_;
_transient UIScrollView *scroller_;
_H<UIActivityIndicatorView> indicator_;
- _H<IndirectDelegate> indirect_;
+ _H<IndirectDelegate, 1> indirect_;
_H<NSURLAuthenticationChallenge> challenge_;
bool error_;
diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm
index 03f0b95..ca2f89a 100644
--- a/CyteKit/WebViewController.mm
+++ b/CyteKit/WebViewController.mm
@@ -25,6 +25,9 @@ extern NSString * const kCAFilterNearest;
#include <WebKit/DOMHTMLBodyElement.h>
#include <WebKit/DOMRGBColor.h>
+#include <dlfcn.h>
+#include <objc/runtime.h>
+
#define ForSaurik 0
#define DefaultTimeout_ 120.0
@@ -138,9 +141,6 @@ float CYScrollViewDecelerationRateNormal;
NSLog(@"[CyteWebViewController dealloc]");
#endif
- [webview_ setDelegate:nil];
- [indirect_ setDelegate:nil];
-
if ([loading_ count] != 0)
[delegate_ releaseNetworkActivityIndicator];
@@ -919,7 +919,7 @@ float CYScrollViewDecelerationRateNormal;
}
- (void) dispatchEvent:(NSString *)event {
- [webview_ dispatchEvent:event];
+ [(CyteWebView *) webview_ dispatchEvent:event];
}
- (bool) hidesNavigationBar {
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:
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 92bce95..4e0343a 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -4896,7 +4896,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
ProgressDelegate
> {
_transient Database *database_;
- _H<CydiaProgressData> progress_;
+ _H<CydiaProgressData, 1> progress_;
unsigned cancel_;
}
@@ -4913,7 +4913,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
- (void) dealloc {
[database_ setProgressDelegate:nil];
- [progress_ setDelegate:nil];
[super dealloc];
}
@@ -5511,7 +5510,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
_H<Package> package_;
_H<NSString> name_;
_H<NSMutableArray> files_;
- _H<UITableView> list_;
+ _H<UITableView, 2> list_;
}
- (id) initWithDatabase:(Database *)database;
@@ -5521,12 +5520,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@implementation FileTable
-- (void) dealloc {
- [(UITableView *) list_ setDataSource:nil];
- [list_ setDelegate:nil];
- [super dealloc];
-}
-
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return files_ == nil ? 0 : [files_ count];
}
@@ -5803,7 +5796,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
unsigned era_;
_H<NSArray> packages_;
_H<NSMutableArray> sections_;
- _H<UITableView> list_;
+ _H<UITableView, 2> list_;
_H<NSMutableArray> index_;
_H<NSMutableDictionary> indices_;
_H<NSString> title_;
@@ -5819,12 +5812,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@implementation PackageListController
-- (void) dealloc {
- [list_ setDataSource:nil];
- [list_ setDelegate:nil];
- [super dealloc];
-}
-
- (bool) isSummarized {
return false;
}
@@ -6467,7 +6454,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
ProgressDelegate
> {
_transient Database *database_;
- _H<RefreshBar> refreshbar_;
+ _H<RefreshBar, 1> refreshbar_;
bool dropped_;
bool updating_;
@@ -6546,7 +6533,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
}
- (void) dealloc {
- [refreshbar_ setDelegate:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
@@ -6932,7 +6918,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
_transient Database *database_;
_H<NSMutableArray> sections_;
_H<NSMutableArray> filtered_;
- _H<UITableView> list_;
+ _H<UITableView, 2> list_;
}
- (id) initWithDatabase:(Database *)database;
@@ -7134,7 +7120,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
unsigned era_;
_H<NSArray> packages_;
_H<NSMutableArray> sections_;
- _H<UITableView> list_;
+ _H<UITableView, 2> list_;
unsigned upgrades_;
}
@@ -7365,7 +7351,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@interface SearchController : FilteredPackageListController <
UISearchBarDelegate
> {
- _H<UISearchBar> search_;
+ _H<UISearchBar, 1> search_;
BOOL searchloaded_;
}
@@ -7376,11 +7362,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@implementation SearchController
-- (void) dealloc {
- [search_ setDelegate:nil];
- [super dealloc];
-}
-
- (NSURL *) navigationURL {
if ([search_ text] == nil || [[search_ text] isEqualToString:@""])
return [NSURL URLWithString:@"cydia://search"];
@@ -7491,7 +7472,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
_transient Database *database_;
_H<NSString> name_;
_H<Package> package_;
- _H<UITableView> table_;
+ _H<UITableView, 2> table_;
_H<UISwitch> subscribedSwitch_;
_H<UISwitch> ignoredSwitch_;
_H<UITableViewCell> subscribedCell_;
@@ -7677,10 +7658,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@implementation InstalledController
-- (void) dealloc {
- [super dealloc];
-}
-
- (NSURL *) navigationURL {
return [NSURL URLWithString:@"cydia://installed"];
}
@@ -7845,7 +7822,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
UITableViewDelegate
> {
_transient Database *database_;
- _H<UITableView> list_;
+ _H<UITableView, 2> list_;
_H<NSMutableArray> sources_;
int offset_;
@@ -8286,7 +8263,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
_transient Database *database_;
// XXX: ok, "roledelegate_"?...
_transient id roledelegate_;
- _H<UITableView> table_;
+ _H<UITableView, 2> table_;
_H<UISegmentedControl> segment_;
_H<UIView> container_;
}