~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Tools/AGSParser.m

Tags: upstream-1.20.0
ImportĀ upstreamĀ versionĀ 1.20.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
   */
20
20
 
21
 
#include "AGSParser.h"
22
 
#include "GNUstepBase/GNUstep.h"
23
 
#include "GNUstepBase/GSCategories.h"
 
21
#import "common.h"
 
22
 
 
23
#import "Foundation/NSArray.h"
 
24
#import "Foundation/NSAutoreleasePool.h"
 
25
#import "Foundation/NSCharacterSet.h"
 
26
#import "Foundation/NSData.h"
 
27
#import "Foundation/NSDictionary.h"
 
28
#import "Foundation/NSEnumerator.h"
 
29
#import "Foundation/NSException.h"
 
30
#import "Foundation/NSFileManager.h"
 
31
#import "Foundation/NSSet.h"
 
32
#import "Foundation/NSUserDefaults.h"
 
33
#import "Foundation/NSValue.h"
 
34
#import "AGSParser.h"
 
35
#import "GNUstepBase/NSString+GNUstepBase.h"
 
36
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
24
37
 
25
38
/**
26
39
 *  The AGSParser class parses Objective-C header and source files
367
380
      BOOL      isDocumentation = NO;
368
381
      BOOL      skippedFirstLine = NO;
369
382
      NSRange   r;
 
383
      BOOL      ignore = NO;
 
384
 
 
385
 
 
386
      /* Jump back here if we have ignored data up to a new comment.
 
387
       */
 
388
comment:
370
389
 
371
390
      pos += 2; /* Skip opening part */
372
391
 
501
520
          if (end > start)
502
521
            {
503
522
              NSString  *tmp;
 
523
              NSRange   r;
504
524
 
505
525
              tmp = [NSString stringWithCharacters: start length: end - start];
506
 
              [self appendComment: tmp to: nil];
 
526
recheck:
 
527
              if (YES == ignore)
 
528
                {
 
529
                  r = [tmp rangeOfString: @"</ignore>"];
 
530
                  if (r.length > 0)
 
531
                    {
 
532
                      tmp = [tmp substringFromIndex: NSMaxRange(r)];
 
533
                      ignore = NO;
 
534
                    }
 
535
                }
 
536
              if (NO == ignore)
 
537
                {
 
538
                  r = [tmp rangeOfString: @"<ignore>"];
 
539
                  if (r.length > 0)
 
540
                    {
 
541
                      [self appendComment: [tmp substringToIndex: r.location]
 
542
                                       to: nil];
 
543
                      tmp = [tmp substringFromIndex: NSMaxRange(r)];
 
544
                      ignore = YES;
 
545
                      goto recheck;
 
546
                    }
 
547
                  [self appendComment: tmp to: nil];
 
548
                }
507
549
            }
508
550
 
509
551
          /*
927
969
            }
928
970
          commentsRead = YES;
929
971
        }
 
972
      if (YES == ignore)
 
973
        {
 
974
          while (pos < length)
 
975
            {
 
976
              switch (buffer[pos])
 
977
                {
 
978
                  case '\'':
 
979
                  case '"':
 
980
                    [self skipLiteral];
 
981
                    break;
 
982
 
 
983
                  case '/':
 
984
                    if (pos + 1 < length)
 
985
                      {
 
986
                        if (buffer[pos + 1] == '/')
 
987
                          {
 
988
                            [self skipRemainderOfLine];
 
989
                          }
 
990
                        else if (buffer[pos + 1] == '*')
 
991
                          {
 
992
                            goto comment;
 
993
                          }
 
994
                      }
 
995
                    pos++;
 
996
                    break;
 
997
 
 
998
                  default:
 
999
                    pos++;
 
1000
                    break;
 
1001
                }
 
1002
            }
 
1003
        }
930
1004
    }
931
1005
  return pos;
932
1006
}
1055
1129
        @"unsigned",
1056
1130
        @"volatile",
1057
1131
        nil];
1058
 
      RETAIN(qualifiers);
 
1132
      IF_NO_GC([qualifiers retain];)
1059
1133
      keep = [NSSet setWithObjects:
1060
1134
        @"const",
1061
1135
        @"long",
1064
1138
        @"unsigned",
1065
1139
        @"volatile",
1066
1140
        nil];
1067
 
      RETAIN(keep);
 
1141
      IF_NO_GC([keep retain];)
1068
1142
    }
1069
1143
 
1070
1144
  a = [NSMutableArray array];
1103
1177
                  pos++;
1104
1178
                  [self skipSpaces];
1105
1179
                }
1106
 
              DESTROY(arp);
 
1180
              IF_NO_GC(DESTROY(arp);)
1107
1181
              return nil;
1108
1182
            }
1109
1183
 
2573
2647
 
2574
2648
  itemName = nil;
2575
2649
  RELEASE(arp);
2576
 
  AUTORELEASE(method);
 
2650
  IF_NO_GC([method autorelease];)
2577
2651
  return method;
2578
2652
 
2579
2653
fail:
3251
3325
  unitName = nil;
3252
3326
  DESTROY(comment);
3253
3327
  RELEASE(arp);
3254
 
  AUTORELEASE(dict);
 
3328
  IF_NO_GC([dict autorelease];)
3255
3329
  return dict;
3256
3330
 
3257
3331
fail:
3698
3772
  pos = 0;
3699
3773
  lines = [[NSArray alloc] initWithArray: a];
3700
3774
  RELEASE(arp);
3701
 
  AUTORELEASE(lines);
3702
 
  AUTORELEASE(data);
 
3775
  IF_NO_GC([lines autorelease];)
 
3776
  IF_NO_GC([data autorelease];)
3703
3777
}
3704
3778
 
3705
3779
/**