Permalink
Browse files

Objective C parser

  • Loading branch information...
1 parent 6bf1de2 commit 2ae883e1e3384de171c333d97afface1845dbfe8 Vincent Berthoux committed Nov 30, 2010
Showing with 1,358 additions and 0 deletions.
  1. +125 −0 Test/objectivec_implementation.m
  2. +64 −0 Test/objectivec_interface.h
  3. +13 −0 Test/objectivec_property.h
  4. +6 −0 Test/objectivec_protocol.h
  5. +1,147 −0 objc.c
  6. +1 −0 parsers.h
  7. +2 −0 source.mak
@@ -0,0 +1,125 @@
+
+@implementation FileTree
+- (FileSize)getDiskSize
+{
+ return diskSize;
+}
+
+- (id)initWithName:(NSString*)treeName
+ atPlace:(FolderTree*)parentFolder
+{
+ self = [super init];
+
+ diskSize = 0;
+ name = treeName;
+ parent = parentFolder;
+ [name retain];
+ representation = nil;
+
+ return self;
+}
+
+- (id)initWithName:(NSString*)treeName
+ andSize:(FileSize)size
+ atPlace:(FolderTree*)parentFolder
+{
+ self = [super init];
+
+ diskSize = size;
+ name = treeName;
+ parent = parentFolder;
+ [name retain];
+ representation = nil;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [name release];
+ [representation release];
+ [super dealloc];
+}
+
+- (LayoutTree*)createLayoutTree
+{
+ return nil;
+}
+@end
+
+@implementation FolderTree
+- (id)initWithName:(NSString*)treeName
+ atPlace:(FolderTree*)parentFolder
+{
+ self = [super initWithName:treeName
+ atPlace:parentFolder];
+
+ children = [[NSMutableArray alloc] init];
+ return self;
+}
+
+- (void)dealloc
+{
+ [children release];
+ [super dealloc];
+}
+
++ (void) createFileList: (NSString*)root atPlace:(FolderTree*)parentFolder
+{
+ NSFileManager *localFileManager = [[NSFileManager alloc] init];
+ NSURL *rootUrl = [NSURL fileURLWithPath:root];
+ NSDirectoryEnumerator *dirEnumerator = [localFileManager enumeratorAtURL:rootUrl
+
+ includingPropertiesForKeys:[NSArray arrayWithObjects:
+ NSURLNameKey,
+ NSURLIsDirectoryKey,
+ nil]
+
+ options:NSDirectoryEnumerationSkipsHiddenFiles
+
+ errorHandler:nil];
+
+ for (NSURL *theURL in dirEnumerator)
+ {
+ [theURL getResourceValue:&fileName
+ forKey:NSURLNameKey
+ error:NULL];
+
+ // Ignore files under the _extras directory
+ if ([isDirectory boolValue]==YES)
+ {
+ [folder populateChildList:root];
+ }
+ else if ([isDirectory boolValue]==NO)
+ {
+ [parentFolder addChild:f];
+ }
+ }
+}
+
+- (void) populateChildList:(NSString*)root
+{
+ NSString *thisRoot = [[root stringByAppendingString:@"/"]
+ stringByAppendingString:name];
+
+ [FolderTree createFileList:thisRoot
+ atPlace:self];
+
+ for ( FileTree *f in children )
+ diskSize += [f getDiskSize];
+}
+
+- (FolderTree*)addChild:(FileTree*)subTree
+{
+ [children addObject:subTree];
+ return self;
+}
+
+- (LayoutTree*)createLayoutTree
+{
+ return
+ [[LayoutTree alloc] initWithFileList:children
+ andTotalSize:diskSize];
+}
+@end
+
@@ -0,0 +1,64 @@
+//
+// commentary test
+// SupaView
+//
+// Created by Vincent Berthoux on 14/06/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "LayoutTree.h"
+
+@class LayoutTree;
+@class FolderTree;
+
+#define A_MACRO_TEST
+
+typedef something SampleTypedefObjC;
+
+// Mer & no_struct_name must not be present in output
+// tag
+ # define ANOTHER_MACRO( WITH, MOAR ) \
+ Mer( ) \
+ struct no_struct_name
+
+struct aStruct
+{
+ int aStructMember;
+ char *anotherStructMember[ NOT_IN_TAG ];
+};
+
+#pragma DONTCARE /* :-) */
+
+@interface FileTree : NSObject {
+ NSString *name;
+ LayoutTree *representation;
+ FolderTree *parent[THISISNOTATAG];
+ FileSize diskSize;
+}
+- (id)initWithName:(NSString*)treeName
+ andSize:(uint64_t)size
+ atPlace:(FolderTree*)parentFolder;
+
+- (id)initWithName:(NSString*)treeName
+ atPlace:(FolderTree*)parentFolder;
+
+- (void)dealloc;
+
+- (FileSize)getDiskSize;
+- (LayoutTree*)createLayoutTree;
+@end
+
+@interface FolderTree : FileTree {
+ NSMutableArray *children;
+}
+
+- (id)initWithName:(NSString*)treeName
+ atPlace:(FolderTree*)parentFolder;
+- (void)dealloc;
+
+- (FolderTree*)addChild:(FileTree*)subTree;
+- (void) populateChildList:(NSString*)root;
+- (LayoutTree*)createLayoutTree;
+@end
+
View
@@ -0,0 +1,13 @@
+
+@interface Person : NSObject {
+ @public
+ NSString *m_name;
+ @private
+ int m_age;
+}
+
+@property(copy) NSString *personName;
+@property(readonly) int personAge;
+
+-(id)initWithAge:(int)age;
+@end
@@ -0,0 +1,6 @@
+
+@protocol Locking
+- (void)lock;
+- (void)unlock;
+@end
+
Oops, something went wrong.

0 comments on commit 2ae883e

Please sign in to comment.