PageRenderTime 32ms CodeModel.GetById 18ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/MapView/GTM/GTMNSNumber+64Bit.m

http://github.com/route-me/route-me
Objective C | 98 lines | 62 code | 19 blank | 17 comment | 2 complexity | 4d970e72dbac5d3272d21a50bf41e64c MD5 | raw file
 1//
 2//  GTMNSNumber+64Bit.m
 3//
 4//  Copyright 2009 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9// 
10//  http://www.apache.org/licenses/LICENSE-2.0
11// 
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import "GTMNSNumber+64Bit.h"
20
21@implementation NSNumber (GTM64BitAdditions)
22+ (NSNumber *)gtm_numberWithCGFloat:(CGFloat)value {
23  return [[[[self class] alloc] gtm_initWithCGFloat:value] autorelease];
24}
25
26+ (NSNumber *)gtm_numberWithInteger:(NSInteger)value {
27  return [[[[self class] alloc] gtm_initWithInteger:value] autorelease];
28}
29
30+ (NSNumber *)gtm_numberWithUnsignedInteger:(NSUInteger)value {
31  return [[[[self class] alloc] gtm_initWithUnsignedInteger:value] autorelease];
32}
33
34#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
35
36- (id)gtm_initWithCGFloat:(CGFloat)value {
37  CFNumberRef numberRef = CFNumberCreate(NULL, kCFNumberCGFloatType, &value);
38  return NSMakeCollectable(numberRef);
39}
40
41- (CGFloat)gtm_cgFloatValue {
42  CGFloat value = 0;
43  CFNumberGetValue((CFNumberRef)self, kCFNumberCGFloatType, &value);
44  return value;
45}
46
47- (id)gtm_initWithInteger:(NSInteger)value {
48  return [self initWithInteger:value];
49}
50
51- (NSInteger)gtm_integerValue {
52  return [self integerValue];
53}
54
55- (id)gtm_initWithUnsignedInteger:(NSUInteger)value {
56  return [self initWithUnsignedInteger:value];
57}
58
59- (NSUInteger)gtm_unsignedIntegerValue {
60  return [self unsignedIntegerValue];
61}
62
63#else  // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
64
65- (id)gtm_initWithCGFloat:(CGFloat)value {
66#if defined(__LP64__) && __LP64__
67  return [self initWithDouble:value];
68#else 
69  return [self initWithFloat:value];
70#endif  // defined(__LP64__) && __LP64__
71}
72
73- (CGFloat)gtm_cgFloatValue {
74#if defined(__LP64__) && __LP64__
75  return [self doubleValue];
76#else 
77  return [self floatValue];
78#endif  // defined(__LP64__) && __LP64__
79}
80
81- (id)gtm_initWithInteger:(NSInteger)value {
82  return [self initWithLong:value];
83}
84
85- (NSInteger)gtm_integerValue {
86  return [self longValue];
87}
88
89- (id)gtm_initWithUnsignedInteger:(NSUInteger)value {
90  return [self initWithUnsignedLong:value];
91}
92
93- (NSUInteger)gtm_unsignedIntegerValue {
94  return [self unsignedLongValue];
95}
96
97#endif  // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
98@end