Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
OODebugInspectorModule.m
Go to the documentation of this file.
1/*
2
3OODebugInspectorModule.m
4
5
6Oolite Debug Bundle
7
8Copyright © 2007-2013 Jens Ayton
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the “Software”), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27
28*/
29
31
32
33@implementation OODebugInspectorModule
34
35- (id) initWithObject:(id <OOWeakReferenceSupport>)object
36{
37 if ((self = [super init]))
38 {
39 _object = [object weakRetain];
40
41 if (![self loadUserInterface])
42 {
43 [self release];
44 self = nil;
45 }
46 }
47
48 return self;
49}
50
51
52- (void) dealloc
53{
54 [_rootView release];
55 [_object release];
56
57 [super dealloc];
58}
59
60
61- (BOOL) loadUserInterface
62{
63 NSString *nibName = nil;
64
65 nibName = [self nibName];
66 if (nibName == nil) return NO;
67
68 return [NSBundle loadNibNamed:nibName owner:self];
69}
70
71
72- (NSString *) nibName
73{
74 return [self className];
75}
76
77
78- (NSView *) rootView
79{
80 return _rootView;
81}
82
83
84- (id) object
85{
86 return [_object weakRefUnderlyingObject];
87}
88
89
90- (void) update
91{
92
93}
94
95@end
96
97
98@implementation NSArray (OODebugInspectorSupportUtilities)
99
100- (NSArray *) arrayByAddingInspectorModuleOfClass:(Class)theClass
101 forObject:(id <OOWeakReferenceSupport>)object
102{
103 id module = nil;
104 NSArray *result = self;
105
106 if ([theClass isSubclassOfClass:[OODebugInspectorModule class]])
107 {
108 module = [[[theClass alloc] initWithObject:object] autorelease];
109 if (module != nil)
110 {
111 result = [result arrayByAddingObject:module];
112 }
113 }
114
115 return result;
116}
117
118@end
119
120
122{
123 static NSString *string = nil;
124 if (string == nil)
125 {
126 string = [NSLocalizedStringFromTableInBundle(@"--", NULL, [NSBundle bundleForClass:[OODebugInspectorModule class]], @"") retain];
127 if (string == nil) string = @"-";
128 }
129
130 return string;
131}
NSString * InspectorUnknownValueString(void)
return nil