summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2006-05-06 21:45:01 +0000
committerishmal <ishmal@users.sourceforge.net>2006-05-06 21:45:01 +0000
commitb151fcd87bfd5892dc3cd166a0944d12666aefab (patch)
tree0d2e099f46dcc747a4685727c3408c23efcdc544 /src
parentr11769@tres: ted | 2006-05-06 09:09:59 -0700 (diff)
downloadinkscape-b151fcd87bfd5892dc3cd166a0944d12666aefab.tar.gz
inkscape-b151fcd87bfd5892dc3cd166a0944d12666aefab.zip
const types
(bzr r754)
Diffstat (limited to 'src')
-rw-r--r--src/extension/script/InkscapeInterpreter.cpp30
-rw-r--r--src/extension/script/InkscapeInterpreter.h4
-rw-r--r--src/extension/script/InkscapePerl.cpp16
-rw-r--r--src/extension/script/InkscapePerl.h14
-rw-r--r--src/extension/script/InkscapePython.cpp20
-rw-r--r--src/extension/script/InkscapePython.h14
-rw-r--r--src/extension/script/InkscapeScript.cpp54
-rw-r--r--src/extension/script/InkscapeScript.h20
8 files changed, 89 insertions, 83 deletions
diff --git a/src/extension/script/InkscapeInterpreter.cpp b/src/extension/script/InkscapeInterpreter.cpp
index 4342922b1..c28163489 100644
--- a/src/extension/script/InkscapeInterpreter.cpp
+++ b/src/extension/script/InkscapeInterpreter.cpp
@@ -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;
diff --git a/src/extension/script/InkscapeInterpreter.h b/src/extension/script/InkscapeInterpreter.h
index 9dd585d0d..7d16ed979 100644
--- a/src/extension/script/InkscapeInterpreter.h
+++ b/src/extension/script/InkscapeInterpreter.h
@@ -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);
diff --git a/src/extension/script/InkscapePerl.cpp b/src/extension/script/InkscapePerl.cpp
index 7b3c3c1a5..1a4c61bcc 100644
--- a/src/extension/script/InkscapePerl.cpp
+++ b/src/extension/script/InkscapePerl.cpp
@@ -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;
}
-
+
diff --git a/src/extension/script/InkscapePerl.h b/src/extension/script/InkscapePerl.h
index 0ec79a9cd..0b9314009 100644
--- a/src/extension/script/InkscapePerl.h
+++ b/src/extension/script/InkscapePerl.h
@@ -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);
-
-
+
+
diff --git a/src/extension/script/InkscapePython.cpp b/src/extension/script/InkscapePython.cpp
index eca09951a..49e6a11a2 100644
--- a/src/extension/script/InkscapePython.cpp
+++ b/src/extension/script/InkscapePython.cpp
@@ -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;
}
-
-
+
+
diff --git a/src/extension/script/InkscapePython.h b/src/extension/script/InkscapePython.h
index fdcd4906f..cdf9bd0f1 100644
--- a/src/extension/script/InkscapePython.h
+++ b/src/extension/script/InkscapePython.h
@@ -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:
diff --git a/src/extension/script/InkscapeScript.cpp b/src/extension/script/InkscapeScript.cpp
index cc9271caa..87d120245 100644
--- a/src/extension/script/InkscapeScript.cpp
+++ b/src/extension/script/InkscapeScript.cpp
@@ -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;
}
diff --git a/src/extension/script/InkscapeScript.h b/src/extension/script/InkscapeScript.h
index 88df2c82a..e8728cb33 100644
--- a/src/extension/script/InkscapeScript.h
+++ b/src/extension/script/InkscapeScript.h
@@ -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);