summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1617c18)
raw | patch | inline | side by side (parent: 1617c18)
| author | ishmal <ishmal@users.sourceforge.net> | |
| Sat, 6 May 2006 21:45:01 +0000 (21:45 +0000) | ||
| committer | ishmal <ishmal@users.sourceforge.net> | |
| Sat, 6 May 2006 21:45:01 +0000 (21:45 +0000) |
diff --git a/src/extension/script/InkscapeInterpreter.cpp b/src/extension/script/InkscapeInterpreter.cpp
index 4342922b15a29dacba6e4b81b6f8ffa561ff7b88..c28163489a2aa12c4a55d7103ea25b991930b29b 100644 (file)
{
}
-
+
/*
*
}
-
-
+
+
/*
* 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();
}
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 9dd585d0d8376d42d7c9256ee74bb6b440ebe032..7d16ed9794033f2111b576f0ce4add659179cae1 100644 (file)
/**
*
*/
- 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)
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+
#include "InkscapePerl.h"
{
}
-
+
/*
*
}
-
-
-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);
}
return true;
}
-
+
index 0ec79a9cd9b33a1a0faa74c34bc5e459520c3c8e..0b93140090af89a1f23357865e29370e8600da4c 100644 (file)
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+
#include "InkscapeInterpreter.h"
#include <glibmm.h>
*
*/
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)
{
}
-
+
/*
*
}
-
-
+
+
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)
{
PyRun_SimpleString(inkscape_module_script);
PyRun_SimpleString("inkscape = _inkscape_py.getInkscape()\n");
PyRun_SimpleString(codeStr);
-
+
//## Check for errors
if (PyErr_Occurred())
{
PyErr_Fetch(&errobj, &errdata, &errtraceback);
//PyErr_Clear();
-
+
if (errobj && PyString_Check(errobj))
{
PyObject *pystring = PyObject_Str(errobj);
return true;
}
-
-
+
+
index fdcd4906f9ba850fb3e6827e49636becb613c225..cdf9bd0f1771d3ffd383585347f7c7a246b45b8d 100644 (file)
*
*/
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)
*/
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
}
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)
}
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)
* 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
*/
} 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);