Oolite 1.91.0.7658-250404-b1488af
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 72 of file OOWeakReference.m.

73{
74 return [_object class];
75}

References class.

Referenced by class, and description.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Definition at line 37 of file OOWeakReference.m.

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

References dealloc.

Referenced by dealloc.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ description

- (NSString *) description
implementation

Definition at line 45 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

References _object, class, description, and nil.

Referenced by description.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ forwardingTargetForSelector:

- (id) forwardingTargetForSelector: (SEL) sel
implementation

Definition at line 132 of file OOWeakReference.m.

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

References _object.

◆ forwardInvocation:

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

Definition at line 84 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 78 of file OOWeakReference.m.

79{
80 return YES;
81}

References isProxy.

Referenced by isProxy.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ methodSignatureForSelector:

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

Definition at line 91 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}

References _object, nil, weakRefDrop, and weakRefUnderlyingObject.

+ Here is the call graph for this function:

◆ OO_RETURNS_RETAINED

- (id) OO_RETURNS_RETAINED

References OO_RETURNS_RETAINED, weakRefDrop, and weakRetain.

Referenced by OO_RETURNS_RETAINED.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ respondsToSelector:

- (BOOL) respondsToSelector: (SEL) selector
implementation

Definition at line 113 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}

References _object, nil, weakRefDrop, and weakRefUnderlyingObject.

+ Here is the call graph for this function:

◆ weakRefDrop

- (void) weakRefDrop

Definition at line 64 of file OOWeakReference.m.

65{
66 _object = nil;
67}

References _object, nil, and weakRefDrop.

Referenced by OOJSScript::dealloc, OOWeakRefObject::dealloc, ShipEntity::dealloc, methodSignatureForSelector:, OO_RETURNS_RETAINED, respondsToSelector:, and weakRefDrop.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ weakRefUnderlyingObject

◆ weakRefWithObject:

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

Definition at line 26 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}

References _object, and nil.

Referenced by OOJSScript::weakRetain, and OOWeakRefObject::weakRetain.

+ Here is the caller graph for this function:

◆ weakRetain

- (id) weakRetain
implementation

Definition at line 58 of file OOWeakReference.m.

59{
60 return [self retain];
61}

References weakRetain.

Referenced by OO_RETURNS_RETAINED, and weakRetain.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _object


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