~ubuntu-branches/ubuntu/oneiric/gnustep-base/oneiric

« back to all changes in this revision

Viewing changes to Source/NSNumber.m

  • Committer: Bazaar Package Importer
  • Author(s): Yavor Doganov
  • Date: 2011-05-31 11:03:16 UTC
  • mfrom: (1.2.12 upstream) (7.2.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110531110316-0uny1hmsdl3gmn5v
Tags: 1.22.0-1
* New major upstream release:
  + Includes support for the new Objective-C runtime (Closes: #624928).
* debian/control.m4 (Vcs-Arch): Replace with...
  (Vcs-Git): ...since tla-buildpackage is gone.
  (Vcs-Browser): New field.
  (Standards-Version): Bump to 3.9.2; no changes needed.
  (Build-Depends): Add libicu-dev, needed for NSLocale.
  (libgnustep-base`'SOV_BASE-dbg) <Conflicts>: Set to
  libgnustep-base1.20-dbg only.
  <Recommends>: Set to libobjc3-dbg.
* debian/control: Regenerate.
* debian/patches/gnutls-deprecated.patch: New; fix usage of deprecated
  GnuTLS function (Closes: #624054).
* debian/patches/missing-header.patch:
* debian/patches/no-march.patch: Delete; fixed upstream.
* debian/patches/NSBundle-PROCFS_EXE_LINK.patch: Delete; apparently not
  needed anymore.
* debian/patches/manpage-fixes.patch: A few more fixes.
* debian/patches/avoid-nsl-linkage.patch: Refresh.
* debian/patches/autoreconf.patch: Regenerate.
* debian/patches/series: Update.
* debian/rules (v_objc, v_make): Bump to 4:4.6 (for libobjc3) and 2.6
  (for the sake of the testsuite) accordingly.
  (debian/build-shared-stamp): Run the testsuite.
  (install-shared): Do not delete non-existent .swp file.
  (install-common): Use $(sov_base) instead of hardcoded version.
* debian/copyright: Update copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
  }\
102
102
return NSOrderedSame;
103
103
 
 
104
#define DCOMPARE(value, other) \
 
105
  if (isnan(value)) \
 
106
    { \
 
107
      if (isnan(other)) \
 
108
        { \
 
109
          return NSOrderedSame; \
 
110
        } \
 
111
      else \
 
112
        { \
 
113
          return NSOrderedAscending; \
 
114
        } \
 
115
    } \
 
116
  else \
 
117
    { \
 
118
      if (isnan(other)) \
 
119
        { \
 
120
          if (value < 0.0) \
 
121
            { \
 
122
              return NSOrderedAscending; \
 
123
            } \
 
124
          return NSOrderedDescending; \
 
125
        } \
 
126
      else if (value < other) \
 
127
        { \
 
128
          return NSOrderedAscending; \
 
129
        } \
 
130
      else if (value > other) \
 
131
        { \
 
132
          return NSOrderedDescending; \
 
133
        } \
 
134
      return NSOrderedSame; \
 
135
    }
 
136
 
104
137
@implementation NSSignedIntegerNumber
105
138
- (NSComparisonResult) compare: (NSNumber*)aNumber
106
139
{
164
197
          double other = [aNumber doubleValue];
165
198
          double value = [self doubleValue];
166
199
 
167
 
          COMPARE (value, other);
 
200
          DCOMPARE(value, other)
168
201
        }
169
202
      default:
170
203
        [NSException raise: NSInvalidArgumentException
239
272
      case 'd':
240
273
        {
241
274
          double other = [aNumber doubleValue];
 
275
          double selfv = [self doubleValue];
242
276
 
243
 
          COMPARE (((double) value), other);
 
277
          DCOMPARE(selfv, other)
244
278
        }
245
279
      default:
246
280
        [NSException raise: NSInvalidArgumentException
279
313
      [NSException raise: NSInvalidArgumentException
280
314
                  format: @"nil argument for compare:"];
281
315
    }
 
316
 
282
317
  other = [aNumber doubleValue];
283
318
  value = [self doubleValue];
284
 
  COMPARE (value, other);
 
319
 
 
320
  DCOMPARE(value, other)
285
321
}
286
322
@end
287
323
 
389
425
  return NO;
390
426
}
391
427
 
392
 
- (unsigned) hash
 
428
- (NSUInteger) hash
393
429
{
394
430
  return (unsigned)[self doubleValue];
395
431
}
411
447
  return 0;                     // Not reached
412
448
}
413
449
 
414
 
#define INTEGER_MACRO(type, ignored, name) \
 
450
#define INTEGER_MACRO(encoding,type, ignored, name) \
415
451
- (id) initWith ## name: (type)aValue \
416
452
{\
417
453
  DESTROY(self);\
455
491
  if (self != NSNumberClass)
456
492
    {
457
493
      return [[[self alloc] initWithBytes: (const void *)&aValue
458
 
        objCType: @encode(char)] autorelease];
 
494
        objCType: @encode(signed char)] autorelease];
459
495
    }
460
496
  return [self numberWithInt: aValue];
461
497
}
643
679
  switch (type[0])
644
680
    {
645
681
      case 'c':
646
 
        return [self initWithInteger: *(char *) value];
 
682
        return [self initWithInteger: *(signed char *) value];
647
683
      case 'C':
648
684
        return [self initWithInteger: *(unsigned char *) value];
649
685
      case 's':
735
771
 * exception here matches OS X behaviour, although they throw an invalid
736
772
 * argument exception.
737
773
 */
738
 
#define INTEGER_MACRO(type, name, ignored) \
 
774
#define INTEGER_MACRO(encoding, type, name, ignored) \
739
775
- (type) name ## Value\
740
776
{\
741
777
  [self subclassResponsibility: _cmd];\