/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2000-2005 SKYRIX Software AG
- This file is part of OpenGroupware.org.
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
- OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with OGo; see the file COPYING. If not, write to the
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#include <NGObjWeb/WOResourceManager.h>
-#include "WOComponentDefinition.h"
+#include <NGObjWeb/WOComponentDefinition.h>
#include "WOComponent+private.h"
#include <NGObjWeb/WORequest.h>
#include <NGObjWeb/WOApplication.h>
but .wo ones in just Resources.
This issue should be fixed in recent woapp-gs.make ...
+
+ Update: since for SOPE 4.3 we only work with gstep-make 1.10, this seems to
+ be fixed?
*/
#if COCOA_Foundation_LIBRARY || NeXT_Foundation_LIBRARY
# define RSRCDIR_CONTENTS 1
static Class UrlClass = Nil;
static NSString *resourcePrefix = @"";
static NSString *rapidTurnAroundPath = nil;
+static NSString *suffix = nil;
static NSNull *null = nil;
static BOOL debugOn = NO;
static BOOL debugComponentLookup = NO;
debugComponentLookup = [ud boolForKey:@"WODebugComponentLookup"];
debugResourceLookup = [ud boolForKey:@"WODebugResourceLookup"];
genMissingResourceLinks = [ud boolForKey:@"WOGenerateMissingResourceLinks"];
- rapidTurnAroundPath = [[ud stringForKey:@"WOProjectDirectory"] copy];
+ rapidTurnAroundPath = [[ud stringForKey:@"WOProjectDirectory"] copy];
+ suffix = [[ud stringForKey:@"WOApplicationSuffix"] copy];
}
static inline BOOL
- (id)initWithPath:(NSString *)_path {
#if __APPLE__
if ([_path length] == 0) {
- NSLog(@"ERROR(%s): missing path!", __PRETTY_FUNCTION__);
+ [self errorWithFormat:@"(%s): missing path!", __PRETTY_FUNCTION__];
/* this doesn't work with subclasses which do not require a path ... */
#if 0
[self release];
- (BOOL)isDebuggingEnabled {
return debugOn;
}
+- (NSString *)loggingPrefix {
+ unsigned char buf[32];
+ sprintf(buf, "[wo-rm-0x%08X]", (unsigned)self);
+ return [NSString stringWithCString:buf];
+}
/* path methods */
fm = [self fileManager];
if ([self->base length] > 0) {
if (![fm fileExistsAtPath:self->base]) {
- NSLog(@"WARNING(%s): Resources base path '%@' does not exist !",
- __PRETTY_FUNCTION__, self->base);
+ [self warnWithFormat:@"(%s): Resources base path '%@' does not exist !",
+ __PRETTY_FUNCTION__, self->base];
return nil;
}
}
if ([self->resources length] > 0) {
if (![fm fileExistsAtPath:self->resources]) {
- [self debugWithFormat:
- @"WARNING(%s): Resources path %@ does not exist !",
+ [self warnWithFormat:
+ @"(%s): Resources path %@ does not exist !",
__PRETTY_FUNCTION__, self->resources];
[self->resources release]; self->resources = nil;
}
}
- (NSString *)resourcesPathForFramework:(NSString *)_fw {
- if (_fw == nil)
+ if (_fw == nil || (_fw == rapidTurnAroundPath))
return [self resourcesPath];
#if RSRCDIR_CONTENTS
static BOOL didLog = NO;
if (!didLog) {
didLog = YES;
- [self debugWithFormat:
- @"WARNING(%s): WebServerResources path '%@' does not exist !",
+ [self warnWithFormat:
+ @"(%s): WebServerResources path '%@' does not exist !",
__PRETTY_FUNCTION__, self->w3resources];
}
[self->w3resources release]; self->w3resources = nil;
fm = [self fileManager];
langCount = [_languages count];
- if ((w3rp = [self webServerResourcesPath])) {
+ if ((w3rp = [self webServerResourcesPath]) != nil) {
NSString *langPath = nil;
unsigned i;
+ if (debugResourceLookup)
+ [self logWithFormat:@" WebServerResources: %@", w3rp];
+
// first check Language.lproj in WebServerResources
for (i = 0; i < langCount; i++) {
langPath = [_languages objectAtIndex:i];
if (debugResourceLookup) {
[self logWithFormat:
@" no language project for '%@' in WebServerResources: %@",
- [_languages objectAtIndex:i],resource];
+ [_languages objectAtIndex:i], langPath];
}
continue;
}
resource = [rp stringByAppendingPathComponent:_name];
if (debugResourceLookup)
[self logWithFormat:@" check in Resources-flat: %@", resource];
- if (_pathExists(self, fm, resource))
+ if (_pathExists(self, fm, resource)) {
+ if (debugResourceLookup)
+ [self logWithFormat:@" found => %@", resource];
return resource;
+ }
}
/* and last check in the application directory */
/* URL methods */
+- (NSString *)_urlForMissingResource:(NSString *)_name request:(WORequest *)_r{
+ WOApplication *app;
+
+ app = [WOApplication application];
+
+ if (!genMissingResourceLinks)
+ return nil;
+
+ return [NSString stringWithFormat:
+ @"/missingresource?name=%@&application=%@",
+ _name, app ? [app name] : [_r applicationName]];
+}
+
- (NSString *)urlForResourceNamed:(NSString *)_name
inFramework:(NSString *)_frameworkName
languages:(NSArray *)_languages
request:(WORequest *)_request
{
- WOApplication *app;
+ WOApplication *app;
+ NSMutableString *url;
NSString *resource = nil, *tmp;
+ NSString *path = nil, *sbase;
+ unsigned len;
app = [WOApplication application];
#endif
#if 0
tmp = [resource stringByStandardizingPath];
- if (tmp) resource = tmp;
+ if (tmp != nil) resource = tmp;
#endif
- if (resource) {
- NSString *path = nil, *sbase;
- unsigned len;
-
- sbase = self->base;
- tmp = [sbase commonPrefixWithString:resource options:0];
+ if (resource == nil) {
+ if (debugResourceLookup)
+ [self logWithFormat:@"did not find resource (cannot build URL)"];
+ return [self _urlForMissingResource:_name request:_request];
+ }
+
+ sbase = self->base;
+ tmp = [sbase commonPrefixWithString:resource options:0];
- len = [tmp length];
- path = [sbase substringFromIndex:len];
- tmp = [resource substringFromIndex:len];
- if (([path length] > 0) && ![tmp hasPrefix:@"/"] && ![tmp hasPrefix:@"\\"])
- path = [path stringByAppendingString:@"/"];
- path = [path stringByAppendingString:tmp];
+ len = [tmp length];
+ path = [sbase substringFromIndex:len];
+ tmp = [resource substringFromIndex:len];
+ if (([path length] > 0) && ![tmp hasPrefix:@"/"] && ![tmp hasPrefix:@"\\"])
+ path = [path stringByAppendingString:@"/"];
+ path = [path stringByAppendingString:tmp];
#ifdef __WIN32__
- {
+ {
NSArray *cs;
cs = [path componentsSeparatedByString:@"\\"];
path = [cs componentsJoinedByString:@"/"];
- }
+ }
#endif
- if (path) {
- static NSString *suffix = nil;
- NSMutableString *url = nil;
-
- if (suffix == nil) {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- suffix = [ud stringForKey:@"WOApplicationSuffix"];
- }
-
- url = [[NSMutableString alloc] initWithCapacity:256];
+ if (path == nil)
+ return [self _urlForMissingResource:_name request:_request];
+
+ url = [[NSMutableString alloc] initWithCapacity:256];
#if 0
- [url appendString:[_request adaptorPrefix]];
+ [url appendString:[_request adaptorPrefix]];
#endif
- if (resourcePrefix)
- [url appendString:resourcePrefix];
- if (![url hasSuffix:@"/"]) [url appendString:@"/"];
- [url appendString:app ? [app name] : [_request applicationName]];
- [url appendString:suffix];
- if (![path hasPrefix:@"/"]) [url appendString:@"/"];
- [url appendString:path];
-
- path = [url copy];
- [url release];
+ if (resourcePrefix)
+ [url appendString:resourcePrefix];
+ if (![url hasSuffix:@"/"]) [url appendString:@"/"];
+ [url appendString:app ? [app name] : [_request applicationName]];
+ [url appendString:suffix];
+ if (![path hasPrefix:@"/"]) [url appendString:@"/"];
+ [url appendString:path];
- return [path autorelease];
- }
- }
-
- if (genMissingResourceLinks) {
- return [NSString stringWithFormat:
- @"/missingresource?name=%@&application=%@",
- _name, app ? [app name] : [_request applicationName]];
- }
- return nil;
+ path = [url copy];
+ [url release];
+ return [path autorelease];
}
- (NSString *)urlForResourceNamed:(NSString *)_name {
fm = [self fileManager];
if (_tableName == nil)
- _tableName = @"default";
+ _tableName = @"Localizable";
/* take a look whether a matching table is already loaded */
inFramework:(NSString *)_framework
{
/* search for component wrapper .. */
+ // TODO: shouldn't we used that for WOx as well?
NSEnumerator *e;
NSString *ext;
if (_name == nil) {
#if DEBUG
- NSLog(@"WARNING(%s): tried to get path to component with <nil> name !",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:
+ @"(%s): tried to get path to component with <nil> name !",
+ __PRETTY_FUNCTION__];
#endif
return nil;
}
return [_name stringByAppendingPathExtension:@"wox"];
}
-- (WOComponentDefinition *)definitionForComponent:(id)_name
- inFramework:(NSString *)_framework
+/* create component definition */
+
+- (void)_getComponentURL:(NSURL **)url_ andName:(NSString **)name_
+ forNameOrURL:(id)_nameOrURL inFramework:(NSString *)_framework
languages:(NSArray *)_languages
{
- WOApplication *app;
- NSFileManager *fm = nil;
- NSEnumerator *languages = nil;
- NSString *language = nil;
- WOComponentDefinition *cdef = nil;
- NSString *sname = nil;
- NSURL *componentURL;
- NSURL *appUrl;
- BOOL doesCache, isDir;
+ NSString *path;
- app = [WOApplication application];
- doesCache = [app isCachingEnabled];
+ if ([_nameOrURL isKindOfClass:UrlClass]) {
+ // TODO: where is this used currently? It probably was required for forms,
+ // but might not be anymore?
+ *url_ = _nameOrURL;
+ *name_ = [*url_ path];
+ if (debugComponentLookup)
+ [self debugWithFormat:@"using URL %@ for component %@", *url_, *name_];
+ return;
+ }
- /* lookup component path */
+ /* the _nameOrURL is a string containing the component name */
- if ([_name isKindOfClass:UrlClass]) {
- componentURL = _name;
- _name = [componentURL path];
- if (debugComponentLookup) {
- [self debugWithFormat:@"using URL %@ for component %@",
- componentURL, _name];
- }
- }
- else {
- NSString *path;
-
- if (_framework == nil && _name != nil) {
- Class clazz;
+ *name_ = _nameOrURL;
+
+ if (_framework == nil && _nameOrURL != nil) {
+ Class clazz;
- /*
- Note: this is a bit of a hack ..., actually this method should never
- be called without a framework and pages shouldn't be instantiated
- without specifying their framework.
- But for legacy reasons this needs to be done and seems to work without
- problems. It is required for loading components from bundles.
- */
- if ((_framework = rapidTurnAroundPath) == nil) {
- if ((clazz = NSClassFromString(_name)))
- _framework = [[NSBundle bundleForClass:clazz] bundlePath];
- }
+ /*
+ Note: this is a bit of a hack ..., actually this method should never
+ be called without a framework and pages shouldn't be instantiated
+ without specifying their framework.
+ But for legacy reasons this needs to be done and seems to work without
+ problems. It is required for loading components from bundles.
+ */
+ if ((_framework = rapidTurnAroundPath) == nil) {
+ if ((clazz = NSClassFromString(_nameOrURL)))
+ _framework = [[NSBundle bundleForClass:clazz] bundlePath];
}
+ }
+
+ if (debugComponentLookup) {
+ [self logWithFormat:@"component '%@' in framework '%@'",
+ _nameOrURL, _framework];
+ }
+
+ /* look for .wox component */
- if (debugComponentLookup) {
- [self logWithFormat:@"component '%@' in framework '%@'",
- _name, _framework];
- }
+ path = [self pathForResourceNamed:
+ [self resourceNameForComponentNamed:*name_]
+ inFramework:_framework
+ languages:_languages];
- /* look for .wox component */
+ if (debugComponentLookup)
+ [self logWithFormat:@" .wox path: '%@'", path];
- path = [self pathForResourceNamed:
- [self resourceNameForComponentNamed:_name]
- inFramework:_framework
- languages:_languages];
+ /* look for .wo component */
+ if ([path length] == 0) {
+ path = [self pathToComponentNamed:*name_
+ inFramework:_framework
+ languages:_languages];
if (debugComponentLookup)
- [self logWithFormat:@" path: '%@'", path];
-
- /* look for .wo component */
-
- if ([path length] == 0) {
- path = [self pathToComponentNamed:_name
- inFramework:_framework
- languages:_languages];
- if (debugComponentLookup)
- [self logWithFormat:@" path: '%@'", path];
- }
-
- /* make URL from path */
-
- componentURL = ([path length] > 0)
- ? [[[UrlClass alloc] initFileURLWithPath:path] autorelease]
- : nil;
- }
-
- if (debugComponentLookup) {
- [self logWithFormat:@" component='%@' in framework='%@': url='%@'",
- _name, _framework, componentURL];
+ [self logWithFormat:@" .wo path: '%@'", path];
}
-
- appUrl = [app baseURL];
-
- /* check whether it's a 'template-less' component ... */
-
- if (componentURL == nil) {
- /* did not find component wrapper ! */
- [app debugWithFormat:@" component '%@' has no template !", _name];
- cdef = [self _definitionForPathlessComponent:_name languages:_languages];
- return cdef;
- }
-
- fm = [self fileManager];
-
- /* ensure that the component exists */
+ /* make URL from path */
+
+ *url_ = ([path length] > 0)
+ ? [[[UrlClass alloc] initFileURLWithPath:path] autorelease]
+ : nil;
+}
- if ([componentURL isFileURL]) {
- NSString *componentPath;
+- (WOComponentDefinition *)definitionForFileURL:(NSURL *)componentURL
+ componentName:(NSString *)_name inFramework:(NSString *)_framework
+ languages:(NSArray *)_languages
+{
+ NSFileManager *fm;
+ NSString *componentPath;
+ BOOL doesCache, isDir;
+ NSEnumerator *languages;
+ NSString *language;
+ NSString *sname = nil;
+ NSURL *appUrl;
- componentPath = [componentURL path];
+ fm = [self fileManager];
+ componentPath = [componentURL path];
+ doesCache = [[WOApplication application] isCachingEnabled];
- if (![fm fileExistsAtPath:componentPath isDirectory:&isDir]) {
- [[WOApplication application]
+ if (![fm fileExistsAtPath:componentPath isDirectory:&isDir]) {
+ [[WOApplication application]
debugWithFormat:
@"%s: did not find component '%@' at path '%@' !",
__PRETTY_FUNCTION__,
_name, componentPath];
- return cdef;
- }
+ return nil;
+ }
- /* if the component spec is a directory (eg a .wo), scan inside for stuff */
-
- if (isDir) {
- languages = [_languages objectEnumerator];
-
- while ((language = [languages nextObject])) {
- NSString *compoundKey = nil;
- NSString *languagePath = nil;
- BOOL isDirectory = NO;
+ /* if the component spec is a directory (eg a .wo), scan inside for stuff*/
+
+ if (!isDir)
+ return nil;
+
+ appUrl = [[WOApplication application] baseURL];
+ languages = [_languages objectEnumerator];
+ while ((language = [languages nextObject])) {
+ WOComponentDefinition *cdef;
+ NSString *compoundKey = nil;
+ NSString *languagePath = nil;
+ NSString *baseUrl = nil;
+ BOOL isDirectory = NO;
- if (sname == nil) sname = [_name stringByAppendingString:@"\t"];
- compoundKey = [sname stringByAppendingString:language];
+ if (sname == nil) sname = [_name stringByAppendingString:@"\t"];
+ compoundKey = [sname stringByAppendingString:language];
- if (doesCache) {
- cdef = NSMapGet(self->componentDefinitions, compoundKey);
-
- if (cdef == (id)null)
- /* resource does not exist */
- continue;
+ if (doesCache) {
+ cdef = NSMapGet(self->componentDefinitions, compoundKey);
+
+ if (cdef == (id)null)
+ /* resource does not exist */
+ continue;
- [cdef touch];
- if (cdef) return cdef; // found definition in cache
- }
-
- /* take a look into the file system */
- languagePath = [language stringByAppendingPathExtension:@"lproj"];
- languagePath =
+ [cdef touch];
+ if (cdef != nil) return cdef; // found definition in cache
+ }
+
+ /* take a look into the file system */
+ languagePath = [language stringByAppendingPathExtension:@"lproj"];
+ languagePath =
[componentPath stringByAppendingPathComponent:languagePath];
- if ([fm fileExistsAtPath:languagePath isDirectory:&isDirectory]) {
- NSString *baseUrl = nil;
-
- if (!isDirectory) {
- NSLog(@"WARNING(%s): language entry %@ is not a directory !",
- __PRETTY_FUNCTION__, languagePath);
+ if (![fm fileExistsAtPath:languagePath isDirectory:&isDirectory]) {
+ if (doesCache) {
+ /* register null in cache, so that we know it's non-existent */
+ NSMapInsert(self->componentDefinitions, compoundKey, null);
+ }
+ continue;
+ }
+
+ if (!isDirectory) {
+ [self warnWithFormat:@"(%s): language entry %@ is not a directory !",
+ __PRETTY_FUNCTION__, languagePath];
if (doesCache && (compoundKey != nil)) {
// register null in cache, so that we know it's non-existent
NSMapInsert(self->componentDefinitions, compoundKey, null);
}
continue;
- }
+ }
- baseUrl = [NSString stringWithFormat:@"%@/%@.lproj/%@.wo",
+ baseUrl = [NSString stringWithFormat:@"%@/%@.lproj/%@.wo",
[appUrl absoluteString], language, _name];
- /* found appropriate language project */
- cdef = [self _definitionWithName:_name
+ /* found appropriate language project */
+ cdef = [self _definitionWithName:_name
path:languagePath
baseURL:[NSURL URLWithString:baseUrl]
frameworkName:nil];
- if (cdef == nil) {
- NSLog(@"WARNING(%s): could not load component definition of "
- @"'%@' from language project: %@",
- __PRETTY_FUNCTION__, _name, languagePath);
+ if (cdef == nil) {
+ [self warnWithFormat:
+ @"(%s): could not load component definition of "
+ @"'%@' from language project: %@",
+ __PRETTY_FUNCTION__, _name, languagePath];
if (doesCache && (compoundKey != nil)) {
// register null in cache, so that we know it's non-existent
NSMapInsert(self->componentDefinitions, compoundKey, null);
}
continue;
- }
+ }
- if (doesCache && (compoundKey != nil)) {
+ if (doesCache && (compoundKey != nil)) {
// register in cache
NSMapInsert(self->componentDefinitions, compoundKey, cdef);
[cdef release];
- }
- else {
+ }
+ else {
// don't register in cache
cdef = [cdef autorelease];
- }
-
- return cdef;
- }
- else {
- if (doesCache) {
- // register null in cache, so that we know it's non-existent
- NSMapInsert(self->componentDefinitions, compoundKey, null);
- }
- }
- }
}
+
+ return cdef;
+ }
+ return nil;
+}
+
+- (WOComponentDefinition *)definitionForComponent:(id)_name
+ inFramework:(NSString *)_framework
+ languages:(NSArray *)_languages
+{
+ // TODO: this method is definitely too big! => refacture
+ WOApplication *app;
+ NSFileManager *fm = nil;
+ WOComponentDefinition *cdef = nil;
+ NSURL *componentURL;
+ NSURL *appUrl;
+ BOOL doesCache;
+
+ app = [WOApplication application];
+ doesCache = [app isCachingEnabled];
+
+ /* lookup component path */
+
+ [self _getComponentURL:&componentURL andName:&_name
+ forNameOrURL:_name inFramework:nil languages:nil];
+
+ if (debugComponentLookup) {
+ [self logWithFormat:@" component='%@' in framework='%@': url='%@'",
+ _name, _framework, componentURL];
+ }
+
+ appUrl = [app baseURL];
+
+ /* check whether it's a 'template-less' component ... */
+
+ if (componentURL == nil) {
+ /* did not find component wrapper ! */
+ [app debugWithFormat:@" component '%@' has no template !", _name];
+
+ cdef = [self _definitionForPathlessComponent:_name languages:_languages];
+ return cdef;
+ }
+
+ fm = [self fileManager];
+
+ /* ensure that the component exists */
+
+ if ([componentURL isFileURL]) {
+ WOComponentDefinition *cdef;
+
+ cdef = [self definitionForFileURL:componentURL componentName:_name
+ inFramework:_framework languages:_languages];
+ if (cdef != nil && ![cdef isNotNull])
+ return nil;
+ else if (cdef != nil)
+ return cdef;
}
/* look flat */
baseURL:[NSURL URLWithString:baseUrl]
frameworkName:nil];
if (cdef == nil) {
- NSLog(@"WARNING(%s): could not load component definition of '%@' from "
- @"component wrapper: '%@'",
- __PRETTY_FUNCTION__, _name, componentURL);
+ [self warnWithFormat:
+ @"(%s): could not load component definition of '%@' from "
+ @"component wrapper: '%@'",
+ __PRETTY_FUNCTION__, _name, componentURL];
if (doesCache) {
/* register null in cache, so that we know it's non-existent */
NSMapInsert(self->componentDefinitions, componentURL, null);
- (WOComponentDefinition *)definitionForComponent:(id)_name
languages:(NSArray *)_langs
{
+ // TODO: who uses that? Probably should be deprecated?
return [self definitionForComponent:_name inFramework:nil languages:_langs];
}
- (WOComponentDefinition *)__definitionForComponent:(id)_name
languages:(NSArray *)_languages
{
+ /*
+ First check whether the cdef is cached, otherwise create a new one.
+
+ This method is used by the higher level methods and just implements the
+ cache control.
+ The definition itself is created by definitionForComponent:languages:.
+ */
WOComponentDefinition *cdef;
/* look into cache */
cdef = [self _cachedDefinitionForComponent:_name languages:_languages];
- if (cdef) {
+ if (cdef != nil) {
if (cdef == (id)null)
/* component does not exist */
return nil;
-
+
if ([cdef respondsToSelector:@selector(touch)])
[cdef touch];
return cdef;
WOComponentDefinition *cdef;
cdef = [self __definitionForComponent:_name languages:_languages];
- if (cdef == nil) return nil;
+ if (cdef == nil)
+ return nil;
return (WOElement *)[cdef template];
}
-- (WOComponent *)pageWithName:(NSString *)_name
- languages:(NSArray *)_languages
-{
+- (WOComponent *)pageWithName:(NSString *)_name languages:(NSArray *)_langs {
/*
TODO: this appears to be deprecated since the WOComponent initializer
- is now -initWithContext: and we have no context here ...
+ is now -initWithContext: and we have no context over here ...
*/
- NSAutoreleasePool *pool = nil;
- WOComponentDefinition *cdef = nil;
+ NSAutoreleasePool *pool;
+ WOComponentDefinition *cdef;
WOComponent *component = nil;
pool = [[NSAutoreleasePool alloc] init];
{
- cdef = [self __definitionForComponent:_name languages:_languages];
- if (cdef) {
+ cdef = [self __definitionForComponent:_name languages:_langs];
+ if (cdef != nil) {
+ // TODO: document what the resource manager is used for in the cdef
component =
- [cdef instantiateWithResourceManager:self languages:_languages];
- component = [component retain];
+ [[cdef instantiateWithResourceManager:self languages:_langs] retain];
}
}
[pool release];
/* description */
- (NSString *)description {
- return [NSString stringWithFormat:@"<%@[0x%08X]: path=%@>",
- [self class], self, self->base];
-
+ NSMutableString *ms;
+
+ ms = [NSMutableString stringWithCapacity:32];
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+ if ([self->base length] > 0)
+ [ms appendFormat:@" path='%@'", self->base];
+ [ms appendString:@">"];
+ return ms;
}
-@end /* WOResourceManager */
-
-@implementation WOResourceManager(KeyedData)
+/* KeyedData */
- (void)setData:(NSData *)_data
forKey:(NSString *)_key
[self unlock];
}
-@end /* WOResourceManager(KeyedData) */
-
-@implementation WOResourceManager(JavaScript)
-
-- (id)_jsfunc_pathForResourceNamed:(NSArray *)_args {
- unsigned argc = [_args count];
-
- return [self pathForResourceNamed:
- argc > 0 ? [_args objectAtIndex:0] : nil
- inFramework:argc > 1 ? [_args objectAtIndex:1] : nil
- languages:argc > 2 ? [_args objectAtIndex:2] : nil];
-}
-
-- (id)_jsfunc_loadPropertyListNamed:(NSArray *)_args {
- NSString *s;
-
- if ((s = [self _jsfunc_pathForResourceNamed:_args]) == nil)
- return nil;
-
- if ((s = [NSString stringWithContentsOfFile:s]) == nil)
- return nil;
-
- return [s propertyList];
-}
-
-@end /* WOResourceManager(JavaScript) */
+@end /* WOResourceManager */