mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Small tidyup in NSBundle +initialize
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24913 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
56b7d94f6a
commit
8a44053afb
2 changed files with 70 additions and 61 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2007-03-21 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
|
* Source/NSBundle.m ([+initialize]): Removed unused check.
|
||||||
|
|
||||||
2007-03-20 Nicola Pero <nicola.pero@meta-innovation.com>
|
2007-03-20 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
* Source/NSUserDefaults.m ([+standardUserDefaults]): Fixed bug
|
* Source/NSUserDefaults.m ([+standardUserDefaults]): Fixed bug
|
||||||
|
|
|
@ -774,86 +774,91 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
|
||||||
if (self == [NSBundle class])
|
if (self == [NSBundle class])
|
||||||
{
|
{
|
||||||
NSDictionary *env;
|
NSDictionary *env;
|
||||||
|
NSString *str;
|
||||||
|
|
||||||
_emptyTable = RETAIN([NSDictionary dictionary]);
|
_emptyTable = RETAIN([NSDictionary dictionary]);
|
||||||
|
|
||||||
/* Need to make this recursive since both mainBundle and initWithPath:
|
/* Need to make this recursive since both mainBundle and
|
||||||
want to lock the thread */
|
* initWithPath: want to lock the thread.
|
||||||
|
*/
|
||||||
load_lock = [NSRecursiveLock new];
|
load_lock = [NSRecursiveLock new];
|
||||||
env = [[NSProcessInfo processInfo] environment];
|
env = [[NSProcessInfo processInfo] environment];
|
||||||
if (env)
|
|
||||||
{
|
|
||||||
NSString *str;
|
|
||||||
|
|
||||||
if ((str = [env objectForKey: @"GNUSTEP_TARGET_CPU"]) != nil)
|
|
||||||
gnustep_target_cpu = RETAIN(str);
|
|
||||||
else if ((str = [env objectForKey: @"GNUSTEP_HOST_CPU"]) != nil)
|
|
||||||
gnustep_target_cpu = RETAIN(str);
|
|
||||||
|
|
||||||
if ((str = [env objectForKey: @"GNUSTEP_TARGET_OS"]) != nil)
|
|
||||||
gnustep_target_os = RETAIN(str);
|
|
||||||
else if ((str = [env objectForKey: @"GNUSTEP_HOST_OS"]) != nil)
|
|
||||||
gnustep_target_os = RETAIN(str);
|
|
||||||
|
|
||||||
if ((str = [env objectForKey: @"GNUSTEP_TARGET_DIR"]) != nil)
|
|
||||||
gnustep_target_dir = RETAIN(str);
|
|
||||||
else if ((str = [env objectForKey: @"GNUSTEP_HOST_DIR"]) != nil)
|
|
||||||
gnustep_target_dir = RETAIN(str);
|
|
||||||
|
|
||||||
if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil)
|
|
||||||
library_combo = RETAIN(str);
|
|
||||||
|
|
||||||
_launchDirectory = RETAIN([[NSFileManager defaultManager]
|
|
||||||
currentDirectoryPath]);
|
|
||||||
|
|
||||||
_gnustep_bundle = RETAIN([self bundleForLibrary: @"gnustep-base"
|
|
||||||
version: OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)]);
|
|
||||||
|
|
||||||
|
/* These variables are used when we are running non-flattened.
|
||||||
|
* This means that there are multiple binaries for different
|
||||||
|
* OSes, and we need constantly to choose the right one (eg,
|
||||||
|
* when loading a bundle or a framework). The choice is based
|
||||||
|
* on these environments variables that are set by GNUstep.sh
|
||||||
|
* (you must source GNUstep.sh when non-flattened).
|
||||||
|
*/
|
||||||
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_CPU"]) != nil)
|
||||||
|
gnustep_target_cpu = RETAIN(str);
|
||||||
|
else if ((str = [env objectForKey: @"GNUSTEP_HOST_CPU"]) != nil)
|
||||||
|
gnustep_target_cpu = RETAIN(str);
|
||||||
|
|
||||||
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_OS"]) != nil)
|
||||||
|
gnustep_target_os = RETAIN(str);
|
||||||
|
else if ((str = [env objectForKey: @"GNUSTEP_HOST_OS"]) != nil)
|
||||||
|
gnustep_target_os = RETAIN(str);
|
||||||
|
|
||||||
|
if ((str = [env objectForKey: @"GNUSTEP_TARGET_DIR"]) != nil)
|
||||||
|
gnustep_target_dir = RETAIN(str);
|
||||||
|
else if ((str = [env objectForKey: @"GNUSTEP_HOST_DIR"]) != nil)
|
||||||
|
gnustep_target_dir = RETAIN(str);
|
||||||
|
|
||||||
|
if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil)
|
||||||
|
library_combo = RETAIN(str);
|
||||||
|
|
||||||
|
_launchDirectory = RETAIN([[NSFileManager defaultManager]
|
||||||
|
currentDirectoryPath]);
|
||||||
|
|
||||||
|
_gnustep_bundle = RETAIN([self bundleForLibrary: @"gnustep-base"
|
||||||
|
version: OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)]);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
_loadingBundle = [self mainBundle];
|
_loadingBundle = [self mainBundle];
|
||||||
handle = objc_open_main_module(stderr);
|
handle = objc_open_main_module(stderr);
|
||||||
printf("%08x\n", handle);
|
printf("%08x\n", handle);
|
||||||
#endif
|
#endif
|
||||||
#if NeXT_RUNTIME
|
#if NeXT_RUNTIME
|
||||||
|
{
|
||||||
|
int i, numClasses = 0, newNumClasses = objc_getClassList(NULL, 0);
|
||||||
|
Class *classes = NULL;
|
||||||
|
while (numClasses < newNumClasses) {
|
||||||
|
numClasses = newNumClasses;
|
||||||
|
classes = objc_realloc(classes, sizeof(Class) * numClasses);
|
||||||
|
newNumClasses = objc_getClassList(classes, numClasses);
|
||||||
|
}
|
||||||
|
for (i = 0; i < numClasses; i++)
|
||||||
{
|
{
|
||||||
int i, numClasses = 0, newNumClasses = objc_getClassList(NULL, 0);
|
[self _addFrameworkFromClass: classes[i]];
|
||||||
Class *classes = NULL;
|
|
||||||
while (numClasses < newNumClasses) {
|
|
||||||
numClasses = newNumClasses;
|
|
||||||
classes = objc_realloc(classes, sizeof(Class) * numClasses);
|
|
||||||
newNumClasses = objc_getClassList(classes, numClasses);
|
|
||||||
}
|
|
||||||
for (i = 0; i < numClasses; i++)
|
|
||||||
{
|
|
||||||
[self _addFrameworkFromClass: classes[i]];
|
|
||||||
}
|
|
||||||
objc_free(classes);
|
|
||||||
}
|
}
|
||||||
|
objc_free(classes);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
{
|
||||||
|
void *state = NULL;
|
||||||
|
Class class;
|
||||||
|
|
||||||
|
while ((class = objc_next_class(&state)))
|
||||||
{
|
{
|
||||||
void *state = NULL;
|
unsigned int len = strlen (class->name);
|
||||||
Class class;
|
|
||||||
|
if (len > sizeof("NSFramework_")
|
||||||
while ((class = objc_next_class(&state)))
|
&& !strncmp("NSFramework_", class->name, 12))
|
||||||
{
|
{
|
||||||
unsigned int len = strlen (class->name);
|
[self _addFrameworkFromClass: class];
|
||||||
|
|
||||||
if (len > sizeof("NSFramework_")
|
|
||||||
&& !strncmp("NSFramework_", class->name, 12))
|
|
||||||
{
|
|
||||||
[self _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);
|
||||||
_loadingBundle = nil;
|
_loadingBundle = nil;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue