Permalink
Browse files

First run through replacing JSCocoa with Mocha

  • Loading branch information...
1 parent 865130a commit 54f52a373ac352f92487feb3e78f96d8247d6b72 @ccgus committed Jul 22, 2012
Showing with 11,147 additions and 360 deletions.
  1. +322 −285 jstalk.xcodeproj/project.pbxproj
  2. +28 −0 mocha/BridgeSupport/MOBridgeSupportController.h
  3. +119 −0 mocha/BridgeSupport/MOBridgeSupportController.m
  4. +29 −0 mocha/BridgeSupport/MOBridgeSupportLibrary.h
  5. +85 −0 mocha/BridgeSupport/MOBridgeSupportLibrary.m
  6. +19 −0 mocha/BridgeSupport/MOBridgeSupportParser.h
  7. +319 −0 mocha/BridgeSupport/MOBridgeSupportParser.m
  8. +235 −0 mocha/BridgeSupport/MOBridgeSupportSymbol.h
  9. +429 −0 mocha/BridgeSupport/MOBridgeSupportSymbol.m
  10. +23 −0 mocha/Categories/NSArray+MochaAdditions.h
  11. +35 −0 mocha/Categories/NSArray+MochaAdditions.m
  12. +23 −0 mocha/Categories/NSDictionary+MochaAdditions.h
  13. +32 −0 mocha/Categories/NSDictionary+MochaAdditions.m
  14. +21 −0 mocha/Categories/NSObject+MochaAdditions.h
  15. +32 −0 mocha/Categories/NSObject+MochaAdditions.m
  16. +23 −0 mocha/Categories/NSOrderedSet+MochaAdditions.h
  17. +35 −0 mocha/Categories/NSOrderedSet+MochaAdditions.m
  18. +18 −0 mocha/Mocha.h
  19. +10 −0 mocha/Mocha.m
  20. +12 −0 mocha/MochaDefines.h
  21. +341 −0 mocha/MochaRuntime.h
  22. +1,363 −0 mocha/MochaRuntime.m
  23. +59 −0 mocha/MochaRuntime_Private.h
  24. +35 −0 mocha/Objects/MOBox.h
  25. +17 −0 mocha/Objects/MOBox.m
  26. +327 −0 mocha/Objects/MOClassDescription.h
  27. +530 −0 mocha/Objects/MOClassDescription.m
  28. +23 −0 mocha/Objects/MOClosure.h
  29. +75 −0 mocha/Objects/MOClosure.m
  30. +14 −0 mocha/Objects/MOClosure_Private.h
  31. +49 −0 mocha/Objects/MOInstanceVariableDescription.h
  32. +41 −0 mocha/Objects/MOInstanceVariableDescription.m
  33. +19 −0 mocha/Objects/MOInstanceVariableDescription_Private.h
  34. +20 −0 mocha/Objects/MOJavaScriptObject.h
  35. +30 −0 mocha/Objects/MOJavaScriptObject.m
  36. +49 −0 mocha/Objects/MOMethod.h
  37. +41 −0 mocha/Objects/MOMethod.m
  38. +48 −0 mocha/Objects/MOMethodDescription.h
  39. +40 −0 mocha/Objects/MOMethodDescription.m
  40. +19 −0 mocha/Objects/MOMethodDescription_Private.h
  41. +19 −0 mocha/Objects/MOMethod_Private.h
  42. +67 −0 mocha/Objects/MOObjCRuntime.h
  43. +97 −0 mocha/Objects/MOObjCRuntime.m
  44. +103 −0 mocha/Objects/MOPropertyDescription.h
  45. +70 −0 mocha/Objects/MOPropertyDescription.m
  46. +166 −0 mocha/Objects/MOProtocolDescription.h
  47. +403 −0 mocha/Objects/MOProtocolDescription.m
  48. +16 −0 mocha/Objects/MOProtocolDescription_Private.h
  49. +95 −0 mocha/Objects/MOStruct.h
  50. +106 −0 mocha/Objects/MOStruct.m
  51. +29 −0 mocha/Objects/MOUndefined.h
  52. +49 −0 mocha/Objects/MOUndefined.m
  53. +75 −0 mocha/Utilities/MOFunctionArgument.h
  54. +1,049 −0 mocha/Utilities/MOFunctionArgument.m
  55. +36 −0 mocha/Utilities/MOPreprocessor.h
  56. +357 −0 mocha/Utilities/MOPreprocessor.m
  57. +39 −0 mocha/Utilities/MOUtilities.h
  58. +929 −0 mocha/Utilities/MOUtilities.m
  59. +2,349 −0 mocha/Utilities/TDTokenizerAmalgamation.m
  60. +2 −0 mocha/en.lproj/InfoPlist.strings
  61. +3 −0 plugins/sqlite-fmdb-jstplugin/fmdb.jstalk
  62. +8 −6 src/JSTAppDelegate.m
  63. +15 −11 src/JSTDocument.m
  64. +5 −5 src/JSTExtras.m
  65. +2 −2 src/JSTListener.m
  66. +1 −1 src/JSTPluginMover.m
  67. +5 −5 src/JSTPreprocessor.m
  68. +4 −5 src/JSTalk.h
  69. +53 −36 src/JSTalk.m
  70. +6 −4 src/jstalkmain.m

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,28 @@
+//
+// 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;
+
+@property (copy, readonly) NSDictionary *symbols;
+- (NSDictionary *)performQueryForSymbolsOfType:(NSArray *)classes;
+
+- (id)performQueryForSymbolName:(NSString *)name;
+- (id)performQueryForSymbolName:(NSString *)name ofType:(Class)klass;
+
+@end
@@ -0,0 +1,119 @@
+//
+// 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
+
+- (NSDictionary *)symbols {
+ return _symbols;
+}
+
+- (NSDictionary *)performQueryForSymbolsOfType:(NSArray *)classes {
+ NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:[_symbols count]];
+ for (NSString *key in _symbols) {
+ MOBridgeSupportSymbol *symbol = [_symbols objectForKey:key];
+ for (Class klass in classes) {
+ if ([symbol isKindOfClass:klass]) {
+ [dictionary setObject:symbol forKey:[symbol name]];
+ }
+ }
+ }
+ return dictionary;
+}
+
+- (id)performQueryForSymbolName:(NSString *)name {
+ return [_symbols objectForKey:name];
+}
+
+- (id)performQueryForSymbolName:(NSString *)name ofType:(Class)klass {
+ id symbol = [self performQueryForSymbolName:name];
+ if ([symbol isKindOfClass:klass]) {
+ return symbol;
+ }
+ return nil;
+}
+
+@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 54f52a3

Please sign in to comment.