X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/7ba62cfde8941d0c5ff27a789c8b81796c0847bb..a2d9403cf5757908ff5912e7312d595c88700da2:/Application.mm diff --git a/Application.mm b/Application.mm index a5be46b..106c7dd 100644 --- a/Application.mm +++ b/Application.mm @@ -1,51 +1,7 @@ -#include -#include +#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#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); - - if (!JSValueIsUndefined(JSGetContext(), result)) { - CFStringRef json(JSValueToJSONCopy(JSGetContext(), result)); - std::cout << [reinterpret_cast(json) UTF8String] << std::endl; - CFRelease(json); - } - - [pool release]; - } - - return 0; + return CYConsole(stdin, stdout, stderr); }