17
17
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
19
19
// First added: 2009-11-27
20
// Last changed: 2012-05-09
20
// Last changed: 2012-12-13
22
22
//=============================================================================
23
23
// In this file we declare some typemaps for the std::set type
36
36
// The typemaps makes a function returning a NumPy array of that primitive
38
38
// TYPE : The primitive type
39
// TYPE_UPPER : The SWIG specific name of the type used in the array type checks
40
// values SWIG use: INT32 for integer, DOUBLE for double aso.
41
39
// ARG_NAME : The name of the argument that will be maped as an 'argout' argument
42
40
// NUMPY_TYPE : The type of the NumPy array that will be returned
43
41
//-----------------------------------------------------------------------------
44
%define ARGOUT_TYPEMAP_BOOST_UNORDERED_SET_OF_PRIMITIVES(TYPE, TYPE_UPPER, ARG_NAME, NUMPY_TYPE)
42
%define ARGOUT_TYPEMAP_STD_SET_OF_PRIMITIVES(TYPE, ARG_NAME, NUMPY_TYPE)
45
43
//-----------------------------------------------------------------------------
46
44
// In typemap removing the argument from the expected in list
47
45
//-----------------------------------------------------------------------------
73
//-----------------------------------------------------------------------------
74
// Macro for defining an out typemap for a boost::unordered_set of primitives
75
// The typemaps makes a function returning a NumPy array of that primitive
77
// TYPE : The primitive type
78
// NUMPY_TYPE : The type of the NumPy array that will be returned
79
//-----------------------------------------------------------------------------
80
%define OUT_TYPEMAP_BOOST_UNORDERED_SET_OF_PRIMITIVES(TYPE, NUMPY_TYPE)
81
//-----------------------------------------------------------------------------
82
// Argout typemap, returning a NumPy array for the boost::unordered_set<TYPE>
83
//-----------------------------------------------------------------------------
84
%typemap(out) boost::unordered_set<TYPE>
86
npy_intp size = $1.size();
87
PyArrayObject *ret = reinterpret_cast<PyArrayObject*>(PyArray_SimpleNew(1, &size, NUMPY_TYPE));
88
TYPE* data = static_cast<TYPE*>(PyArray_DATA(ret));
91
for (boost::unordered_set<TYPE>::const_iterator it = $1.begin(); it != $1.end(); ++it)
97
// Append the output to $result
98
$result = PyArray_Return(ret);
76
// NOTE: Because of bug introduced by SWIG 2.0.5 we cannot use templated versions
104
// NOTE: Because of bug introduced by SWIG 2.0.5 we cannot use templated versions
77
105
// NOTE: of typdefs, which means we need to use unsigned int instead of dolfin::uint
78
106
// NOTE: in typemaps
79
ARGOUT_TYPEMAP_BOOST_UNORDERED_SET_OF_PRIMITIVES(unsigned int, INT32, ids_result, NPY_INT)
80
ARGOUT_TYPEMAP_BOOST_UNORDERED_SET_OF_PRIMITIVES(unsigned int, INT32, cells, NPY_INT)
107
ARGOUT_TYPEMAP_STD_SET_OF_PRIMITIVES(std::size_t, ids_result, NPY_UINTP)
108
ARGOUT_TYPEMAP_STD_SET_OF_PRIMITIVES(std::size_t, cells, NPY_UINTP)
110
OUT_TYPEMAP_BOOST_UNORDERED_SET_OF_PRIMITIVES(std::size_t, NPY_UINTP)