Oolite
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 107 of file OOWeakReference.h.

Method Documentation

◆ class

- (Class) class
implementation

Definition at line 67 of file OOWeakReference.m.

68{
69 return [_object class];
70}

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 35 of file OOWeakReference.m.

36{
37 [_object weakRefDied:self];
38
39 [super dealloc];
40}

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 42 of file OOWeakReference.m.

43{
44 if (_object != nil)
45 return [_object description];
46 else
47 return [NSString stringWithFormat:@"<Dead %@ %p>", [self class], self];
48}
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 115 of file OOWeakReference.m.

115 :(SEL)sel
116{
117 return _object;
118}

References _object.

◆ forwardInvocation:

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

Definition at line 77 of file OOWeakReference.m.

77 :(NSInvocation*)invocation
78{
79 // Does the right thing even with nil _object.
80 [invocation invokeWithTarget:_object];
81}

◆ isProxy

- (BOOL) isProxy
implementation

Definition at line 72 of file OOWeakReference.m.

73{
74 return YES;
75}

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 83 of file OOWeakReference.m.

83 :(SEL)selector
84{
85 NSMethodSignature* result = nil;
86
87 if (__builtin_expect(
88 selector != @selector(weakRefDrop) && selector != @selector(weakRefUnderlyingObject), 1)) {
89 // Not a proxy method; get signature from _object if it exists, otherwise generic signature for nil calls.
90 if (__builtin_expect(_object != nil, 1))
91 result = [(id)_object methodSignatureForSelector:selector];
92 else
93 result = [OOWeakReferenceTemplates methodSignatureForSelector:@selector(nilMethod)];
94 } else {
95 // One of OOWeakReference's own methods.
96 result = [OOWeakReferenceTemplates methodSignatureForSelector:selector];
97 }
98
99 return result;
100}

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 102 of file OOWeakReference.m.

102 :(SEL)selector
103{
104 if (__builtin_expect(_object != nil && selector != @selector(weakRefDrop) && selector != @selector(weakRefUnderlyingObject), 1)) {
105 // _object exists and it's not one of our methods, ask _object.
106 return [_object respondsToSelector:selector];
107 } else {
108 // Selector we responds to, or _object is nil and therefore responds to everything.
109 return YES;
110 }
111}

References _object, nil, weakRefDrop, and weakRefUnderlyingObject.

Here is the call graph for this function:

◆ weakRefDrop

- (void) weakRefDrop

Definition at line 60 of file OOWeakReference.m.

61{
62 _object = nil;
63}

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 24 of file OOWeakReference.m.

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

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 55 of file OOWeakReference.m.

56{
57 return [self retain];
58}

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: