Permalink
Browse files

Initial commit.

  • Loading branch information...
logancollins committed May 13, 2012
0 parents commit 5ecee24c514d80c1c113df017cde4d6431222add
Showing with 3,822 additions and 0 deletions.
  1. +17 −0 .gitignore
  2. +586 −0 Mocha.xcodeproj/project.pbxproj
  3. +24 −0 Mocha/BridgeSupport/MOBridgeSupportController.h
  4. +94 −0 Mocha/BridgeSupport/MOBridgeSupportController.m
  5. +29 −0 Mocha/BridgeSupport/MOBridgeSupportLibrary.h
  6. +85 −0 Mocha/BridgeSupport/MOBridgeSupportLibrary.m
  7. +19 −0 Mocha/BridgeSupport/MOBridgeSupportParser.h
  8. +288 −0 Mocha/BridgeSupport/MOBridgeSupportParser.m
  9. +219 −0 Mocha/BridgeSupport/MOBridgeSupportSymbol.h
  10. +335 −0 Mocha/BridgeSupport/MOBridgeSupportSymbol.m
  11. +18 −0 Mocha/Exceptions/MOException.h
  12. +37 −0 Mocha/Exceptions/MOException.m
  13. +21 −0 Mocha/Exceptions/MOException_Private.h
  14. +30 −0 Mocha/Mocha-Info.plist
  15. +7 −0 Mocha/Mocha-Prefix.pch
  16. +13 −0 Mocha/Mocha.h
  17. +10 −0 Mocha/Mocha.m
  18. +12 −0 Mocha/MochaDefines.h
  19. +70 −0 Mocha/MochaRuntime.h
  20. +1,130 −0 Mocha/MochaRuntime.m
  21. +58 −0 Mocha/MochaRuntime_Private.h
  22. +18 −0 Mocha/Objects/MOBox.h
  23. +17 −0 Mocha/Objects/MOBox.m
  24. +21 −0 Mocha/Objects/MOBridgeSupportObject.h
  25. +27 −0 Mocha/Objects/MOBridgeSupportObject.m
  26. +19 −0 Mocha/Objects/MOFunction.h
  27. +25 −0 Mocha/Objects/MOFunction.m
  28. +17 −0 Mocha/Objects/MOFunction_Private.h
  29. +14 −0 Mocha/Objects/MOObject.h
  30. +14 −0 Mocha/Objects/MOObject.m
  31. +23 −0 Mocha/Objects/NSArray+MochaAdditions.h
  32. +32 −0 Mocha/Objects/NSArray+MochaAdditions.m
  33. +23 −0 Mocha/Objects/NSDictionary+MochaAdditions.h
  34. +27 −0 Mocha/Objects/NSDictionary+MochaAdditions.m
  35. +20 −0 Mocha/Utilities/MOUtilities.h
  36. +287 −0 Mocha/Utilities/MOUtilities.m
  37. +2 −0 Mocha/en.lproj/InfoPlist.strings
  38. 0 README.mdown
  39. +17 −0 moc/MOCInterpreter.h
  40. +84 −0 moc/MOCInterpreter.m
  41. +26 −0 moc/main.m
  42. +7 −0 moc/moc-Prefix.pch
@@ -0,0 +1,17 @@
+# Xcode
+build
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcodeproj/project.xcworkspace
+xcuserdata
+profile
+*.moved-aside
+
+# OS files
+.DS_Store

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,24 @@
+//
+// MOBridgeSupportController.h
+// Mocha
+//
+// Created by Logan Collins on 5/11/12.
+// Copyright (c) 2012 Sunflower Softworks. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@class MOBridgeSupportSymbol;
+
+
+@interface MOBridgeSupportController : NSObject
+
++ (MOBridgeSupportController *)sharedController;
+
+- (BOOL)isBridgeSupportLoadedForURL:(NSURL *)aURL;
+- (BOOL)loadBridgeSupportAtURL:(NSURL *)aURL error:(NSError **)outError;
+
+- (MOBridgeSupportSymbol *)performQueryForSymbolName:(NSString *)name;
+
+@end
@@ -0,0 +1,94 @@
+//
+// MOBridgeSupportController.m
+// Mocha
+//
+// Created by Logan Collins on 5/11/12.
+// Copyright (c) 2012 Sunflower Softworks. All rights reserved.
+//
+
+#import "MOBridgeSupportController.h"
+
+#import "MOBridgeSupportLibrary.h"
+#import "MOBridgeSupportSymbol.h"
+
+#import "MOBridgeSupportParser.h"
+
+
+@implementation MOBridgeSupportController {
+ NSMutableArray *_loadedURLs;
+ NSMutableArray *_loadedLibraries;
+ NSMutableDictionary *_symbols;
+ MOBridgeSupportParser *_parser;
+}
+
++ (MOBridgeSupportController *)sharedController {
+ static MOBridgeSupportController *sharedController = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedController = [[self alloc] init];
+ });
+ return sharedController;
+}
+
+- (id)init {
+ self = [super init];
+ if (self) {
+ _loadedURLs = [[NSMutableArray alloc] init];
+ _loadedLibraries = [[NSMutableArray alloc] init];
+ _symbols = [[NSMutableDictionary alloc] init];
+ _parser = [[MOBridgeSupportParser alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [_loadedURLs release];
+ [_loadedLibraries release];
+ [_symbols release];
+ [_parser release];
+ [super dealloc];
+}
+
+
+#pragma mark -
+#pragma mark Loading
+
+- (BOOL)isBridgeSupportLoadedForURL:(NSURL *)aURL {
+ return [_loadedURLs containsObject:aURL];
+}
+
+- (BOOL)loadBridgeSupportAtURL:(NSURL *)aURL error:(NSError **)outError {
+ if ([self isBridgeSupportLoadedForURL:aURL]) {
+ return YES;
+ }
+
+ MOBridgeSupportLibrary *library = [_parser libraryWithBridgeSupportURL:aURL error:outError];
+ if (library == nil) {
+ return NO;
+ }
+
+ [_loadedURLs addObject:aURL];
+ [_loadedLibraries addObject:library];
+
+ for (NSString *name in library.symbols) {
+ MOBridgeSupportSymbol *symbol = [library.symbols objectForKey:name];
+ if ([_symbols objectForKey:name] == nil) {
+ [_symbols setObject:symbol forKey:name];
+ }
+ else {
+ //NSLog(@"Symbol with name \"%@\" is already loaded.", name);
+ }
+ }
+
+ return YES;
+}
+
+
+#pragma mark -
+#pragma mark Queries
+
+- (MOBridgeSupportSymbol *)performQueryForSymbolName:(NSString *)name {
+ return [_symbols objectForKey:name];
+}
+
+@end
@@ -0,0 +1,29 @@
+//
+// MOBridgeSupportLibrary.h
+// Mocha
+//
+// Created by Logan Collins on 5/11/12.
+// Copyright (c) 2012 Sunflower Softworks. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@class MOBridgeSupportSymbol;
+
+
+@interface MOBridgeSupportLibrary : NSObject
+
+@property (copy) NSString *name;
+@property (copy) NSURL *URL;
+
+@property (copy) NSArray *dependencies;
+- (void)addDependency:(NSString *)dependency;
+- (void)removeDependency:(NSString *)dependency;
+
+@property (copy) NSDictionary *symbols;
+- (MOBridgeSupportSymbol *)symbolWithName:(NSString *)name;
+- (void)setSymbol:(MOBridgeSupportSymbol *)symbol forName:(NSString *)name;
+- (void)removeSymbolForName:(NSString *)name;
+
+@end
@@ -0,0 +1,85 @@
+//
+// MOBridgeSupportLibrary.m
+// Mocha
+//
+// Created by Logan Collins on 5/11/12.
+// Copyright (c) 2012 Sunflower Softworks. All rights reserved.
+//
+
+#import "MOBridgeSupportLibrary.h"
+
+
+@implementation MOBridgeSupportLibrary {
+ NSMutableArray *_dependencies;
+ NSMutableDictionary *_symbols;
+}
+
+@synthesize name=_name;
+@synthesize URL=_URL;
+
+- (id)init {
+ self = [super init];
+ if (self) {
+ _dependencies = [[NSMutableArray alloc] init];
+ _symbols = [[NSMutableDictionary alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [_name release];
+ [_URL release];
+ [_dependencies release];
+ [_symbols release];
+ [super dealloc];
+}
+
+
+#pragma mark -
+#pragma mark Dependencies
+
+- (NSArray *)dependencies {
+ return _dependencies;
+}
+
+- (void)setDependencies:(NSArray *)dependencies {
+ [_dependencies setArray:dependencies];
+}
+
+- (void)addDependency:(NSString *)dependency {
+ if (![_dependencies containsObject:dependency]) {
+ [_dependencies addObject:dependency];
+ }
+}
+
+- (void)removeDependency:(NSString *)dependency {
+ if ([_dependencies containsObject:dependency]) {
+ [_dependencies removeObject:dependency];
+ }
+}
+
+
+#pragma mark -
+#pragma mark Symbols
+
+- (NSDictionary *)symbols {
+ return _symbols;
+}
+
+- (void)setSymbols:(NSDictionary *)symbols {
+ [_symbols setDictionary:symbols];
+}
+
+- (MOBridgeSupportSymbol *)symbolWithName:(NSString *)name {
+ return [_symbols objectForKey:name];
+}
+
+- (void)setSymbol:(MOBridgeSupportSymbol *)symbol forName:(NSString *)name {
+ [_symbols setObject:symbol forKey:name];
+}
+
+- (void)removeSymbolForName:(NSString *)name {
+ [_symbols removeObjectForKey:name];
+}
+
+@end
@@ -0,0 +1,19 @@
+//
+// MOBridgeSupportParser.h
+// Mocha
+//
+// Created by Logan Collins on 5/11/12.
+// Copyright (c) 2012 Sunflower Softworks. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@class MOBridgeSupportLibrary;
+
+
+@interface MOBridgeSupportParser : NSObject
+
+- (MOBridgeSupportLibrary *)libraryWithBridgeSupportURL:(NSURL *)aURL error:(NSError **)outError;
+
+@end
Oops, something went wrong.

0 comments on commit 5ecee24

Please sign in to comment.