00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_PYTHON_PYLIST_HELPER
00008 #define BALL_PYTHON_PYLIST_HELPER
00009
00010 #include <BALL/DATATYPE/regularData3D.h>
00011 #include <BALL/DATATYPE/list.h>
00012
00013 namespace BALL
00014 {
00015
00016 typedef List<RegularData3D*> RegularData3DList;
00017
00018
00019 #define BALL_CONVERT_LIST_FROM(TYPE)\
00020 PyObject *pl;\
00021 \
00022 if ((pl = PyList_New(0)) == NULL) return NULL;\
00023 \
00024 for (TYPE##List::const_iterator it = sipCpp->begin(); it != sipCpp->end(); ++it)\
00025 {\
00026 PyObject *inst = BALL_CONVERT_FROM_INSTANCE(*it, TYPE, 0);\
00027 \
00028 if (inst == NULL || PyList_Append(pl,inst) < 0)\
00029 {\
00030 Py_DECREF(pl);\
00031 return NULL;\
00032 }\
00033 }\
00034 \
00035 return pl;
00036
00037
00038
00039 #define BALL_CONVERT_LIST_TO(TYPE)\
00040 if (sipIsErr == NULL) return PyList_Check(sipPy);\
00041 \
00042 TYPE##List* alist = new TYPE##List;\
00043 \
00044 for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)\
00045 {\
00046 TYPE* a = reinterpret_cast<TYPE*>(BALL_FORCE_CONVERT_TO_TYPE(PyList_GET_ITEM(sipPy,i), TYPE));\
00047 \
00048 if (*sipIsErr)\
00049 {\
00050 delete alist;\
00051 return 0;\
00052 }\
00053 \
00054 alist->push_back(a);\
00055 }\
00056 \
00057 *sipCppPtr = alist;\
00058 \
00059 return 1;
00060
00061 }
00062
00063 #endif