summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c7991a2)
raw | patch | inline | side by side (parent: c7991a2)
author | ishmal <ishmal@users.sourceforge.net> | |
Sun, 15 Apr 2007 01:34:15 +0000 (01:34 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Sun, 15 Apr 2007 01:34:15 +0000 (01:34 +0000) |
src/extension/script/InkscapePython.cpp | patch | blob | history |
index 186d7c664efc68667b3658537bb224d9726779ed..e2172db81fb465c6ca94461059a98937c34d07d7 100644 (file)
* Python Interpreter wrapper for Inkscape
*
* Authors:
- * Bob Jamison <rjamison@titan.com>
+ * Bob Jamison <ishmalius@gmail.com>
*
* Copyright (C) 2004-2007 Authors
*
+
+
//########################################################################
-//# I N K S C A P E
+//# I N K S C A P E and siblings
+//#
+//# The following are children of PyInkscapeModule and are spawned
+//# by its methods. The classes above are spawned by PyInkscape and
+//# it descendants.
+//#
//########################################################################
{
public:
- PyInkscape()
+ PyInkscape(InkscapePython &par) : parent(par)
{
inkscape = INKSCAPE;
}
private:
+ InkscapePython &parent;
+
Inkscape::Application *inkscape;
};
//# O U T P U T S
//########################################################################
-static InkscapePython *inkscapePython = NULL;
class PyStdOut : public Py::PythonExtension<PyStdOut>
{
public:
- PyStdOut()
+ PyStdOut(InkscapePython &par) : parent(par)
{
}
virtual Py::Object write(const Py::Tuple &args)
{
- g_message("PyStdOut");
- if (inkscapePython)
+ for(unsigned int i=0 ; i<args.length() ; i++)
{
- for(unsigned int i=0 ; i<args.length() ; i++)
- {
- Py::String str(args[i]);
- inkscapePython->writeStdOut(str.as_std_string());
- }
+ Py::String str(args[i]);
+ parent.writeStdOut(str.as_std_string());
}
return Py::Nothing();
}
"redirects stdout");
}
+private:
+
+ InkscapePython &parent;
};
{
public:
- PyStdErr()
+ PyStdErr(InkscapePython &par) : parent(par)
{
}
virtual Py::Object write(const Py::Tuple &args)
{
- g_message("PyStdErr");
- if (inkscapePython)
+ for(unsigned int i=0 ; i<args.length() ; i++)
{
- for(unsigned int i=0 ; i<args.length() ; i++)
- {
- Py::String str(args[i]);
- inkscapePython->writeStdErr(str.as_std_string());
- }
+ Py::String str(args[i]);
+ parent.writeStdErr(str.as_std_string());
}
return Py::Nothing();
}
"redirects stderr");
}
+private:
+
+ InkscapePython &parent;
+
};
class PyInkscapeModule : public Py::ExtensionModule<PyInkscapeModule>
{
public:
- PyInkscapeModule()
- : Py::ExtensionModule<PyInkscapeModule>( "PyInkscapeModule" )
+ PyInkscapeModule(InkscapePython &par)
+ : Py::ExtensionModule<PyInkscapeModule>( "PyInkscapeModule" ),
+ parent(par)
{
//# Init our module's classes
PyInkscape::init_type();
virtual Py::Object getInkscape(const Py::Tuple &args)
{
- Py::Object obj(Py::asObject(new PyInkscape()));
+ Py::Object obj(Py::asObject(new PyInkscape(parent)));
return obj;
}
virtual Py::Object getStdOut(const Py::Tuple &args)
{
- Py::Object obj(Py::asObject(new PyStdOut()));
+ Py::Object obj(Py::asObject(new PyStdOut(parent)));
return obj;
}
virtual Py::Object getStdErr(const Py::Tuple &args)
{
- Py::Object obj(Py::asObject(new PyStdErr()));
+ Py::Object obj(Py::asObject(new PyStdErr(parent)));
return obj;
}
+private:
+
+ InkscapePython &parent;
+
};
Glib::ustring &output, Glib::ustring &error)
{
- inkscapePython = this;
-
stdOut.clear();
stdErr.clear();
//# Init our custom objects
- PyInkscapeModule inkscapeModule;
+ PyInkscapeModule inkscapeModule(*this);
PyObject *globalMod = PyImport_AddModule("__main__");
PyObject *globalDict = PyModule_GetDict(globalMod);