void KstJS::resetInterpreter() { // FIXME: save and restore the script registry _jsPart->globalObject().imp()->deleteAllProperties(_jsPart->globalExec()); while (KJS::Interpreter::collect()) {} _jsPart->interpreter()->initGlobalObject(); delete _jsPart->builtins; KJS::Object obj = _jsPart->globalObject(); _jsPart->createBuiltIn(_jsPart->globalExec(), obj); createBindings(); }
KstJS::KstJS(QObject *parent, const char *name, const QStringList& l) : KstExtension(parent, name, l), KXMLGUIClient() { KJSEmbed::JSSecurityPolicy::setDefaultPolicy(KJSEmbed::JSSecurityPolicy::CapabilityAll); _jsPart = new KJSEmbed::KJSEmbedPart(0L, "javascript", this, "kjsembedpart"); createBindings(); #ifdef KST_HAVE_READLINE _showAction = new KToggleAction(i18n("Show &JavaScript Console"), 0, 0, 0, 0, actionCollection(), "js_console_show"); connect(_showAction, SIGNAL(toggled(bool)), this, SLOT(doShow(bool))); #endif new KAction(i18n("Load JavaScript..."), 0, 0, this, SLOT(loadScript()), actionCollection(), "js_load"); new KAction(i18n("Clear JavaScript &Interpreter"), 0, 0, this, SLOT(resetInterpreter()), actionCollection(), "js_reset"); setInstance(app()->instance()); setXMLFile("kstextension_js.rc", true); app()->guiFactory()->addClient(this); _merge = new KstUIMerge(this, "KstUIMerge"); _jsPart->addObject(_merge, _merge->name()); createRegistry(); _iface = new JSIfaceImpl(_jsPart); _splitter = 0L; _konsolePart = 0L; }