mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
* configure.in: added --with-libxml-include, --with-libxml-library
and --with-libiconv-library. Added -I/usr/local/include and -L/usr/local/lib for FreeBSD. * framework.make: new file. * common.make: added common frameworks defines (library, header paths). * bundle.make: added ALL_FRAMEWORKS_DIRS * rules.make: added frameworks headers flags. Prebuild framework header dir. Set framework name/dir/version. * subproject.make: build framework headers and resource files. * target.make: added SHARED_FRAMEWORK_LINK_CMD * tool.make: added ALL_FRAMEWORKS_DIRS * ld_lib_path.csh: added paths for frameworks. * ld_lib_path.sh (lib_paths): added paths for frameworks. * GNUmakefile.in (MAKE_FILES): added framework.make * Headers/gnustep/base/NSBundle.h: added ivar. * Source/NSBundle.m ([NSBundle +_addFrameworkFromClass:]): new private method to parse NSFramework_* classes. (_bundle_load_callback): added framework support. Wrap classes in a NSValue to avoid implicit initialization. ([NSBundle +allBundles]): added framework support. ([NSBundle +allFrameworks]): implemented. ([NSBundle +bundleForClass:]): get classes from NSValue object. ([NSBundle -classNamed:]): likewise. * Headers/gnustep/base/objc-load.h (LINKER_GETSYMBOL): new define. * Source/objc-load.m (objc_get_symbol_path): get lib path of a Class or Category. * Source/simple-load.h (__objc_dynamic_get_symbol_path): indentifies lib path of a symbol. * Source/dld-load.h (__objc_dynamic_get_symbol_path): not supported. * Source/hpux-load.h (__objc_dynamic_get_symbol_path): not implemented. * Source/mframe/mframe.foot (mframe_get_arg): typ declaration fix. (mframe_set_arg): idem * Headers/gnustep/base/config.h.in: added HAVE_DLADDR * aclocal.m4 (OBJC_SYS_DYNAMIC_LINKER): test for dladdr() * configure.in: added --with-libxml-include and --with-libxml-library, added -I/usr/local/include and -L/usr/local/lib for FreeBSD. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7918 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7c19cc64ca
commit
bf7f7e8c36
13 changed files with 881 additions and 283 deletions
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,31 @@
|
|||
2000-10-28 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||
|
||||
* Headers/gnustep/base/NSBundle.h: added ivar.
|
||||
* Source/NSBundle.m ([NSBundle +_addFrameworkFromClass:]): new private
|
||||
method to parse NSFramework_* classes.
|
||||
(_bundle_load_callback): added framework support. Wrap classes in a
|
||||
NSValue to avoid implicit initialization.
|
||||
([NSBundle +allBundles]): added framework support.
|
||||
([NSBundle +allFrameworks]): implemented.
|
||||
([NSBundle +bundleForClass:]): get classes from NSValue object.
|
||||
([NSBundle -classNamed:]): likewise.
|
||||
|
||||
* Headers/gnustep/base/objc-load.h (LINKER_GETSYMBOL): new define.
|
||||
* Source/objc-load.m (objc_get_symbol_path): get lib path of a Class
|
||||
or Category.
|
||||
* Source/simple-load.h (__objc_dynamic_get_symbol_path): indentifies
|
||||
lib path of a symbol.
|
||||
* Source/dld-load.h (__objc_dynamic_get_symbol_path): not supported.
|
||||
* Source/hpux-load.h (__objc_dynamic_get_symbol_path): not implemented.
|
||||
|
||||
* Source/mframe/mframe.foot (mframe_get_arg): typ declaration fix.
|
||||
(mframe_set_arg): idem
|
||||
|
||||
* Headers/gnustep/base/config.h.in: added HAVE_DLADDR
|
||||
* aclocal.m4 (OBJC_SYS_DYNAMIC_LINKER): test for dladdr()
|
||||
* configure.in: added --with-libxml-include and --with-libxml-library,
|
||||
added -I/usr/local/include and -L/usr/local/lib for FreeBSD.
|
||||
|
||||
2000-10-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: Reverted last change -
|
||||
|
@ -81,7 +109,6 @@
|
|||
* Source/GSString.m: Changed all substringFromRange: to
|
||||
substringWithRange: as this is the basic method.
|
||||
|
||||
>>>>>>> 1.737
|
||||
2000-10-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: ([-fastestEncoding]), ([-smallestEncoding])
|
||||
|
|
|
@ -45,6 +45,7 @@ GS_EXPORT NSString* NSLoadedClasses;
|
|||
unsigned _bundleType;
|
||||
BOOL _codeLoaded;
|
||||
unsigned _version;
|
||||
NSString *_frameworkVersion;
|
||||
}
|
||||
|
||||
+ (NSArray*) allBundles;
|
||||
|
|
|
@ -132,6 +132,9 @@
|
|||
/* Define if you have the vsprintf function. */
|
||||
#undef HAVE_VSPRINTF
|
||||
|
||||
/* Define if you have the dladdr function. */
|
||||
#undef HAVE_DLADDR
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
|
|
|
@ -10,6 +10,13 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <objc/objc-api.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
#if HAVE_DLADDR
|
||||
#define LINKER_GETSYMBOL 1
|
||||
#else
|
||||
#define LINKER_GETSYMBOL 0
|
||||
#endif
|
||||
|
||||
extern long objc_load_module(
|
||||
const char *filename,
|
||||
|
@ -33,4 +40,8 @@ extern long objc_unload_modules(
|
|||
FILE *errorStream,
|
||||
void (*unloadCallback)(Class, Category*));
|
||||
|
||||
extern NSString *objc_get_symbol_path(
|
||||
Class theClass,
|
||||
Category *theCategory);
|
||||
|
||||
#endif /* __objc_load_h_INCLUDE */
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
||||
Date: May 1993
|
||||
|
||||
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||
Date: October 2000 Added frameworks support
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
@ -39,10 +42,19 @@
|
|||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
@interface NSObject (PrivateFrameworks)
|
||||
+ (NSString *)frameworkEnv;
|
||||
+ (NSString *)frameworkPath;
|
||||
+ (NSString *)frameworkVersion;
|
||||
+ (NSString **)frameworkClasses;
|
||||
@end
|
||||
|
||||
typedef enum {
|
||||
NSBUNDLE_BUNDLE = 1, NSBUNDLE_APPLICATION, NSBUNDLE_LIBRARY
|
||||
NSBUNDLE_BUNDLE = 1, NSBUNDLE_APPLICATION, NSBUNDLE_FRAMEWORK
|
||||
} bundle_t;
|
||||
|
||||
/* Class variables - We keep track of all the bundles */
|
||||
|
@ -200,32 +212,274 @@ _bundle_name_first_match(NSString* directory, NSString* name)
|
|||
}
|
||||
|
||||
@interface NSBundle (Private)
|
||||
+ (BOOL) _addFrameworkFromClass:(Class)frameworkClass;
|
||||
- (NSArray *) _bundleClasses;
|
||||
@end
|
||||
|
||||
@implementation NSBundle (Private)
|
||||
|
||||
+ (BOOL) _addFrameworkFromClass:(Class)frameworkClass
|
||||
{
|
||||
NSBundle *bundle;
|
||||
NSString **fmClasses, *bundlePath = nil;
|
||||
int len = strlen(frameworkClass->name);
|
||||
|
||||
if (len > 12*sizeof(char)
|
||||
&& !strncmp("NSFramework_", frameworkClass->name, sizeof(char)*12))
|
||||
{
|
||||
NSString *varEnv, *path, *name;
|
||||
|
||||
name = [NSString stringWithCString: &frameworkClass->name[12]];
|
||||
|
||||
varEnv = [frameworkClass frameworkEnv];
|
||||
if (varEnv && [varEnv length])
|
||||
bundlePath = [[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: varEnv];
|
||||
|
||||
path = [frameworkClass frameworkPath];
|
||||
if (path && [path length])
|
||||
{
|
||||
if (bundlePath)
|
||||
bundlePath = [bundlePath
|
||||
stringByAppendingPathComponent: path];
|
||||
else
|
||||
bundlePath = path;
|
||||
}
|
||||
else
|
||||
bundlePath = [bundlePath
|
||||
stringByAppendingPathComponent: @"Library/Frameworks"];
|
||||
|
||||
bundlePath = [bundlePath stringByAppendingPathComponent:
|
||||
[NSString stringWithFormat: @"%@.framework",
|
||||
name]];
|
||||
|
||||
bundle = [NSBundle bundleWithPath: bundlePath];
|
||||
bundle->_bundleType = NSBUNDLE_FRAMEWORK;
|
||||
bundle->_codeLoaded = YES;
|
||||
bundle->_frameworkVersion = RETAIN([frameworkClass frameworkVersion]);
|
||||
bundle->_bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]);
|
||||
|
||||
fmClasses = [frameworkClass frameworkClasses];
|
||||
|
||||
while (*fmClasses)
|
||||
{
|
||||
NSValue *value;
|
||||
Class class = NSClassFromString(*fmClasses);
|
||||
|
||||
value = [NSValue valueWithNonretainedObject: class];
|
||||
|
||||
[(NSMutableArray *)[bundle _bundleClasses]
|
||||
addObject: value];
|
||||
|
||||
if (_loadingBundle)
|
||||
{
|
||||
NSEnumerator *classEnum;
|
||||
NSValue *obj;
|
||||
|
||||
classEnum = [_loadingBundle->_bundleClasses objectEnumerator];
|
||||
while ((obj = [classEnum nextObject]))
|
||||
{
|
||||
if ([obj nonretainedObjectValue] == class)
|
||||
{
|
||||
[(NSMutableArray *)_loadingBundle->_bundleClasses
|
||||
removeObject: obj];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmClasses++;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSArray *) _bundleClasses
|
||||
{
|
||||
return _bundleClasses;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static NSString *lastSymbolPath = nil;
|
||||
static NSString *lastFrameworkName = nil;
|
||||
static NSBundle *lastFrameworkBundle = nil;
|
||||
|
||||
void
|
||||
_bundle_load_callback(Class theClass, Category *theCategory)
|
||||
{
|
||||
NSBundle *bundle = nil;
|
||||
NSString *className;
|
||||
NSString *path, *bundlePath = nil, *lastComponent;
|
||||
NSString *libName, *frameworkVersion = nil;
|
||||
BOOL isFramework = NO;
|
||||
|
||||
NSCAssert(_loadingBundle, NSInternalInconsistencyException);
|
||||
|
||||
if (theClass)
|
||||
className = NSStringFromClass(theClass);
|
||||
else
|
||||
className = [NSString stringWithCString: theCategory->class_name];
|
||||
|
||||
#if !LINKER_GETSYMBOL
|
||||
if ([NSBundle _addFrameworkFromClass: theClass] == YES)
|
||||
return;
|
||||
#else
|
||||
path = objc_get_symbol_path(theClass, theCategory);
|
||||
|
||||
if (lastSymbolPath && [lastSymbolPath isEqual: path] == YES)
|
||||
isFramework = YES;
|
||||
else
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
DESTROY(lastSymbolPath);
|
||||
DESTROY(lastFrameworkBundle);
|
||||
DESTROY(lastFrameworkName);
|
||||
|
||||
/*
|
||||
* Check for framework dirs
|
||||
*
|
||||
* <path_to>/Library/Frameworks/
|
||||
* <path_to>/Library/Libraries/
|
||||
*/
|
||||
|
||||
libName = [path lastPathComponent];
|
||||
s = [path stringByDeletingLastPathComponent]; // remove lib name
|
||||
s = [s stringByDeletingLastPathComponent]; // remove *-*-*-*
|
||||
s = [s stringByDeletingLastPathComponent]; // remove system name
|
||||
s = [s stringByDeletingLastPathComponent]; // remove processor
|
||||
|
||||
lastComponent = [s lastPathComponent];
|
||||
|
||||
// is in <path_to>/Library/Libraries ?
|
||||
if ([lastComponent isEqual: @"Libraries"] == YES)
|
||||
{
|
||||
s = [s stringByDeletingLastPathComponent]; // remove Libraries
|
||||
|
||||
if ([[s lastPathComponent] isEqual: @"Library"] == YES)
|
||||
{
|
||||
const char *cString;
|
||||
int i, len;
|
||||
|
||||
s = [s stringByAppendingPathComponent: @"Frameworks"];
|
||||
|
||||
cString = [libName cString];
|
||||
len = [libName length];
|
||||
|
||||
if (len > 3)
|
||||
{
|
||||
for (i = 3; i < len; i++)
|
||||
if (cString[i] == '.')
|
||||
break;
|
||||
|
||||
if (i-3)
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
name = [NSString stringWithCString: &cString[3]
|
||||
length: i-3];
|
||||
|
||||
bundlePath = [s stringByAppendingPathComponent:
|
||||
[NSString stringWithFormat:
|
||||
@"%@.framework", name]];
|
||||
|
||||
name = [NSString stringWithFormat: @"NSFramework_%@",
|
||||
name];
|
||||
|
||||
ASSIGN(lastFrameworkName, name);
|
||||
ASSIGN(lastSymbolPath, path);
|
||||
|
||||
isFramework = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there is an extension it is not a framework
|
||||
if ([[lastComponent pathExtension] length] == 0)
|
||||
{
|
||||
frameworkVersion = lastComponent;
|
||||
s = [s stringByDeletingLastPathComponent]; // remove version
|
||||
bundlePath = [s stringByDeletingLastPathComponent]; // remove version dir
|
||||
|
||||
if ([[bundlePath pathExtension] isEqual: @"framework"] == YES)
|
||||
{
|
||||
ASSIGN(lastSymbolPath, path);
|
||||
isFramework = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isFramework == YES)
|
||||
{
|
||||
if (_bundles)
|
||||
bundle = (NSBundle *)NSMapGet(_bundles, bundlePath);
|
||||
|
||||
if (!bundle && _releasedBundles)
|
||||
{
|
||||
bundle = (NSBundle *)NSMapGet(_releasedBundles, bundlePath);
|
||||
|
||||
if (bundle)
|
||||
{
|
||||
NSMapInsert(_bundles, bundlePath, bundle);
|
||||
NSMapRemove(_releasedBundles, bundlePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!bundle)
|
||||
{
|
||||
bundle = [NSBundle bundleWithPath: bundlePath];
|
||||
bundle->_bundleType = NSBUNDLE_FRAMEWORK;
|
||||
bundle->_codeLoaded = YES;
|
||||
bundle->_frameworkVersion = RETAIN(frameworkVersion);
|
||||
bundle->_bundleClasses = RETAIN([NSMutableArray
|
||||
arrayWithCapacity: 2]);
|
||||
}
|
||||
|
||||
ASSIGN(lastFrameworkBundle, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
if (isFramework == YES)
|
||||
{
|
||||
bundle = lastFrameworkBundle;
|
||||
|
||||
if (lastFrameworkName)
|
||||
{
|
||||
if ([className isEqual: lastFrameworkName] == YES)
|
||||
{
|
||||
bundle->_frameworkVersion = RETAIN([theClass frameworkVersion]);
|
||||
|
||||
DESTROY(lastFrameworkName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
bundle = _loadingBundle;
|
||||
|
||||
/* Don't store categories */
|
||||
if (!theCategory)
|
||||
[(NSMutableArray *)[_loadingBundle _bundleClasses] addObject: (id)theClass];
|
||||
[(NSMutableArray *)[bundle _bundleClasses]
|
||||
addObject: [NSValue
|
||||
valueWithNonretainedObject: (id)theClass]];
|
||||
}
|
||||
|
||||
|
||||
@implementation NSBundle
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [NSBundle class])
|
||||
{
|
||||
NSDictionary *env;
|
||||
NSDictionary *env;
|
||||
void *state = NULL;
|
||||
Class class;
|
||||
|
||||
_emptyTable = RETAIN([NSDictionary dictionary]);
|
||||
|
||||
|
@ -276,6 +530,23 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
|
||||
RETAIN(_executable_path);
|
||||
_gnustep_bundle = RETAIN([NSBundle bundleWithPath: system]);
|
||||
|
||||
#if 0
|
||||
_loadingBundle = [NSBundle mainBundle];
|
||||
handle = objc_open_main_module(stderr);
|
||||
printf("%08x\n", handle);
|
||||
#endif
|
||||
while ((class = objc_next_class(&state)))
|
||||
[NSBundle _addFrameworkFromClass: class];
|
||||
|
||||
#if 0
|
||||
// _bundle_load_callback(class, NULL);
|
||||
|
||||
// bundle = (NSBundle *)NSMapGet(_bundles, bundlePath);
|
||||
|
||||
objc_close_main_module(handle);
|
||||
_loadingBundle = nil;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -291,9 +562,11 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
enumerate = NSEnumerateMapTable(_bundles);
|
||||
while (NSNextMapEnumeratorPair(&enumerate, &key, (void **)&bundle))
|
||||
{
|
||||
if (bundle->_bundleType == NSBUNDLE_FRAMEWORK)
|
||||
continue;
|
||||
|
||||
if ([array indexOfObjectIdenticalTo: bundle] == NSNotFound)
|
||||
{
|
||||
/* FIXME - must ignore frameworks here */
|
||||
[array addObject: bundle];
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +576,23 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
|
||||
+ (NSArray *) allFrameworks
|
||||
{
|
||||
return [self notImplemented: _cmd];
|
||||
NSMapEnumerator enumerate;
|
||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 2];
|
||||
void *key;
|
||||
NSBundle *bundle;
|
||||
|
||||
[load_lock lock];
|
||||
enumerate = NSEnumerateMapTable(_bundles);
|
||||
while (NSNextMapEnumeratorPair(&enumerate, &key, (void **)&bundle))
|
||||
{
|
||||
if (bundle->_bundleType == NSBUNDLE_FRAMEWORK
|
||||
&& [array indexOfObjectIdenticalTo: bundle] == NSNotFound)
|
||||
{
|
||||
[array addObject: bundle];
|
||||
}
|
||||
}
|
||||
[load_lock unlock];
|
||||
return array;
|
||||
}
|
||||
|
||||
+ (NSBundle *)mainBundle
|
||||
|
@ -366,10 +655,21 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
enumerate = NSEnumerateMapTable(_bundles);
|
||||
while (NSNextMapEnumeratorPair(&enumerate, &key, (void **)&bundle))
|
||||
{
|
||||
int j;
|
||||
j = [[bundle _bundleClasses] indexOfObject: aClass];
|
||||
if (j != NSNotFound && [bundle _bundleClasses])
|
||||
int i, j;
|
||||
NSArray *bundleClasses = [bundle _bundleClasses];
|
||||
BOOL found = NO;
|
||||
|
||||
j = [bundleClasses count];
|
||||
for (i = 0; i < j && found == NO; i++)
|
||||
{
|
||||
if ([[bundleClasses objectAtIndex: i]
|
||||
nonretainedObjectValue] == aClass)
|
||||
found = YES;
|
||||
}
|
||||
|
||||
if (found == YES)
|
||||
break;
|
||||
|
||||
bundle = nil;
|
||||
}
|
||||
[load_lock unlock];
|
||||
|
@ -440,9 +740,16 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
}
|
||||
|
||||
_path = [path copy];
|
||||
_bundleType = (unsigned int)NSBUNDLE_BUNDLE;
|
||||
if (self == _mainBundle)
|
||||
_bundleType = (unsigned int)NSBUNDLE_APPLICATION;
|
||||
|
||||
if ([[[_path lastPathComponent] pathExtension] isEqual: @"framework"] == YES)
|
||||
_bundleType = (unsigned int)NSBUNDLE_FRAMEWORK;
|
||||
else
|
||||
{
|
||||
if (self == _mainBundle)
|
||||
_bundleType = (unsigned int)NSBUNDLE_APPLICATION;
|
||||
else
|
||||
_bundleType = (unsigned int)NSBUNDLE_BUNDLE;
|
||||
}
|
||||
|
||||
[load_lock lock];
|
||||
if (!_bundles)
|
||||
|
@ -494,6 +801,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
[load_lock unlock];
|
||||
RELEASE(_path);
|
||||
}
|
||||
TEST_RELEASE(_frameworkVersion);
|
||||
TEST_RELEASE(_bundleClasses);
|
||||
TEST_RELEASE(_infoDict);
|
||||
TEST_RELEASE(_localizations);
|
||||
|
@ -507,8 +815,9 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
|
||||
- (Class) classNamed: (NSString *)className
|
||||
{
|
||||
int j;
|
||||
int i, j;
|
||||
Class theClass = Nil;
|
||||
|
||||
if (!_codeLoaded)
|
||||
{
|
||||
if (self != _mainBundle && ![self load])
|
||||
|
@ -526,9 +835,20 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
}
|
||||
else
|
||||
{
|
||||
j = [_bundleClasses indexOfObject: NSClassFromString(className)];
|
||||
if (j != NSNotFound)
|
||||
theClass = [_bundleClasses objectAtIndex: j];
|
||||
BOOL found = NO;
|
||||
|
||||
theClass = NSClassFromString(className);
|
||||
j = [_bundleClasses count];
|
||||
|
||||
for (i = 0; i < j && found == NO; i++)
|
||||
{
|
||||
if ([[_bundleClasses objectAtIndex: i]
|
||||
nonretainedObjectValue] == theClass)
|
||||
found = YES;
|
||||
}
|
||||
|
||||
if (found == NO)
|
||||
theClass = Nil;
|
||||
}
|
||||
|
||||
return theClass;
|
||||
|
@ -557,7 +877,8 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
if (class_name)
|
||||
_principalClass = NSClassFromString(class_name);
|
||||
else if ([_bundleClasses count])
|
||||
_principalClass = [_bundleClasses objectAtIndex:0];
|
||||
_principalClass = [[_bundleClasses objectAtIndex: 0]
|
||||
nonretainedObjectValue];
|
||||
return _principalClass;
|
||||
}
|
||||
|
||||
|
@ -572,14 +893,22 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
[load_lock lock];
|
||||
if (!_codeLoaded)
|
||||
{
|
||||
NSString* object;
|
||||
NSString *object, *path;
|
||||
NSEnumerator *classEnumerator;
|
||||
NSMutableArray *classNames;
|
||||
NSValue *class;
|
||||
|
||||
object = [[self infoDictionary] objectForKey: @"NSExecutable"];
|
||||
if (object == nil || [object length] == 0)
|
||||
{
|
||||
[load_lock unlock];
|
||||
return NO;
|
||||
}
|
||||
object = bundle_object_name(_path, object);
|
||||
if (_bundleType == NSBUNDLE_FRAMEWORK)
|
||||
path = [_path stringByAppendingPathComponent:@"Versions/Current"];
|
||||
else
|
||||
path = _path;
|
||||
object = bundle_object_name(path, object);
|
||||
_loadingBundle = self;
|
||||
_bundleClasses = RETAIN([NSMutableArray arrayWithCapacity: 2]);
|
||||
if (objc_load_module([object cString],
|
||||
|
@ -588,14 +917,27 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
[load_lock unlock];
|
||||
return NO;
|
||||
}
|
||||
DESTROY(lastSymbolPath);
|
||||
DESTROY(lastFrameworkName);
|
||||
DESTROY(lastFrameworkBundle);
|
||||
|
||||
_codeLoaded = YES;
|
||||
_loadingBundle = nil;
|
||||
|
||||
classNames = [NSMutableArray arrayWithCapacity: [_bundleClasses count]];
|
||||
classEnumerator = [_bundleClasses objectEnumerator];
|
||||
while ((class = [classEnumerator nextObject]))
|
||||
[classNames addObject: NSStringFromClass([class
|
||||
nonretainedObjectValue])];
|
||||
|
||||
[load_lock unlock];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSBundleDidLoadNotification
|
||||
object: self
|
||||
userInfo: [NSDictionary dictionaryWithObjects: &_bundleClasses
|
||||
forKeys: &NSLoadedClasses count: 1]];
|
||||
userInfo: [NSDictionary dictionaryWithObject: classNames
|
||||
forKey: NSLoadedClasses]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
[load_lock unlock];
|
||||
|
@ -612,7 +954,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
<main bundle>/<bundlePath>/<language.lproj>
|
||||
*/
|
||||
+ (NSArray *) _bundleResourcePathsWithRootPath: (NSString *)rootPath
|
||||
subPath: (NSString *)bundlePath
|
||||
subPath: (NSString *)bundlePath
|
||||
{
|
||||
NSString* primary;
|
||||
NSString* language;
|
||||
|
@ -639,10 +981,10 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
}
|
||||
|
||||
+ (NSString *) pathForResource: (NSString *)name
|
||||
ofType: (NSString *)ext
|
||||
inRootPath: (NSString *)rootPath
|
||||
inDirectory: (NSString *)bundlePath
|
||||
withVersion: (int)version
|
||||
ofType: (NSString *)ext
|
||||
inRootPath: (NSString *)rootPath
|
||||
inDirectory: (NSString *)bundlePath
|
||||
withVersion: (int)version
|
||||
{
|
||||
NSString *path, *fullpath;
|
||||
NSEnumerator* pathlist;
|
||||
|
@ -655,9 +997,9 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
}
|
||||
|
||||
pathlist = [[NSBundle _bundleResourcePathsWithRootPath: rootPath
|
||||
subPath: bundlePath] objectEnumerator];
|
||||
subPath: bundlePath] objectEnumerator];
|
||||
fullpath = nil;
|
||||
while((path = [pathlist nextObject]))
|
||||
while ((path = [pathlist nextObject]))
|
||||
{
|
||||
if (!bundle_directory_readable(path))
|
||||
continue;
|
||||
|
@ -702,45 +1044,53 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
}
|
||||
|
||||
+ (NSString *) pathForResource: (NSString *)name
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath
|
||||
withVersion: (int) version
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath
|
||||
withVersion: (int) version
|
||||
{
|
||||
return [self pathForResource: name
|
||||
ofType: ext
|
||||
inRootPath: bundlePath
|
||||
inDirectory: nil
|
||||
withVersion: version];
|
||||
ofType: ext
|
||||
inRootPath: bundlePath
|
||||
inDirectory: nil
|
||||
withVersion: version];
|
||||
}
|
||||
|
||||
+ (NSString *) pathForResource: (NSString *)name
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath
|
||||
{
|
||||
return [self pathForResource: name
|
||||
ofType: ext
|
||||
inRootPath: bundlePath
|
||||
inDirectory: nil
|
||||
withVersion: 0];
|
||||
ofType: ext
|
||||
inRootPath: bundlePath
|
||||
inDirectory: nil
|
||||
withVersion: 0];
|
||||
}
|
||||
|
||||
- (NSString *) pathForResource: (NSString *)name
|
||||
ofType: (NSString *)ext;
|
||||
ofType: (NSString *)ext;
|
||||
{
|
||||
return [self pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: nil];
|
||||
ofType: ext
|
||||
inDirectory: nil];
|
||||
}
|
||||
|
||||
- (NSString *) pathForResource: (NSString *)name
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath;
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath;
|
||||
{
|
||||
NSString *rootPath;
|
||||
|
||||
if (_frameworkVersion)
|
||||
rootPath = [NSString stringWithFormat:@"%@/Versions/%@", [self bundlePath],
|
||||
_frameworkVersion];
|
||||
else
|
||||
rootPath = [self bundlePath];
|
||||
|
||||
return [NSBundle pathForResource: name
|
||||
ofType: ext
|
||||
inRootPath: [self bundlePath]
|
||||
inDirectory: bundlePath
|
||||
withVersion: _version];
|
||||
ofType: ext
|
||||
inRootPath: rootPath
|
||||
inDirectory: bundlePath
|
||||
withVersion: _version];
|
||||
}
|
||||
|
||||
- (NSArray *) pathsForResourcesOfType: (NSString *)extension
|
||||
|
@ -753,7 +1103,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
|
||||
pathlist = [[NSBundle _bundleResourcePathsWithRootPath: [self bundlePath]
|
||||
subPath: bundlePath] objectEnumerator];
|
||||
subPath: bundlePath] objectEnumerator];
|
||||
resources = [NSMutableArray arrayWithCapacity: 2];
|
||||
allfiles = (extension == nil || [extension length] == 0);
|
||||
|
||||
|
@ -778,7 +1128,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
table: (NSString *)tableName
|
||||
{
|
||||
NSDictionary *table;
|
||||
NSString *newString;
|
||||
NSString *newString = nil;
|
||||
|
||||
if (_localizations == nil)
|
||||
_localizations = [[NSMutableDictionary alloc] initWithCapacity: 1];
|
||||
|
@ -866,7 +1216,17 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
|
||||
- (NSString *) resourcePath
|
||||
{
|
||||
return [_path stringByAppendingPathComponent: @"Resources"];
|
||||
NSString *version = _frameworkVersion;
|
||||
|
||||
if (!version)
|
||||
version = @"Current";
|
||||
|
||||
if (_bundleType == NSBUNDLE_FRAMEWORK)
|
||||
return [_path stringByAppendingPathComponent:
|
||||
[NSString stringWithFormat:@"Versions/%@/Resources",
|
||||
version]];
|
||||
else
|
||||
return [_path stringByAppendingPathComponent: @"Resources"];
|
||||
}
|
||||
|
||||
- (NSDictionary *) infoDictionary
|
||||
|
@ -1002,22 +1362,22 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
|
||||
/* Search user first */
|
||||
path = [user_bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
/* Search local second */
|
||||
path = [local_bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
/* Search system last */
|
||||
path = [_gnustep_bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
if (path)
|
||||
return path;
|
||||
|
||||
|
|
|
@ -136,4 +136,11 @@ __objc_dynamic_list_undefined_symbols(void)
|
|||
return dld_list_undefined_sym();
|
||||
}
|
||||
|
||||
/* current dld version does not support an equivalent of dladdr() */
|
||||
static char *
|
||||
__objc_dynamic_get_symbol_path(dl_handle_t handle, dl_symbol_t symbol)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* __dld_load_h_INCLUDE */
|
||||
|
|
|
@ -81,4 +81,11 @@ __objc_dynamic_list_undefined_symbols(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: search for an hp-ux equivalent of dladdr() */
|
||||
static char *
|
||||
__objc_dynamic_get_symbol_path(dl_handle_t handle, dl_symbol_t symbol)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* __hpux_load_h_INCLUDE */
|
||||
|
|
|
@ -22,8 +22,10 @@ mframe_arg_addr(arglist_t argf, NSArgumentInfo *info)
|
|||
inline static void
|
||||
mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
|
||||
{
|
||||
#if MFRAME_STRUCT_BYREF
|
||||
#if MFRAME_STRUCT_BYREF || MFRAME_FLT_IN_FRAME_AS_DBL
|
||||
const char *typ = info->type;
|
||||
#endif
|
||||
#if MFRAME_STRUCT_BYREF
|
||||
|
||||
/*
|
||||
* If structures are passed in the stack frame by reference - we need
|
||||
|
@ -48,8 +50,10 @@ mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
|
|||
inline static void
|
||||
mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
|
||||
{
|
||||
#if MFRAME_STRUCT_BYREF
|
||||
#if MFRAME_STRUCT_BYREF || MFRAME_FLT_IN_FRAME_AS_DBL
|
||||
const char *typ = info->type;
|
||||
#endif
|
||||
#if MFRAME_STRUCT_BYREF
|
||||
|
||||
/*
|
||||
* If structures are passed in the stack frame by reference - we need
|
||||
|
|
|
@ -243,3 +243,61 @@ objc_unload_modules(
|
|||
fprintf(errorStream, "Warning: unloading modules not implemented\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objc_get_symbol_path(Class theClass, Category *theCategory)
|
||||
{
|
||||
const char *ret;
|
||||
char buf[125], *p = buf;
|
||||
int len = strlen(theClass->name);
|
||||
|
||||
if (!theCategory)
|
||||
{
|
||||
if (len+sizeof(char)*19 > sizeof(buf))
|
||||
{
|
||||
p = malloc(len+sizeof(char)*19);
|
||||
|
||||
if (!p)
|
||||
{
|
||||
fprintf(stderr, "Unable to allocate memory !!");
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(buf, "__objc_class_name_", sizeof(char)*18);
|
||||
memcpy(&buf[18*sizeof(char)], theClass->name,
|
||||
strlen(theClass->name)+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
len += strlen(theCategory->category_name);
|
||||
|
||||
if (len+sizeof(char)*23 > sizeof(buf))
|
||||
{
|
||||
p = malloc(len+sizeof(char)*23);
|
||||
|
||||
if (!p)
|
||||
{
|
||||
fprintf(stderr, "Unable to allocate memory !!");
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(buf, "__objc_category_name_", sizeof(char)*21);
|
||||
memcpy(&buf[21*sizeof(char)], theCategory->class_name,
|
||||
strlen(theCategory->class_name)+1);
|
||||
memcpy(&buf[strlen(p)], "_", 2*sizeof(char));
|
||||
memcpy(&buf[strlen(p)], theCategory->category_name,
|
||||
strlen(theCategory->category_name)+1);
|
||||
}
|
||||
|
||||
ret = __objc_dynamic_get_symbol_path(0, p);
|
||||
|
||||
if (p != buf)
|
||||
free(p);
|
||||
|
||||
if (ret)
|
||||
return [NSString stringWithCString:ret];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -84,4 +84,21 @@ __objc_dynamic_list_undefined_symbols(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
__objc_dynamic_get_symbol_path(dl_handle_t handle, dl_symbol_t symbol)
|
||||
{
|
||||
dl_symbol_t sym;
|
||||
Dl_info info;
|
||||
|
||||
sym = dlsym(RTLD_NEXT, symbol);
|
||||
|
||||
if (!sym)
|
||||
return NULL;
|
||||
|
||||
if (!dladdr(sym, &info))
|
||||
return NULL;
|
||||
|
||||
return info.dli_fname;
|
||||
}
|
||||
|
||||
#endif /* __sunos_load_h_INCLUDE */
|
||||
|
|
5
aclocal.m4
vendored
5
aclocal.m4
vendored
|
@ -84,6 +84,11 @@ if test $DYNAMIC_LINKER = null; then
|
|||
AC_CHECK_HEADER(dld/defs.h, DYNAMIC_LINKER=dld)
|
||||
fi
|
||||
|
||||
if test $DYNAMIC_LINKER = simple; then
|
||||
AC_TRY_LINK([#include <dlfcn.h>], dladdr(0,0);,
|
||||
AC_DEFINE(HAVE_DLADDR))
|
||||
fi
|
||||
|
||||
AC_SUBST(DYNAMIC_LINKER)dnl
|
||||
])
|
||||
|
||||
|
|
31
configure.in
31
configure.in
|
@ -48,6 +48,14 @@ AC_PATH_PROG(WHOAMI, whoami, echo, $PATH:/usr/ucb)
|
|||
PIPE='-pipe'
|
||||
AC_SUBST(PIPE)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# specific target_os options
|
||||
#--------------------------------------------------------------------
|
||||
case "$target_os" in
|
||||
freebsd*) CPPFLAGS="$CPPFLAGS -I/usr/local/include"
|
||||
LIBS="$LIBS -L/usr/local/lib";;
|
||||
esac
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Find out if we\'re using NeXT\'s compiler.
|
||||
# if yes:
|
||||
|
@ -781,6 +789,24 @@ AC_MSG_RESULT($enable_fake_main)
|
|||
# Check recent libxlm for Properytlists, GSXML, GSDoc etc.
|
||||
#--------------------------------------------------------------------
|
||||
echo "Checking for libxml"
|
||||
AC_ARG_WITH(libxml-include,
|
||||
[ --with-libxml-include=PATH include path for libxml headers],
|
||||
libxml_incdir="$withval", libxml_incdir="no")
|
||||
|
||||
AC_ARG_WITH(libxml-library,
|
||||
[ --with-libxml-library=PATH library path for libxml libraries],
|
||||
libxml_libdir="$withval", libxml_libdir="no")
|
||||
|
||||
cppflags_temp=$CFLAGS
|
||||
libs_temp=$LIBS
|
||||
|
||||
if test "$libxml_incdir" != "no"; then
|
||||
CPPFLAGS="$CPPFLAGS -I$libxml_incdir"
|
||||
fi
|
||||
if test "$libxml_libdir" != "no"; then
|
||||
LIBS="$LIBS -L$libxml_libdir"
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(libxml/xmlversion.h)
|
||||
if test $ac_cv_header_libxml_xmlversion_h = no; then
|
||||
echo "Could not find libxml headers"
|
||||
|
@ -802,6 +828,11 @@ else
|
|||
fi
|
||||
AC_SUBST(HAVE_LIBXML)
|
||||
|
||||
if test "$HAVE_LIBXML" = "0"; then
|
||||
CPPFLAGS="$cppflags_temp";
|
||||
LIBS="$libs_temp";
|
||||
fi
|
||||
|
||||
|
||||
AC_SUBST(whole_archive)
|
||||
AC_SUBST(no_whole_archive)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue