From 51b6165e0dd24e4d40ff80e504922f705ddd7b62 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 20 Jan 2014 04:42:39 -0800 Subject: [PATCH] Add a new ?gc to run GC without running a script. --- Console.cpp | 2 ++ Execute.cpp | 7 ++++++- JavaScript.hpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Console.cpp b/Console.cpp index ec849fe..f7c6a0a 100644 --- a/Console.cpp +++ b/Console.cpp @@ -499,6 +499,8 @@ static void Console(CYOptions &options) { *out_ << "debug == " << (debug ? "true" : "false") << std::endl; } else if (data == "destroy") { CYDestroyContext(); + } else if (data == "gc") { + CYGarbageCollect(CYGetJSContext()); } else if (data == "expand") { expand = !expand; *out_ << "expand == " << (expand ? "true" : "false") << std::endl; diff --git a/Execute.cpp b/Execute.cpp index b2e0e0a..a71d29f 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -342,8 +342,13 @@ static JSValueRef $cyq(JSContextRef context, JSObjectRef object, JSObjectRef _th return CYCastJSValue(context, name); } CYCatch(NULL) } -static JSValueRef Cycript_gc_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { + +void CYGarbageCollect(JSContextRef context) { JSGarbageCollect(context); +} + +static JSValueRef Cycript_gc_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { + CYGarbageCollect(context); return CYJSUndefined(context); } CYCatch(NULL) } diff --git a/JavaScript.hpp b/JavaScript.hpp index b863a93..c8a8fd8 100644 --- a/JavaScript.hpp +++ b/JavaScript.hpp @@ -143,6 +143,7 @@ JSStringRef CYCopyJSString(JSStringRef value); JSStringRef CYCopyJSString(CYUTF8String value); JSStringRef CYCopyJSString(JSContextRef context, JSValueRef value); +void CYGarbageCollect(JSContextRef context); void CYDestroyContext(); class CYJSString { -- 2.47.2