]> git.tokkee.org Git - inkscape.git/commitdiff

Code

const types
authorishmal <ishmal@users.sourceforge.net>
Sat, 6 May 2006 21:45:01 +0000 (21:45 +0000)
committerishmal <ishmal@users.sourceforge.net>
Sat, 6 May 2006 21:45:01 +0000 (21:45 +0000)
src/extension/script/InkscapeInterpreter.cpp
src/extension/script/InkscapeInterpreter.h
src/extension/script/InkscapePerl.cpp
src/extension/script/InkscapePerl.h
src/extension/script/InkscapePython.cpp
src/extension/script/InkscapePython.h
src/extension/script/InkscapeScript.cpp
src/extension/script/InkscapeScript.h

index 4342922b15a29dacba6e4b81b6f8ffa561ff7b88..c28163489a2aa12c4a55d7103ea25b991930b29b 100644 (file)
@@ -24,7 +24,7 @@ InkscapeInterpreter::InkscapeInterpreter()
 {
 }
 
-    
+
 
 /*
  *
@@ -34,40 +34,40 @@ InkscapeInterpreter::~InkscapeInterpreter()
 
 }
 
-    
-    
+
+
 
 /*
  *  Interpret an in-memory string
  */
-bool InkscapeInterpreter::interpretScript(Glib::ustring &script,
-                                 Glib::ustring &output,
-                                 Glib::ustring &error)
+bool InkscapeInterpreter::interpretScript(const Glib::ustring &script,
+                                          Glib::ustring &output,
+                                          Glib::ustring &error)
 {
     //do nothing.  let the subclasses implement this
     return true;
 }
 
-    
-    
+
+
 
 /*
  *  Interpret a named file
  */
-bool InkscapeInterpreter::interpretUri(Glib::ustring &uri,
-                                 Glib::ustring &output,
-                                 Glib::ustring &error)
+bool InkscapeInterpreter::interpretUri(const Glib::ustring &uri,
+                                       Glib::ustring &output,
+                                       Glib::ustring &error)
 {
     char *curi = (char *)uri.raw().c_str();
     std::ifstream ins(curi);
     if (!ins.good())
         {
-        printf("interpretUri: Could not open %s for reading\n", curi);
+        g_error("interpretUri: Could not open %s for reading\n", curi);
         return false;
         }
-        
+
     Glib::ustring buf;
-    
+
     while (!ins.eof())
         {
         gunichar ch = (gunichar) ins.get();
@@ -75,7 +75,7 @@ bool InkscapeInterpreter::interpretUri(Glib::ustring &uri,
         }
 
     ins.close();
-    
+
     bool ret = interpretScript(buf, output, error);
 
     return ret;
index 9dd585d0d8376d42d7c9256ee74bb6b440ebe032..7d16ed9794033f2111b576f0ce4add659179cae1 100644 (file)
@@ -36,14 +36,14 @@ public:
     /**
      *
      */
-    virtual bool interpretScript(Glib::ustring &script,
+    virtual bool interpretScript(const Glib::ustring &script,
                                  Glib::ustring &output,
                                  Glib::ustring &error);
 
     /**
      *
      */
-    virtual bool interpretUri(Glib::ustring &uri,
+    virtual bool interpretUri(const Glib::ustring &uri,
                               Glib::ustring &output,
                               Glib::ustring &error);
 
index 7b3c3c1a5e9d3b4e76e0d413744d0149ea10be32..1a4c61bcc2a5ebf4ca3213052012f49c6ca499dd 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
+
 
 
 #include "InkscapePerl.h"
@@ -40,7 +40,7 @@ InkscapePerl::InkscapePerl()
 {
 }
 
-    
+
 
 /*
  *
@@ -50,13 +50,13 @@ InkscapePerl::~InkscapePerl()
 
 }
 
-    
-    
 
 
-bool InkscapePerl::interpretScript(Glib::ustring &script,
-                                 Glib::ustring &output,
-                                 Glib::ustring &error)
+
+
+bool InkscapePerl::interpretScript(const Glib::ustring &script,
+                                   Glib::ustring &output,
+                                   Glib::ustring &error)
 {
     char *codeBuf = (char *)script.raw().c_str();
     int ret = InkscapePerlParseBuf(inkscape_module_script, codeBuf);
@@ -66,7 +66,7 @@ bool InkscapePerl::interpretScript(Glib::ustring &script,
         }
     return true;
 }
-    
+
 
 
 
index 0ec79a9cd9b33a1a0faa74c34bc5e459520c3c8e..0b93140090af89a1f23357865e29370e8600da4c 100644 (file)
@@ -11,7 +11,7 @@
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
+
 #include "InkscapeInterpreter.h"
 #include <glibmm.h>
 
@@ -28,23 +28,23 @@ public:
      *
      */
     InkscapePerl();
-    
+
 
     /*
      *
      */
     virtual ~InkscapePerl();
-    
-    
+
+
 
     /*
      *
      */
-    bool interpretScript(Glib::ustring &script,
+    bool interpretScript(const Glib::ustring &script,
                          Glib::ustring &output,
                          Glib::ustring &error);
-    
-    
+
+
 
 
 
index eca09951aea1389d73216e8bb0787a52a62c2353..49e6a11a288789a8d35c499819b5ed5136b85348 100644 (file)
@@ -37,7 +37,7 @@ InkscapePython::InkscapePython()
 {
 }
 
-    
+
 
 /*
  *
@@ -47,15 +47,15 @@ InkscapePython::~InkscapePython()
 
 }
 
-    
-    
+
+
 static bool initialized = false;
 /*
  *  Interpret an in-memory string
  */
-bool InkscapePython::interpretScript(Glib::ustring &script,
-                                 Glib::ustring &output,
-                                 Glib::ustring &error)
+bool InkscapePython::interpretScript(const Glib::ustring &script,
+                                     Glib::ustring &output,
+                                     Glib::ustring &error)
 {
     if (!initialized)
         {
@@ -67,7 +67,7 @@ bool InkscapePython::interpretScript(Glib::ustring &script,
     PyRun_SimpleString(inkscape_module_script);
     PyRun_SimpleString("inkscape = _inkscape_py.getInkscape()\n");
     PyRun_SimpleString(codeStr);
-    
+
     //## Check for errors
     if (PyErr_Occurred())
         {
@@ -77,7 +77,7 @@ bool InkscapePython::interpretScript(Glib::ustring &script,
 
         PyErr_Fetch(&errobj, &errdata, &errtraceback);
         //PyErr_Clear();
-        
+
         if (errobj && PyString_Check(errobj))
             {
             PyObject *pystring = PyObject_Str(errobj);
@@ -98,8 +98,8 @@ bool InkscapePython::interpretScript(Glib::ustring &script,
     return true;
 }
 
-    
-    
+
+
 
 
 
index fdcd4906f9ba850fb3e6827e49636becb613c225..cdf9bd0f1771d3ffd383585347f7c7a246b45b8d 100644 (file)
@@ -29,25 +29,25 @@ public:
      *
      */
     InkscapePython();
-    
+
 
     /*
      *
      */
     virtual ~InkscapePython();
-    
-    
+
+
 
     /*
      *
      */
-    virtual bool interpretScript(Glib::ustring &script,
+    virtual bool interpretScript(const Glib::ustring &script,
                                  Glib::ustring &output,
                                  Glib::ustring &error);
-    
-    
 
-    
+
+
+
 private:
 
 
index cc9271caa1caea10b90096e1470fd5bd187d5972..87d120245f038983fc15780bb8c3bb18d49ff84d 100644 (file)
@@ -32,9 +32,6 @@ namespace Script {
  */
 InkscapeScript::InkscapeScript()
 {
-
-
-
 }
 
 
@@ -45,24 +42,22 @@ InkscapeScript::InkscapeScript()
  */
 InkscapeScript::~InkscapeScript()
 {
-
-
 }
 
 
 
 
 /**
- *
+ * Interprets the script in the 'script' buffer,
+ * storing the stdout output in 'output', and any
+ * error messages in 'error.'  Language is one of the
+ * enumerated types in ScriptLanguage above.
  */
-bool InkscapeScript::interpretScript(Glib::ustring &script,
+bool InkscapeScript::interpretScript(const Glib::ustring &script,
                                  Glib::ustring &output,
                                  Glib::ustring &error,
                                  ScriptLanguage language)
 {
-#ifndef __GNUC__
-    static char const __FUNCTION__[] = "interpretScript";
-#endif
     char * langname=NULL;
     InkscapeInterpreter *interp = NULL;
     //if() instead of switch() lets us scope vars
@@ -82,35 +77,37 @@ bool InkscapeScript::interpretScript(Glib::ustring &script,
         }
     else
         {
-        //replace with g_error
-        fprintf(stderr, "%s: Unknown Script Language type: %d\n",
-                        __FUNCTION__, language);
+        g_error("interpretScript: Unknown Script Language type: %d\n",
+                        language);
         return false;
         }
-        
+
     if (!interp)
         {
-        fprintf(stderr, "%s: error starting Language '%s'\n",
-                        __FUNCTION__, langname);
+        g_error("interpretScript: error starting Language '%s'\n",
+                        langname);
         return false;
         }
 
     if (!interp->interpretScript(script, output, error))
         {
-        fprintf(stderr, "%s: error in executing %s script\n",
-                        __FUNCTION__, langname);
+        g_error("interpretScript: error in executing %s script\n",
+                        langname);
         return false;
         }
-        
+
     delete interp;
-    
+
     return true;
 }
 
 /**
- *
+ * Interprets the script in the 'script' buffer,
+ * storing the stdout output in 'output', and any
+ * error messages in 'error.'  Language is one of the
+ * enumerated types in ScriptLanguage above.
  */
-bool InkscapeScript::interpretUri(Glib::ustring &uri,
+bool InkscapeScript::interpretUri(const Glib::ustring &uri,
                                  Glib::ustring &output,
                                  Glib::ustring &error,
                                  ScriptLanguage language)
@@ -132,20 +129,23 @@ bool InkscapeScript::interpretUri(Glib::ustring &uri,
         }
     else
         {
-        //replace with g_error
-        fprintf(stderr, "Unknown Script Language type:%d\n", language);
+        g_error("interpretUri: Unknown Script Language type:%d\n",
+                           language);
         return false;
         }
-        
+
     if (!interp)
         return false;
 
     if (!interp->interpretUri(uri, output, error))
         {
-        fprintf(stderr, "error in executing script '%s'\n", uri.raw().c_str());
+        g_error("interpretUri: error in executing script '%s'\n",
+                           uri.raw().c_str());
         return false;
         }
-        
+
+    delete interp;
+
     return true;
 }
 
index 88df2c82ad3ddf35cde9d4dd155634ead1384a87..e8728cb3347e0efe975e3b099ef17739dd68d9d2 100644 (file)
@@ -7,7 +7,7 @@
  * Authors:
  *   Bob Jamison <rjamison@titan.com>
  *
- * Copyright (C) 2004 Authors
+ * Copyright (C) 2004-2006 Bob Jamison
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -35,27 +35,33 @@ public:
         } ScriptLanguage;
 
     /**
-     *
+     * Creates a generic script interpreter.
      */
     InkscapeScript();
 
     /**
-     *
+     *  Destructor
      */
     ~InkscapeScript();
 
     /**
-     *
+     * Interprets the script in the 'script' buffer,
+     * storing the stdout output in 'output', and any
+     * error messages in 'error.'  Language is one of the
+     * enumerated types in ScriptLanguage above.
      */
-    bool interpretScript(Glib::ustring &script,
+    bool interpretScript(const Glib::ustring &script,
                          Glib::ustring &output,
                          Glib::ustring &error,
                          ScriptLanguage language);
 
     /**
-     *
+     * Interprets the script at the uri (file) named by 'uri',
+     * storing the stdout output in 'output', and any
+     * error messages in 'error.'  Language is one of the
+     * enumerated types in ScriptLanguage above.
      */
-    bool interpretUri(Glib::ustring &uri,
+    bool interpretUri(const Glib::ustring &uri,
                       Glib::ustring &output,
                       Glib::ustring &error,
                       ScriptLanguage language);