|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-12-18 12:43:10
"HellcatV HellcatV" <hellcatv_at_[hidden]> writes:
> I've been struggling to port boost v1 to boost v2 and I haven't
> located a nice sort of documentation for it--
What's wrong with
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/index.html?
??
We worked very hard on it!
> luckily i have almost finished figuring it out...and just need to
> figure out how to register from_python
>
> I have tried and failed to contact the mailing list
What did you try to do?
Instructions are at http://www.python.org/sigs/c++-sig/
> so I'm hoping you can help me, Dave :-)
> or point me to where I cna find infos
See above.
> so I'm trying to get boost v2 to work with my new project at LBL
>
> my test code appears to be 100% working ( to_python converted to that
> big macro,
Huh? That big macro?
> sloppy casts of "member" functions that included something
> that casted to the true member function has been removed)
I'm still confused, but it sound like you're saying things have
improved.
> but I get a type error when trying to call a function with a tuple
> that really takes a Vector.
> struct Vector {
> float i; float j; float k;
> };
>
> This is because I have not figured out how to properly define a
> from_python operator in boost v2... I have scoured google and all the
> docs and have only encountered half-debates on what convention to use
> and no solid rules--and I cannot appear to make anything I have tried
> work.
Ralf also works at Berkeley Labs, so you have the expert on-site.
> can you point me to some documentation on which functioN I should make
> that takes in a PyObject * and return a Vector so that I can call
> functions that take a Vector as an argument?
>
> my old from_python method is as follows:
> inline Vector from_python(PyObject *p,boost::python::type<Vector>) {
> Vector vec(0,0,0);
> PyArg_ParseTuple(p,"fff",&vec.i,&vec.j,&vec.k);
> return vec;
> }
> error checking is not required :-)
>
> if anyone can help me get this function to work in v2 I believe the
> rest of my code will magically work (because
>
> the only functions currently failing involve taking IN
> vectors...returning them is accomplished with
> BOOST_PYTHON_TO_PYTHON_BY_VALUE(QVector,
> boost::python::to_python_value<boost::python::tuple> ()(bo\
> ost::python::make_tuple((double)x.i,(double)x.j,(double)x.k)));
Ahh, that macro is an implementation detail; I'm not sure that you
should be using it. I probably should be #undef ing it at the end of
the header.
static void* QVector_convertible(PyObject* p)
{
return PyTuple_Check(p);
}
static void QVector_construct(PyObject* source, rvalue_from_python_stage1_data* data)
{
void* const storage = ((converter::rvalue_from_python_storage<QVector>*)data)->storage.bytes;
new (storage) QVector();
// Fill in QVector values from source tuple here
// details left to reader.
data->convertible = storage;
}
...
boost::python::converter::registry::insert(QVector_convertible, QVector_construct, type_id<QVector>());
> is the above calling syntax going to be portable to newer versions of
> boost? or am I going to have to scour through millions of header files
> for version 1.30?
Scouring headers is never a good idea. I recommend reading the docs,
then asking questions.
> anyhow thanks for a great library....
You're welcome!
> unfortunately only boost v1 compiles on my macintosh with gcc-3.1
> it appears there is a preprocessing error with gcc-3.1 :-( and I'm not
> sure what to do about it...
>
> it says: (postprocessed)
>
> template < typename 0 = mpl::void_ , typename B1 = mpl::void_ ,
> typename B2 = mpl::void_ , typena\
> me B3 = mpl::void_ , typename B4 = mpl::void_ , typename B5 =
> mpl::void_ , typename B6 = mpl::void_\
> , typename B7 = mpl::void_ , typename B8 = mpl::void_ , typename B9 =
> mpl::void_ >
> struct bases : detail::type_list< B0 , B1 , B2 , B3 , B4 , B5 , B6 ,
> B7 , B8 , B9 >::type
> {};
>
> where I think it means B0 instead of just plain ole 0....
Ouch! Yes, that's right.
> I think it's a gcc-3.1 b0rken sign but I don't know how to get around
> it :-/
GCC-3.2.1?
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk