Indentation changes - only code change is that the third argument of strncmp

should be 12 not 12*sizeof(char)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12118 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2002-01-16 13:03:45 +00:00
parent 7dcce62bc6
commit 9a6c4e02be

View file

@ -232,46 +232,64 @@ _bundle_name_first_match(NSString* directory, NSString* name)
int len; int len;
if (frameworkClass == Nil) if (frameworkClass == Nil)
{
return NO; return NO;
}
len = strlen(frameworkClass->name); len = strlen(frameworkClass->name);
if (len > 12 * sizeof(char) if (len > 12 * sizeof(char)
&& !strncmp("NSFramework_", frameworkClass->name, sizeof(char)*12)) && !strncmp("NSFramework_", frameworkClass->name, 12))
{ {
NSString *varEnv, *path, *name; NSString *varEnv, *path, *name;
name = [NSString stringWithCString: &frameworkClass->name[12]]; name = [NSString stringWithCString: &frameworkClass->name[12]];
/* varEnv is something like GNUSTEP_LOCAL_ROOT. */
varEnv = [frameworkClass frameworkEnv]; varEnv = [frameworkClass frameworkEnv];
if (varEnv && [varEnv length]) if (varEnv != nil && [varEnv length] > 0)
{
/* I don't think we should be reading it from the
environment directly! */
bundlePath = [[[NSProcessInfo processInfo] environment] bundlePath = [[[NSProcessInfo processInfo] environment]
objectForKey: varEnv]; objectForKey: varEnv];
}
/* path is something like ?. */
path = [frameworkClass frameworkPath]; path = [frameworkClass frameworkPath];
if (path && [path length]) if (path && [path length])
{ {
if (bundlePath) if (bundlePath)
{
bundlePath = [bundlePath stringByAppendingPathComponent: path]; bundlePath = [bundlePath stringByAppendingPathComponent: path];
else
bundlePath = path;
} }
else else
bundlePath = [bundlePath {
stringByAppendingPathComponent: @"Library/Frameworks"]; bundlePath = path;
}
}
else
{
bundlePath = [bundlePath stringByAppendingPathComponent:
@"Library/Frameworks"];
}
bundlePath = [bundlePath stringByAppendingPathComponent: bundlePath = [bundlePath stringByAppendingPathComponent:
[NSString stringWithFormat: @"%@.framework", name]]; [NSString stringWithFormat: @"%@.framework",
name]];
bundle = [[NSBundle alloc] initWithPath: bundlePath]; bundle = [[NSBundle alloc] initWithPath: bundlePath];
bundle->_bundleType = NSBUNDLE_FRAMEWORK; bundle->_bundleType = NSBUNDLE_FRAMEWORK;
bundle->_codeLoaded = YES; bundle->_codeLoaded = YES;
/* frameworkVersion is something like 'A'. */
bundle->_frameworkVersion = RETAIN([frameworkClass frameworkVersion]); bundle->_frameworkVersion = RETAIN([frameworkClass frameworkVersion]);
bundle->_bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]); bundle->_bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]);
/* A NULL terminated list of class names - the classes contained
in the framework. */
fmClasses = [frameworkClass frameworkClasses]; fmClasses = [frameworkClass frameworkClasses];
while (*fmClasses) while (*fmClasses != NULL)
{ {
NSValue *value; NSValue *value;
Class class = NSClassFromString(*fmClasses); Class class = NSClassFromString(*fmClasses);
@ -342,6 +360,8 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
className = [NSString stringWithCString: theCategory->class_name]; className = [NSString stringWithCString: theCategory->class_name];
} }
NSLog (@"objc bundle load callback for %@", className);
#if LINKER_GETSYMBOL #if LINKER_GETSYMBOL
path = objc_get_symbol_path(theClass, theCategory); path = objc_get_symbol_path(theClass, theCategory);
@ -366,7 +386,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
libName = [path lastPathComponent]; libName = [path lastPathComponent];
s = [path stringByDeletingLastPathComponent]; // remove lib name s = [path stringByDeletingLastPathComponent]; // remove lib name
s = [s stringByDeletingLastPathComponent]; // remove *-*-*-* s = [s stringByDeletingLastPathComponent]; // remove library-combo
s = [s stringByDeletingLastPathComponent]; // remove system name s = [s stringByDeletingLastPathComponent]; // remove system name
s = [s stringByDeletingLastPathComponent]; // remove processor s = [s stringByDeletingLastPathComponent]; // remove processor
@ -488,7 +508,9 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
} }
#else #else
if ([NSBundle _addFrameworkFromClass: theClass] == YES) if ([NSBundle _addFrameworkFromClass: theClass] == YES)
{
return; return;
}
bundle = _loadingBundle; bundle = _loadingBundle;
#endif #endif
@ -579,16 +601,19 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
newNumClasses = objc_getClassList(classes, numClasses); newNumClasses = objc_getClassList(classes, numClasses);
} }
for (i = 0; i < numClasses; i++) for (i = 0; i < numClasses; i++)
{
[NSBundle _addFrameworkFromClass: classes[i]]; [NSBundle _addFrameworkFromClass: classes[i]];
}
free(classes); free(classes);
} }
#else #else
while ((class = objc_next_class(&state))) while ((class = objc_next_class(&state)))
{
[NSBundle _addFrameworkFromClass: class]; [NSBundle _addFrameworkFromClass: class];
}
#endif #endif
#if 0 #if 0
// _bundle_load_callback(class, NULL); // _bundle_load_callback(class, NULL);
// bundle = (NSBundle *)NSMapGet(_bundles, bundlePath); // bundle = (NSBundle *)NSMapGet(_bundles, bundlePath);
objc_close_main_module(handle); objc_close_main_module(handle);
@ -789,7 +814,9 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
_path = [path copy]; _path = [path copy];
if ([[[_path lastPathComponent] pathExtension] isEqual: @"framework"] == YES) if ([[[_path lastPathComponent] pathExtension] isEqual: @"framework"] == YES)
{
_bundleType = (unsigned int)NSBUNDLE_FRAMEWORK; _bundleType = (unsigned int)NSBUNDLE_FRAMEWORK;
}
else else
{ {
if (self == _mainBundle) if (self == _mainBundle)
@ -887,16 +914,25 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
theClass = NSClassFromString(className); theClass = NSClassFromString(className);
j = [_bundleClasses count]; j = [_bundleClasses count];
fprintf (stderr, "Number of classes in bundle: %d\n", j);
for (i = 0; i < j && found == NO; i++) for (i = 0; i < j && found == NO; i++)
{ {
if ([[_bundleClasses objectAtIndex: i] Class c = [[_bundleClasses objectAtIndex: i] nonretainedObjectValue];
nonretainedObjectValue] == theClass)
fprintf (stderr, "Considering class %s\n", c->name);
if (c == theClass)
{
found = YES; found = YES;
} }
}
if (found == NO) if (found == NO)
{
theClass = Nil; theClass = Nil;
} }
}
return theClass; return theClass;
} }
@ -906,7 +942,9 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
NSString* class_name; NSString* class_name;
if (_principalClass) if (_principalClass)
{
return _principalClass; return _principalClass;
}
class_name = [[self infoDictionary] objectForKey: @"NSPrincipalClass"]; class_name = [[self infoDictionary] objectForKey: @"NSPrincipalClass"];
@ -914,18 +952,26 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
{ {
_codeLoaded = YES; _codeLoaded = YES;
if (class_name) if (class_name)
{
_principalClass = NSClassFromString(class_name); _principalClass = NSClassFromString(class_name);
}
return _principalClass; return _principalClass;
} }
if ([self load] == NO) if ([self load] == NO)
{
return Nil; return Nil;
}
if (class_name) if (class_name)
{
_principalClass = NSClassFromString(class_name); _principalClass = NSClassFromString(class_name);
}
else if ([_bundleClasses count]) else if ([_bundleClasses count])
{
_principalClass = [[_bundleClasses objectAtIndex: 0] _principalClass = [[_bundleClasses objectAtIndex: 0]
nonretainedObjectValue]; nonretainedObjectValue];
}
return _principalClass; return _principalClass;
} }
@ -952,9 +998,13 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
return NO; return NO;
} }
if (_bundleType == NSBUNDLE_FRAMEWORK) if (_bundleType == NSBUNDLE_FRAMEWORK)
{
path = [_path stringByAppendingPathComponent:@"Versions/Current"]; path = [_path stringByAppendingPathComponent:@"Versions/Current"];
}
else else
{
path = _path; path = _path;
}
object = bundle_object_name(path, object); object = bundle_object_name(path, object);
_loadingBundle = self; _loadingBundle = self;
_bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]); _bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]);
@ -973,9 +1023,11 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
classNames = [NSMutableArray arrayWithCapacity: [_bundleClasses count]]; classNames = [NSMutableArray arrayWithCapacity: [_bundleClasses count]];
classEnumerator = [_bundleClasses objectEnumerator]; classEnumerator = [_bundleClasses objectEnumerator];
while ((class = [classEnumerator nextObject])) while ((class = [classEnumerator nextObject]) != nil)
{
[classNames addObject: NSStringFromClass([class [classNames addObject: NSStringFromClass([class
nonretainedObjectValue])]; nonretainedObjectValue])];
}
[load_lock unlock]; [load_lock unlock];
@ -1270,11 +1322,16 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
version = @"Current"; version = @"Current";
if (_bundleType == NSBUNDLE_FRAMEWORK) if (_bundleType == NSBUNDLE_FRAMEWORK)
{
return [_path stringByAppendingPathComponent: return [_path stringByAppendingPathComponent:
[NSString stringWithFormat:@"Versions/%@/Resources", version]]; [NSString stringWithFormat:@"Versions/%@/Resources",
version]];
}
else else
{
return [_path stringByAppendingPathComponent: @"Resources"]; return [_path stringByAppendingPathComponent: @"Resources"];
} }
}
- (NSDictionary *) infoDictionary - (NSDictionary *) infoDictionary
{ {