Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOWeakReference Class Reference

#include <OOWeakReference.h>

+ Inheritance diagram for OOWeakReference:
+ Collaboration diagram for OOWeakReference:

Instance Methods

(id) - weakRefUnderlyingObject
 
(id) - OO_RETURNS_RETAINED
 
(void) - weakRefDrop
 
(void) - dealloc [implementation]
 
(NSString *) - description [implementation]
 
(id) - weakRetain [implementation]
 
(Class) - class [implementation]
 
(BOOL) - isProxy [implementation]
 
(void) - forwardInvocation: [implementation]
 
(NSMethodSignature *) - methodSignatureForSelector: [implementation]
 
(BOOL) - respondsToSelector: [implementation]
 
(id) - forwardingTargetForSelector: [implementation]
 

Class Methods

(id) + weakRefWithObject:
 

Protected Attributes

id< OOWeakReferenceSupport_object
 

Detailed Description

Definition at line 109 of file OOWeakReference.h.

Method Documentation

◆ class

- (Class) class
implementation

Definition at line 1 of file OOWeakReference.m.

73{
74 return [_object class];
75}

◆ dealloc

- (void) dealloc
implementation

Definition at line 1 of file OOWeakReference.m.

38{
39 [_object weakRefDied:self];
40
41 [super dealloc];
42}

◆ description

- (NSString *) description
implementation

Definition at line 1 of file OOWeakReference.m.

46{
47 if (_object != nil) return [_object description];
48 else return [NSString stringWithFormat:@"<Dead %@ %p>", [self class], self];
49}
return nil
id< OOWeakReferenceSupport > _object

◆ forwardingTargetForSelector:

- (id) forwardingTargetForSelector: (SEL) sel
implementation

Definition at line 1 of file OOWeakReference.m.

132 :(SEL)sel
133{
134 return _object;
135}

◆ forwardInvocation:

- (void) forwardInvocation: (NSInvocation *) invocation
implementation

Definition at line 1 of file OOWeakReference.m.

84 :(NSInvocation *)invocation
85{
86 // Does the right thing even with nil _object.
87 [invocation invokeWithTarget:_object];
88}

◆ isProxy

- (BOOL) isProxy
implementation

Definition at line 1 of file OOWeakReference.m.

79{
80 return YES;
81}

◆ methodSignatureForSelector:

- (NSMethodSignature *) methodSignatureForSelector: (SEL) selector
implementation

Definition at line 1 of file OOWeakReference.m.

91 :(SEL)selector
92{
93 NSMethodSignature *result = nil;
94
95 if (__builtin_expect(
96 selector != @selector(weakRefDrop) &&
97 selector != @selector(weakRefUnderlyingObject), 1))
98 {
99 // Not a proxy method; get signature from _object if it exists, otherwise generic signature for nil calls.
100 if (__builtin_expect(_object != nil, 1)) result = [(id)_object methodSignatureForSelector:selector];
101 else result = [OOWeakReferenceTemplates methodSignatureForSelector:@selector(nilMethod)];
102 }
103 else
104 {
105 // One of OOWeakReference's own methods.
106 result = [OOWeakReferenceTemplates methodSignatureForSelector:selector];
107 }
108
109 return result;
110}

◆ OO_RETURNS_RETAINED

- (id) OO_RETURNS_RETAINED

◆ respondsToSelector:

- (BOOL) respondsToSelector: (SEL) selector
implementation

Definition at line 1 of file OOWeakReference.m.

113 :(SEL)selector
114{
115 if (__builtin_expect(_object != nil &&
116 selector != @selector(weakRefDrop) &&
117 selector != @selector(weakRefUnderlyingObject), 1))
118 {
119 // _object exists and it's not one of our methods, ask _object.
120 return [_object respondsToSelector:selector];
121 }
122 else
123 {
124 // Selector we responds to, or _object is nil and therefore responds to everything.
125 return YES;
126 }
127}

◆ weakRefDrop

- (void) weakRefDrop

Definition at line 1 of file OOWeakReference.m.

65{
66 _object = nil;
67}

◆ weakRefUnderlyingObject

- (id) weakRefUnderlyingObject

Definition at line 1 of file OOWeakReference.m.

53{
54 return _object;
55}

◆ weakRefWithObject:

+ (id) weakRefWithObject: (id<OOWeakReferenceSupport>) object

Definition at line 1 of file OOWeakReference.m.

26 :(id<OOWeakReferenceSupport>)object
27{
28 if (object == nil) return nil;
29
30 OOWeakReference *result = [OOWeakReference alloc];
31 // No init for proxies.
32 result->_object = object;
33 return [result autorelease];
34}

◆ weakRetain

- (id) weakRetain
implementation

Definition at line 1 of file OOWeakReference.m.

59{
60 return [self retain];
61}

Member Data Documentation

◆ _object

- (id<OOWeakReferenceSupport>) _object
protected

Definition at line 111 of file OOWeakReference.h.


The documentation for this class was generated from the following files: