Skip to content

Commit

Permalink
More Mocha transitional stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccgus committed Jul 22, 2012
1 parent b850231 commit d20aebd
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 45 deletions.
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -169,7 +169,13 @@ As said earlier, JSTalk is a blend of existing technologies, and has very little


- JSTalk Icon, from Brad Ellis. - JSTalk Icon, from Brad Ellis.
- JavaScriptCore, from Apple and the WebKit team. - JavaScriptCore, from Apple and the WebKit team.
- [JSCocoa](http://inexdo.com/JSCocoa), from Patrick Geiller. - [Mocha](https://github.com/logancollins/Mocha), from Logan Collins.
- [TDParseKit](http://ditchnet.org/tdparsekit/), from Todd Ditchendorf. - [TDParseKit](http://ditchnet.org/tdparsekit/), from Todd Ditchendorf.
- [NoodleLineNumberView](http://www.noodlesoft.com/blog/2008/10/05/displaying-line-numbers-with-nstextview/), from Paul Kim / Noodlesoft. - [NoodleLineNumberView](http://www.noodlesoft.com/blog/2008/10/05/displaying-line-numbers-with-nstextview/), from Paul Kim / Noodlesoft.
- [TextExtras](http://www.lorax.com/FreeStuff/TextExtras.html), from Mike Ferris. - [TextExtras](http://www.lorax.com/FreeStuff/TextExtras.html), from Mike Ferris.


### Mocha Transition Notes for Gus:

Hey, JSTCodeSketcher has a lot of commented out code that you'll need to figure out still

12 changes: 4 additions & 8 deletions jstalk.xcodeproj/project.pbxproj
Expand Up @@ -134,6 +134,8 @@
CC3A9B5D15BCB2E00075F377 /* TDWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D790F48BB2C007A2941 /* TDWord.m */; }; CC3A9B5D15BCB2E00075F377 /* TDWord.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D790F48BB2C007A2941 /* TDWord.m */; };
CC3A9B5E15BCB2E00075F377 /* TDWordOrReservedState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7B0F48BB2C007A2941 /* TDWordOrReservedState.m */; }; CC3A9B5E15BCB2E00075F377 /* TDWordOrReservedState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7B0F48BB2C007A2941 /* TDWordOrReservedState.m */; };
CC3A9B5F15BCB2E00075F377 /* TDWordState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7D0F48BB2C007A2941 /* TDWordState.m */; }; CC3A9B5F15BCB2E00075F377 /* TDWordState.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1C7D7D0F48BB2C007A2941 /* TDWordState.m */; };
CC3A9B6315BCB82C0075F377 /* MochaRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36AF15BA5E44008D8460 /* MochaRuntime.m */; };
CC3A9B6415BCB82E0075F377 /* Mocha.m in Sources */ = {isa = PBXBuildFile; fileRef = CCEC36AC15BA5E44008D8460 /* Mocha.m */; };
CC41432E0F25257C00E46669 /* JSTalk_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = CCC5B8CB0F1EFAAA00126722 /* JSTalk_Prefix.pch */; settings = {ATTRIBUTES = (Private, ); }; }; CC41432E0F25257C00E46669 /* JSTalk_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = CCC5B8CB0F1EFAAA00126722 /* JSTalk_Prefix.pch */; settings = {ATTRIBUTES = (Private, ); }; };
CC41433B0F25259400E46669 /* JSTalk.h in Headers */ = {isa = PBXBuildFile; fileRef = CC5FB7D60F1FDDE900F4ECC2 /* JSTalk.h */; settings = {ATTRIBUTES = (Public, ); }; }; CC41433B0F25259400E46669 /* JSTalk.h in Headers */ = {isa = PBXBuildFile; fileRef = CC5FB7D60F1FDDE900F4ECC2 /* JSTalk.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC41433C0F25259400E46669 /* JSTalk.m in Sources */ = {isa = PBXBuildFile; fileRef = CC5FB7D70F1FDDE900F4ECC2 /* JSTalk.m */; }; CC41433C0F25259400E46669 /* JSTalk.m in Sources */ = {isa = PBXBuildFile; fileRef = CC5FB7D70F1FDDE900F4ECC2 /* JSTalk.m */; };
Expand Down Expand Up @@ -1191,6 +1193,7 @@
CC1C7DDF0F48BB2C007A2941 /* TDChar.m in Sources */, CC1C7DDF0F48BB2C007A2941 /* TDChar.m in Sources */,
CC1C7DE00F48BB2C007A2941 /* TDCharacterAssembly.m in Sources */, CC1C7DE00F48BB2C007A2941 /* TDCharacterAssembly.m in Sources */,
CC3A9B2315BC8F390075F377 /* MOBridgeSupportController.m in Sources */, CC3A9B2315BC8F390075F377 /* MOBridgeSupportController.m in Sources */,
CC3A9B6315BCB82C0075F377 /* MochaRuntime.m in Sources */,
CC3A9B2415BC8F390075F377 /* MOBridgeSupportLibrary.m in Sources */, CC3A9B2415BC8F390075F377 /* MOBridgeSupportLibrary.m in Sources */,
CC3A9B2515BC8F390075F377 /* MOBridgeSupportParser.m in Sources */, CC3A9B2515BC8F390075F377 /* MOBridgeSupportParser.m in Sources */,
CC3A9B2615BC8F390075F377 /* MOBridgeSupportSymbol.m in Sources */, CC3A9B2615BC8F390075F377 /* MOBridgeSupportSymbol.m in Sources */,
Expand Down Expand Up @@ -1234,6 +1237,7 @@
CC1C7DF40F48BB2C007A2941 /* TDSequence.m in Sources */, CC1C7DF40F48BB2C007A2941 /* TDSequence.m in Sources */,
CC1C7DF60F48BB2C007A2941 /* TDSingleLineCommentState.m in Sources */, CC1C7DF60F48BB2C007A2941 /* TDSingleLineCommentState.m in Sources */,
CC1C7DF70F48BB2C007A2941 /* TDSpecificChar.m in Sources */, CC1C7DF70F48BB2C007A2941 /* TDSpecificChar.m in Sources */,
CC3A9B6415BCB82E0075F377 /* Mocha.m in Sources */,
CC1C7DF80F48BB2C007A2941 /* TDSymbol.m in Sources */, CC1C7DF80F48BB2C007A2941 /* TDSymbol.m in Sources */,
CC1C7DF90F48BB2C007A2941 /* TDSymbolNode.m in Sources */, CC1C7DF90F48BB2C007A2941 /* TDSymbolNode.m in Sources */,
CC1C7DFA0F48BB2C007A2941 /* TDSymbolRootNode.m in Sources */, CC1C7DFA0F48BB2C007A2941 /* TDSymbolRootNode.m in Sources */,
Expand Down Expand Up @@ -1302,10 +1306,6 @@
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/lib\"",
);
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -1328,10 +1328,6 @@
x86_64, x86_64,
i386, i386,
); );
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/lib\"",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = src/JSTalk_Prefix.pch; GCC_PREFIX_HEADER = src/JSTalk_Prefix.pch;
INFOPLIST_FILE = res/Info.plist; INFOPLIST_FILE = res/Info.plist;
Expand Down
4 changes: 2 additions & 2 deletions plugins/imagetools/ImageTools.xcodeproj/project.pbxproj
Expand Up @@ -300,7 +300,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks";
OTHER_CFLAGS = "-DDEBUG"; OTHER_CFLAGS = "-DDEBUG";
PRODUCT_NAME = ImageTools; PRODUCT_NAME = ImageTools;
SDKROOT = macosx; SDKROOT = macosx10.7;
WRAPPER_EXTENSION = jstplugin; WRAPPER_EXTENSION = jstplugin;
}; };
name = Debug; name = Debug;
Expand Down Expand Up @@ -328,7 +328,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "@executable_path/../Frameworks";
OTHER_CFLAGS = "-DDEBUG"; OTHER_CFLAGS = "-DDEBUG";
PRODUCT_NAME = ImageTools; PRODUCT_NAME = ImageTools;
SDKROOT = macosx; SDKROOT = macosx10.7;
WRAPPER_EXTENSION = jstplugin; WRAPPER_EXTENSION = jstplugin;
}; };
name = Release; name = Release;
Expand Down
4 changes: 2 additions & 2 deletions plugins/imagetools/JSTCodeSketcher.h
Expand Up @@ -8,7 +8,6 @@


#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <JSTalk/JSTalk.h> #import <JSTalk/JSTalk.h>
#import <JSTalk/JSCocoa.h>


@interface JSTCodeSketcher : NSView { @interface JSTCodeSketcher : NSView {


Expand Down Expand Up @@ -54,12 +53,13 @@
- (void)stop; - (void)stop;
- (void)start; - (void)start;


/*
- (void)setDraw:(JSValueRefAndContextRef)ref; - (void)setDraw:(JSValueRefAndContextRef)ref;
- (void)setMouseMove:(JSValueRefAndContextRef)ref; - (void)setMouseMove:(JSValueRefAndContextRef)ref;
- (void)setMouseUp:(JSValueRefAndContextRef)ref; - (void)setMouseUp:(JSValueRefAndContextRef)ref;
- (void)setMouseDown:(JSValueRefAndContextRef)ref; - (void)setMouseDown:(JSValueRefAndContextRef)ref;
- (void)setMouseDrag:(JSValueRefAndContextRef)ref; - (void)setMouseDrag:(JSValueRefAndContextRef)ref;

*/


@end @end


Expand Down
22 changes: 13 additions & 9 deletions plugins/imagetools/JSTCodeSketcher.m
Expand Up @@ -103,34 +103,35 @@ - (void)stop {
_redrawTimer = 0x00; _redrawTimer = 0x00;


if (_setupFunction) { if (_setupFunction) {
JSValueUnprotect([[_jstalk jsController] ctx], _drawFunction); JSValueUnprotect([_jstalk context], _drawFunction);
} }


if (_drawFunction) { if (_drawFunction) {
JSValueUnprotect([[_jstalk jsController] ctx], _drawFunction); JSValueUnprotect([_jstalk context], _drawFunction);
} }


if (_mouseUpFunction) { if (_mouseUpFunction) {
JSValueUnprotect([[_jstalk jsController] ctx], _mouseUpFunction); JSValueUnprotect([_jstalk context], _mouseUpFunction);
} }


if (_mouseDownFunction) { if (_mouseDownFunction) {
JSValueUnprotect([[_jstalk jsController] ctx], _mouseDownFunction); JSValueUnprotect([_jstalk context], _mouseDownFunction);
} }


if (_mouseMoveFunction) { if (_mouseMoveFunction) {
JSValueUnprotect([[_jstalk jsController] ctx], _mouseMoveFunction); JSValueUnprotect([_jstalk context], _mouseMoveFunction);
} }


if (_mouseDragFunction) { if (_mouseDragFunction) {
JSValueUnprotect([[_jstalk jsController] ctx], _mouseDragFunction); JSValueUnprotect([_jstalk context], _mouseDragFunction);
} }
} }


- (void)start { - (void)start {


if (_setupFunction) { if (_setupFunction) {
[[_jstalk jsController] callJSFunction:_setupFunction withArguments:0x00]; #pragma message "FIXME: add this back in with the Mocha transition"
//[[_jstalk jsController] callJSFunction:_setupFunction withArguments:0x00];
} }


[self setupWindow]; [self setupWindow];
Expand Down Expand Up @@ -230,7 +231,9 @@ - (void)drawRect:(NSRect)dirtyRect {


if (_drawFunction) { if (_drawFunction) {
[self pushContext]; [self pushContext];
[[_jstalk jsController] callJSFunction:_drawFunction withArguments:0x00];
#pragma message "FIXME: add back in w/ Mocha transition"
//[[_jstalk jsController] callJSFunction:_drawFunction withArguments:0x00];
[self popContext]; [self popContext];
} }


Expand All @@ -244,7 +247,7 @@ - (void)drawRect:(NSRect)dirtyRect {
- (void)viewDidEndLiveResize { - (void)viewDidEndLiveResize {
[self resizeContext]; [self resizeContext];
} }

/*
- (void)setSetup:(JSValueRefAndContextRef)ref { - (void)setSetup:(JSValueRefAndContextRef)ref {
_setupFunction = ref.value; _setupFunction = ref.value;
JSValueProtect([[_jstalk jsController] ctx], _setupFunction); JSValueProtect([[_jstalk jsController] ctx], _setupFunction);
Expand Down Expand Up @@ -328,6 +331,7 @@ - (void)mouseMoved:(NSEvent *)event {
} }
} }
*/


- (BOOL)isFlipped { - (BOOL)isFlipped {
return _flipped; return _flipped;
Expand Down
2 changes: 1 addition & 1 deletion plugins/imagetools/JSTOpenCLProgram.m
Expand Up @@ -16,7 +16,7 @@ - (id)printController;


@interface JSTOpenCLKernel () @interface JSTOpenCLKernel ()
@property (readwrite) cl_kernel computeKernel; @property (readwrite) cl_kernel computeKernel;
@property (readwrite) int workGroupSize; @property (readwrite) size_t workGroupSize;
@end @end


@implementation JSTOpenCLProgram @implementation JSTOpenCLProgram
Expand Down
8 changes: 2 additions & 6 deletions src/JSTAppDelegate.m
Expand Up @@ -8,7 +8,6 @@


#import "JSTAppDelegate.h" #import "JSTAppDelegate.h"
#import "JSTalk.h" #import "JSTalk.h"
//#import "JSCocoaController.h"


@interface JSTAppDelegate (PrivateStuff) @interface JSTAppDelegate (PrivateStuff)
- (void)restoreWorkspace; - (void)restoreWorkspace;
Expand Down Expand Up @@ -220,11 +219,9 @@ - (NSFont*)defaultEditorFont {
return defaultFont; return defaultFont;
} }


/* - (void)JSTalk:(JSTalk*)jstalk hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url {
- (void)JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url {
_serviceError = [error retain]; _serviceError = [error retain];
} }
*/




- (void)runAsJSTalkScript:(NSPasteboard *)pb userData:(NSDictionary *)userData error:(NSString **)error { - (void)runAsJSTalkScript:(NSPasteboard *)pb userData:(NSDictionary *)userData error:(NSString **)error {
Expand All @@ -246,8 +243,7 @@ - (void)runAsJSTalkScript:(NSPasteboard *)pb userData:(NSDictionary *)userData e


JSTalk *jstalk = [[JSTalk alloc] init]; JSTalk *jstalk = [[JSTalk alloc] init];


//JSCocoaController *jsController = [jstalk jsController]; [jstalk setErrorController:self];
//jsController.delegate = self;


[[[NSThread currentThread] threadDictionary] setObject:jstalk forKey:@"org.jstalk.currentJSTalkContext"]; [[[NSThread currentThread] threadDictionary] setObject:jstalk forKey:@"org.jstalk.currentJSTalkContext"];


Expand Down
6 changes: 1 addition & 5 deletions src/JSTDocument.m
Expand Up @@ -10,7 +10,6 @@
#import "JSTAppDelegate.h" #import "JSTAppDelegate.h"
#import "JSTListener.h" #import "JSTListener.h"
#import "JSTalk.h" #import "JSTalk.h"
//#import "JSCocoaController.h"
#import "JSTPreprocessor.h" #import "JSTPreprocessor.h"


@interface JSTDocument (SuperSecretItsPrivateDontEvenThinkOfUsingTheseMethodsOutsideThisClass) @interface JSTDocument (SuperSecretItsPrivateDontEvenThinkOfUsingTheseMethodsOutsideThisClass)
Expand Down Expand Up @@ -151,7 +150,7 @@ - (void)JSTalk:(JSTalk*)jstalk hadError:(NSString*)error onLineNumber:(NSInteger
[errorLabel setStringValue:error]; [errorLabel setStringValue:error];
} }
else { else {
[errorLabel setStringValue:[NSString stringWithFormat:@"Line %d, %@", lineNumber, error]]; [errorLabel setStringValue:[NSString stringWithFormat:@"Line %ld, %@", lineNumber, error]];


NSUInteger lineIdx = 0; NSUInteger lineIdx = 0;
NSRange lineRange = NSMakeRange(0, 0); NSRange lineRange = NSMakeRange(0, 0);
Expand All @@ -174,9 +173,6 @@ - (void)runScript:(NSString*)s {


[[[NSThread currentThread] threadDictionary] setObject:jstalk forKey:@"org.jstalk.currentJSTalkContext"]; [[[NSThread currentThread] threadDictionary] setObject:jstalk forKey:@"org.jstalk.currentJSTalkContext"];


#pragma message "FIXME: the error delegate stuff needs to be added back in"
//jsController.delegate = self;

[jstalk setPrintController:self]; [jstalk setPrintController:self];
[jstalk setErrorController:self]; [jstalk setErrorController:self];


Expand Down
2 changes: 1 addition & 1 deletion src/JSTalk.h
Expand Up @@ -27,7 +27,7 @@
- (void)pushObject:(id)obj withName:(NSString*)name; - (void)pushObject:(id)obj withName:(NSString*)name;
- (void)deleteObjectWithName:(NSString*)name; - (void)deleteObjectWithName:(NSString*)name;


- (Mocha*)mochaRuntime; - (JSGlobalContextRef)context;
- (id)callFunctionNamed:(NSString*)name withArguments:(NSArray*)args; - (id)callFunctionNamed:(NSString*)name withArguments:(NSArray*)args;


+ (void)listen; + (void)listen;
Expand Down
4 changes: 2 additions & 2 deletions src/JSTalk.m
Expand Up @@ -85,8 +85,8 @@ - (void)dealloc {
} }




- (Mocha*)mochaRuntime { - (JSGlobalContextRef)context {
return _mochaRuntime; return [_mochaRuntime context];
} }


- (void)addExtrasToRuntime { - (void)addExtrasToRuntime {
Expand Down
10 changes: 2 additions & 8 deletions src/jstalkmain.m
@@ -1,7 +1,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "JSTListener.h" #import "JSTListener.h"
#import "JSTalk.h" #import "JSTalk.h"
//#import "JSCocoaController.h"


BOOL JSCErrorHandlerExitOnError = YES; BOOL JSCErrorHandlerExitOnError = YES;


Expand All @@ -12,16 +11,14 @@ @interface JSCErrorHandler : NSObject {


@implementation JSCErrorHandler @implementation JSCErrorHandler


/* - (void)JSTalk:(JSTalk*)jstalk hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url {
- (void)JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url {


printf("Error line %d, %s\n", (int)lineNumber, [[error description] UTF8String]); printf("Error line %d, %s\n", (int)lineNumber, [[error description] UTF8String]);


if (JSCErrorHandlerExitOnError) { if (JSCErrorHandlerExitOnError) {
exit(1); exit(1);
} }
} }
*/




@end @end
Expand Down Expand Up @@ -62,12 +59,9 @@ int main(int argc, char *argv[]) {


NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


JSCErrorHandler *eh = [[[JSCErrorHandler alloc] init] autorelease];

JSTalk *t = [[[JSTalk alloc] init] autorelease]; JSTalk *t = [[[JSTalk alloc] init] autorelease];


//JSCocoaController *jsController = [t jsController]; [t setErrorController:[[[JSCErrorHandler alloc] init] autorelease]];
//jsController.delegate = eh;


if (argc < 2) { if (argc < 2) {
runREPL(t); runREPL(t);
Expand Down

0 comments on commit d20aebd

Please sign in to comment.