forked from 280north/narwhal-jsc
-
Notifications
You must be signed in to change notification settings - Fork 4
/
narwhal-jsc.c
53 lines (45 loc) · 1.43 KB
/
narwhal-jsc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <narwhal.h>
#ifdef JSCOCOA
#import <JSCocoa/JSCocoa.h>
#endif
#ifdef WEBKIT
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>
#elif WEBKIT_DEBUG
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <WebKit/WebKit.h>
#import "NWDebug.h"
#endif
int main(int argc, char *argv[], char *envp[])
{
#ifdef WEBKIT
NSAutoreleasePool *pool = [NSAutoreleasePool new];
WebView *webView = [[WebView alloc] init];
JSGlobalContextRef _context = [[webView mainFrame] globalContext];
#elif WEBKIT_DEBUG
NSAutoreleasePool *pool = [NSAutoreleasePool new];
WebView *webView = NW_init(argc, argv, envp);
JSGlobalContextRef _context = [[webView mainFrame] globalContext];
#elif defined(JSCOCOA)
NSAutoreleasePool *pool = [NSAutoreleasePool new];
JSCocoaController *jsc = [JSCocoa new];
JSGlobalContextRef _context = [jsc ctx];
#else
JSGlobalContextRef _context = JSGlobalContextCreate(NULL);
#endif
#ifdef WEBKIT_DEBUG
return NSApplicationMain(argc, (const char **)argv);
#else
JSValueRef exception = NULL;
JSValueRef *_exception = &exception;
CALL(narwhal, argc, argv, envp, 1);
int code = !!(*_exception);
#ifdef WEBKIT
[pool drain];
#elif defined(JSCOCOA)
[pool drain];
#endif
return code;
#endif
}