NEURON
nrnpython.h
Go to the documentation of this file.
1
#ifndef nrnpython_h
2
#define nrnpython_h
3
4
#ifdef _WIN64
5
#define MS_WIN64
6
#define MS_WIN32
7
#define MS_WINDOWS
8
#endif
9
10
#include <../../nrnconf.h>
11
#include <nrnpython_config.h>
12
13
#if defined(NRNPYTHON_DYNAMICLOAD) && NRNPYTHON_DYNAMICLOAD >= 30
14
#define PY_LIMITED_API
15
#endif
16
17
#if defined(USE_PYTHON)
18
#undef _POSIX_C_SOURCE
19
#undef _XOPEN_SOURCE
20
#include <
nrnwrap_Python.h
>
21
22
#endif
/*USE_PYTHON*/
23
24
#define PyString_FromString PyUnicode_FromString
25
#define PyInt_Check PyLong_Check
26
#define PyInt_CheckExact PyLong_CheckExact
27
#define PyInt_AS_LONG PyLong_AsLong
28
#define PyInt_AsLong PyLong_AsLong
29
#define PyInt_FromLong PyLong_FromLong
30
31
static_assert(PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 6),
"Python >= 3.6 required"
);
32
33
extern
PyObject*
nrnpy_hoc_pop
();
34
extern
int
nrnpy_numbercheck
(PyObject*);
35
36
#if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ > __SIZEOF_LONG__
37
#define castptr2long (long)(long long)
38
#else
39
#define castptr2long (long)
40
#endif
41
42
43
44
/*
45
Because python types have so many methods, attempt to do all set and get
46
using a PyHocObject which has different amounts filled in as the information
47
is gathered with a view toward ultimately making a call to hoc_object_component.
48
That requires that array indices or function arguments are on the stack.
49
The major variant is that we may be at the top level. The function arg
50
case is easy since they all come as a tuple in the call method. The
51
array indices come sequentially with a series of calls to the
52
sequence method. A nice side effect of intermediate objects is the extra
53
efficiency of reuse that avoids symbol lookup. Sadly, the scalar case does
54
not give this since the value is set/get instead of returning the
55
intermediate.
56
*/
57
namespace
PyHoc
{
58
enum
ObjectType
{
59
HocTopLevelInterpreter
= 0,
60
HocObject
= 1,
61
HocFunction
= 2,
// function or TEMPLATE
62
HocArray
= 3,
63
HocRefNum
= 4,
64
HocRefStr
= 5,
65
HocRefObj
= 6,
66
HocForallSectionIterator
= 7,
67
HocSectionListIterator
= 8,
68
HocScalarPtr
= 9,
69
HocArrayIncomplete
=
70
10,
// incomplete pointer to a hoc array (similar to HocArray)
71
HocRefPStr
= 11,
72
};
73
enum
IteratorState
{
74
Begin
,
75
NextNotLast
,
76
Last
77
};
78
}
// namespace PyHoc
79
80
#endif
81
nrnpy_hoc_pop
PyObject * nrnpy_hoc_pop()
Definition:
nrnpy_hoc.cpp:551
PyHoc::HocFunction
Definition:
nrnpython.h:61
PyHoc
Definition:
nrnpython.h:57
nrnwrap_Python.h
PyHoc::Last
Definition:
nrnpython.h:76
PyHoc::Begin
Definition:
nrnpython.h:74
PyHoc::HocRefObj
Definition:
nrnpython.h:65
PyHoc::HocRefPStr
Definition:
nrnpython.h:71
PyHoc::HocArrayIncomplete
Definition:
nrnpython.h:69
PyHoc::ObjectType
ObjectType
Definition:
nrnpython.h:58
PyHoc::HocForallSectionIterator
Definition:
nrnpython.h:66
PyHoc::HocArray
Definition:
nrnpython.h:62
PyHoc::HocRefStr
Definition:
nrnpython.h:64
PyHoc::HocScalarPtr
Definition:
nrnpython.h:68
PyHoc::NextNotLast
Definition:
nrnpython.h:75
PyHoc::IteratorState
IteratorState
Definition:
nrnpython.h:73
PyHoc::HocTopLevelInterpreter
Definition:
nrnpython.h:59
PyHoc::HocObject
Definition:
nrnpython.h:60
PyHoc::HocRefNum
Definition:
nrnpython.h:63
PyHoc::HocSectionListIterator
Definition:
nrnpython.h:67
nrnpy_numbercheck
int nrnpy_numbercheck(PyObject *)
Definition:
nrnpy_hoc.cpp:478
src
nrnpython
nrnpython.h