17
17
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
19
19
// First added: 2011-01-25
20
// Last changed: 2013-03-08
20
// Last changed: 2013-03-12
22
22
//-----------------------------------------------------------------------------
23
23
// User macro for defining in typmaps for std::pair of a pointer to some
28
28
//-----------------------------------------------------------------------------
29
29
// Make SWIG aware of the shared_ptr version of TYPE
30
30
//-----------------------------------------------------------------------------
31
%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<TYPE>*);
33
//-----------------------------------------------------------------------------
34
// Run the macros for the combination of const and no const of
35
// {const} std::vector<{const} dolfin::TYPE *>
36
//-----------------------------------------------------------------------------
37
//IN_TYPEMAP_STD_VECTOR_OF_POINTERS(TYPE,,)
31
%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<TYPE >*);
33
////-----------------------------------------------------------------------------
34
//// Run the macros for the combination of const and no const of
35
//// {const} std::vector<{const} dolfin::TYPE *>
36
////-----------------------------------------------------------------------------
37
////IN_TYPEMAP_STD_VECTOR_OF_POINTERS(TYPE,,)
38
38
IN_TYPEMAP_STD_PAIR_OF_POINTER_AND_DOUBLE(TYPE,const,)
39
39
IN_TYPEMAP_STD_PAIR_OF_POINTER_AND_DOUBLE(TYPE,,const)
40
40
IN_TYPEMAP_STD_PAIR_OF_POINTER_AND_DOUBLE(TYPE,const,const)
53
53
//-----------------------------------------------------------------------------
54
54
%typecheck(SWIG_TYPECHECK_POINTER) CONST_PAIR std::pair<CONST dolfin::TYPE *, double>
56
$1 = PyTuple_Check($input) ? 1 : 0;
57
// TYPECHEK IN_TYPEMAP_STD_PAIR_OF_POINTER_AND_DOUBLE(TYPE, CONST, CONST_PAIR)
59
if (PyTuple_Check($input) && PyTuple_Size($input) == 2)
62
PyObject* py_first = PyTuple_GetItem($input, 0);
63
int res = SWIG_ConvertPtr(py_first, &itemp, $descriptor(dolfin::TYPE *), 0);
66
// If failed with normal pointer conversion then
67
// try with shared_ptr conversion
69
res = SWIG_ConvertPtrAndOwn(py_first, &itemp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< dolfin::TYPE > *), 0, &newmem);
73
if (newmem & SWIG_CAST_NEW_MEMORY)
75
delete reinterpret_cast< SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< dolfin::TYPE > * >(itemp);
59
86
//-----------------------------------------------------------------------------
61
88
//-----------------------------------------------------------------------------
62
%typemap(in) CONST_PAIR std::pair<CONST dolfin::TYPE*, double> (std::pair<CONST dolfin::TYPE*, double> tmp_pair, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<dolfin::TYPE> tempshared, dolfin::TYPE * arg)
89
%typemap(in) CONST_PAIR std::pair<CONST dolfin::TYPE*, double> (std::pair<CONST dolfin::TYPE*, double> tmp_pair, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<dolfin::TYPE > tempshared, dolfin::TYPE * arg)
91
// TYPEMAP IN_TYPEMAP_STD_PAIR_OF_POINTER_AND_DOUBLE(TYPE, CONST, CONST_PAIR)
94
122
// If we need to release memory
95
123
if (newmem & SWIG_CAST_NEW_MEMORY)
97
tempshared = *reinterpret_cast< SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<dolfin::TYPE> * >(itemp);
125
tempshared = *reinterpret_cast< SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<dolfin::TYPE > * >(itemp);
98
126
delete reinterpret_cast< SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< dolfin::TYPE > * >(itemp);
99
127
arg = const_cast< dolfin::TYPE * >(tempshared.get());
119
147
// Run the different macros and instantiate the typemaps
120
148
//-----------------------------------------------------------------------------
121
149
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(Function)
122
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunction)
123
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunctionInt)
124
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunctionSizet)
125
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunctionDouble)
126
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunctionBool)
150
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(Mesh)
151
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunction<int>)
152
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunction<std::size_t> )
153
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunction<double> )
154
IN_TYPEMAPS_STD_PAIR_OF_POINTER_AND_DOUBLE(MeshFunction<bool>)
128
156
//-----------------------------------------------------------------------------
129
157
// In typemap for std::pair<TYPE,TYPE>