summaryrefslogtreecommitdiff
path: root/tikzit/src/common/TikzGraphAssembler.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/TikzGraphAssembler.m
parent9e4f8a6ff37161da4fa0af14604ad22d9c212fde (diff)
parent49c0d2041f0aae6d08d325b7f7fc1cd707d942f8 (diff)
Merge branch 'arc'
Diffstat (limited to 'tikzit/src/common/TikzGraphAssembler.m')
-rw-r--r--tikzit/src/common/TikzGraphAssembler.m30
1 files changed, 28 insertions, 2 deletions
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;
}