Last active
October 17, 2016 01:05
-
-
Save Kureev/24c173b74f7caaf9cebc22daa2d11859 to your computer and use it in GitHub Desktop.
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
@implementation ChakraProxy | |
-(void)run { | |
unsigned currentSourceContext = 0; | |
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"main" ofType:@"js"]; | |
NSError *error; | |
NSString *fileContents = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:&error]; | |
if (error) { | |
NSLog(@"Error reading file: %@", error.localizedDescription); | |
} | |
const char *script = [fileContents cStringUsingEncoding:NSASCIIStringEncoding]; | |
// Create a runtime | |
JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime); | |
// Create a context | |
JsCreateContext(runtime, &context); | |
JsSetCurrentContext(context); | |
// Run script | |
JsRunScriptUtf8(script, currentSourceContext++, "", nullptr); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment