]> git.saurik.com Git - cycript.git/blobdiff - Application.mm
Checkpoint before something drastic.
[cycript.git] / Application.mm
index f14cb5ce17d5066bd2a41e5ed57b2729a7f4afc8..106c7ddb07aa91e53edf0afc5159c26904a38f2c 100644 (file)
@@ -1,49 +1,7 @@
-#include <iostream>
-#include <string>
+#include <cstdio>
 
-#include <CoreFoundation/CoreFoundation.h>
-#include <CoreFoundation/CFLogUtilities.h>
-
-#include <Foundation/Foundation.h>
-
-#include <JavaScriptCore/JSBase.h>
-#include <JavaScriptCore/JSValueRef.h>
-#include <JavaScriptCore/JSObjectRef.h>
-#include <JavaScriptCore/JSContextRef.h>
-#include <JavaScriptCore/JSStringRef.h>
-#include <JavaScriptCore/JSStringRefCF.h>
-
-#define _trace() do { \
-    CFLog(kCFLogLevelNotice, CFSTR("_trace(%u)"), __LINE__); \
-} while (false)
-
-JSContextRef JSGetContext(void);
-CFStringRef JSValueToJSONCopy(JSContextRef ctx, JSValueRef value);
+int CYConsole(FILE *in, FILE *out, FILE *err);
 
 int main() {
-    for (;;) {
-        NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
-
-        std::cout << ">>> " << std::flush;
-
-        std::string line;
-        if (!std::getline(std::cin, line))
-            break;
-
-        JSStringRef script(JSStringCreateWithUTF8CString(line.c_str()));
-
-        JSValueRef exception;
-        JSValueRef result(JSEvaluateScript(JSGetContext(), script, NULL, NULL, 0, &exception));
-        if (result == NULL)
-            result = exception;
-        JSStringRelease(script);
-
-        CFStringRef json(JSValueToJSONCopy(JSGetContext(), result));
-        std::cout << [reinterpret_cast<const NSString *>(json) UTF8String] << std::endl;
-        CFRelease(json);
-
-        [pool release];
-    }
-
-    return 0;
+    return CYConsole(stdin, stdout, stderr);
 }