Both those changes sound reasonable to me, as long as they are clearly commented so that someone (like me) doesn't come along later and, forgetting what they are for, remove them because the look unneccessary.

Hi,

the patch is attached for your review and inclusion.

I ran make check, which produced an issue which I then fixed, so some testing was involved. I may possibly come up with more patches, but this should get me started.

Thanks!
--
Luboš Doležel
--- gnustep-base-1.24.4/Source/NSBundle.m.orig	2012-10-17 15:47:11.000000000 +0200
+++ gnustep-base-1.24.4/Source/NSBundle.m	2013-05-22 10:35:06.180236946 +0200
@@ -622,16 +622,39 @@
 
 @interface NSBundle (Private)
 + (NSString *) _absolutePathOfExecutable: (NSString *)path;
-+ (NSBundle*) _addFrameworkFromClass: (Class)frameworkClass;
++ (NSBundle*) _addFrameworkFromClass: (Class)frameworkClass
+                            withPath:(NSString*)path;
 + (NSMutableArray*) _addFrameworks;
 + (NSString*) _gnustep_target_cpu;
 + (NSString*) _gnustep_target_dir;
 + (NSString*) _gnustep_target_os;
 + (NSString*) _library_combo;
++ (long) _loadModuleWithFilename: (NSString*)filename
+                     errorStream: (FILE*)errorStream
+                    loadCallback: (void (*)(Class, struct objc_category *))loadCallback
+                          header: (void**)header
+                   debugFilename: (NSString*)debugFilename;
 @end
 
 @implementation NSBundle (Private)
 
+/*
+ This helper method enables NSBundle subclasses to add support for
+ using different loading techniques for specific bundles.
+
+ This method could, for example, be overridden to use a different
+ dynamic loader to load the module.
+*/
+
++ (long) _loadModuleWithFilename: (NSString*)filename
+                     errorStream: (FILE*)errorStream
+                    loadCallback: (void (*)(Class, struct objc_category *))loadCallback
+                          header: (void**)header
+                   debugFilename: (NSString*)debugFilename
+{
+  return GSPrivateLoadModule(filename, errorStream, loadCallback, header, debugFilename);
+}
+
 + (NSString *) _absolutePathOfExecutable: (NSString *)path
 {
   return AbsolutePathOfExecutable(path, NO);
@@ -682,12 +705,19 @@
    the main application) to record them, and try finding the path on
    disk to those framework bundles.
 
+   The bundlePath argument can have a nil value, in which case the
+   function will try its best to detect the correct bundle path.
+   Passing a bundle path may serve as a performance optimization
+   and at the same time enable support for dynamic libraries not
+   loaded by system's default loader - for which the detection would
+   not work.
+
 */
 + (NSBundle*) _addFrameworkFromClass: (Class)frameworkClass
+                            withPath: (NSString*)bundlePath
 {
   NSBundle	*bundle = nil;
   NSString	**fmClasses;
-  NSString	*bundlePath = nil;
   unsigned int	len;
   const char    *frameworkClassName;
 
@@ -734,7 +764,8 @@
        * really universal way of getting the framework path ... we can
        * locate the framework no matter where it is on disk!
        */
-      bundlePath = GSPrivateSymbolPath (frameworkClass, NULL);
+	  if (bundlePath == nil)
+        bundlePath = GSPrivateSymbolPath (frameworkClass, NULL);
 
       if ([bundlePath isEqualToString: GSPrivateExecutablePath()])
 	{
@@ -966,7 +997,8 @@
     }
   for (i = 0; i < numClasses; i++)
     {
-      NSBundle  *bundle = [self _addFrameworkFromClass: classes[i]];
+      NSBundle  *bundle = [self _addFrameworkFromClass: classes[i]
+                                              withPath: nil];
 
       if (nil != bundle)
         {
@@ -2010,7 +2042,11 @@
 	 _codeLoaded before loading the bundle. */
       _codeLoaded = YES;
 
-      if (GSPrivateLoadModule(object, stderr, _bundle_load_callback, 0, 0))
+	  if ([[self class] _loadModuleWithFilename: object
+                                    errorStream: stderr
+                                   loadCallback: _bundle_load_callback
+                                         header: 0
+                                  debugFilename: 0])
 	{
 	  _codeLoaded = NO;
           _loadingBundle = savedLoadingBundle;
@@ -2028,7 +2064,8 @@
       classEnumerator = [_loadingFrameworks objectEnumerator];
       while ((class = [classEnumerator nextObject]) != nil)
 	{
-	  [NSBundle _addFrameworkFromClass: (Class)[class pointerValue]];
+      [NSBundle _addFrameworkFromClass: (Class)[class pointerValue]
+                              withPath: object];
 	}
 
       /* After we load code from a bundle, we retain the bundle until
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to