~corrado-maurini/dolfin/tao

« back to all changes in this revision

Viewing changes to dolfin/swig/typemaps/std_set.i

  • Committer: corrado maurini
  • Date: 2012-12-18 12:16:08 UTC
  • mfrom: (6685.78.207 trunk)
  • Revision ID: corrado.maurini@upmc.fr-20121218121608-nk82ly9jgsld9u84
updating with trunk, fix uint in TAO solver and hacking the check for tao FindTAO.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
18
18
//
19
19
// First added:  2009-11-27
20
 
// Last changed: 2012-05-09
 
20
// Last changed: 2012-12-13
21
21
 
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
37
37
//
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
//-----------------------------------------------------------------------------
72
70
 
73
71
%enddef
74
72
 
 
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
 
76
//
 
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> 
 
85
{
 
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));
 
89
 
 
90
  int i = 0;
 
91
  for (boost::unordered_set<TYPE>::const_iterator it = $1.begin(); it != $1.end(); ++it)
 
92
  {
 
93
    data[i] = *it;
 
94
    ++i;
 
95
  }
 
96
 
 
97
  // Append the output to $result
 
98
  $result = PyArray_Return(ret);
 
99
}
 
100
 
 
101
%enddef
 
102
 
75
103
// NOTE: SWIG BUG
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)
 
109
 
 
110
OUT_TYPEMAP_BOOST_UNORDERED_SET_OF_PRIMITIVES(std::size_t, NPY_UINTP)