This file is indexed.

/usr/include/dolfin/swig/typemaps/primitives.i is in libdolfin-dev 2017.2.0.post0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
/* -*- C -*- */
// Copyright (C) 2007-2009 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Ola Skavhaug, 2007-2009.
// Modified by Garth N. Wells, 2007.
// Modified by Johan Hake, 2008-2011.
//
// First added:  2006-04-16
// Last changed: 2013-05-28

//=============================================================================
// General typemaps for PyDOLFIN
//=============================================================================

//-----------------------------------------------------------------------------
// Fragment for bool (after SWIG 3.0)
// Allow Python bool, scalar numpy booleans and 1 sized boolean arrays
//-----------------------------------------------------------------------------
%fragment(SWIG_AsVal_frag(bool2),"header",
          fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN int
SWIG_AsVal_dec(bool2)(PyObject *obj, bool *val)
{
  int r;
  if (!(PyBool_Check(obj)||PyArray_IsScalar(obj, Bool)||(PyArray_Check(obj)&&PyArray_SIZE(reinterpret_cast<PyArrayObject*>(obj))==1)&&PyArray_TYPE(reinterpret_cast<PyArrayObject*>(obj))==NPY_BOOL))
    return SWIG_ERROR;
  r = PyObject_IsTrue(obj);
  if (r == -1)
    return SWIG_ERROR;
  if (val) *val = r ? true : false;
  return SWIG_OK;
}
}

// Include limit header
%fragment("limits_header", "header")
{
  // Include the limits header
  %#include <limits>
}

// Make sure Python int from std::size_t can be constructed
// It looks like SWIG_From_size_t is available but not SWIG_From_std_size_t
%fragment("SWIG_From_std_size_t", "header", fragment=SWIG_From_frag(size_t),
          fragment="limits_header")
{
  SWIGINTERNINLINE PyObject * SWIG_From_std_size_t(std::size_t value)
  {
    return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value));
    return PyInt_FromSize_t(value);
  }
}

// Make sure Python int from dolfin::la_index can be constructed
%fragment("SWIG_From_dolfin_la_index", "header")
{
  SWIGINTERNINLINE PyObject * SWIG_From_dolfin_la_index(dolfin::la_index value)
  {
    return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value));
    return PyInt_FromSize_t(static_cast<std::size_t>(value));
  }
}

//-----------------------------------------------------------------------------
// A home brewed type check for checking integers
// Needed due to problems with PyInt_Check from python 2.6 and NumPy
//-----------------------------------------------------------------------------
%fragment("PyInteger_Check", "header")
{
// Homebrewed Integer enumerate
typedef enum {
  _NO_PYTHON_INTEGER_TYPE=-1,
  _INT_PYTHON_INTEGER_TYPE,
  _LONG_PYTHON_INTEGER_TYPE,
  _NPY_PYTHON_INTEGER_TYPE
} PYTHON_INTEGER_TYPES;

SWIGINTERNINLINE PYTHON_INTEGER_TYPES PyInteger_Check(PyObject* in)
{
  if (PyInt_Check(in))
    return _INT_PYTHON_INTEGER_TYPE;
  if (PyLong_Check(in))
    return _LONG_PYTHON_INTEGER_TYPE;
  if (PyArray_CheckScalar(in) && PyArray_IsScalar(in,Integer))
    return _NPY_PYTHON_INTEGER_TYPE;

  // No integer type
  return _NO_PYTHON_INTEGER_TYPE;
}
}

//-----------------------------------------------------------------------------
// Home brewed versions of the SWIG provided SWIG_AsVal(Type). These are needed
// as long as we need the PyInteger_Check. Whenever Python 2.6 is not supported
// we can scrap them.
//-----------------------------------------------------------------------------
#define Py_convert_frag(Type) "Py_convert_" {Type}

%fragment("Py_convert_std_size_t", "header", fragment="PyInteger_Check")
{

SWIGINTERNINLINE bool Py_convert_std_size_t(PyObject* in, std::size_t& value)
{

  // Get integer type
  PYTHON_INTEGER_TYPES int_type = PyInteger_Check(in);

  // No integer type?
  if (int_type == _NO_PYTHON_INTEGER_TYPE)
  {
    return false;
  }

  // Conversion if python int
  if (int_type == _INT_PYTHON_INTEGER_TYPE)
  {
%#if PY_MAJOR_VERSION >= 3
    const long signed_value = PyLong_AS_LONG(in);
%#else
    const long signed_value = PyInt_AS_LONG(in);
%#endif
    value = static_cast<std::size_t>(signed_value);
    return signed_value>=0;
  }

  // Conversion if numpy scalar
  if (int_type == _NPY_PYTHON_INTEGER_TYPE)
  {
    return PyArray_CastScalarToCtype(in, &value, PyArray_DescrFromType(NPY_UINTP))==0;
  }

  // Conversion if python long
  if (int_type == _LONG_PYTHON_INTEGER_TYPE)
  {
%#if PY_MAJOR_VERSION >= 3
    value = PyLong_AsSize_t(in);
%#else
    value = static_cast<std::size_t>(PyLong_AsUnsignedLongLong(in));
%#endif
    return !PyErr_Occurred();
  }

  // Should never reach this point
  return false;
}
}

%fragment("Py_convert_double", "header") {
  // A check for float and converter for double
  SWIGINTERNINLINE bool Py_convert_double(PyObject* in, double& value)
  {
    return SWIG_AsVal(double)(in, &value);
  }
}

%fragment("Py_convert_int", "header", fragment="PyInteger_Check") {
  // A check for int and converter for int
SWIGINTERNINLINE bool Py_convert_int(PyObject* in, int& value)
{

  // Get integer type
  PYTHON_INTEGER_TYPES int_type = PyInteger_Check(in);

  // No integer type?
  if (int_type == _NO_PYTHON_INTEGER_TYPE)
  {
    return false;
  }

  // Conversion if python int or numpy type
  if (int_type == _INT_PYTHON_INTEGER_TYPE || int_type == _NPY_PYTHON_INTEGER_TYPE)
  {
    value = static_cast<int>(PyInt_AsLong(in));
    return true;
  }

  // Conversion if python long
  if (int_type == _LONG_PYTHON_INTEGER_TYPE)
  {
    long long_value = PyLong_AsLong(in);
    value = static_cast<int>(long_value);
    return true;
  }

  // Should never reach this point
  return false;
}

}

%fragment("Py_convert_uint", "header", fragment="PyInteger_Check") {
  // A check for int and converter to uint
  SWIGINTERNINLINE bool Py_convert_uint(PyObject* in, unsigned int& value)
{

  // Get integer type
  PYTHON_INTEGER_TYPES int_type = PyInteger_Check(in);

  // No integer type?
  if (int_type == _NO_PYTHON_INTEGER_TYPE)
  {
    return false;
  }

  // Conversion if python int or numpy int
  if (int_type == _INT_PYTHON_INTEGER_TYPE || int_type == _NPY_PYTHON_INTEGER_TYPE)
  {
%#if PY_MAJOR_VERSION >= 3
    const long signed_value = PyLong_AS_LONG(in);
%#else
    const long signed_value = PyInt_AS_LONG(in);
%#endif
    value = static_cast<unsigned int>(signed_value);
    return signed_value>=0;
  }

  // Conversion if python long
  if (int_type == _LONG_PYTHON_INTEGER_TYPE)
  {
    const npy_longlong signed_value = PyLong_AsLong(in);
    value = static_cast<unsigned int>(signed_value);
    return signed_value>=0;
  }

  // Should never reach this point
  return false;
}
}

//-----------------------------------------------------------------------------
// Typemaps for unsigned int and int
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Out typemap (unsigned int)
//-----------------------------------------------------------------------------
%typemap(out, fragment=SWIG_From_frag(unsigned int)) unsigned int
{
  // Typemap unsigned int
  $result = PyInt_FromLong(static_cast<long>($1));
  // NOTE: From SWIG 2.0.5 does this macro return a Python long,
  // NOTE: which we do not want
  // NOTE: Fixed in 2.0.7, but keep the above fix for now
  // $result = SWIG_From(unsigned int)($1);
}

//-----------------------------------------------------------------------------
// Out typemap (std::size_t)
//-----------------------------------------------------------------------------
%typemap(out, fragment=SWIG_From_frag(std::size_t)) std::size_t
{
  if ($1<std::numeric_limits<long>::max())
%#if PY_MAJOR_VERSION >= 3
    $result = PyLong_FromSsize_t($1);
%#else
    $result = PyInt_FromSsize_t($1);
%#endif
  else
    $result = PyLong_FromUnsignedLongLong(static_cast<unsigned long long>($1));
}

//-----------------------------------------------------------------------------
// Typecheck and in typemap (unsigned int)
//-----------------------------------------------------------------------------
%typecheck(SWIG_TYPECHECK_INTEGER) unsigned int
{
  $1 = PyInteger_Check($input) == _NO_PYTHON_INTEGER_TYPE ? 0 : 1;
}

%typemap(in, fragment="Py_convert_uint") unsigned int
{
  if (!Py_convert_uint($input, $1))
    SWIG_exception(SWIG_TypeError, "(uint) expected positive 'int' for argument $argnum");
}

//-----------------------------------------------------------------------------
// Typecheck and in typemap (std::size_t)
//-----------------------------------------------------------------------------
%typecheck(SWIG_TYPECHECK_INTEGER) std::size_t
{
  $1 = PyInteger_Check($input) == _NO_PYTHON_INTEGER_TYPE ? 0 : 1;
}

%typemap(in, fragment="Py_convert_std_size_t") std::size_t
{
  if (!Py_convert_std_size_t($input, $1))
    SWIG_exception(SWIG_TypeError, "(size_t) expected positive 'int' for argument $argnum");
}

//-----------------------------------------------------------------------------
// The typecheck (int)
//-----------------------------------------------------------------------------
%typecheck(SWIG_TYPECHECK_INTEGER) int
{
  $1 = PyInteger_Check($input) == _NO_PYTHON_INTEGER_TYPE ? 0 : 1;
}

//-----------------------------------------------------------------------------
// The typemap (int)
//-----------------------------------------------------------------------------
%typemap(in, fragment="Py_convert_int") int
{
  if (!Py_convert_int($input, $1))
    SWIG_exception(SWIG_TypeError, "expected 'int' for argument $argnum");
}
//-----------------------------------------------------------------------------
// The typecheck (bool) Needed after SWIG 3.0
//-----------------------------------------------------------------------------
%typecheck(SWIG_TYPECHECK_BOOL) book
{
  $1 = PyBool_Check(obj)||PyArray_IsScalar(obj, Bool);
}

//-----------------------------------------------------------------------------
// The typemaps (bool)
//-----------------------------------------------------------------------------
%typemap(in, fragment=SWIG_AsVal_frag(bool2)) bool
{
  int swig_res = SWIG_AsVal_dec(bool2)($input, &$1);
  if (!SWIG_IsOK(swig_res))
    SWIG_exception(SWIG_TypeError, "expected 'bool' for argument $argnum");
}

%typemap(directorout, fragment=SWIG_AsVal_frag(bool2)) bool
{
  int swig_res = SWIG_AsVal_dec(bool2)($1, &$result);
  if (!SWIG_IsOK(swig_res))
    Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(SWIG_ArgError(swig_res)), "expected 'bool' as the output argument of '$symname'");
}

//-----------------------------------------------------------------------------
// Ensure typefragments
//-----------------------------------------------------------------------------
%fragment(SWIG_From_frag(unsigned long));
%fragment(SWIG_From_frag(double));
%fragment(SWIG_From_frag(unsigned int));
%fragment(SWIG_From_frag(int));
%fragment(SWIG_From_frag(std::size_t));
%fragment(SWIG_From_frag(dolfin::la_index));
%fragment("Py_convert_int");
%fragment("Py_convert_uint");
%fragment("Py_convert_std_size_t");