Skip to content

Commit 76c93e3

Browse files
author
chris0@lavabit.com
committed
Cleaned up in preparation for further changes.
Mostly white-space but also some comments, macros & typedefs. Updated svn:mime-type subversion property of images. Deleted some old unused files. Updated URL in build script to point to Subversion's new repository.
1 parent 280b2ba commit 76c93e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+892
-3488
lines changed

ArrayCountTransformer.m

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
#import "ArrayCountTransformer.h"
22

33

4+
// Transformer to workaround what I think is a limitation of Panther.
5+
// One should be able to use path.@count in the keyPath field of interface builder,
6+
// but this doesn't seem to work.
7+
48
@implementation ArrayCountTransformer
5-
/*
6-
Transformer to workaround what I think is a limitation of Panther.
7-
One should be able to use path.@count in the keyPath field of interface builder,
8-
but this doesn't seem to work.
9-
10-
*/
11-
+ (Class)transformedValueClass
9+
10+
+ (Class) transformedValueClass
1211
{
13-
return [NSNumber class];
12+
return [NSNumber class];
1413
}
1514

16-
+ (BOOL)allowsReverseTransformation
15+
+ (BOOL) allowsReverseTransformation
1716
{
18-
return NO;
17+
return NO;
1918
}
2019

21-
- (id)transformedValue:(id)aArray
20+
- (id) transformedValue: (id) aArray
2221
{
23-
return [NSNumber numberWithInt:[aArray count]];
22+
return [NSNumber numberWithInt: [aArray count]];
2423
}
2524

2625
@end
26+

CommonUtils.h

+39-17
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,61 @@
11
//----------------------------------------------------------------------------------------
22
// CommonUtils.h - Common Cocoa utilities & definitions
33
//
4-
// Copyright © Chris, 2003 - 2009. All rights reserved.
4+
// Copyright © Chris, 2003 - 2010. All rights reserved.
55
//----------------------------------------------------------------------------------------
66

7-
#pragma once
8-
97
#import <Foundation/Foundation.h>
108

9+
//----------------------------------------------------------------------------------------
1110

1211
#define for_each0(en, it, col, msg) en = [(col) msg]; for_each1(en, it)
1312
#define for_each1(en, it) for (id it; (it = [en nextObject]) != nil; )
1413
#define for_each_(en, it, col, msg) NSEnumerator* for_each0(en, it, col, msg)
15-
#define for_each(en, it, col) for_each_(en, it, col, objectEnumerator)
16-
#define for_each_obj(en, it, col) for_each(en, it, col) // Same as for_each
14+
#define for_each_obj(en, it, col) for_each_(en, it, col, objectEnumerator)
1715
#define for_each_key(en, ke, dict) for_each_(en, ke, dict, keyEnumerator)
1816

19-
static inline UInt64 microseconds()
20-
{ UnsignedWide t; Microseconds(&t); return *(UInt64*) &t; }
17+
18+
//----------------------------------------------------------------------------------------
19+
// Macros
20+
21+
#if __LP64__
22+
typedef double GCoord;
23+
#elif 1
24+
typedef float GCoord;
25+
#endif
26+
27+
#if (__APPLE_CC__ > 5400)
28+
#define XC3(A, B) A // Xcode >= 3
29+
#else
30+
#define XC3(A, B) B // Xcode < 3
31+
#endif
32+
33+
#define UTF_8_16(u8,u16) XC3(@u16, UTF8(u8))
34+
#define ISA(OBJ, CLASS) ([(OBJ) isKindOfClass: [CLASS class]])
35+
36+
#define SetVar(var, ref) do { id old = (var); (var) = [(ref) retain]; \
37+
[old release]; } while (0)
38+
#define ResetVar(var) do { [(var) release]; (var) = nil; } while (0)
2139

2240

2341
//----------------------------------------------------------------------------------------
42+
// Basic Types
2443

25-
typedef CFAbsoluteTime UTCTime;
44+
typedef const UInt8* ConstBytePtr;
45+
typedef NSString* const ConstString;
46+
typedef unsigned int NSIndex;
47+
typedef CFAbsoluteTime UTCTime;
2648
#ifndef qConstCStr
27-
typedef const char* ConstCStr;
49+
typedef const char* ConstCStr;
2850
#define qConstCStr
2951
#endif
30-
#if __LP64__
31-
typedef double GCoord;
32-
#elif 1
33-
typedef float GCoord;
34-
#endif
3552

36-
#define kNSTrue ((id) kCFBooleanTrue)
37-
#define kNSFalse ((id) kCFBooleanFalse)
38-
#define NSBool(f) ((f) ? kNSTrue : kNSFalse)
53+
#define kNSTrue ((id) kCFBooleanTrue)
54+
#define kNSFalse ((id) kCFBooleanFalse)
55+
#define NSBool(f) ((f) ? kNSTrue : kNSFalse)
56+
static const NSIndex kIndex0 = 0;
3957

58+
//----------------------------------------------------------------------------------------
4059

4160
NSUserDefaults* Preferences (void);
4261
BOOL SyncPreference (void);
@@ -59,6 +78,9 @@ BOOL Folder_IsEqual (OSType folderType, NSURL* url);
5978
BOOL Folder_IsTemporaryItems (NSURL* url);
6079
BOOL Folder_IsChewableItems (NSURL* url);
6180

81+
static inline UInt64 microseconds ()
82+
{ UnsignedWide t; Microseconds(&t); return *(UInt64*) &t; }
83+
6284

6385
//----------------------------------------------------------------------------------------
6486
// Wrap a selector in an object for sending later.

CommonUtils.m

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//----------------------------------------------------------------------------------------
22
// CommonUtils.m - Common Cocoa utilities
33
//
4-
// Copyright © Chris, 2003 - 2009. All rights reserved.
4+
// Copyright © Chris, 2003 - 2010. All rights reserved.
55
//----------------------------------------------------------------------------------------
66

77
#import <Cocoa/Cocoa.h>
@@ -95,7 +95,7 @@
9595
#if qDebug
9696
NSMethodSignature* methodSig = [[target class] instanceMethodSignatureForSelector: selector];
9797
if (methodSig == nil)
98-
dprintf("(%@ '@%s'): ERROR: no method found", target, sel_getName(selector));
98+
dprintf("(%@ '%s'): ERROR: no method found", target, sel_getName(selector));
9999
Assert(methodSig != nil);
100100
NSInvocation* callback = [NSInvocation invocationWithMethodSignature: methodSig];
101101
#else
@@ -105,6 +105,8 @@
105105
[callback setSelector: selector];
106106
[callback setTarget: target];
107107

108+
// dprintf("(0x%X=%@ 0x%X='%s') => 0x%X=%@",
109+
// target, target, selector, sel_getName(selector), callback, callback);
108110
return callback;
109111
}
110112

@@ -349,7 +351,7 @@ - (NSComparisonResult) compareObject: (id) obj1 toObject: (id) obj2
349351

350352
- (id) reversedSortDescriptor
351353
{
352-
return [[AlphaNumSortDesc alloc] initWithKey: fKey ascending: !fAscending];
354+
return [[[self class] alloc] initWithKey: fKey ascending: !fAscending];
353355
}
354356

355357

DrawerLogView.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
@interface DrawerLogView : NSView
1313
{
14-
IBOutlet id _view;
14+
IBOutlet id _view;
1515
IBOutlet NSTextView *logTextView;
1616
IBOutlet NSObjectController *documentProxy;
17-
17+
1818
id document;
19-
19+
2020
id currentTaskObj;
2121
}
2222

@@ -25,3 +25,4 @@
2525
- (void) setDocument: (id) aDocument;
2626

2727
@end
28+

DrawerLogView.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ - (void) unload
5454
_view = nil;
5555

5656
// objects that are bound to the file owner retain it
57-
// we need to unbind them
57+
// we need to unbind them
5858
[docProxy unbind: @"contentObject"];
5959

60-
// the owner has to release its top level nib objects
60+
// the owner has to release its top level nib objects
6161
[docProxy release];
6262
[view release];
6363
}

EditListResponder.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ typedef struct EditListPrefKeys
1212

1313
@interface EditListResponder : NSResponder
1414
{
15-
IBOutlet NSWindow* fWindow;
16-
IBOutlet NSTableView* fTableView;
15+
IBOutlet NSWindow* fWindow;
16+
IBOutlet NSTableView* fTableView;
1717
IBOutlet NSBox* fEditBox;
1818
IBOutlet MyDragSupportArrayController* fAC;
1919
NSMutableArray* fDataArray;

EditListResponder.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#import "ViewUtils.h"
99

1010

11-
static NSString* const kCopyType = @"svnX_COPIED_ROWS",
12-
* const kMoveType = @"svnX_MOVED_ROWS";
11+
static ConstString kCopyType = @"svnX_COPIED_ROWS",
12+
kMoveType = @"svnX_MOVED_ROWS";
1313

1414

1515
@implementation EditListResponder
@@ -173,7 +173,7 @@ - (IBAction) newItem: (id) sender
173173
{
174174
#pragma unused(sender)
175175
[fAC setSelectionIndex: [[fAC arrangedObjects] count] - 1];
176-
[fWindow makeFirstResponder: [self nameTextField]];
176+
[fWindow makeFirstResponder: [self nameTextField]];
177177
}
178178

179179

@@ -288,15 +288,15 @@ - (BOOL) tableView: (NSTableView*) tableView
288288
url ? NSURLPboardType : nil, nil];
289289
[pboard declareTypes: typesArray owner: self];
290290
if (url)
291-
[url writeToPasteboard: pboard];
291+
[url writeToPasteboard: pboard];
292292

293293
// add rows array for local move
294294
[pboard setPropertyList: rows forType: kMoveType];
295295

296296
// create new array of selected rows for remote drop
297297
// could do deferred provision, but keep it direct for clarity
298298
NSMutableArray* rowCopies = [NSMutableArray arrayWithCapacity: [rows count]];
299-
for_each(enumerator, idx, rows)
299+
for_each_obj(enumerator, idx, rows)
300300
{
301301
[rowCopies addObject: [arrangedObjects objectAtIndex: [idx intValue]]];
302302
}
@@ -319,7 +319,7 @@ - (NSDragOperation) tableView: (NSTableView*) tableView
319319
NSDragOperation sourceMask = [info draggingSourceOperationMask];
320320

321321
// we want to put the object at, not over,
322-
// the current row (contrast NSTableViewDropOn)
322+
// the current row (contrast NSTableViewDropOn)
323323
[tableView setDropRow: row dropOperation: NSTableViewDropAbove];
324324

325325
if (sourceMask & NSDragOperationMove) return NSDragOperationMove;
@@ -382,14 +382,14 @@ - (BOOL) tableView: (NSTableView*) tableView
382382

383383
if (!accept)
384384
{
385-
const id obj = [self newObject: pboard];
385+
const id obj = [self newObject: pboard];
386386
if (obj)
387387
{
388388
[fAC insertObject: obj atArrangedObjectIndex: row];
389389
[fAC setSelectionIndex: row]; // set selected rows to that of the new object
390390
[obj release];
391391

392-
accept = YES;
392+
accept = YES;
393393
}
394394
}
395395

FavoriteWorkingCopies.m

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
static NSString* const kDocType = @"workingCopy";
13-
static /*const*/ EditListPrefKeys kPrefKeys =
13+
static /*const*/ EditListPrefKeys kPrefKeys =
1414
{ @"favoriteWorkingCopies", @"wcEditShown", @"wcPanelFrame"/*, NSFilenamesPboardType*/ };
1515

1616

@@ -44,15 +44,15 @@ - (void) dealloc
4444

4545
- (id) newObject: (NSPasteboard*) pboard
4646
{
47-
id obj = nil;
47+
id obj = nil;
4848
NSString* filePath = [[pboard propertyListForType: NSFilenamesPboardType] lastObject];
4949
if (filePath)
5050
{
51-
obj = [fAC newObject];
51+
obj = [fAC newObject];
5252
[obj setValue: filePath forKey: @"fullPath"];
5353
[obj setValue: [filePath lastPathComponent] forKey: @"name"];
5454
}
55-
return obj;
55+
return obj;
5656
}
5757

5858

@@ -77,7 +77,7 @@ - (id) newObjectWithName: (NSString*) name
7777
- (void) awakeFromNib
7878
{
7979
// Notification for user creating a new working copy => will add item into favorites list.
80-
[[NSNotificationCenter defaultCenter] addObserver: self
80+
[[NSNotificationCenter defaultCenter] addObserver: self
8181
selector: @selector(newWorkingCopyNotificationHandler:) name: @"newWorkingCopy" object: nil];
8282

8383
[[NSUserDefaultsController sharedUserDefaultsController]
@@ -107,7 +107,7 @@ - (void) observeValueForKeyPath: (NSString*) keyPath
107107
- (void) newWorkingCopyNotificationHandler: (NSNotification*) notification
108108
{
109109
[self newWorkingCopyItemWithPath: [notification object]];
110-
110+
111111
[fWindow makeKeyAndOrderFront: nil];
112112
}
113113

@@ -136,7 +136,7 @@ - (void) newWorkingCopyItemWithPath: (NSString*) workingCopyPath
136136
- (BOOL) showExtantWindow: (NSString*) name
137137
fullPath: (NSString*) fullPath
138138
{
139-
for_each(en, doc, [[NSDocumentController sharedDocumentController] documents])
139+
for_each_obj(en, doc, [[NSDocumentController sharedDocumentController] documents])
140140
{
141141
if ([[doc fileType] isEqualToString: kDocType] &&
142142
[[doc windowTitle] isEqualToString: name] &&
@@ -241,7 +241,7 @@ - (id) findWorkingCopy: (NSString*) aPath
241241

242242
// Find among the open working copies one that has a matching path
243243
MyWorkingCopy* wcDocument = nil;
244-
for_each(en1, it, [[NSDocumentController sharedDocumentController] documents])
244+
for_each_obj(en1, it, [[NSDocumentController sharedDocumentController] documents])
245245
{
246246
if ([[it fileType] isEqualToString: kDocType])
247247
{
@@ -258,7 +258,7 @@ - (id) findWorkingCopy: (NSString*) aPath
258258

259259
// Find among the known working copies one that has a matching path
260260
NSDictionary* wcEntry = nil;
261-
for_each(en2, it, [fAC arrangedObjects])
261+
for_each_obj(en2, it, [fAC arrangedObjects])
262262
{
263263
NSRange r = [aPath rangeOfString: [it objectForKey: @"fullPath"]
264264
options: NSLiteralSearch | NSAnchoredSearch];

FilePathCleanUpTransformer.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ @implementation FilePathAbbreviatedTransformer
3838

3939
+ (Class) transformedValueClass
4040
{
41-
return [NSString class];
41+
return [NSString class];
4242
}
4343

4444
+ (BOOL) allowsReverseTransformation
4545
{
46-
return NO;
46+
return NO;
4747
}
4848

4949
- (id) transformedValue: (id) aString
@@ -75,7 +75,7 @@ - (id) init
7575
fTransform = GetPreferenceBool(@"abbrevWCFilePaths");
7676
}
7777

78-
return self;
78+
return self;
7979
}
8080

8181

@@ -112,13 +112,13 @@ @implementation OneLineTransformer
112112

113113
+ (Class) transformedValueClass
114114
{
115-
return [NSString class];
115+
return [NSString class];
116116
}
117117

118118

119119
+ (BOOL) allowsReverseTransformation
120120
{
121-
return YES;
121+
return YES;
122122
}
123123

124124

0 commit comments

Comments
 (0)