[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs
From:       Anders Lund <anders () alweb ! dk>
Date:       2005-03-24 23:29:47
Message-ID: 20050324232947.E6FB35B6 () office ! kde ! org
[Download RAW message or body]

CVS commit by alund: 

Add a debug area fro kate kjs scripts
Add a stub for global methods to kate kjs script, with one method: debug(string)
This will print a message throught kdDebug, using the new area.


  M +41 -6     kate/part/katejscript.cpp   1.27
  M +1 -0      kdecore/kdebug.areas   1.334


--- kdelibs/kdecore/kdebug.areas  #1.333:1.334
@@ -372,4 +372,5 @@
 13040   Kate (Plugins)
 13050   Kate (Scripting)
+13051   Kate (KJS Scripts)
 
 # Kopete

--- kdelibs/kate/part/katejscript.cpp  #1.26:1.27
@@ -68,5 +68,38 @@ QConstString UString::qconststring() con
 }
 
+//BEGIN global methods
+class KateJSGlobalFunctions : public ObjectImp
+{
+  public:
+    KateJSGlobalFunctions(int i, int length);
+    virtual bool implementsCall() const { return true; }
+    virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+
+    enum {
+      Debug
+    };
+
+  private:
+    int id;
+};
+KateJSGlobalFunctions::KateJSGlobalFunctions(int i, int length) : ObjectImp(), id(i)
+{
+  putDirect(lengthPropertyName,length,DontDelete|ReadOnly|DontEnum);
 }
+Value KateJSGlobalFunctions::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+{
+  switch (id) {
+    case Debug:
+      kdDebug(13051) << args[0].toString(exec).ascii() << endl;
+      return Undefined();
+    default:
+      break;
+  }
+
+  return Undefined();
+}
+//END global methods
+
+} // namespace KJS
 
 //BEGIN JS API STUFF
@@ -156,4 +189,6 @@ KateJScript::KateJScript ()
   m_interpreter->globalObject().put(m_interpreter->globalExec(), "document", *m_document);
   m_interpreter->globalObject().put(m_interpreter->globalExec(), "view", *m_view);
+  m_interpreter->globalObject().put(m_interpreter->globalExec(), "debug",
+        KJS::Object(new KateJSGlobalFunctions(KateJSGlobalFunctions::Debug,1)));
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic