Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unit_from_to_python.h
Go to the documentation of this file.
1 #ifndef _UNIT_FROM_TO_PYTHON_H_
2 #define _UNIT_FROM_TO_PYTHON_H_
3 #include <boost/version.hpp>
4 #if BOOST_VERSION != 102800
5 //#include <boost/python/converter/arg_from_python.hpp>
6 
7 #include "init.h"
8 BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE BOOST_PYTHON_TO_PYTHON_BY_VALUE( Unit*, ::boost::python::to_python_value< UnitWrapper > () (
9  UnitWrapper( x ) ) );
10 template < >
11 struct default_result_converter::apply< Unit* >
12 {
13 //typedef boost::python::to_python_value<Unit *> type;
14  typedef::boost::python::default_result_converter::apply< UnitWrapper >::type type;
15 };
16 
17 /*namespace converter{
18  *
19  * template <>
20  * struct arg_rvalue_from_python <Vector>
21  * {
22  * // typedef typename boost::add_reference<
23  * // typename boost::add_const<Vector>::type
24  * // >::type result_type;
25  * typedef Vector result_type;
26  *
27  * arg_rvalue_from_python(PyObject*p);
28  * bool convertible() const {return true;}
29  *
30  * result_type operator()(PyObject*p) {
31  * Vector vec(0,0,0);
32  * PyArg_ParseTuple(p,"fff",&vec.i,&vec.j,&vec.k);
33  * return vec;
34  * }
35  *
36  * private:
37  * rvalue_from_python_data<result_type> m_data;
38  * };
39  *
40  * template <>
41  * struct arg_rvalue_from_python <QVector>
42  * {
43  * // typedef typename boost::add_reference<
44  * // typename boost::add_const<QVector>::type
45  * // >::type result_type;
46  * typedef QVector result_type;
47  *
48  * arg_rvalue_from_python(PyObject*p);
49  * bool convertible() const {return true;}
50  *
51  * result_type operator()(PyObject*p) {
52  * QVector vec(0,0,0);
53  * PyArg_ParseTuple(p,"ddd",&vec.i,&vec.j,&vec.k);
54  * return vec;
55  * }
56  *
57  * private:
58  * rvalue_from_python_data<result_type> m_data;
59  * };
60  *
61  * }
62  */
63 
64 BOOST_PYTHON_END_CONVERSION_NAMESPACE
65 #else
68 
70 BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
71 inline PyObject*to_python( Unit*un )
72 {
73  return to_python( UnitWrapper( un ) );
74 }
75 inline Unit * from_python( PyObject *p, boost::python::type< Unit* >)
76 {
77  UnitWrapper uw = ( from_python( p, boost::python::type< UnitWrapper& > () ) );
78  return uw.GetUnit();
79 }
80 BOOST_PYTHON_END_CONVERSION_NAMESPACE
81 #endif
82 #endif
83