Oolite
Loading...
Searching...
No Matches
NSNumber(OOExtensions) Category Reference

#include <NSNumberOOExtensions.h>

Instance Methods

(BOOL) - oo_isFloatingPointNumber
(BOOL) - oo_isBoolean

Detailed Description

Definition at line 32 of file NSNumberOOExtensions.h.

Method Documentation

◆ oo_isBoolean

- (BOOL) oo_isBoolean

Definition at line 47 of file NSNumberOOExtensions.m.

48{
49 /* There's no explicit way to test this. However, on Mac OS X boolean
50 NSNumbers are required to be constant objects because they're toll-
51 free bridged with kCFBooleanTrue and kCFBooleanFalse, so comparison to
52 those values has to work.
53
54 In GNUstep, constant objects are also used, because they're not about
55 to miss such an obvious optimization.
56 */
57
58#if __COREFOUNDATION_CFNUMBER__
59 return self == (NSNumber*)kCFBooleanTrue || self == (NSNumber*)kCFBooleanFalse;
60#else
61 static NSNumber *sTrue = nil, *sFalse;
62 if (EXPECT_NOT(sTrue == nil)) {
63 sTrue = [[NSNumber numberWithBool:YES] retain];
64 sFalse = [[NSNumber numberWithBool:NO] retain];
65 }
66 return self == sTrue || self == sFalse;
67#endif
68}
#define EXPECT_NOT(x)
return nil

References EXPECT_NOT, nil, and oo_isBoolean.

Referenced by oo_isBoolean.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ oo_isFloatingPointNumber

- (BOOL) oo_isFloatingPointNumber

Definition at line 33 of file NSNumberOOExtensions.m.

34{
35#if __COREFOUNDATION_CFNUMBER__
36 return CFNumberIsFloatType((CFNumberRef)self);
37#else
38 /* This happily assumes the compiler will inline strcmp() where one
39 argument is a single-character constant string. Verified under
40 apple-gcc 4.0 (even with -O0).
41 */
42 const char* type = [self objCType];
43 return (strcmp(type, @encode(double)) == 0 || strcmp(type, @encode(float)) == 0);
44#endif
45}

References oo_isFloatingPointNumber.

Referenced by oo_isFloatingPointNumber.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following files: