summaryrefslogtreecommitdiff
path: root/numpy/f2py/lib/extgen/converters.py
blob: 182c95339bc074c4a9cb568b32b17a6ec565bb85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

from base import Component
from c_code import CCode

Component.register(
    CCode('''
static int pyobj_to_int(PyObject *obj, int* value) {
  int status = 1;
  if (PyInt_Check(obj)) {
    *value = PyInt_AS_LONG(obj);
    status = 0;
  }
  return status;
}
''', provides='pyobj_to_int'),
    CCode('''\
static PyObject* pyobj_from_int(int* value) {
  return PyInt_FromLong(*value);
}
''', provides='pyobj_from_int'),

    )