Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOPListScript(SetUp) Category Reference

Instance Methods

(id) - initWithName:scriptArray:metadata:
 

Class Methods

(NSArray *) + scriptsFromDictionaryOfScripts:filePath:
 
(NSArray *) + loadCachedScripts:
 

Detailed Description

Definition at line 42 of file OOPListScript.m.

Method Documentation

◆ initWithName:scriptArray:metadata:

- (id) initWithName: (NSString *) name
scriptArray: (NSArray *) script
metadata: (NSDictionary *) metadata 

Extends class OOPListScript.

Definition at line 39 of file OOPListScript.m.

194 :(NSString *)name scriptArray:(NSArray *)script metadata:(NSDictionary *)metadata
195{
196 self = [super init];
197 if (self != nil)
198 {
199 _script = [script retain];
200 if (name != nil)
201 {
202 if (metadata == nil) metadata = [NSDictionary dictionaryWithObject:name forKey:kMDKeyName];
203 else
204 {
205 NSMutableDictionary *mutableMetadata = [[metadata mutableCopy] autorelease];
206 [mutableMetadata setObject:name forKey:kMDKeyName];
207 metadata = mutableMetadata;
208 }
209 }
210 _metadata = [metadata copy];
211 }
212
213 return self;
214}
return nil

◆ loadCachedScripts:

+ (NSArray *) loadCachedScripts: (NSDictionary *) cachedScripts

Extends class OOPListScript.

Definition at line 39 of file OOPListScript.m.

170 :(NSDictionary *)cachedScripts
171{
172 NSEnumerator *keyEnum = nil;
173 NSString *key = nil;
174
175 NSMutableArray *result = [NSMutableArray arrayWithCapacity:[cachedScripts count]];
176
177 for (keyEnum = [cachedScripts keyEnumerator]; (key = [keyEnum nextObject]); )
178 {
179 NSDictionary *cacheValue = [cachedScripts oo_dictionaryForKey:key];
180 NSArray *scriptArray = [cacheValue oo_arrayForKey:kKeyScript];
181 NSDictionary *metadata = [cacheValue oo_dictionaryForKey:kKeyMetadata];
182 OOPListScript *script = [[self alloc] initWithName:key scriptArray:scriptArray metadata:metadata];
183 if (script != nil)
184 {
185 [result addObject:script];
186 [script release];
187 }
188 }
189
190 return [[result copy] autorelease];
191}

◆ scriptsFromDictionaryOfScripts:filePath:

+ (NSArray *) scriptsFromDictionaryOfScripts: (NSDictionary *) dictionary
filePath: (NSString *) filePath 

Extends class OOPListScript.

Definition at line 39 of file OOPListScript.m.

125 :(NSDictionary *)dictionary filePath:(NSString *)filePath
126{
127 NSMutableArray *result = nil;
128 NSEnumerator *keyEnum = nil;
129 NSString *key = nil;
130 NSArray *scriptArray = nil;
131 NSDictionary *metadata = nil;
132 NSMutableDictionary *cachedScripts = nil;
133 OOPListScript *script = nil;
134
135 NSUInteger count = [dictionary count];
136 result = [NSMutableArray arrayWithCapacity:count];
137 cachedScripts = [NSMutableDictionary dictionaryWithCapacity:count];
138
139 metadata = [dictionary objectForKey:kKeyMetadata];
140 if (![metadata isKindOfClass:[NSDictionary class]]) metadata = nil;
141
142 for (keyEnum = [dictionary keyEnumerator]; (key = [keyEnum nextObject]); )
143 {
144 scriptArray = [dictionary objectForKey:key];
145 if ([key isKindOfClass:[NSString class]] &&
146 [scriptArray isKindOfClass:[NSArray class]] &&
147 ![key isEqual:kKeyMetadata])
148 {
149 scriptArray = OOSanitizeLegacyScript(scriptArray, key, NO);
150 if (scriptArray != nil)
151 {
152 script = [[self alloc] initWithName:key scriptArray:scriptArray metadata:metadata];
153 if (script != nil)
154 {
155 [result addObject:script];
156 [cachedScripts setObject:[NSDictionary dictionaryWithObjectsAndKeys:scriptArray, kKeyScript, metadata, kKeyMetadata, nil] forKey:key];
157
158 [script release];
159 }
160 }
161 }
162 }
163
164 [[OOCacheManager sharedCache] setObject:cachedScripts forKey:filePath inCache:kCacheName];
165
166 return [[result copy] autorelease];
167}
NSArray * OOSanitizeLegacyScript(NSArray *script, NSString *context, BOOL allowAIMethods)
static NSString *const kKeyMetadata
unsigned count
void setObject:forKey:inCache:(id inElement,[forKey] NSString *inKey,[inCache] NSString *inCacheKey)
OOCacheManager * sharedCache()

The documentation for this category was generated from the following file: