[Kst] kdeextragear-2/kst/kst/extensions/js
George Staikos
staikos at kde.org
Tue Mar 29 00:30:07 CEST 2005
CVS commit by staikos:
looks like this is the approach to take for doing the Kst bindings. This
creates a Vector binding with a length() method that returns nothing presently
A bind_vector.cpp 1.1 [GPL (v2+)]
A bind_vector.h 1.1 [GPL (v2+)]
A kstbinding.cpp 1.1 [GPL (v2+)]
A kstbinding.h 1.1 [GPL (v2+)]
M +2 -1 Makefile.am 1.7
M +14 -3 js.cpp 1.9
M +2 -0 js.h 1.9
R jsproxies.cpp 1.3
R jsproxies.h 1.2
--- kdeextragear-2/kst/kst/extensions/js/Makefile.am #1.6:1.7
@@ -10,5 +10,6 @@
kstextension_js_la_LDFLAGS=$(all_libraries) -module -avoid-version
kstextension_js_la_LIBADD=../../libkst.la $(LIB_KPARTS) -lkjsembed
-kstextension_js_la_SOURCES=js.cpp jsproxies.cpp jsiface.skel jsiface_impl.cpp
+kstextension_js_la_SOURCES=js.cpp jsiface.skel jsiface_impl.cpp \
+ kstbinding.cpp bind_vector.cpp
--- kdeextragear-2/kst/kst/extensions/js/js.cpp #1.8:1.9
@@ -18,5 +18,4 @@
#include "js.h"
#include "jsiface_impl.h"
-#include "jsproxies.h"
#include <kst.h>
@@ -31,8 +30,11 @@
#include <kjsembed/jsconsolewidget.h>
#include <kjsembed/jsfactory.h>
+#include <kjsembed/jsproxy.h>
#include <kjsembed/jssecuritypolicy.h>
#include <kmessagebox.h>
#include <kparts/part.h>
+#include "bind_vector.h"
+
K_EXPORT_COMPONENT_FACTORY(kstextension_js, KGenericFactory<KstJS>)
@@ -44,9 +46,9 @@ KstJS::KstJS(QObject *parent, const char
// FIXME: bad
_jsPart->addObject(app(), "kst");
- KstJSDataProxy *dataProxy = new KstJSDataProxy(_jsPart->factory(), this, "data");
- _jsPart->addObject(dataProxy, "data");
_jsPart->factory()->addType("KstJSUIBuilder");
_jsPart->factory()->addType("KActionCollection");
+ createBindings();
+
_showAction = new KToggleAction(i18n("Show &JavaScript Console"), 0, 0, 0, 0, actionCollection(), "js_console_show");
connect(_showAction, SIGNAL(toggled(bool)), this, SLOT(doShow(bool)));
@@ -77,4 +79,13 @@ KstJS::~KstJS() {
+void KstJS::createBindings() {
+ KJS::ExecState *exec = _jsPart->globalExec();
+ KJS::Object globalObj = _jsPart->globalObject();
+ KJS::Object bindObj;
+ bindObj = KJS::Object(new KstBindVector(exec)); // FIXME: LEAKED?
+ globalObj.put(exec, "Vector", bindObj);
+}
+
+
static char shellStr[30];
--- kdeextragear-2/kst/kst/extensions/js/js.h #1.8:1.9
@@ -61,4 +61,6 @@ class KstJS : public KstExtension, publi
private:
+ void createBindings();
+
QStringList _scripts;
KJSEmbed::KJSEmbedPart *_jsPart;
More information about the Kst
mailing list