[Kst] kdeextragear-2/kst/kst/extensions/js

George Staikos staikos at kde.org
Tue Mar 29 05:54:19 CEST 2005


CVS commit by staikos: 

- add the vector and scalar lists
- create objects for scalars
- add ability to get pointers to vectors and scalars


  A            bind_kst.cpp   1.1 [GPL (v2+)]
  A            bind_kst.h   1.1 [GPL (v2+)]
  A            bind_scalar.cpp   1.1 [GPL (v2+)]
  A            bind_scalar.h   1.1 [GPL (v2+)]
  M +2 -1      Makefile.am   1.9
  M +11 -2     bind_vector.cpp   1.3
  M +1 -0      bind_vector.h   1.3
  M +4 -0      js.cpp   1.11
  M +2 -2      kstbinding.cpp   1.2
  M +3 -2      kstbinding.h   1.2


--- kdeextragear-2/kst/kst/extensions/js/Makefile.am  #1.8:1.9
@@ -11,5 +11,6 @@
 kstextension_js_la_LIBADD=../../libkstguiapp.la ../../libkstmath.la ../../libkst.la $(LIB_KDEPRINT) -lkjsembed
 kstextension_js_la_SOURCES=js.cpp jsiface.skel jsiface_impl.cpp \
-                        kstbinding.cpp bind_vector.cpp
+                        kstbinding.cpp bind_vector.cpp bind_kst.cpp \
+                        bind_scalar.cpp
 
 

--- kdeextragear-2/kst/kst/extensions/js/bind_vector.cpp  #1.2:1.3
@@ -24,4 +24,11 @@
 using namespace KJSEmbed;
 
+KstBindVector::KstBindVector(KJS::ExecState *exec, KstVectorPtr v)
+: KstBinding("Vector"), _v(v) {
+  KJS::Object o(this);
+  addBindings(exec, o);
+}
+
+
 KstBindVector::KstBindVector(KJS::ExecState *exec, KJS::Object *globalObject)
 : KstBinding("Vector") {
@@ -71,5 +78,6 @@ KJS::Value KstBindVector::call(KJS::Exec
   int id = this->id();
   if (id <= 0) {
-    // FIXME: should we throw an exception or return an error instead?
+    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+    exec->setException(eobj);
     return KJS::Value();
   }
@@ -77,5 +85,6 @@ KJS::Value KstBindVector::call(KJS::Exec
   KstBindVector *imp = dynamic_cast<KstBindVector*>(self.imp());
   if (!imp) {
-    // FIXME: should we throw an exception or return an error instead?
+    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+    exec->setException(eobj);
     return KJS::Value();
   }

--- kdeextragear-2/kst/kst/extensions/js/bind_vector.h  #1.2:1.3
@@ -30,4 +30,5 @@ using namespace KJSEmbed;
 class KstBindVector : public KstBinding {
   public:
+    KstBindVector(KJS::ExecState *exec, KstVectorPtr v);
     KstBindVector(KJS::ExecState *exec, KJS::Object *globalObject = 0L);
     ~KstBindVector();

--- kdeextragear-2/kst/kst/extensions/js/js.cpp  #1.10:1.11
@@ -35,4 +35,6 @@
 #include <kparts/part.h>
 
+#include "bind_kst.h"
+#include "bind_scalar.h"
 #include "bind_vector.h"
 
@@ -83,4 +85,6 @@ void KstJS::createBindings() {
   KJS::Object globalObj = _jsPart->globalObject();
   new KstBindVector(exec, &globalObj); // FIXME: LEAKED?
+  new KstBindScalar(exec, &globalObj); // FIXME: LEAKED?
+  new KstBindKst(exec, &globalObj); // FIXME: LEAKED?
 }
 

--- kdeextragear-2/kst/kst/extensions/js/kstbinding.cpp  #1.1:1.2
@@ -20,6 +20,6 @@
 using namespace KJSEmbed;
 
-KstBinding::KstBinding(const QString& name)
-: JSProxy(JSProxy::BuiltinProxy), _name(name), _id(KST_BINDING_CONSTRUCTOR) {
+KstBinding::KstBinding(const QString& name, bool hasConstructor)
+: JSProxy(JSProxy::BuiltinProxy), _name(name), _id(hasConstructor ? KST_BINDING_CONSTRUCTOR : KST_BINDING_NOCONSTRUCTOR) {
 }
 

--- kdeextragear-2/kst/kst/extensions/js/kstbinding.h  #1.1:1.2
@@ -21,9 +21,10 @@
 #include <kjsembed/jsproxy.h>
 
+#define KST_BINDING_NOCONSTRUCTOR -1
 #define KST_BINDING_CONSTRUCTOR 0
 
 class KstBinding : public KJSEmbed::JSProxy {
   public:
-    KstBinding(const QString& name);
+    KstBinding(const QString& name, bool hasConstructor = true);
     virtual ~KstBinding();
 




More information about the Kst mailing list