Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1b5a5e
commit f798f8a
Showing
9 changed files
with
142 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# xcode noise | ||
build/* | ||
*.pbxuser | ||
*.mode1v3 | ||
*.perspectivev3 | ||
# osx noise | ||
.DS_Store | ||
profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.58 KB
(120%)
...deproj/project.xcworkspace/xcuserdata/johannes.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
...ddressBookSpy.xcodeproj/xcuserdata/johannes.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
type = "1" | ||
version = "1.0"> | ||
<FileBreakpoints> | ||
<FileBreakpoint | ||
shouldBeEnabled = "No" | ||
ignoreCount = "0" | ||
continueAfterRunningActions = "No" | ||
filePath = "AddressBookSpy/ABSViewController.m" | ||
timestampString = "352071585.881848" | ||
startingColumnNumber = "9223372036854775807" | ||
endingColumnNumber = "9223372036854775807" | ||
startingLineNumber = "11" | ||
endingLineNumber = "11" | ||
landmarkName = "@implementation ABSViewController" | ||
landmarkType = "3"> | ||
</FileBreakpoint> | ||
</FileBreakpoints> | ||
</Bucket> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// ABSEngine.h | ||
// AddressBookSpy | ||
// | ||
// Created by Johannes Fahrenkrug on 27.02.12. | ||
// Copyright (c) 2012 Springenwerk. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <JavaScriptCore/JavaScriptCore.h> | ||
|
||
@interface ABSEngine : NSObject { | ||
JSGlobalContextRef _JSContext; | ||
} | ||
|
||
- (JSGlobalContextRef) JSContext; | ||
- (NSString *)runJS:(NSString *)aJSString; | ||
- (void)loadJSLibrary:(NSString*)libraryName; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// ABSEngine.m | ||
// AddressBookSpy | ||
// | ||
// Created by Johannes Fahrenkrug on 27.02.12. | ||
// Copyright (c) 2012 Springenwerk. All rights reserved. | ||
// | ||
|
||
#import "ABSEngine.h" | ||
|
||
@implementation ABSEngine | ||
|
||
/** | ||
Lazily initializes and returns a JS context | ||
*/ | ||
- (JSGlobalContextRef)JSContext | ||
{ | ||
if (_JSContext == NULL) { | ||
_JSContext = JSGlobalContextCreate(NULL); | ||
} | ||
|
||
return _JSContext; | ||
} | ||
|
||
/** | ||
Runs a string of JS in this instance's JS context and returns the result as a string | ||
*/ | ||
- (NSString *)runJS:(NSString *)aJSString | ||
{ | ||
if (!aJSString) { | ||
NSLog(@"[JSC] JS String is empty!"); | ||
return nil; | ||
} | ||
|
||
|
||
JSStringRef scriptJS = JSStringCreateWithUTF8CString([aJSString UTF8String]); | ||
JSValueRef exception = NULL; | ||
|
||
JSValueRef result = JSEvaluateScript([self JSContext], scriptJS, NULL, NULL, 0, &exception); | ||
NSString *res = nil; | ||
|
||
if (!result) { | ||
if (exception) { | ||
JSStringRef exceptionArg = JSValueToStringCopy([self JSContext], exception, NULL); | ||
NSString* exceptionRes = (__bridge NSString*)JSStringCopyCFString(kCFAllocatorDefault, exceptionArg); | ||
|
||
JSStringRelease(exceptionArg); | ||
NSLog(@"[JSC] JavaScript exception: %@", exceptionRes); | ||
} | ||
|
||
NSLog(@"[JSC] No result returned"); | ||
} else { | ||
JSStringRef jstrArg = JSValueToStringCopy([self JSContext], result, NULL); | ||
res = (__bridge NSString*)JSStringCopyCFString(kCFAllocatorDefault, jstrArg); | ||
|
||
JSStringRelease(jstrArg); | ||
} | ||
|
||
JSStringRelease(scriptJS); | ||
|
||
return res; | ||
} | ||
|
||
/** | ||
Loads a JS library file from the app's bundle (without the .js extension) | ||
*/ | ||
- (void)loadJSLibrary:(NSString*)libraryName { | ||
NSString *library = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:libraryName ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]; | ||
|
||
NSLog(@"[JSC] loading library %@...", libraryName); | ||
[self runJS:library]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters