~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to Source/NSBundle.m

  • Committer: Bazaar Package Importer
  • Author(s): Hubert Chathi
  • Date: 2009-04-11 13:30:33 UTC
  • mfrom: (1.2.8 upstream) (7.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090411133033-g6qrsuo8mep7h0eo
Tags: 1.19.0-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
 
30
30
   <title>NSBundle class reference</title>
31
 
   $Date: 2008-06-12 11:44:00 +0100 (Thu, 12 Jun 2008) $ $Revision: 26630 $
 
31
   $Date: 2008-12-06 21:48:37 +0000 (Sat, 06 Dec 2008) $ $Revision: 27233 $
32
32
*/
33
33
 
34
34
#include "config.h"
597
597
            {
598
598
              bundlePath = [bundlePath stringByDeletingLastPathComponent];
599
599
            }
 
600
#if defined(__MINGW32__)
 
601
          /* On windows, the library (dll) is in the Tools area rather than
 
602
           * in the framework, so we can adjust the path here.
 
603
           */
 
604
          if ([[bundlePath lastPathComponent] isEqual: @"Tools"])
 
605
            {
 
606
              bundlePath = [bundlePath stringByDeletingLastPathComponent];
 
607
              bundlePath
 
608
                = [bundlePath stringByAppendingPathComponent: @"Library"];
 
609
              bundlePath
 
610
                = [bundlePath stringByAppendingPathComponent: @"Frameworks"];
 
611
              bundlePath = [bundlePath stringByAppendingPathComponent:
 
612
                [NSString stringWithFormat: @"%@%@", name, @".framework"]];
 
613
            }
 
614
#else
600
615
          /* There are no Versions on MinGW.  Skip the Versions check here.  */
601
 
#if !defined(__MINGW32__)
602
616
          /* version name */
603
617
          bundlePath = [bundlePath stringByDeletingLastPathComponent];
604
618
 
694
708
       */
695
709
      if (_loadingBundle != nil && _loadingBundle != bundle)
696
710
        {
697
 
          [_loadingBundle->_bundleClasses
698
 
            removeObjectsInArray: bundle->_bundleClasses];
 
711
          int i, j;
 
712
          id b = bundle->_bundleClasses;
 
713
          id l = _loadingBundle->_bundleClasses;
 
714
 
 
715
          /* The following essentially does:
 
716
           *
 
717
           * [_loadingBundle->_bundleClasses
 
718
           *  removeObjectsInArray: bundle->_bundleClasses];
 
719
           *
 
720
           * The problem with that code is isEqual: gets
 
721
           * sent to the classes, which will cause them to be
 
722
           * initialized (which should not happen.)
 
723
           */
 
724
          for (i = 0; i < [b count]; i++)
 
725
            {
 
726
              for (j = 0; j < [l count]; j++)
 
727
                {
 
728
                  if ([[l objectAtIndex: j] nonretainedObjectValue]
 
729
                     == [[b objectAtIndex:i] nonretainedObjectValue])
 
730
                    {
 
731
                      [l removeObjectAtIndex:j];
 
732
                    }
 
733
                }
 
734
            }
699
735
        }
700
736
    }
701
737
}
1159
1195
           * Get the library bundle ... if there wasn't one then we
1160
1196
           * will assume the class was in the program executable and
1161
1197
           * return the mainBundle instead.
1162
 
           *
1163
 
           * FIXME: This will not work well with versioned library
1164
 
           * resources.  It used to work fine (maybe) with unversioned
1165
 
           * library resources.
1166
1198
           */
1167
1199
          bundle = [NSBundle bundleForLibrary: lib];
1168
1200
          if (bundle == nil)
2273
2305
  NSEnumerator *enumerator;
2274
2306
  NSString *path;
2275
2307
  NSFileManager *fm = [NSFileManager defaultManager];
 
2308
  NSRange       r;
2276
2309
 
2277
2310
  /*
2278
2311
   * Eliminate any base path or extensions.
2279
2312
   */
2280
2313
  libraryName = [libraryName lastPathComponent];
2281
 
  do
2282
 
    {
2283
 
      libraryName = [libraryName stringByDeletingPathExtension];
2284
 
    }
2285
 
  while ([[libraryName pathExtension] length] > 0);
 
2314
 
 
2315
#if defined(__MINGW32__)
 
2316
  /* A dll is usually of the form 'xxx-maj_min.dll'
 
2317
   * so we can extract the version info and use it.
 
2318
   */
 
2319
  if ([[libraryName pathExtension] isEqual: @"dll"])
 
2320
    {
 
2321
      libraryName = [libraryName stringByDeletingPathExtension];
 
2322
      r = [libraryName rangeOfString: @"-" options: NSBackwardsSearch];
 
2323
      if (r.length > 0)
 
2324
        {
 
2325
          NSString      *ver;
 
2326
 
 
2327
          ver = [[libraryName substringFromIndex: NSMaxRange(r)]
 
2328
            stringByReplacingString: @"_" withString: @"."];
 
2329
          libraryName = [libraryName substringToIndex: r.location];
 
2330
          if (interfaceVersion == nil)
 
2331
            {
 
2332
              interfaceVersion = ver;
 
2333
            }
 
2334
        }
 
2335
    }
 
2336
#else
 
2337
  /* A .so is usually of the form 'libxxx.so.maj.min.sub'
 
2338
   * so we can extract the version info and use it.
 
2339
   */
 
2340
  r = [libraryName rangeOfString: @".so."];
 
2341
  if (r.length > 0)
 
2342
    {
 
2343
      NSString  *s = [libraryName substringFromIndex: NSMaxRange(r)];
 
2344
      NSArray   *a = [s componentsSeparatedByString: @"."];
 
2345
 
 
2346
      libraryName = [libraryName substringToIndex: r.location];
 
2347
      if (interfaceVersion == nil && [a count] >= 2)
 
2348
        {
 
2349
          interfaceVersion = [NSString stringWithFormat: @"%@.%@",
 
2350
            [a objectAtIndex: 0], [a objectAtIndex: 1]];
 
2351
        }
 
2352
    }
 
2353
#endif
 
2354
 
 
2355
  while ([[libraryName pathExtension] length] > 0)
 
2356
    {
 
2357
      libraryName = [libraryName stringByDeletingPathExtension];
 
2358
    }
 
2359
 
2286
2360
  /*
2287
2361
   * Discard leading 'lib'
2288
2362
   */