I was rejected by a spam filter. Trying again...
Here is the patch for the latter aproach. I modified lst.cpp, maybe
you move it somewhere else.
--- pyginac-orig/src/lst.cpp 2005-03-07 17:38:59.000000000 +0100
+++ pyginac/src/lst.cpp 2005-04-28 17:17:59.945485288 +0200
@@ -62,6 +62,22 @@
}
};
+struct exvector_to_python
+{
+ static PyObject* convert( const GiNaC::exvector& obj)
+ {
+ boost::python::list ret;
+ GiNaC::exvector::const_iterator i =3D obj.begin();
+ GiNaC::exvector::const_iterator i_end =3D obj.end();
+ while (i !=3D i_end) {
+ ret.append( boost::python::object(*i));
+ ++i;
+ }
+ Py_INCREF(ret.ptr());
+ return ret.ptr();
+ }
+};
+
} // !namespace pyginac::(unnamed)
void
@@ -128,6 +144,8 @@
to_python_converter<GiNaC::lst, lst_to_python>();
// TODO: Implement implicit conversions from Python lists of expressio=
ns
// to GiNaC::lst 's.
+ //
+ to_python_converter<GiNaC::exvector, exvector_to_python>();
}
On 4/28/05, Ondrej Certik <ond...@gm...> wrote:
> Hello,
> I would like to implement indexed objects, because I need them. But I
> have some problems with boost.python. I would like to use
> basic::get_free_indices, which returns std::vector<ex>,
> so I would like to implicitly convert std::vector<ex> to python list.
> I found vector_wrapper in cctbx:
>
> http://cvs.sourceforge.net/viewcvs.py/*checkout*/cctbx/scitbx/include/sci=
tbx/stl
> /vector_wrapper.h?rev=3D1.4
>
> but unfortunately it uses many headers from cctbx. Maybe it is easier to
> convert it like you do in lst.cpp? I try the latter approach.
>
> O. Certik
>
|