-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEXProxy.m
More file actions
78 lines (64 loc) · 2.02 KB
/
EXProxy.m
File metadata and controls
78 lines (64 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// EXProxy.m
// Entropy
// (C) 2007-2009 Codesign
// Licensed under LGPL (v3)
//
#import "EXProxy.h"
@implementation EXProxy
- (id)initWithObjectID:(int)oid container:(EXContainer*)_container loadedObjects:(NSMutableDictionary*)_loadedObjects {
if (self = [super init]) {
objectID = oid;
container = _container;
loadedObjects = _loadedObjects;
}
return self;
}
- (BOOL)__isUnused {
return object == nil;
}
- (id)__object {
if (object == nil) {
//NSNumber* key = [NSNumber numberWithInt: objectID];
//object = [loadedObjects objectForKey: key]; // causes an infinite loop
//if (object == nil) {
object = [[container queryWithID: objectID atomically: ![container isTransactionInProgress]
retrievedObjects: [NSMutableDictionary dictionary] lazyLoading: YES] retain];
//[loadedObjects setObject: object forKey: key]; // probably not necessary but avoids forwarding
//}
}
return object;
}
- (NSString*)className {
return [[self __object] className];
}
- (NSString*)description {
id _object = [self __object];
NSString* desc = [_object description];
return desc; //[NSString stringWithFormat: @"(proxy) %@", desc];
}
- (BOOL)isKindOfClass:(Class)cls {
return [[self __object] isKindOfClass: cls];
}
- (BOOL)isMemberOfClass:(Class)cls {
return [[self __object] isMemberOfClass: cls];
}
- (void)encodeWithCoder:(NSCoder*)coder {
[[self __object] encodeWithCoder: coder];
}
- (NSMethodSignature*)methodSignatureForSelector:(SEL)selector {
NSMethodSignature* signature = [super methodSignatureForSelector: selector];
if (signature) return signature;
signature = [[self __object] methodSignatureForSelector: selector];
if (signature == nil) NSLog(@"the wrapped object doesn't recognize the forwarded selector");
return signature;
}
- (void)forwardInvocation:(NSInvocation*)invocation {
if ([object respondsToSelector: [invocation selector]]) [invocation invokeWithTarget: object];
else [self doesNotRecognizeSelector: [invocation selector]];
}
- (void)dealloc {
[object release];
[super dealloc];
}
@end