Code

Deweirdification of user visible messages as proposed by Tav
[inkscape.git] / src / bind / javabind.h
index f01627a1533125e20366991ce676a8bdc214109b..894f52d5dddffe902625054a7b4d97ffbbf34f8f 100644 (file)
@@ -1,7 +1,6 @@
-#ifndef __JAVABIND_H__
-#define __JAVABIND_H__
 /**
- * This is a simple mechanism to bind Inkscape to Java, and thence
+ * @file
+ * @brief This is a simple mechanism to bind Inkscape to Java, and thence
  * to all of the nice things that can be layered upon that. 
  *
  * Authors:
@@ -24,6 +23,9 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#ifndef __JAVABIND_H__
+#define __JAVABIND_H__
+
 #include <glibmm.h>
 #include <vector>
 
@@ -41,6 +43,28 @@ namespace Bind
 typedef Glib::ustring String;
 
 
+/**
+ * This is the base class of all things which will be C++ object
+ * instances
+ */  
+class BaseObject
+{
+public:
+
+    /**
+     * Simple constructor
+     */             
+    BaseObject()
+        {}
+
+    /**
+     * Destructor
+     */             
+    virtual ~BaseObject()
+        {}
+
+};
+
 
 /**
  *
@@ -58,7 +82,8 @@ public:
         BIND_INT,
         BIND_BOOLEAN,
         BIND_DOUBLE,
-        BIND_STRING
+        BIND_STRING,
+        BIND_OBJECT
         } ValueType;
 
     /**
@@ -69,6 +94,42 @@ public:
         init();
         }
 
+    /**
+     *
+     */
+    Value(int ival)
+        {
+        init();
+        setInt(ival);
+        }
+
+    /**
+     *
+     */
+    Value(bool bval)
+        {
+        init();
+        setBoolean(bval);
+        }
+
+    /**
+     *
+     */
+    Value(double dval)
+        {
+        init();
+        setDouble(dval);
+        }
+
+    /**
+     *
+     */
+    Value(const String &sval)
+        {
+        init();
+        setString(sval);
+        }
+
     /**
      *
      */
@@ -240,7 +301,8 @@ public:
     /**
      *
      */
-    virtual bool callMain(const String &/*className*/)
+    virtual bool callMain(const String &/*className*/,
+                             const std::vector<String> &/*args*/)
         {
         return false;
         }
@@ -256,39 +318,61 @@ public:
     /**
      *
      */
-    virtual bool doBinding()
+    virtual bool scriptRun(const String &/*lang*/, const String &/*script*/)
         {
         return false;
         }
-        
-    virtual String stdOutGet()
+
+    /**
+     *
+     */
+    virtual bool scriptRunFile(const String &/*lang*/, const String &/*fileName*/)
         {
-        return stdOutBuf;
+        return false;
         }
 
-    virtual void stdOutClear()
+    /**
+     *
+     */
+    virtual bool showConsole()
         {
-        stdOutBuf.clear();
+        return false;
         }
 
-    virtual String stdErrGet()
+    /**
+     *
+     */
+    virtual bool doBinding()
         {
-        return stdErrBuf;
+        return false;
         }
-
-    virtual void stdErrClear()
+        
+    /**
+     *
+     */
+    virtual String getException()
+        {
+               return "";
+               }
+        
+    virtual String logGet()
         {
-        stdErrBuf.clear();
+        return logBuf;
         }
 
-    virtual void stdOut(int ch)
+    virtual void logClear()
         {
-        stdOutBuf.push_back((char)ch);
+        logBuf.clear();
         }
 
-    virtual void stdErr(int ch)
+    virtual void log(int ch)
         {
-        stdErrBuf.push_back((char)ch);
+        logBuf.push_back((char)ch);
+        if (ch == '\n' || ch == '\r')
+            {
+            g_message("%s", logBuf.c_str());
+            logBuf.clear();
+                       }
         }
 
 
@@ -302,6 +386,7 @@ protected:
 
     String stdOutBuf;
     String stdErrBuf;
+    String logBuf;
 
 };