Revision: 4211
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4211&view=rev
Author:   hofman
Date:     2008-07-14 12:04:42 -0700 (Mon, 14 Jul 2008)

Log Message:
-----------
Reorder code, divide in DO server stuff and actual parsing/finding

Modified Paths:
--------------
    trunk/SKPDFSynchronizer.h
    trunk/SKPDFSynchronizer.m

Modified: trunk/SKPDFSynchronizer.h
===================================================================
--- trunk/SKPDFSynchronizer.h   2008-07-14 18:52:38 UTC (rev 4210)
+++ trunk/SKPDFSynchronizer.h   2008-07-14 19:04:42 UTC (rev 4211)
@@ -37,12 +37,7 @@
  */
 
 #import <Cocoa/Cocoa.h>
-
-#define SYNCTEX_FEATURE 1
-
-#ifdef SYNCTEX_FEATURE
 #import "synctex_parser.h"
-#endif
 
 @interface SKPDFSynchronizer : NSObject {
     NSString *fileName;
@@ -53,9 +48,7 @@
     NSMutableArray *pages;
     NSMutableDictionary *lines;
     
-#ifdef SYNCTEX_FEATURE
     synctex_scanner_t scanner;
-#endif
     
     id delegate;
     

Modified: trunk/SKPDFSynchronizer.m
===================================================================
--- trunk/SKPDFSynchronizer.m   2008-07-14 18:52:38 UTC (rev 4210)
+++ trunk/SKPDFSynchronizer.m   2008-07-14 19:04:42 UTC (rev 4211)
@@ -113,9 +113,7 @@
         pages = [[NSMutableArray alloc] init];
         lines = [[NSMutableDictionary alloc] init];
         
-#ifdef SYNCTEX_FEATURE
         scanner = NULL;
-#endif        
         
         NSPort *port1 = [NSPort port];
         NSPort *port2 = [NSPort port];
@@ -216,13 +214,16 @@
     return date;
 }
 
+#pragma mark DO server
+
+#pragma mark | Accessor
+
 - (BOOL)shouldKeepRunning {
     OSMemoryBarrier();
     return serverFlags->shouldKeepRunning == 1;
 }
 
-#pragma mark API
-#pragma mark | DO server
+#pragma mark | API
 
 - (void)stopDOServer {
     // set the stop flag so any running task may finish
@@ -240,40 +241,16 @@
     serverOnServerThread = nil;    
 }
 
-#pragma mark | Finding
+#pragma mark | Main thread
 
-- (void)findFileAndLineForLocation:(NSPoint)point inRect:(NSRect)rect 
atPageIndex:(unsigned int)pageIndex {
-    [serverOnServerThread serverFindFileAndLineForLocation:point inRect:rect 
atPageIndex:pageIndex];
-}
-
-- (void)findPageAndLocationForLine:(int)line inFile:(NSString *)file {
-    [serverOnServerThread serverFindPageAndLocationForLine:line inFile:file];
-}
-
-#pragma mark Main thread
-#pragma mark | DO server
-
 - (void)setLocalServer:(byref id)anObject {
     [anObject setProtocolForProxy:@protocol(SKPDFSynchronizerServerThread)];
     serverOnServerThread = [anObject retain];
 }
 
-#pragma mark | Finding
+#pragma mark | Server thread
 
-- (oneway void)serverFoundLine:(int)line inFile:(bycopy NSString *)file {
-    if ([self shouldKeepRunning] && [delegate 
respondsToSelector:@selector(synchronizer:foundLine:inFile:)])
-        [delegate synchronizer:self foundLine:line inFile:file];
-}
-
-- (oneway void)serverFoundLocation:(NSPoint)point atPageIndex:(unsigned 
int)pageIndex {
-    if ([self shouldKeepRunning] && [delegate 
respondsToSelector:@selector(synchronizer:foundLocation:atPageIndex:)])
-        [delegate synchronizer:self foundLocation:point atPageIndex:pageIndex];
-}
-
-#pragma mark Server thread
-#pragma mark | DO server
-
-- (oneway void)stopRunning {log_method();
+- (oneway void)stopRunning {
     // not really necessary, as the main thread should already have done this
     OSAtomicCompareAndSwap32Barrier(1, 0, (int32_t 
*)&serverFlags->shouldKeepRunning);
 }
@@ -316,7 +293,7 @@
         OSAtomicCompareAndSwap32Barrier(0, 1, (int32_t 
*)&serverFlags->serverReady);
     }
     
-    @finally {log_method();
+    @finally {
         // clean up the connection in the server thread
         [localThreadConnection setRootObject:nil];
         
@@ -330,19 +307,41 @@
         [serverOnMainThread release];
         serverOnMainThread = nil;    
         
-#ifdef SYNCTEX_FEATURE
         if (scanner) {
             synctex_scanner_free(scanner);
             scanner = NULL;
         }
-#endif
         
         [pool release];
     }
 }
 
-#pragma mark | Parsing and Finding
+#pragma mark Finding and Parsing
 
+#pragma mark | API
+
+- (void)findFileAndLineForLocation:(NSPoint)point inRect:(NSRect)rect 
atPageIndex:(unsigned int)pageIndex {
+    [serverOnServerThread serverFindFileAndLineForLocation:point inRect:rect 
atPageIndex:pageIndex];
+}
+
+- (void)findPageAndLocationForLine:(int)line inFile:(NSString *)file {
+    [serverOnServerThread serverFindPageAndLocationForLine:line inFile:file];
+}
+
+#pragma mark | Main thread
+
+- (oneway void)serverFoundLine:(int)line inFile:(bycopy NSString *)file {
+    if ([self shouldKeepRunning] && [delegate 
respondsToSelector:@selector(synchronizer:foundLine:inFile:)])
+        [delegate synchronizer:self foundLine:line inFile:file];
+}
+
+- (oneway void)serverFoundLocation:(NSPoint)point atPageIndex:(unsigned 
int)pageIndex {
+    if ([self shouldKeepRunning] && [delegate 
respondsToSelector:@selector(synchronizer:foundLocation:atPageIndex:)])
+        [delegate synchronizer:self foundLocation:point atPageIndex:pageIndex];
+}
+
+#pragma mark | Server thread
+
 #pragma mark || PDFSync
 
 - (BOOL)parsePdfsyncFile:(NSString *)theFileName {
@@ -570,7 +569,6 @@
 
 - (BOOL)parseSynctexFile:(NSString *)theFileName {
     BOOL rv = NO;
-#ifdef SYNCTEX_FEATURE
     if (scanner)
         synctex_scanner_free(scanner);
     if (scanner = synctex_scanner_new_with_output_file([theFileName 
fileSystemRepresentation])) {
@@ -578,13 +576,11 @@
         isPdfsync = NO;
         rv = [self shouldKeepRunning];
     }
-#endif
     return rv;
 }
 
 - (BOOL)synctexFindFileLine:(int *)line file:(NSString **)file 
forLocation:(NSPoint)point inRect:(NSRect)rect atPageIndex:(unsigned 
int)pageIndex {
     BOOL rv = NO;
-#ifdef SYNCTEX_FEATURE
     if (synctex_edit_query(scanner, (int)pageIndex + 1, PDF_TO_SYNC(point.x), 
PDF_TO_SYNC(point.y)) > 0) {
         synctex_node_t node = synctex_next_result(scanner);
         if (node) {
@@ -593,13 +589,11 @@
             rv = YES;
         }
     }
-#endif
     return rv;
 }
 
 - (BOOL)synctexFindPage:(unsigned int *)pageIndex location:(NSPoint *)point 
forLine:(int)line inFile:(NSString *)file {
     BOOL rv = NO;
-#ifdef SYNCTEX_FEATURE
     if (synctex_display_query(scanner, [file fileSystemRepresentation], line, 
0) > 0) {
         synctex_node_t node = synctex_next_result(scanner);
         if (node) {
@@ -609,7 +603,6 @@
             rv = YES;
         }
     }
-#endif
     return rv;
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to