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 >= 7),
32
"Python >= 3.7 required"
);
33
34
extern
PyObject*
nrnpy_hoc_pop
();
35
extern
int
nrnpy_numbercheck
(PyObject*);
36
37
#if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ > __SIZEOF_LONG__
38
#define castptr2long (long) (long long)
39
#else
40
#define castptr2long (long)
41
#endif
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
= 10,
// incomplete pointer to a hoc array (similar to HocArray)
70
HocRefPStr
= 11,
71
};
72
enum
IteratorState
{
Begin
,
NextNotLast
,
Last
};
73
}
// namespace PyHoc
74
75
#endif
PyHoc
Definition:
nrnpython.h:57
PyHoc::IteratorState
IteratorState
Definition:
nrnpython.h:72
PyHoc::NextNotLast
@ NextNotLast
Definition:
nrnpython.h:72
PyHoc::Last
@ Last
Definition:
nrnpython.h:72
PyHoc::Begin
@ Begin
Definition:
nrnpython.h:72
PyHoc::ObjectType
ObjectType
Definition:
nrnpython.h:58
PyHoc::HocScalarPtr
@ HocScalarPtr
Definition:
nrnpython.h:68
PyHoc::HocRefObj
@ HocRefObj
Definition:
nrnpython.h:65
PyHoc::HocRefNum
@ HocRefNum
Definition:
nrnpython.h:63
PyHoc::HocForallSectionIterator
@ HocForallSectionIterator
Definition:
nrnpython.h:66
PyHoc::HocArrayIncomplete
@ HocArrayIncomplete
Definition:
nrnpython.h:69
PyHoc::HocRefStr
@ HocRefStr
Definition:
nrnpython.h:64
PyHoc::HocObject
@ HocObject
Definition:
nrnpython.h:60
PyHoc::HocArray
@ HocArray
Definition:
nrnpython.h:62
PyHoc::HocRefPStr
@ HocRefPStr
Definition:
nrnpython.h:70
PyHoc::HocTopLevelInterpreter
@ HocTopLevelInterpreter
Definition:
nrnpython.h:59
PyHoc::HocSectionListIterator
@ HocSectionListIterator
Definition:
nrnpython.h:67
PyHoc::HocFunction
@ HocFunction
Definition:
nrnpython.h:61
nrnpy_numbercheck
int nrnpy_numbercheck(PyObject *)
Definition:
nrnpy_hoc.cpp:474
nrnpy_hoc_pop
PyObject * nrnpy_hoc_pop()
Definition:
nrnpy_hoc.cpp:547
nrnwrap_Python.h
src
nrnpython
nrnpython.h