[Kst] kdeextragear-2/kst/kst/extensions/js
George Staikos
staikos at kde.org
Thu Apr 7 23:35:16 CEST 2005
CVS commit by staikos:
resetInterpreter() was nuking KJSEmbed too. D'oh. No way to do it cleanly in
KJSEmbed yet, but will be fixed eventually says Ian.
M +23 -8 js.cpp 1.24
M +1 -0 js.h 1.12
--- kdeextragear-2/kst/kst/extensions/js/js.cpp #1.23:1.24
@@ -16,4 +16,10 @@
***************************************************************************/
+#define private public
+#define protected public
+#include <kjsembed/kjsembedpart.h>
+#undef protected
+#undef private
+
#include "js.h"
#include "jsiface_impl.h"
@@ -27,5 +33,5 @@
#include <kfiledialog.h>
#include <kgenericfactory.h>
-#include <kjsembed/kjsembedpart.h>
+#include <kjsembed/jsbuiltin.h>
#include <kjsembed/jsconsolewidget.h>
#include <kjsembed/jsfactory.h>
@@ -57,9 +63,4 @@ KstJS::KstJS(QObject *parent, const char
KJSEmbed::JSSecurityPolicy::setDefaultPolicy(KJSEmbed::JSSecurityPolicy::CapabilityAll);
_jsPart = new KJSEmbed::KJSEmbedPart(0L, "javascript", this, "kjsembedpart");
- // FIXME: bad
- _jsPart->addObject(app(), "kst");
- _jsPart->factory()->addType("KstJSUIBuilder");
- _jsPart->factory()->addType("KActionCollection");
-
createBindings();
@@ -72,6 +73,6 @@ KstJS::KstJS(QObject *parent, const char
app()->guiFactory()->addClient(this);
- KstUIMerge *m = new KstUIMerge(this, "KstUIMerge");
- _jsPart->addObject(m, m->name());
+ _merge = new KstUIMerge(this, "KstUIMerge");
+ _jsPart->addObject(_merge, _merge->name());
createRegistry();
@@ -94,4 +95,12 @@ KstJS::~KstJS() {
void KstJS::createBindings() {
+ // FIXME: bad
+ _jsPart->addObject(app(), "kst");
+ _jsPart->factory()->addType("KstJSUIBuilder");
+ _jsPart->factory()->addType("KActionCollection");
+ if (_merge) {
+ _jsPart->addObject(_merge, _merge->name());
+ }
+
KJS::ExecState *exec = _jsPart->globalExec();
KJS::Object globalObj = _jsPart->globalObject();
@@ -116,11 +125,17 @@ void KstJS::createBindings() {
new KstBindDebug(exec, &globalObj);
new KstBindKst(exec, &globalObj, this);
+
+ createRegistry();
}
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();
}
--- kdeextragear-2/kst/kst/extensions/js/js.h #1.11:1.12
@@ -72,4 +72,5 @@ class KstJS : public KstExtension, publi
QGuardedPtr<QWidget> _oldCentralWidget;
KToggleAction *_showAction;
+ QGuardedPtr<QObject> _merge;
};
More information about the Kst
mailing list