summaryrefslogtreecommitdiff
path: root/tikzit/src/common/ColorRGB.m
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2017-01-02 11:31:52 +0100
committerAleks Kissinger <aleks0@gmail.com>2017-01-02 11:31:52 +0100
commitff79a9c213dfd75ea00ed5112d3a6e314601e064 (patch)
tree19ecef47bf11803fc4fc59e06c185c65aa7fdd19 /tikzit/src/common/ColorRGB.m
parent9e4f8a6ff37161da4fa0af14604ad22d9c212fde (diff)
parent49c0d2041f0aae6d08d325b7f7fc1cd707d942f8 (diff)
Merge branch 'arc'
Diffstat (limited to 'tikzit/src/common/ColorRGB.m')
-rw-r--r--tikzit/src/common/ColorRGB.m26
1 files changed, 23 insertions, 3 deletions
diff --git a/tikzit/src/common/ColorRGB.m b/tikzit/src/common/ColorRGB.m
index c108cfe..840d716 100644
--- a/tikzit/src/common/ColorRGB.m
+++ b/tikzit/src/common/ColorRGB.m
@@ -25,7 +25,11 @@
#import "util.h"
typedef struct {
- NSString *name;
+#if __has_feature(objc_arc)
+ __unsafe_unretained NSString *name;
+#else
+ NSString *name;
+#endif
unsigned short r, g, b;
} ColorRGBEntry;
@@ -278,17 +282,29 @@ static NSMapTable *colorHash = nil;
+ (ColorRGB*)colorWithRed:(unsigned short)r green:(unsigned short)g blue:(unsigned short)b {
ColorRGB *col = [[ColorRGB alloc] initWithRed:r green:g blue:b];
- return [col autorelease];
+#if __has_feature(objc_arc)
+ return col;
+#else
+ return [col autorelease];
+#endif
}
+ (ColorRGB*)colorWithFloatRed:(float)r green:(float)g blue:(float)b {
ColorRGB *col = [[ColorRGB alloc] initWithFloatRed:r green:g blue:b];
- return [col autorelease];
+#if __has_feature(objc_arc)
+ return col;
+#else
+ return [col autorelease];
+#endif
}
+ (ColorRGB*) colorWithRColor:(RColor)color {
+#if __has_feature(objc_arc)
+ return [[self alloc] initWithRColor:color];
+#else
return [[[self alloc] initWithRColor:color] autorelease];
+#endif
}
+ (void)makeColorHash {
@@ -300,13 +316,17 @@ static NSMapTable *colorHash = nil;
blue:kColors[i].b];
[h setObject:kColors[i].name forKey:col];
//NSLog(@"adding color %@ (%d)", kColors[i].name, [col hash]);
+#if ! __has_feature(objc_arc)
[col release];
+#endif
}
colorHash = h;
}
+ (void)releaseColorHash {
+#if ! __has_feature(objc_arc)
[colorHash release];
+#endif
}
- (void)setToClosestHashed {