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 {
60  HocObject = 1,
61  HocFunction = 2, // function or TEMPLATE
62  HocArray = 3,
63  HocRefNum = 4,
64  HocRefStr = 5,
65  HocRefObj = 6,
70  10, // incomplete pointer to a hoc array (similar to HocArray)
71  HocRefPStr = 11,
72 };
77 };
78 } // namespace PyHoc
79 
80 #endif
81 
PyObject * nrnpy_hoc_pop()
Definition: nrnpy_hoc.cpp:551
ObjectType
Definition: nrnpython.h:58
IteratorState
Definition: nrnpython.h:73
int nrnpy_numbercheck(PyObject *)
Definition: nrnpy_hoc.cpp:478