From: ishmal Date: Sat, 6 May 2006 21:45:01 +0000 (+0000) Subject: const types X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9b6ca604624f6108560d53e3af5627ed998a00bf;p=inkscape.git const types --- 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 @@ -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 * - * 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);