} else if (data == "debug") {
debug = !debug;
*out_ << "debug == " << (debug ? "true" : "false") << std::endl;
+ } else if (data == "destroy") {
+ CYDestroyContext();
} else if (data == "expand") {
expand = !expand;
*out_ << "expand == " << (expand ? "true" : "false") << std::endl;
CYRunSetups(context);
}
+static JSGlobalContextRef context_;
+
JSGlobalContextRef CYGetJSContext() {
CYInitializeDynamic();
- static JSGlobalContextRef context_;
-
if (context_ == NULL) {
context_ = JSGlobalContextCreate(Global_);
CYSetupContext(context_);
return context_;
}
+
+void CYDestroyContext() {
+ if (context_ == NULL)
+ return;
+ JSGlobalContextRelease(context_);
+ context_ = NULL;
+}
JSStringRef CYCopyJSString(CYUTF8String value);
JSStringRef CYCopyJSString(JSContextRef context, JSValueRef value);
+void CYDestroyContext();
+
class CYJSString {
private:
JSStringRef string_;