Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
ReleaseLockProxy Class Reference

#include <ReleaseLockProxy.h>

+ Inheritance diagram for ReleaseLockProxy:
+ Collaboration diagram for ReleaseLockProxy:

Instance Methods

(id) - initWithObject:name:
 
(id) - initWithRetainedObject:name:
 
(void) - rlpAllowRelease
 
(NSString *) - rlpObjectDescription
 
(void) - dealloc [implementation]
 
(void) - release [implementation]
 
(id) - autorelease [implementation]
 
(void) - forwardInvocation: [implementation]
 
(NSMethodSignature *) - methodSignatureForSelector: [implementation]
 
(BOOL) - respondsToSelector: [implementation]
 

Class Methods

(id) + proxyWithObject:name:
 
(id) + proxyWithRetainedObject:name:
 
(BOOL) + instancesRespondToSelector: [implementation]
 

Private Attributes

id< NSObject > _object
 
NSString * _name
 
BOOL _locked
 

Detailed Description

Definition at line 15 of file ReleaseLockProxy.h.

Method Documentation

◆ autorelease

- (id) autorelease
implementation

Definition at line 1 of file ReleaseLockProxy.m.

127{
128 VerboseLog(@"-- ReleaseLockProxy (%@): autoreleased while %slocked and retain count at %u.", [self rlpObjectDescription], _locked ? "" : "not ", [self retainCount]);
129 return [super autorelease];
130}
#define VerboseLog(...)
NSString * rlpObjectDescription()

◆ dealloc

- (void) dealloc
implementation

Definition at line 1 of file ReleaseLockProxy.m.

71{
72 if (_locked)
73 {
74 NSLog(@"** ReleaseLockProxy (%@): deallocated while locked. This shouldn't happen, unless -dealloc is being called directly.", [self rlpObjectDescription]);
75 }
76 else
77 {
78 VerboseLog(@"-- ReleaseLockProxy (%@): deallocated while not locked.", [self rlpObjectDescription]);
79 }
80
81 [_object release];
82 [_name release];
83
84 [super dealloc];
85}
#define NSLog(format,...)
Definition OOLogging.h:137

◆ forwardInvocation:

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

Definition at line 1 of file ReleaseLockProxy.m.

135 :(NSInvocation *)invocation
136{
137 [invocation invokeWithTarget:_object];
138}

◆ initWithObject:name:

- (id) initWithObject: (id<NSObject>) object
name: (NSString *) name 

Definition at line 1 of file ReleaseLockProxy.m.

45 :(id<NSObject>)object name:(NSString *)name
46{
47 return [self initWithRetainedObject:[object retain] name:name];
48}

◆ initWithRetainedObject:name:

- (id) initWithRetainedObject: (id<NSObject>) object
name: (NSString *) name 

Definition at line 1 of file ReleaseLockProxy.m.

51 :(id<NSObject>)object name:(NSString *)name
52{
53 if (object == nil)
54 {
55 NSLog(@"** ReleaseLockProxy: passed nil object, returning nil proxy.");
56 [self release];
57 return nil;
58 }
59
60 // No super init for proxies.
61
62 _object = object;
63 _name = [name copy];
64 _locked = YES;
65
66 return self;
67}
return nil
id< NSObject > _object

◆ instancesRespondToSelector:

+ (BOOL) instancesRespondToSelector: (SEL) selector
implementation

Definition at line 1 of file ReleaseLockProxy.m.

161 :(SEL)selector
162{
163 if (selector == @selector(initWithObject:name:) ||
164 selector == @selector(initWithRetainedObject:name:) ||
165 selector == @selector(rlpAllowRelease) ||
166 selector == @selector(rlpObjectDescription))
167 {
168 return YES;
169 }
170 else
171 {
172 return NO;
173 }
174}

◆ methodSignatureForSelector:

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

Definition at line 1 of file ReleaseLockProxy.m.

141 :(SEL)selector
142{
143 NSMethodSignature *result = nil;
144
145 if (selector == @selector(initWithObject:name:) ||
146 selector == @selector(initWithRetainedObject:name:) ||
147 selector == @selector(rlpAllowRelease) ||
148 selector == @selector(rlpObjectDescription))
149 {
150 result = [ReleaseLockProxy_SignatureTemplateClass methodSignatureForSelector:selector];
151 }
152 else
153 {
154 result = [(id)_object methodSignatureForSelector:selector];
155 }
156
157 return result;
158}

◆ proxyWithObject:name:

+ (id) proxyWithObject: (id<NSObject>) object
name: (NSString *) name 

Definition at line 1 of file ReleaseLockProxy.m.

33 :(id<NSObject>)object name:(NSString *)name
34{
35 return [[[self alloc] initWithObject:object name:name] autorelease];
36}

◆ proxyWithRetainedObject:name:

+ (id) proxyWithRetainedObject: (id<NSObject>) object
name: (NSString *) name 

Definition at line 1 of file ReleaseLockProxy.m.

39 :(id<NSObject>)object name:(NSString *)name
40{
41 return [[[self alloc] initWithRetainedObject:object name:name] autorelease];
42}

◆ release

- (void) release
implementation

Definition at line 1 of file ReleaseLockProxy.m.

103{
104 unsigned retainCount = [self retainCount];
105
106 if (_locked && retainCount == 1)
107 {
108 // Breakpoint here to catch what would otherwise be the last release before crashing.
109 NSLog(@"** ReleaseLockProxy (%@): released while locked and retain count is one - intercepting retain. Something is broken.", [self rlpObjectDescription]);
110 return;
111 }
112
113 if (_locked)
114 {
115 VerboseLog(@"-- ReleaseLockProxy (%@): released while locked, but retain count > 1; retain count going from %u to %u.", [self rlpObjectDescription], retainCount, retainCount - 1);
116 }
117 else
118 {
119 VerboseLog(@"-- ReleaseLockProxy (%@): released while not locked; retain count going from %u to %u.", [self rlpObjectDescription], retainCount, retainCount - 1);
120 }
121
122 [super release];
123}

◆ respondsToSelector:

- (BOOL) respondsToSelector: (SEL) selector
implementation

Definition at line 1 of file ReleaseLockProxy.m.

177 :(SEL)selector
178{
180}
BOOL instancesRespondToSelector:(SEL selector)

◆ rlpAllowRelease

- (void) rlpAllowRelease

Definition at line 1 of file ReleaseLockProxy.m.

89{
90 _locked = NO;
91}

◆ rlpObjectDescription

- (NSString *) rlpObjectDescription

Definition at line 1 of file ReleaseLockProxy.m.

95{
96 return _name ? _name : [_object description];
97}

Member Data Documentation

◆ _locked

- (BOOL) _locked
private

Definition at line 20 of file ReleaseLockProxy.h.

◆ _name

- (NSString*) _name
private

Definition at line 19 of file ReleaseLockProxy.h.

◆ _object

- (id<NSObject>) _object
private

Definition at line 18 of file ReleaseLockProxy.h.


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