summaryrefslogtreecommitdiff
path: root/tikzit/src
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src')
-rw-r--r--tikzit/src/common/ColorRGB.m26
-rw-r--r--tikzit/src/common/Edge.m44
-rw-r--r--tikzit/src/common/EdgeStyle.m20
-rw-r--r--tikzit/src/common/Graph.m112
-rw-r--r--tikzit/src/common/GraphChange.m201
-rw-r--r--tikzit/src/common/GraphElementData.m59
-rw-r--r--tikzit/src/common/GraphElementProperty.m23
-rw-r--r--tikzit/src/common/NSString+LatexConstants.m4
-rw-r--r--tikzit/src/common/NSString+Tikz.m11
-rw-r--r--tikzit/src/common/Node.m34
-rw-r--r--tikzit/src/common/NodeStyle.m24
-rw-r--r--tikzit/src/common/PickSupport.m19
-rw-r--r--tikzit/src/common/Preambles.m28
-rw-r--r--tikzit/src/common/PropertyHolder.m2
-rw-r--r--tikzit/src/common/Shape.m16
-rw-r--r--tikzit/src/common/StyleManager.m47
-rw-r--r--tikzit/src/common/TikzGraphAssembler.m30
-rw-r--r--tikzit/src/common/TikzShape.m4
-rw-r--r--tikzit/src/common/Transformer.m12
-rw-r--r--tikzit/src/common/tikzparserdefs.h9
20 files changed, 609 insertions, 116 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 {
diff --git a/tikzit/src/common/Edge.m b/tikzit/src/common/Edge.m
index ba80aef..ee0f03d 100644
--- a/tikzit/src/common/Edge.m
+++ b/tikzit/src/common/Edge.m
@@ -72,7 +72,11 @@
}
// if we didn't find a style, fill in a default one
+#if __has_feature(objc_arc)
+ style = [EdgeStyle defaultEdgeStyleWithName:style_name];
+#else
style = [[EdgeStyle defaultEdgeStyleWithName:style_name] retain];
+#endif
return NO;
}
@@ -318,8 +322,12 @@
- (EdgeStyle*)style {return style;}
- (void)setStyle:(EdgeStyle*)s {
if (style != s) {
+#if __has_feature(objc_arc)
+ style = s;
+#else
[style release];
style = [s retain];
+#endif
}
}
@@ -335,9 +343,13 @@
[self setSourceAnchor:@""];
}
+#if __has_feature(objc_arc)
+ source = s;
+#else
[source release];
source = [s retain];
-
+#endif
+
if (source==target) {
bendMode = EdgeBendModeInOut;
weight = 1.0f;
@@ -365,9 +377,13 @@
[self setTargetAnchor:@""];
}
+#if __has_feature(objc_arc)
+ target = t;
+#else
[target release];
target = [t retain];
-
+#endif
+
if (source==target) {
bendMode = EdgeBendModeInOut;
weight = 1.0f;
@@ -422,8 +438,12 @@
[self willChangeValueForKey:@"hasEdgeNode"];
if (edgeNode != n) {
hasEdgeNode = (n != nil);
+#if __has_feature(objc_arc)
+ edgeNode = n;
+#else
[edgeNode release];
edgeNode = [n retain];
+#endif
// don't set dirty bit, because control points don't need update
}
[self didChangeValueForKey:@"edgeNode"];
@@ -450,7 +470,9 @@
}else{
sourceAnchor = @"";
}
+#if ! __has_feature(objc_arc)
[oldSourceAnchor release];
+#endif
}
- (NSString*) targetAnchor { return targetAnchor; }
@@ -461,7 +483,9 @@
}else{
targetAnchor = @"";
}
+#if ! __has_feature(objc_arc)
[oldTargetAnchor release];
+#endif
}
@synthesize data;
@@ -558,11 +582,15 @@
- (void)setPropertiesFromEdge:(Edge*)e {
Node *en = [[e edgeNode] copy];
[self setEdgeNode:en];
+#if ! __has_feature(objc_arc)
[en release];
+#endif
GraphElementData *d = [[e data] copy];
[self setData:d];
+#if ! __has_feature(objc_arc)
[d release];
+#endif
[self setStyle:[e style]];
[self setBend:[e bend]];
@@ -683,12 +711,14 @@
forKeyPath:@"style"];
[target removeObserver:self
forKeyPath:@"style"];
+#if ! __has_feature(objc_arc)
[source release];
[target release];
[data release];
[sourceAnchor release];
[targetAnchor release];
[super dealloc];
+#endif
}
- (id)copyWithZone:(NSZone*)zone {
@@ -702,11 +732,19 @@
}
+ (Edge*)edge {
+#if __has_feature(objc_arc)
+ return [[Edge alloc] init];
+#else
return [[[Edge alloc] init] autorelease];
+#endif
}
+ (Edge*)edgeWithSource:(Node*)s andTarget:(Node*)t {
- return [[[Edge alloc] initWithSource:s andTarget:t] autorelease];
+#if __has_feature(objc_arc)
+ return [[Edge alloc] initWithSource:s andTarget:t];
+#else
+ return [[[Edge alloc] initWithSource:s andTarget:t] autorelease];
+#endif
}
@end
diff --git a/tikzit/src/common/EdgeStyle.m b/tikzit/src/common/EdgeStyle.m
index 39810fa..c61e94a 100644
--- a/tikzit/src/common/EdgeStyle.m
+++ b/tikzit/src/common/EdgeStyle.m
@@ -77,10 +77,12 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[name release];
[category release];
[colorRGB release];
[super dealloc];
+#endif
}
- (NSString*) description {
@@ -98,7 +100,11 @@
}
+ (EdgeStyle*)defaultEdgeStyleWithName:(NSString*)nm {
+#if __has_feature(objc_arc)
+ return [[EdgeStyle alloc] initWithName:nm];
+#else
return [[[EdgeStyle alloc] initWithName:nm] autorelease];
+#endif
}
- (NSString*)name { return name; }
@@ -107,7 +113,9 @@
NSString *oldValue = name;
name = [s copy];
[self postPropertyChanged:@"name" oldValue:oldValue];
+#if ! __has_feature(objc_arc)
[oldValue release];
+#endif
}
}
@@ -147,8 +155,10 @@
NSString *oldValue = category;
category = [s copy];
[self postPropertyChanged:@"category" oldValue:oldValue];
- [oldValue release];
- }
+#if ! __has_feature(objc_arc)
+ [oldValue release];
+#endif
+ }
}
- (ColorRGB*)colorRGB {
@@ -160,8 +170,10 @@
ColorRGB *oldValue = colorRGB;
colorRGB = [c copy];
[self postPropertyChanged:@"colorRGB" oldValue:oldValue];
- [oldValue release];
- }
+#if ! __has_feature(objc_arc)
+ [oldValue release];
+#endif
+ }
}
- (NSString*)tikz {
diff --git a/tikzit/src/common/Graph.m b/tikzit/src/common/Graph.m
index 2d07ccc..cf09a69 100644
--- a/tikzit/src/common/Graph.m
+++ b/tikzit/src/common/Graph.m
@@ -51,8 +51,12 @@
}
- (id)initFromTikz:(NSString*)tikz error:(NSError**)e {
- [self release];
- return [[TikzGraphAssembler parseTikz:tikz error:e] retain];
+#if __has_feature(objc_arc)
+ return [TikzGraphAssembler parseTikz:tikz error:e];
+#else
+ [self release];
+ return [[TikzGraphAssembler parseTikz:tikz error:e] retain];
+#endif
}
- (id)initFromTikz:(NSString*)tikz {
@@ -69,7 +73,8 @@
[[NSNotificationCenter defaultCenter] removeObserver:self];
[graphLock lock];
- [inEdges release];
+#if ! __has_feature(objc_arc)
+ [inEdges release];
[outEdges release];
[edges release];
[nodes release];
@@ -78,18 +83,23 @@
[graphLock release];
[super dealloc];
+#endif
}
- (void)sync {
[graphLock lock];
if (dirty) {
- [inEdges release];
- [outEdges release];
+#if ! __has_feature(objc_arc)
+ [inEdges release];
+ [outEdges release];
+#endif
inEdges = [[NSMapTable alloc] initWithKeyOptions:NSMapTableStrongMemory valueOptions:NSMapTableStrongMemory capacity:10];
outEdges = [[NSMapTable alloc] initWithKeyOptions:NSMapTableStrongMemory valueOptions:NSMapTableStrongMemory capacity:10];
+#if ! __has_feature(objc_arc)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+#endif
+
for (Edge *e in edges) {
NSMutableSet *ie = [inEdges objectForKey:[e target]];
NSMutableSet *oe = [outEdges objectForKey:[e source]];
@@ -108,8 +118,9 @@
[oe addObject:e];
}
+#if ! __has_feature(objc_arc)
[pool drain];
-
+#endif
dirty = NO;
}
@@ -150,12 +161,20 @@
- (NSSet*)inEdgesForNode:(Node*)nd {
[self sync];
- return [[[inEdges objectForKey:nd] retain] autorelease];
+#if __has_feature(objc_arc)
+ return [inEdges objectForKey:nd];
+#else
+ return [[[inEdges objectForKey:nd] retain] autorelease];
+#endif
}
- (NSSet*)outEdgesForNode:(Node*)nd {
[self sync];
- return [[[outEdges objectForKey:nd] retain] autorelease];
+#if __has_feature(objc_arc)
+ return [outEdges objectForKey:nd];
+#else
+ return [[[outEdges objectForKey:nd] retain] autorelease];
+#endif
}
- (NSSet*)incidentEdgesForNodes:(NSSet*)nds {
@@ -347,7 +366,10 @@
}
GraphChange *change = [GraphChange nodeOrderChangeFrom:oldOrder to:nodes moved:nodeSet];
[graphLock unlock];
- [oldOrder release];
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
return change;
}
@@ -365,8 +387,11 @@
}
}
GraphChange *change = [GraphChange nodeOrderChangeFrom:oldOrder to:nodes moved:nodeSet];
- [oldOrder release];
-
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
+
return change;
}
@@ -383,7 +408,10 @@
}
GraphChange *change = [GraphChange edgeOrderChangeFrom:oldOrder to:edges moved:edgeSet];
[graphLock unlock];
- [oldOrder release];
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
return change;
}
@@ -401,8 +429,11 @@
}
}
GraphChange *change = [GraphChange edgeOrderChangeFrom:oldOrder to:edges moved:edgeSet];
- [oldOrder release];
-
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
+
return change;
}
@@ -419,7 +450,10 @@
}
GraphChange *change = [GraphChange nodeOrderChangeFrom:oldOrder to:nodes moved:nodeSet];
[graphLock unlock];
- [oldOrder release];
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
return change;
}
@@ -437,7 +471,10 @@
}
GraphChange *change = [GraphChange edgeOrderChangeFrom:oldOrder to:edges moved:edgeSet];
[graphLock unlock];
- [oldOrder release];
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
return change;
}
@@ -455,8 +492,11 @@
}
}
GraphChange *change = [GraphChange nodeOrderChangeFrom:oldOrder to:nodes moved:nodeSet];
- [oldOrder release];
-
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
+
return change;
}
@@ -473,8 +513,11 @@
}
}
GraphChange *change = [GraphChange edgeOrderChangeFrom:oldOrder to:edges moved:edgeSet];
- [oldOrder release];
-
+
+#if ! __has_feature(objc_arc)
+ [oldOrder release];
+#endif
+
return change;
}
@@ -571,7 +614,9 @@
[e1 setSource:[newNds objectForKey:[e source]]];
[e1 setTarget:[newNds objectForKey:[e target]]];
[newGraph addEdge:e1];
- [e1 release]; // e1 belongs to newGraph
+#if ! __has_feature(objc_arc)
+ [e1 release]; // e1 belongs to newGraph
+#endif
}
}
@@ -584,8 +629,9 @@
[self sync];
NSMutableSet *cover = [NSMutableSet set];
+#if ! __has_feature(objc_arc)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+#endif
NSMutableSet *remainingEdges = [NSMutableSet setWithArray:edges];
while ([remainingEdges count] != 0) {
@@ -610,10 +656,14 @@
}
[cover addObject:path];
+#if ! __has_feature(objc_arc)
[path release];
+#endif
}
-
+
+#if ! __has_feature(objc_arc)
[pool drain];
+#endif
return cover;
}
@@ -780,7 +830,11 @@
}
+ (Graph*)graph {
+#if __has_feature(objc_arc)
+ return [[self alloc] init];
+#else
return [[[self alloc] init] autorelease];
+#endif
}
+ (Graph*)graphFromTikz:(NSString*)tikz error:(NSError**)e {
@@ -803,9 +857,15 @@
for (Node *n in nds) {
Node *ncopy = [n copyWithZone:zone];
[tab setObject:ncopy forKey:n];
+#if ! __has_feature(objc_arc)
[ncopy release]; // tab should still retain ncopy.
+#endif
}
- return [tab autorelease];
+#if __has_feature(objc_arc)
+ return tab;
+#else
+ return [tab autorelease];
+#endif
}
+ (NSMapTable*)edgeTableForEdges:(NSSet*)es {
@@ -820,7 +880,9 @@
for (Edge *e in es) {
Edge *ecopy = [e copyWithZone:zone];
[tab setObject:ecopy forKey:e];
+#if ! __has_feature(objc_arc)
[ecopy release]; // tab should still retain ecopy.
+#endif
}
return tab;
}
diff --git a/tikzit/src/common/GraphChange.m b/tikzit/src/common/GraphChange.m
index 239ae23..29a3939 100644
--- a/tikzit/src/common/GraphChange.m
+++ b/tikzit/src/common/GraphChange.m
@@ -36,6 +36,7 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[affectedNodes release];
[affectedEdges release];
[nodeRef release];
@@ -56,6 +57,7 @@
[nwEdgeOrder release];
[super dealloc];
+#endif
}
@synthesize changeType;
@@ -77,65 +79,128 @@
switch ([self changeType]) {
case GraphAddition:
[inverse setChangeType:GraphDeletion];
- inverse->affectedNodes = [affectedNodes retain];
- inverse->affectedEdges = [affectedEdges retain];
+#if __has_feature(objc_arc)
+ inverse->affectedNodes = affectedNodes;
+ inverse->affectedEdges = affectedEdges;
+#else
+ inverse->affectedNodes = [affectedNodes retain];
+ inverse->affectedEdges = [affectedEdges retain];
+#endif
break;
case GraphDeletion:
[inverse setChangeType:GraphAddition];
- inverse->affectedNodes = [affectedNodes retain];
- inverse->affectedEdges = [affectedEdges retain];
+#if __has_feature(objc_arc)
+ inverse->affectedNodes = affectedNodes;
+ inverse->affectedEdges = affectedEdges;
+#else
+ inverse->affectedNodes = [affectedNodes retain];
+ inverse->affectedEdges = [affectedEdges retain];
+#endif
break;
case NodePropertyChange:
- inverse->nodeRef = [nodeRef retain];
- inverse->oldNode = [nwNode retain];
- inverse->nwNode = [oldNode retain];
+#if __has_feature(objc_arc)
+ inverse->nodeRef = nodeRef;
+ inverse->oldNode = nwNode;
+ inverse->nwNode = oldNode;
+#else
+ inverse->nodeRef = [nodeRef retain];
+ inverse->oldNode = [nwNode retain];
+ inverse->nwNode = [oldNode retain];
+#endif
break;
case NodesPropertyChange:
- inverse->oldNodeTable = [nwNodeTable retain];
- inverse->nwNodeTable = [oldNodeTable retain];
+#if __has_feature(objc_arc)
+
+#else
+ inverse->oldNodeTable = [nwNodeTable retain];
+ inverse->nwNodeTable = [oldNodeTable retain];
+#endif
break;
case EdgePropertyChange:
- inverse->edgeRef = [edgeRef retain];
- inverse->oldEdge = [nwEdge retain];
- inverse->nwEdge = [oldEdge retain];
+#if __has_feature(objc_arc)
+ inverse->edgeRef = edgeRef;
+ inverse->oldEdge = nwEdge;
+ inverse->nwEdge = oldEdge;
+#else
+ inverse->edgeRef = [edgeRef retain];
+ inverse->oldEdge = [nwEdge retain];
+ inverse->nwEdge = [oldEdge retain];
+#endif
break;
case EdgesPropertyChange:
- inverse->oldEdgeTable = [nwEdgeTable retain];
- inverse->nwEdgeTable = [oldEdgeTable retain];
+#if __has_feature(objc_arc)
+ inverse->oldEdgeTable = nwEdgeTable;
+ inverse->nwEdgeTable = oldEdgeTable;
+#else
+ inverse->oldEdgeTable = [nwEdgeTable retain];
+ inverse->nwEdgeTable = [oldEdgeTable retain];
+#endif
break;
case NodesShift:
- inverse->affectedNodes = [affectedNodes retain];
- [inverse setShiftPoint:NSMakePoint(-[self shiftPoint].x,
- -[self shiftPoint].y)];
+#if __has_feature(objc_arc)
+ inverse->affectedNodes = affectedNodes;
+#else
+ inverse->affectedNodes = [affectedNodes retain];
+#endif
+ [inverse setShiftPoint:NSMakePoint(-[self shiftPoint].x,
+ -[self shiftPoint].y)];
break;
case NodesFlip:
- inverse->affectedNodes = [affectedNodes retain];
- [inverse setHorizontal:[self horizontal]];
+#if __has_feature(objc_arc)
+ inverse->affectedNodes = affectedNodes;
+#else
+ inverse->affectedNodes = [affectedNodes retain];
+#endif
+ [inverse setHorizontal:[self horizontal]];
break;
case EdgesReverse:
- inverse->affectedEdges = [affectedEdges retain];
+#if __has_feature(objc_arc)
+ inverse->affectedEdges = affectedEdges;
+#else
+ inverse->affectedEdges = [affectedEdges retain];
+#endif
break;
case BoundingBoxChange:
inverse->oldBoundingBox = nwBoundingBox;
inverse->nwBoundingBox = oldBoundingBox;
break;
case GraphPropertyChange:
- inverse->oldGraphData = [nwGraphData retain];
- inverse->nwGraphData = [oldGraphData retain];
+#if __has_feature(objc_arc)
+ inverse->oldGraphData = nwGraphData;
+ inverse->nwGraphData = oldGraphData;
+#else
+ inverse->oldGraphData = [nwGraphData retain];
+ inverse->nwGraphData = [oldGraphData retain];
+#endif
break;
case NodeOrderChange:
- inverse->affectedNodes = [affectedNodes retain];
- inverse->oldNodeOrder = [nwNodeOrder retain];
- inverse->nwNodeOrder = [oldNodeOrder retain];
+#if __has_feature(objc_arc)
+ inverse->affectedNodes = affectedNodes;
+ inverse->oldNodeOrder = nwNodeOrder;
+ inverse->nwNodeOrder = oldNodeOrder;
+#else
+ inverse->affectedNodes = [affectedNodes retain];
+ inverse->oldNodeOrder = [nwNodeOrder retain];
+ inverse->nwNodeOrder = [oldNodeOrder retain];
+#endif
break;
case EdgeOrderChange:
- inverse->affectedEdges = [affectedEdges retain];
- inverse->oldEdgeOrder = [nwEdgeOrder retain];
- inverse->nwEdgeOrder = [oldEdgeOrder retain];
+#if __has_feature(objc_arc)
+ inverse->affectedEdges = affectedEdges;
+ inverse->oldEdgeOrder = nwEdgeOrder;
+ inverse->nwEdgeOrder = oldEdgeOrder;
+#else
+ inverse->affectedEdges = [affectedEdges retain];
+ inverse->oldEdgeOrder = [nwEdgeOrder retain];
+ inverse->nwEdgeOrder = [oldEdgeOrder retain];
+#endif
break;
}
-
+#if __has_feature(objc_arc)
+ return inverse;
+#else
return [inverse autorelease];
+#endif
}
+ (GraphChange*)graphAdditionWithNodes:(NSSet *)ns edges:(NSSet *)es {
@@ -143,7 +208,11 @@
[gc setChangeType:GraphAddition];
[gc setAffectedNodes:ns];
[gc setAffectedEdges:es];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)graphDeletionWithNodes:(NSSet *)ns edges:(NSSet *)es {
@@ -151,7 +220,11 @@
[gc setChangeType:GraphDeletion];
[gc setAffectedNodes:ns];
[gc setAffectedEdges:es];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)propertyChangeOfNode:(Node*)nd fromOld:(Node*)old toNew:(Node*)nw {
@@ -160,7 +233,11 @@
[gc setNodeRef:nd];
[gc setOldNode:old];
[gc setNwNode:nw];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)propertyChangeOfNodesFromOldCopies:(NSMapTable*)oldC
@@ -169,7 +246,11 @@
[gc setChangeType:NodesPropertyChange];
[gc setOldNodeTable:oldC];
[gc setNwNodeTable:newC];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)propertyChangeOfEdge:(Edge*)e fromOld:(Edge *)old toNew:(Edge *)nw {
@@ -178,7 +259,11 @@
[gc setEdgeRef:e];
[gc setOldEdge:old];
[gc setNwEdge:nw];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)propertyChangeOfEdgesFromOldCopies:(NSMapTable*)oldC
@@ -187,7 +272,11 @@
[gc setChangeType:EdgesPropertyChange];
[gc setOldEdgeTable:oldC];
[gc setNwEdgeTable:newC];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)shiftNodes:(NSSet*)ns byPoint:(NSPoint)p {
@@ -195,7 +284,11 @@
[gc setChangeType:NodesShift];
[gc setAffectedNodes:ns];
[gc setShiftPoint:p];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)flipNodes:(NSSet*)ns horizontal:(BOOL)b {
@@ -203,14 +296,22 @@
[gc setChangeType:NodesFlip];
[gc setAffectedNodes:ns];
[gc setHorizontal:b];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)reverseEdges:(NSSet*)es {
GraphChange *gc = [[GraphChange alloc] init];
[gc setChangeType:EdgesReverse];
[gc setAffectedEdges:es];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)changeBoundingBoxFrom:(NSRect)oldBB to:(NSRect)newBB {
@@ -218,7 +319,11 @@
[gc setChangeType:BoundingBoxChange];
[gc setOldBoundingBox:oldBB];
[gc setNwBoundingBox:newBB];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)propertyChangeOfGraphFrom:(GraphElementData*)oldData to:(GraphElementData*)newData {
@@ -226,7 +331,11 @@
[gc setChangeType:GraphPropertyChange];
[gc setOldGraphData:oldData];
[gc setNwGraphData:newData];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)nodeOrderChangeFrom:(NSArray*)old to:(NSArray*)new moved:(NSSet*)affected {
@@ -235,7 +344,11 @@
[gc setAffectedNodes:affected];
[gc setOldNodeOrder:old];
[gc setNwNodeOrder:new];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
+ (GraphChange*)edgeOrderChangeFrom:(NSArray*)old to:(NSArray*)new moved:(NSSet*)affected {
@@ -244,7 +357,11 @@
[gc setAffectedEdges:affected];
[gc setOldEdgeOrder:old];
[gc setNwEdgeOrder:new];
- return [gc autorelease];
+#if __has_feature(objc_arc)
+ return gc;
+#else
+ return [gc autorelease];
+#endif
}
@end
diff --git a/tikzit/src/common/GraphElementData.m b/tikzit/src/common/GraphElementData.m
index 0750296..41dc9aa 100644
--- a/tikzit/src/common/GraphElementData.m
+++ b/tikzit/src/common/GraphElementData.m
@@ -28,7 +28,11 @@
@implementation GraphElementData
+ (id)data {
+#if __has_feature(objc_arc)
+ return [[self alloc] init];
+#else
return [[[self alloc] init] autorelease];
+#endif
}
- (id)init {
@@ -48,9 +52,15 @@
- (NSArray*)objectsAtIndexes:(NSIndexSet*)indexes {
return [properties objectsAtIndexes:indexes];
}
+
+#if __has_feature(objc_arc)
+- (void) getObjects:(__unsafe_unretained id*)buffer range:(NSRange)range {
+#else
- (void) getObjects:(id*)buffer range:(NSRange)range {
+#endif
[properties getObjects:buffer range:range];
}
+
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index {
[properties insertObject:anObject atIndex:index];
}
@@ -66,22 +76,33 @@
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject {
[properties replaceObjectAtIndex:index withObject:anObject];
}
+
+#if __has_feature(objc_arc)
+- (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state
+ objects:(__unsafe_unretained id [])stackbuf
+ count:(NSUInteger)len {
+#else
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
objects:(id *)stackbuf
count:(NSUInteger)len {
- return [properties countByEnumeratingWithState:state objects:stackbuf count:len];
+#endif
+ return [properties countByEnumeratingWithState:state objects:stackbuf count:len];
}
- (void)setProperty:(NSString*)val forKey:(NSString*)key {
GraphElementProperty *m = [[GraphElementProperty alloc] initWithKeyMatching:key];
NSInteger idx = [properties indexOfObject:m];
- [m release];
+#if !__has_feature(objc_arc)
+ [m release];
+#endif
GraphElementProperty *p;
if (idx == NSNotFound) {
p = [[GraphElementProperty alloc] initWithPropertyValue:val forKey:key];
[properties addObject:p];
- [p release];
+#if !__has_feature(objc_arc)
+ [p release];
+#endif
} else {
p = [properties objectAtIndex:idx];
[p setValue:val];
@@ -91,13 +112,19 @@
- (void)unsetProperty:(NSString*)key {
GraphElementProperty *m = [[GraphElementProperty alloc] initWithKeyMatching:key];
[properties removeObject:m];
- [m release];
+#if !__has_feature(objc_arc)
+ [m release];
+#endif
+
}
- (NSString*)propertyForKey:(NSString*)key {
GraphElementProperty *m = [[GraphElementProperty alloc] initWithKeyMatching:key];
NSInteger idx = [properties indexOfObject:m];
- [m release];
+#if !__has_feature(objc_arc)
+ [m release];
+#endif
+
if (idx == NSNotFound) {
return nil;
@@ -110,19 +137,25 @@
- (void)setAtom:(NSString*)atom {
GraphElementProperty *a = [[GraphElementProperty alloc] initWithAtomName:atom];
if (![properties containsObject:a]) [properties addObject:a];
- [a release];
+#if !__has_feature(objc_arc)
+ [a release];
+#endif
}
- (void)unsetAtom:(NSString*)atom {
GraphElementProperty *a = [[GraphElementProperty alloc] initWithAtomName:atom];
[properties removeObject:a];
- [a release];
+#if !__has_feature(objc_arc)
+ [a release];
+#endif
}
- (BOOL)isAtomSet:(NSString*)atom {
GraphElementProperty *a = [[GraphElementProperty alloc] initWithAtomName:atom];
BOOL set = [properties containsObject:a];
- [a release];
+#if !__has_feature(objc_arc)
+ [a release];
+#endif
return set;
}
@@ -136,14 +169,18 @@
for (GraphElementProperty *p in properties) {
GraphElementProperty *p2 = [p copy];
[cp addObject:p2];
- [p2 release];
+#if !__has_feature(objc_arc)
+ [p2 release];
+#endif
}
return cp;
}
- (void)dealloc {
- [properties release];
- [super dealloc];
+#if !__has_feature(objc_arc)
+ [properties release];
+ [super dealloc];
+#endif
}
@end
diff --git a/tikzit/src/common/GraphElementProperty.m b/tikzit/src/common/GraphElementProperty.m
index 1acdc09..25e1b15 100644
--- a/tikzit/src/common/GraphElementProperty.m
+++ b/tikzit/src/common/GraphElementProperty.m
@@ -28,13 +28,25 @@
@implementation GraphElementProperty
+ (id)atom:(NSString*)n {
- return [[[self alloc] initWithAtomName:n] autorelease];
+#if __has_feature(objc_arc)
+ return [[self alloc] initWithAtomName:n];
+#else
+ return [[[self alloc] initWithAtomName:n] autorelease];
+#endif
}
+ (id)property:(NSString*)k withValue:(NSString*)v {
+#if __has_feature(objc_arc)
+ return [[self alloc] initWithPropertyValue:v forKey:k];
+#else
return [[[self alloc] initWithPropertyValue:v forKey:k] autorelease];
+#endif
}
+ (id)keyMatching:(NSString*)k {
+#if __has_feature(objc_arc)
+ return [[self alloc] initWithKeyMatching:k];
+#else
return [[[self alloc] initWithKeyMatching:k] autorelease];
+#endif
}
- (id)initWithAtomName:(NSString*)n {
@@ -65,15 +77,18 @@
}
- (void) dealloc {
+#if ! __has_feature(objc_arc)
[key release];
-// the below line causes a exc_bad_access. Uncommenting it gains a memory leak but at least no crashing.
-// [value release];
+ [value release];
[super dealloc];
+#endif
}
- (void)setValue:(NSString *)v {
if (value != v) {
+#if ! __has_feature(objc_arc)
[value release];
+#endif
value = [v copy];
}
}
@@ -89,7 +104,9 @@
- (void)setKey:(NSString *)k {
if (key != k) {
+#if ! __has_feature(objc_arc)
[key release];
+#endif
key = [k copy];
}
if (key == nil)
diff --git a/tikzit/src/common/NSString+LatexConstants.m b/tikzit/src/common/NSString+LatexConstants.m
index bd598b7..634c189 100644
--- a/tikzit/src/common/NSString+LatexConstants.m
+++ b/tikzit/src/common/NSString+LatexConstants.m
@@ -197,10 +197,14 @@ static NSSet *texModifiers = nil;
}
NSString *ret = [buf copy];
+#if __has_feature(objc_arc)
+ return ret;
+#else
[buf release];
[wordBuf release];
return [ret autorelease];
+#endif
}
@end
diff --git a/tikzit/src/common/NSString+Tikz.m b/tikzit/src/common/NSString+Tikz.m
index 520ffd3..1e3073b 100644
--- a/tikzit/src/common/NSString+Tikz.m
+++ b/tikzit/src/common/NSString+Tikz.m
@@ -23,12 +23,21 @@
- (NSString*) tikzEscapedString {
static NSCharacterSet *avoid = nil;
if (avoid == nil)
- avoid = [[[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>-'0123456789. "] invertedSet] retain];
+#if __has_feature(objc_arc)
+ avoid = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>-'0123456789. "] invertedSet];
+#else
+ avoid = [[[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>-'0123456789. "] invertedSet] retain];
+#endif
+
if ([self rangeOfCharacterFromSet:avoid].length > 0) {
return [NSString stringWithFormat:@"{%@}", self];
} else {
+#if __has_feature(objc_arc)
+ return self;
+#else
return [[self retain] autorelease];
+#endif
}
}
diff --git a/tikzit/src/common/Node.m b/tikzit/src/common/Node.m
index 8c64b6b..c5b11d1 100644
--- a/tikzit/src/common/Node.m
+++ b/tikzit/src/common/Node.m
@@ -50,11 +50,13 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[name release];
[style release];
[data release];
[label release];
[super dealloc];
+#endif
}
- (Shape*) shape {
@@ -67,7 +69,11 @@
- (Transformer*) shapeTransformerFromTransformer:(Transformer*)t {
// we take a copy to keep the reflection attributes
+#if ! __has_feature(objc_arc)
Transformer *transformer = [[t copy] autorelease];
+#else
+ Transformer *transformer = [t copy];
+#endif
NSPoint screenPos = [t toScreen:point];
[transformer setOrigin:screenPos];
float scale = [t scale];
@@ -101,7 +107,11 @@
}
- (BOOL)attachStyleFromTable:(NSArray*)styles {
- NSString *style_name = [[[data propertyForKey:@"style"] retain] autorelease];
+#if __has_feature(objc_arc)
+ NSString *style_name = [data propertyForKey:@"style"];
+#else
+ NSString *style_name = [[[data propertyForKey:@"style"] retain] autorelease];
+#endif
[self setStyle:nil];
@@ -137,11 +147,19 @@
}
+ (Node*)nodeWithPoint:(NSPoint)p {
- return [[[Node alloc] initWithPoint:p] autorelease];
+#if __has_feature(objc_arc)
+ return [[Node alloc] initWithPoint:p];
+#else
+ return [[[Node alloc] initWithPoint:p] autorelease];
+#endif
}
+ (Node*)node {
- return [[[Node alloc] init] autorelease];
+#if __has_feature(objc_arc)
+ return [[Node alloc] init];
+#else
+ return [[[Node alloc] init] autorelease];
+#endif
}
@@ -180,9 +198,13 @@
- (void)setStyle:(NodeStyle *)st {
if (style != st) {
- NodeStyle *oldStyle = style;
- style = [st retain];
- [oldStyle release];
+#if __has_feature(objc_arc)
+ style = st;
+#else
+ NodeStyle *oldStyle = style;
+ style = [st retain];
+ [oldStyle release];
+#endif
}
[self updateData];
}
diff --git a/tikzit/src/common/NodeStyle.m b/tikzit/src/common/NodeStyle.m
index 26ab793..193d44d 100644
--- a/tikzit/src/common/NodeStyle.m
+++ b/tikzit/src/common/NodeStyle.m
@@ -87,12 +87,14 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[name release];
[category release];
[shapeName release];
[strokeColorRGB release];
[fillColorRGB release];
[super dealloc];
+#endif
}
- (NSString*) description {
@@ -110,7 +112,11 @@
}
+ (NodeStyle*)defaultNodeStyleWithName:(NSString*)nm {
- return [[[NodeStyle alloc] initWithName:nm] autorelease];
+#if __has_feature(objc_arc)
+ return [[NodeStyle alloc] initWithName:nm];
+#else
+ return [[[NodeStyle alloc] initWithName:nm] autorelease];
+#endif
}
- (NSString*)name {
@@ -122,7 +128,9 @@
NSString *oldValue = name;
name = [s copy];
[self postPropertyChanged:@"name" oldValue:oldValue];
+#if ! __has_feature(objc_arc)
[oldValue release];
+#endif
}
}
@@ -135,7 +143,9 @@
NSString *oldValue = shapeName;
shapeName = [s copy];
[self postPropertyChanged:@"shapeName" oldValue:oldValue];
+#if ! __has_feature(objc_arc)
[oldValue release];
+#endif
}
}
@@ -148,8 +158,10 @@
NSString *oldValue = category;
category = [s copy];
[self postPropertyChanged:@"category" oldValue:oldValue];
+#if ! __has_feature(objc_arc)
[oldValue release];
- }
+#endif
+ }
}
- (int)strokeThickness { return strokeThickness; }
@@ -175,8 +187,10 @@
ColorRGB *oldValue = strokeColorRGB;
strokeColorRGB = [c copy];
[self postPropertyChanged:@"strokeColorRGB" oldValue:oldValue];
+#if ! __has_feature(objc_arc)
[oldValue release];
- }
+#endif
+ }
}
- (ColorRGB*)fillColorRGB {
@@ -188,8 +202,10 @@
ColorRGB *oldValue = fillColorRGB;
fillColorRGB = [c copy];
[self postPropertyChanged:@"fillColorRGB" oldValue:oldValue];
+#if ! __has_feature(objc_arc)
[oldValue release];
- }
+#endif
+ }
}
- (NSString*)tikz {
diff --git a/tikzit/src/common/PickSupport.m b/tikzit/src/common/PickSupport.m
index 6470214..560fc2c 100644
--- a/tikzit/src/common/PickSupport.m
+++ b/tikzit/src/common/PickSupport.m
@@ -42,15 +42,24 @@
self = [super init];
if (self) {
- selectedNodes = [[NSMutableSet set] retain];
- selectedEdges = [[NSMutableSet set] retain];
+#if __has_feature(objc_arc)
+ selectedNodes = [NSMutableSet set];
+ selectedEdges = [NSMutableSet set];
+#else
+ selectedNodes = [[NSMutableSet set] retain];
+ selectedEdges = [[NSMutableSet set] retain];
+#endif
}
return self;
}
+ (PickSupport*)pickSupport {
- return [[[PickSupport alloc] init] autorelease];
+#if __has_feature(objc_arc)
+ return [[PickSupport alloc] init];
+#else
+ return [[[PickSupport alloc] init] autorelease];
+#endif
}
@synthesize selectedNodes;
@@ -176,7 +185,9 @@
}
if (replace) {
+#if ! __has_feature(objc_arc)
[selectedNodes release];
+#endif
selectedNodes = [nodes mutableCopy];
} else {
[selectedNodes unionSet:nodes];
@@ -208,10 +219,12 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[selectedNodes release];
[selectedEdges release];
[super dealloc];
+#endif
}
@end
diff --git a/tikzit/src/common/Preambles.m b/tikzit/src/common/Preambles.m
index 651bbcd..922fc30 100644
--- a/tikzit/src/common/Preambles.m
+++ b/tikzit/src/common/Preambles.m
@@ -55,7 +55,11 @@ static NSString *POSTAMBLE =
@implementation Preambles
+ (Preambles*)preambles {
+#if __has_feature(objc_arc)
+ return [[self alloc] init];
+#else
return [[[self alloc] init] autorelease];
+#endif
}
- (id)init {
@@ -72,10 +76,12 @@ static NSString *POSTAMBLE =
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[selectedPreambleName release];
[styles release];
[styleManager release];
[super dealloc];
+#endif
}
- (NSString*)preambleForName:(NSString*)name {
@@ -101,14 +107,18 @@ static NSString *POSTAMBLE =
}
- (void)setStyles:(NSArray*)sty {
+#if ! __has_feature(objc_arc)
[sty retain];
[styles release];
+#endif
styles = sty;
}
- (void)setEdges:(NSArray*)edg {
+#if ! __has_feature(objc_arc)
[edg retain];
[edges release];
+#endif
edges = edg;
}
@@ -116,7 +126,9 @@ static NSString *POSTAMBLE =
if (styleManager != nil) {
[self setStyles:[styleManager nodeStyles]];
}
+#if ! __has_feature(objc_arc)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
NSMutableString *buf = [NSMutableString string];
NSMutableString *colbuf = [NSMutableString string];
NSMutableSet *colors = [NSMutableSet setWithCapacity:2*[styles count]];
@@ -154,8 +166,12 @@ static NSString *POSTAMBLE =
NSString *defs = [[NSString alloc] initWithFormat:@"%@\n%@", colbuf, buf];
+#if __has_feature(objc_arc)
+ return defs;
+#else
[pool drain];
return [defs autorelease];
+#endif
}
- (NSString*)defaultPreamble {
@@ -170,7 +186,9 @@ static NSString *POSTAMBLE =
- (NSString*)selectedPreambleName { return selectedPreambleName; }
- (void)setSelectedPreambleName:(NSString *)sel {
if (sel != selectedPreambleName) {
+#if ! __has_feature(objc_arc)
[selectedPreambleName release];
+#endif
selectedPreambleName = [sel copy];
}
}
@@ -190,8 +208,10 @@ static NSString *POSTAMBLE =
}
- (void)setStyleManager:(StyleManager *)manager {
+#if ! __has_feature(objc_arc)
[manager retain];
[styleManager release];
+#endif
styleManager = manager;
}
@@ -240,10 +260,14 @@ static NSString *POSTAMBLE =
isSelected = YES;
}
NSString *preamble = [preambleDict objectForKey:old];
+#if ! __has_feature(objc_arc)
[preamble retain];
+#endif
[preambleDict removeObjectForKey:old];
[preambleDict setObject:preamble forKey:new];
+#if ! __has_feature(objc_arc)
[preamble release];
+#endif
if (isSelected) {
[self setSelectedPreambleName:new];
}
@@ -254,11 +278,15 @@ static NSString *POSTAMBLE =
if ([name isEqualToString:@"default"])
return NO;
// "name" may be held only by being the selected preamble...
+#if ! __has_feature(objc_arc)
[name retain];
+#endif
if ([name isEqualToString:selectedPreambleName])
[self setSelectedPreambleName:nil];
[preambleDict removeObjectForKey:name];
+#if ! __has_feature(objc_arc)
[name release];
+#endif
return YES;
}
diff --git a/tikzit/src/common/PropertyHolder.m b/tikzit/src/common/PropertyHolder.m
index 2b3442f..6aaf125 100644
--- a/tikzit/src/common/PropertyHolder.m
+++ b/tikzit/src/common/PropertyHolder.m
@@ -63,8 +63,10 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[notificationName release];
[super dealloc];
+#endif
}
@end
diff --git a/tikzit/src/common/Shape.m b/tikzit/src/common/Shape.m
index 5dc25e3..e887688 100644
--- a/tikzit/src/common/Shape.m
+++ b/tikzit/src/common/Shape.m
@@ -61,8 +61,12 @@
- (NSSet*)paths {return paths;}
- (void)setPaths:(NSSet *)p {
if (paths != p) {
+#if __has_feature(objc_arc)
+ paths = p;
+#else
[paths release];
paths = [p retain];
+#endif
[self calcBoundingRect];
}
}
@@ -79,9 +83,11 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[paths release];
[styleTikz release];
[super dealloc];
+#endif
}
NSDictionary *shapeDictionary = nil;
@@ -101,7 +107,9 @@ NSDictionary *shapeDictionary = nil;
[shapeDir stringByAppendingPathComponent:f]];
if (sh != nil) {
[shapeDict setObject:sh forKey:nm];
+#if ! __has_feature(objc_arc)
[sh release];
+#endif
}
}
}
@@ -122,7 +130,9 @@ NSDictionary *shapeDictionary = nil;
shapes[3], SHAPE_UP_TRIANGLE,
shapes[4], SHAPE_DOWN_TRIANGLE,
nil];
+#if ! __has_feature(objc_arc)
for (int i = 0; i<5; ++i) [shapes[i] release];
+#endif
NSString *systemShapeDir = [[SupportDir systemSupportDir] stringByAppendingPathComponent:@"shapes"];
NSString *userShapeDir = [[SupportDir userSupportDir] stringByAppendingPathComponent:@"shapes"];
@@ -137,7 +147,9 @@ NSDictionary *shapeDictionary = nil;
postNotificationName:@"ShapeDictionaryReplaced"
object:self];
+#if ! __has_feature(objc_arc)
[oldShapeDictionary release];
+#endif
}
+ (NSDictionary*)shapeDictionary {
@@ -147,7 +159,11 @@ NSDictionary *shapeDictionary = nil;
+ (Shape*)shapeForName:(NSString*)shapeName {
Shape *s = [[[self shapeDictionary] objectForKey:shapeName] copy];
+#if __has_feature(objc_arc)
+ return s;
+#else
return [s autorelease];
+#endif
}
@end
diff --git a/tikzit/src/common/StyleManager.m b/tikzit/src/common/StyleManager.m
index ae0d488..05c6c86 100644
--- a/tikzit/src/common/StyleManager.m
+++ b/tikzit/src/common/StyleManager.m
@@ -90,7 +90,11 @@
}
+ (StyleManager*) manager {
+#if __has_feature(objc_arc)
+ return [[self alloc] init];
+#else
return [[[self alloc] init] autorelease];
+#endif
}
- (id) init {
@@ -107,15 +111,18 @@
- (void) dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
-
+#if ! __has_feature(objc_arc)
[nodeStyles release];
[edgeStyles release];
[super dealloc];
+#endif
}
- (void) loadDefaultEdgeStyles {
+#if ! __has_feature(objc_arc)
[edgeStyles release];
+#endif
edgeStyles = [[NSMutableArray alloc] initWithCapacity:3];
EdgeStyle *simple = [EdgeStyle defaultEdgeStyleWithName:@"simple"];
@@ -138,7 +145,9 @@
}
- (void) loadDefaultNodeStyles {
+#if ! __has_feature(objc_arc)
[nodeStyles release];
+#endif
nodeStyles = [[NSMutableArray alloc] initWithCapacity:3];
NodeStyle *rn = [NodeStyle defaultNodeStyleWithName:@"rn"];
@@ -212,8 +221,10 @@
- (void) _setNodeStyles:(NSMutableArray*)styles {
[self ignoreAllNodeStyles];
+#if ! __has_feature(objc_arc)
[nodeStyles release];
[styles retain];
+#endif
nodeStyles = styles;
for (NodeStyle *style in styles) {
[self listenToNodeStyle:style];
@@ -223,8 +234,10 @@
- (void) _setEdgeStyles:(NSMutableArray*)styles {
[self ignoreAllEdgeStyles];
+#if ! __has_feature(objc_arc)
[edgeStyles release];
[styles retain];
+#endif
edgeStyles = styles;
for (EdgeStyle *style in styles) {
[self listenToEdgeStyle:style];
@@ -257,10 +270,14 @@
}
[self ignoreNodeStyle:style];
+#if ! __has_feature(objc_arc)
[style retain];
+#endif
[nodeStyles removeObject:style];
[self postNodeStyleRemoved:style];
+#if ! __has_feature(objc_arc)
[style release];
+#endif
}
- (EdgeStyle*) edgeStyleForName:(NSString*)name {
@@ -288,10 +305,14 @@
}
[self ignoreEdgeStyle:style];
+#if ! __has_feature(objc_arc)
[style retain];
+#endif
[edgeStyles removeObject:style];
[self postEdgeStyleRemoved:style];
+#if ! __has_feature(objc_arc)
[style release];
+#endif
}
- (void) updateFromManager:(StyleManager*)m {
@@ -302,7 +323,11 @@
[currentStyle updateFromStyle:style];
[ns addObject:currentStyle];
} else {
+#if __has_feature(objc_arc)
+ [ns addObject:[style copy]];
+#else
[ns addObject:[[style copy] autorelease]];
+#endif
}
}
NSMutableArray *es = [NSMutableArray arrayWithCapacity:[[m edgeStyles] count]];
@@ -312,8 +337,12 @@
[currentStyle updateFromStyle:style];
[es addObject:currentStyle];
} else {
- [es addObject:[[style copy] autorelease]];
- }
+#if __has_feature(objc_arc)
+ [es addObject:[style copy]];
+#else
+ [es addObject:[[style copy] autorelease]];
+#endif
+ }
}
[self _setNodeStyles:ns];
[self _setEdgeStyles:es];
@@ -324,11 +353,19 @@
NSMutableArray *ns = [NSMutableArray arrayWithCapacity:[nodeStyles count]];
for (NodeStyle *style in nodeStyles) {
- [ns addObject:[[style copyWithZone:zone] autorelease]];
+#if __has_feature(objc_arc)
+ [ns addObject:[style copyWithZone:zone]];
+#else
+ [ns addObject:[[style copyWithZone:zone] autorelease]];
+#endif
}
NSMutableArray *es = [NSMutableArray arrayWithCapacity:[edgeStyles count]];
for (EdgeStyle *style in edgeStyles) {
- [es addObject:[[style copyWithZone:zone] autorelease]];
+#if __has_feature(objc_arc)
+ [es addObject:[style copyWithZone:zone]];
+#else
+ [es addObject:[[style copyWithZone:zone] autorelease]];
+#endif
}
[m _setNodeStyles:ns];
[m _setEdgeStyles:es];
diff --git a/tikzit/src/common/TikzGraphAssembler.m b/tikzit/src/common/TikzGraphAssembler.m
index 380b71c..c5d2811 100644
--- a/tikzit/src/common/TikzGraphAssembler.m
+++ b/tikzit/src/common/TikzGraphAssembler.m
@@ -31,14 +31,20 @@
@implementation TikzGraphAssembler
- (id)init {
+#if ! __has_feature(objc_arc)
[self release];
+#endif
return nil;
}
- (id)initWithGraph:(Graph*)g {
self = [super init];
if (self) {
+#if __has_feature(objc_arc)
+ graph = g;
+#else
graph = [g retain];
+#endif
nodeMap = [[NSMutableDictionary alloc] init];
yylex_init (&scanner);
yyset_extra(self, scanner);
@@ -47,29 +53,39 @@
}
- (void)dealloc {
+#if ! __has_feature(objc_arc)
[graph release];
[nodeMap release];
[lastError release];
yylex_destroy (scanner);
[super dealloc];
+#endif
}
- (BOOL) parseTikz:(NSString*)t error:(NSError**)error {
+#if ! __has_feature(objc_arc)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
tikzStr = [t UTF8String];
yy_scan_string(tikzStr, scanner);
int result = yyparse(scanner);
tikzStr = NULL;
+#if ! __has_feature(objc_arc)
[pool drain];
+#endif
if (result == 0) {
return YES;
} else {
if (error) {
if (lastError) {
+#if __has_feature(objc_arc)
+ *error = lastError;
+#else
*error = [[lastError retain] autorelease];
+#endif
} else if (result == 1) {
*error = [NSError errorWithMessage:@"Syntax error"
code:TZ_ERR_PARSE];
@@ -91,10 +107,16 @@
+ (Graph*) parseTikz:(NSString*)tikz error:(NSError**)e {
Graph *gr = [[Graph alloc] init];
if ([self parseTikz:tikz forGraph:gr error:e]) {
+#if __has_feature(objc_arc)
+ return gr;
+#else
return [gr autorelease];
+#endif
} else {
+#if ! __has_feature(objc_arc)
[gr release];
- return nil;
+#endif
+ return nil;
}
}
+ (Graph*) parseTikz:(NSString*)tikz {
@@ -109,8 +131,10 @@
TikzGraphAssembler *assembler = [[self alloc] initWithGraph:gr];
BOOL success = [assembler parseTikz:tikz error:error];
+#if ! __has_feature(objc_arc)
[assembler release];
- return success;
+#endif
+ return success;
}
+ (BOOL)validateTikzPropertyNameOrValue:(NSString*)tikz {
@@ -171,8 +195,10 @@
}
- (void) setLastError:(NSError*)error {
+#if ! __has_feature(objc_arc)
[error retain];
[lastError release];
+#endif
lastError = error;
}
diff --git a/tikzit/src/common/TikzShape.m b/tikzit/src/common/TikzShape.m
index c07c61e..555a7df 100644
--- a/tikzit/src/common/TikzShape.m
+++ b/tikzit/src/common/TikzShape.m
@@ -55,7 +55,11 @@
-NSMidY(bds));
[t setOrigin:shift];
[graph applyTransformer:t];
+#if __has_feature(objc_arc)
+ paths = [graph pathCover];
+#else
paths = [[graph pathCover] retain];
+#endif
}
return self;
}
diff --git a/tikzit/src/common/Transformer.m b/tikzit/src/common/Transformer.m
index 403ae87..2b56813 100644
--- a/tikzit/src/common/Transformer.m
+++ b/tikzit/src/common/Transformer.m
@@ -28,11 +28,19 @@ float const PIXELS_PER_UNIT = 50;
@implementation Transformer
+ (Transformer*)transformer {
- return [[[Transformer alloc] init] autorelease];
+#if __has_feature(objc_arc)
+ return [[Transformer alloc] init];
+#else
+ return [[[Transformer alloc] init] autorelease];
+#endif
}
+ (Transformer*)transformerWithTransformer:(Transformer*)t {
- return [[t copy] autorelease];
+#if __has_feature(objc_arc)
+ return [t copy];
+#else
+ return [[t copy] autorelease];
+#endif
}
+ (Transformer*)transformerWithOrigin:(NSPoint)o andScale:(float)scale {
diff --git a/tikzit/src/common/tikzparserdefs.h b/tikzit/src/common/tikzparserdefs.h
index 587bcd6..cde3345 100644
--- a/tikzit/src/common/tikzparserdefs.h
+++ b/tikzit/src/common/tikzparserdefs.h
@@ -37,8 +37,13 @@
@class Node;
struct noderef {
- Node *node;
- NSString *anchor;
+#if __has_feature(objc_arc)
+ __unsafe_unretained Node *node;
+ __unsafe_unretained NSString *anchor;
+#else
+ Node *node;
+ NSString *anchor;
+#endif
};
// vi:ft=objc:noet:ts=4:sts=4:sw=4