2 #include <structmember.h> 12 #include "../nrniv/shapeplt.h" 14 #if defined(HAVE_DLFCN_H) 18 #if defined(NRNPYTHON_DYNAMICLOAD) && NRNPYTHON_DYNAMICLOAD > 0 20 #undef NRNPYTHON_DYNAMICLOAD 21 #define NRNPYTHON_DYNAMICLOAD PY_MAJOR_VERSION 36 extern Object** (*nrnpy_gui_helper_)(
const char*,
Object*);
38 extern char** (*nrnpy_gui_helper3_str_)(
const char*,
Object*,
int);
40 extern void* (*nrnpy_get_pyobj)(
Object* obj);
71 extern PyObject*
nrnpy_cas(PyObject*, PyObject*);
83 extern IvocVect* (*nrnpy_vec_from_python_p_)(
void*);
84 extern Object** (*nrnpy_vec_to_python_p_)(
void*);
85 extern Object** (*nrnpy_vec_as_numpy_helper_)(
int,
double*);
125 "class neuron.hoc.HocObject - Hoc Object wrapper";
131 #define HocTopContextSet \ 132 if (hoc_thisobject) { \ 135 assert(hoc_thisobject == 0); 136 #define HocContextRestore 166 static PyObject*
nrnexec(PyObject*
self, PyObject* args) {
168 if (!PyArg_ParseTuple(args,
"s", &cmd)) {
172 return Py_BuildValue(
"i", b ? 1 : 0);
175 static PyObject*
hoc_ac(PyObject*
self, PyObject* args) {
176 PyArg_ParseTuple(args,
"|d", &
hoc_ac_);
177 return Py_BuildValue(
"d",
hoc_ac_);
181 {
"execute",
nrnexec, METH_VARARGS,
182 "Execute a hoc command, return 1 on success, 0 on failure."},
183 {
"hoc_ac",
hoc_ac, METH_VARARGS,
"Get (or set) the scalar hoc_ac_."},
198 if (self->indices_) {
199 delete[]
self->indices_;
204 ((PyObject*)
self)->ob_type->tp_free((PyObject*)
self);
215 subself = subtype->tp_alloc(subtype, 0);
217 if (subself == NULL) {
224 self->indices_ =
NULL;
228 if (kwds && PyDict_Check(kwds)) {
229 PyObject* base = PyDict_GetItemString(kwds,
"hocbase");
232 if (PyObject_TypeCheck(base, hocobject_type)) {
235 hbase->
sym_->type == TEMPLATE) {
239 PyDict_DelItemString(kwds,
"hocbase");
255 PyErr_SetString(PyExc_TypeError,
"HOC base class not valid");
263 static int hocobj_init(PyObject* subself, PyObject* args, PyObject* kwds) {
267 if (subself != NULL) {
273 self->indices_ =
NULL;
300 self->ho_ ?
"." :
"", self->sym_->name);
302 for (
int i = 0;
i <
self->nindex_; ++
i) {
303 sprintf(cp += strlen(cp),
"[%d]", self->indices_[
i]);
305 sprintf(cp += strlen(cp),
"[?]");
307 sprintf(cp += strlen(cp),
"()");
310 sprintf(cp,
"<hoc ref value %g>", self->u.x_);
312 sprintf(cp,
"<hoc ref str \"%s\">", self->u.s_);
314 sprintf(cp,
"<hoc ref pstr \"%s\">", *self->u.pstr_);
318 sprintf(cp,
"<all section iterator next>");
320 sprintf(cp,
"<SectionList iterator>");
322 sprintf(cp,
"<pointer to hoc scalar %g>",
323 self->u.px_ ? *self->u.px_ : -1e100);
325 sprintf(cp,
"<incomplete pointer to hoc array %s>", self->sym_->name);
327 sprintf(cp,
"<TopLevelHocInterpreter>");
329 po = Py_BuildValue(
"s", buf);
342 int i,
narg = PyTuple_Size(args);
343 for (i = 0; i <
narg; ++
i) {
344 PyObject* po = PyTuple_GetItem(args, i);
348 PyObject* pn = PyNumber_Float(po);
361 s2free.push_back(*ts);
362 hoc_execerr_ext(
"python string arg cannot decode into c_str. Pyerr message: %s", *ts);
365 s2free.push_back(*ts);
367 }
else if (PyObject_TypeCheck(po, hocobject_type)) {
410 std::vector<char*>::iterator it = s2free.begin();
411 for (; it != s2free.end(); ++it) {
423 if (!sym && strcmp(name,
"delay") == 0) {
425 }
else if (!sym && ho->
aliases) {
434 if (sym && sym->
type == UNDEF) {
439 sprintf(e,
"'%s' is not a defined hoc variable name.", name);
440 PyErr_SetString(PyExc_LookupError, e);
451 hoc_return_type_code = 0;
465 fc[3].
i = po->
ho_->ctemplate->id;
471 if (po->
ho_->ctemplate->id <= hoc_max_builtin_class_id) {
474 hoc_return_type_code = 0;
484 int rval = PyNumber_Check(po);
486 if (rval == 1 && po->ob_type->tp_as_sequence) {
492 PyObject* tmp = PyNumber_Float(po);
511 po = Py_BuildValue(
"");
512 }
else if (o->ctemplate->sym == nrnpy_pyobj_sym_) {
533 }
else if (PyObject_TypeCheck(po, hocobject_type)) {
564 result = Py_BuildValue(
"d", *px);
566 PyErr_SetString(PyExc_AttributeError,
"POINTER is NULL");
571 result = Py_BuildValue(
"d",
hoc_xpop());
592 if (PyArg_Parse(po,
"s", &s) == 1) {
601 if (PyArg_Parse(po,
"d", &x) == 1) {
608 PyErr_SetString(PyExc_AttributeError,
"POINTER is NULL");
618 if (PyArg_Parse(po,
"O!", hocobject_type, &pho) == 1) {
621 PyErr_SetString(PyExc_TypeError,
622 "argument cannot be a hoc object intermediate");
643 return (
void*) Py_BuildValue(
"i", (
long)
hoc_xpop());
647 return (
void*) PyBool_FromLong((
long)
hoc_xpop());
650 static void*
fcall(
void* vself,
void* vargs) {
658 std::vector<char*> strings_to_free;
663 self->nindex_ =
narg;
675 if (self->sym_->type == BLTIN) {
681 }
else if (self->sym_->type == TEMPLATE) {
692 fc[1].sym =
self->sym_;
708 return PyTuple_GetItem(curargs_, i);
720 PyObject* section = 0;
722 if (kwrds && PyDict_Check(kwrds)) {
724 PyObject* keys = PyDict_Keys(kwrds);
725 assert(PyList_Check(keys));
726 int n = PyList_Size(keys);
727 for (
int i = 0;
i <
n; ++
i) {
728 PyObject*
key = PyList_GetItem(keys,
i);
729 PyObject*
value = PyDict_GetItem(kwrds, key);
730 printf(
"%s %s\n", PyUnicode_AsUTF8(key), PyUnicode_AsUTF8(PyObject_Str(value)));
733 section = PyDict_GetItemString(kwrds,
"sec");
734 int num_kwargs = PyDict_Size(kwrds);
735 if (num_kwargs > 1) {
736 PyErr_SetString(PyExc_RuntimeError,
"invalid keyword argument");
737 curargs_ = prevargs_;
745 curargs_ = prevargs_;
750 PyErr_SetString(PyExc_TypeError,
"sec is not a Section");
751 curargs_ = prevargs_;
756 PyErr_SetString(PyExc_RuntimeError,
"invalid keyword argument");
757 curargs_ = prevargs_;
763 result =
nrnexec((PyObject*)
self, args);
768 result = (PyObject*)oj->
fpycall(
fcall, (
void*)
self, (
void*)args);
770 if (result == NULL) {
771 PyErr_SetString(PyExc_RuntimeError,
"hocobj_call error");
774 result = (PyObject*)
fcall((
void*)
self, (
void*)args);
778 PyErr_SetString(PyExc_TypeError,
"object is not callable");
779 curargs_ = prevargs_;
785 curargs_ = prevargs_;
801 if (sym->
type == VAR &&
842 for (i = 0; i <
n; ++
i) {
891 if (PyObject_TypeCheck(po, hocobject_type)) {
902 PyObject* nn = Py_BuildValue(
"");
904 if (
s->type == UNDEF) {
continue; }
905 if (
s->cpublic == 1 || sl == hoc_built_in_symlist ||
906 sl == hoc_top_level_symlist) {
907 if (strcmp(
s->name,
"del") == 0) {
908 PyDict_SetItemString(dict,
"delay", nn);
910 PyDict_SetItemString(dict,
s->name, nn);
919 if (pfunc_get_docstring) {
922 pdoc = PyImport_ImportModule(
"neuron.doc");
924 PyErr_SetString(PyExc_ImportError,
925 "Failed to import neuron.doc documentation module.");
928 pfunc_get_docstring = PyObject_GetAttrString(pdoc,
"get_docstring");
930 if (pfunc_get_docstring == NULL) {
932 PyExc_AttributeError,
933 "neuron.doc module does not have attribute 'get_docstring'!");
943 PyObject* descr = PyDict_GetItemString(topmethdict, n);
946 descrgetfunc f = descr->ob_type->tp_descr_get;
948 result = f(descr, subself, (PyObject*)Py_TYPE(subself));
959 PyErr_SetString(PyExc_TypeError,
"not a compound type");
968 name.
set_pyerr(PyExc_TypeError,
"attribute name must be a string");
975 self->ho_->ctemplate->sym == nrnpy_pyobj_sym_) {
977 return PyObject_GenericGetAttr(p, pyname);
985 if (strcmp(n,
"__dict__") == 0) {
989 sl =
self->ho_->ctemplate->symtable;
990 }
else if (self->sym_ && self->sym_->type == TEMPLATE) {
991 sl =
self->sym_->u.ctemplate->symtable;
993 PyObject* dict = PyDict_New();
1005 PyDict_SetItemString(dict,
"__array_interface__", Py_None);
1007 PyDict_SetItemString(dict,
"plot", Py_None);
1010 }
else if (strncmp(n,
"_ref_", 5) == 0) {
1012 PyErr_SetString(PyExc_TypeError,
1013 "not a HocTopLevelInterpreter or HocObject");
1016 sym =
getsym(n + 5, self->ho_, 0);
1018 return PyObject_GenericGetAttr((PyObject*)subself, pyname);
1024 }
else if (self->type_ ==
PyHoc::HocObject && !self->ho_->ctemplate->constructor) {
1031 char** cpp =
OPSTR(sym);
1038 "Hoc pointer error, %s is not a hoc variable or range variable or strdef",
1040 PyErr_SetString(PyExc_TypeError, buf);
1046 strcmp(n,
"__array_interface__") == 0) {
1049 Vect*
v = (
Vect*)self->ho_->u.this_pointer;
1050 int size = v->size();
1053 return Py_BuildValue(
"{s:(i),s:s,s:i,s:(N,O)}",
"shape", size,
"typestr",
1054 array_interface_typestr,
"version", 3,
"data",
1055 PyLong_FromVoidPtr(x), Py_True);
1057 }
else if (
is_obj_type(self->ho_,
"RangeVarPlot") && strcmp(n,
"plot") == 0) {
1058 return PyObject_CallFunctionObjArgs(rvp_plot, (PyObject*)
self, NULL);
1059 }
else if (
is_obj_type(self->ho_,
"PlotShape") && strcmp(n,
"plot") == 0) {
1060 return PyObject_CallFunctionObjArgs(plotshape_plot, (PyObject*)
self, NULL);
1061 }
else if (strcmp(n,
"__doc__") == 0) {
1063 PyObject* docobj =
NULL;
1065 docobj = Py_BuildValue(
"s s", self->ho_->ctemplate->sym->name,
1066 self->sym_ ? self->sym_->name :
"");
1067 }
else if (self->sym_) {
1069 docobj = Py_BuildValue(
"s s",
"", self->sym_->name);
1073 docobj = Py_BuildValue(
"s s",
"",
"");
1076 result = PyObject_CallObject(pfunc_get_docstring, docobj);
1083 strncmp(n,
"__nrnsec_0x", 11) == 0) {
1086 PyErr_SetString(PyExc_NameError, n);
1097 strncmp(n,
"__pysec_", 8) == 0) {
1100 PyErr_SetString(PyExc_NameError, n);
1113 return PyObject_GenericGetAttr((PyObject*)subself, pyname);
1123 "No hoc method for a callable. Missing parentheses before the '.'?");
1127 PyErr_SetString(PyExc_TypeError,
"Missing array index");
1133 po->
ho_ =
self->ho_;
1139 if (t == VAR || t ==
STRING || t == OBJECTVAR || t == RANGEVAR ||
1141 if (sym != nrn_child_sym && !
ISARRAY(sym)) {
1147 PyErr_SetString(PyExc_TypeError,
"No value");
1153 if (t == SECTION || t == SECTIONREF) {
1183 result = Py_BuildValue(
"i", *(sym->
u.
pvalint));
1188 PyErr_SetString(PyExc_TypeError,
"Section access unspecified");
1199 PyErr_SetString(PyExc_TypeError,
"Cannot be a reference");
1208 result = Py_BuildValue(
"d", *
hoc_pxpop());
1251 case HOCOBJFUNCTION:
1258 po->
ho_ =
self->ho_;
1266 case SETPOINTERKEYWORD:
1271 if (PyDict_GetItemString(pmech_types, n)) {
1272 result = PyObject_CallFunction(get_mech_object_,
"s", n);
1274 }
else if (PyDict_GetItemString(rangevars_, n)) {
1275 PyErr_Format(PyExc_TypeError,
"Cannot access %s directly; it is a range variable and may be accessed via a section or segment.", n);
1277 PyErr_Format(PyExc_TypeError,
"Cannot access %s (NEURON type %d) directly.", n, sym->
type);
1287 if (!PyArg_ParseTuple(args,
"O", &name)) {
1296 if ((PyTypeObject*)PyObject_Type(subself) != hocobject_type) {
1298 result = PyObject_GenericGetAttr(subself, name);
1306 if (!refuse_to_look) {
1318 int issub = ((PyTypeObject*)PyObject_Type(subself) !=
hocobject_type);
1322 if (PyObject_HasAttr(subself, pyname)) {
1325 return PyObject_GenericSetAttr(subself, pyname, value);
1339 name.
set_pyerr(PyExc_TypeError,
"attribute name must be a string");
1346 return PyObject_GenericSetAttr(subself, pyname, value);
1348 self->ho_->ctemplate->sym == nrnpy_pyobj_sym_) {
1350 return PyObject_GenericSetAttr(p, pyname, value);
1351 }
else if (strncmp(n,
"_ref_", 5) == 0) {
1354 if (rvsym && rvsym->
type == RANGEVAR) {
1357 PyErr_SetString(PyExc_TypeError,
"Point_process not located in a section");
1363 sym =
getsym(n, self->ho_, 1);
1365 sym =
getsym(n, self->ho_, 1);
1374 po->
ho_ =
self->ho_;
1380 if (t == VAR || t ==
STRING || t == OBJECTVAR || t == RANGEVAR ||
1388 PyErr_SetString(PyExc_TypeError,
"No value");
1396 sprintf(e,
"'%s' requires subscript for assignment", n);
1397 PyErr_SetString(PyExc_TypeError, e);
1402 PyErr_SetString(PyExc_TypeError,
"not assignable");
1410 PyErr_SetString(PyExc_TypeError,
"wrong number of subscripts");
1414 err = PyArg_Parse(value,
"i", sym->
u.
pvalint) == 0;
1417 PyErr_SetString(PyExc_TypeError,
"Section access unspecified");
1424 if (PyArg_Parse(value,
"i", &i) != 0 && i > 0 && i <= 32767) {
1427 PyErr_SetString(PyExc_ValueError,
"nseg must be an integer in range 1 to 32767");
1431 err = PyArg_Parse(value,
"d", &x) == 0;
1439 err = PyArg_Parse(value,
"d",
hoc_pxpop()) == 0;
1442 sprintf(mes,
"Assignment to %s value of physical constant %s",
1445 err = PyErr_WarnEx(PyExc_Warning, mes, 1);
1456 if (PyArg_Parse(value,
"s", &s) == 1) {
1469 if (PyArg_Parse(value,
"O", &po) == 1) {
1470 if (po == Py_None) {
1473 }
else if (PyObject_TypeCheck(po, hocobject_type)) {
1476 PyErr_SetString(PyExc_TypeError,
1477 "argument cannot be a hoc object intermediate");
1493 PyErr_SetString(PyExc_TypeError,
"not assignable");
1510 if (po->
sym_ == sym_vec_x) {
1512 }
else if (po->
sym_ == sym_netcon_weight) {
1515 }
else if (po->
sym_ == nrn_child_sym) {
1517 }
else if (po->
sym_ == sym_mat_x) {
1527 if (ix < 0 || n <= ix) {
1533 PyErr_SetString(PyExc_IndexError, e);
1542 if (po->
ho_->ctemplate == hoc_vec_template_) {
1544 }
else if (po->
ho_->ctemplate == hoc_list_template_) {
1546 }
else if (po->
ho_->ctemplate == hoc_sectionlist_template_) {
1547 PyErr_SetString(PyExc_TypeError,
"hoc.SectionList has no len()");
1553 }
else if (po->
sym_ && po->
sym_->type == TEMPLATE) {
1554 return po->
sym_->u.ctemplate->count;
1556 PyErr_SetString(PyExc_TypeError,
"hoc all section iterator() has no len()");
1559 PyErr_SetString(PyExc_TypeError,
"hoc SectionList iterator() has no len()");
1562 PyErr_SetString(PyExc_TypeError,
"Most HocObject have no len()");
1571 if (po->
ho_->ctemplate == hoc_vec_template_) {
1573 }
else if (po->
ho_->ctemplate == hoc_list_template_) {
1579 }
else if (po->
sym_ && po->
sym_->type == TEMPLATE) {
1586 PyObject* po =
hocobj_new(hocobject_type, 0, 0);
1598 if (po->
ho_->ctemplate == hoc_vec_template_) {
1599 return PySeqIter_New(
self);
1600 }
else if (po->
ho_->ctemplate == hoc_list_template_) {
1601 return PySeqIter_New(
self);
1602 }
else if (po->
ho_->ctemplate == hoc_sectionlist_template_) {
1617 return PySeqIter_New(
self);
1618 }
else if (po->
sym_ && po->
sym_->type == TEMPLATE) {
1623 PyErr_SetString(PyExc_TypeError,
"Not an iterable HocObject");
1630 for ( next = q->
next; next != ql; next = nextnext) {
1631 nextnext = next->
next;
1688 if (curitem != ql) {
1746 }
else if (po->
sym_->type == TEMPLATE) {
1748 if (q != po->
sym_->u.ctemplate->olist) {
1768 PyErr_SetString(PyExc_IndexError,
"index for hoc ref must be 0");
1772 result = Py_BuildValue(
"d", po->
u.
px_[ix]);
1774 result = Py_BuildValue(
"d", po->
u.
x_);
1776 result = Py_BuildValue(
"s", po->
u.
s_);
1778 result = Py_BuildValue(
"s", *po->
u.
pstr_);
1785 if (po->
ho_->ctemplate == hoc_vec_template_) {
1790 PyErr_SetString(PyExc_IndexError, e);
1793 return PyFloat_FromDouble(
vector_vec(hv)[ix]);
1795 }
else if (po->
ho_->ctemplate == hoc_list_template_) {
1797 if (ix < 0 || ix >= hl->
count()) {
1800 PyErr_SetString(PyExc_IndexError, e);
1806 PyErr_SetString(PyExc_TypeError,
"unsubscriptable object");
1813 PyErr_SetString(PyExc_TypeError,
"unsubscriptable object");
1815 }
else if (po->
sym_->type == TEMPLATE) {
1820 if (ob->
index == ix) {
1825 sprintf(e,
"%s[%ld] instance does not exist", po->
sym_->name, ix);
1826 PyErr_SetString(PyExc_IndexError, e);
1831 sprintf(e,
"unsubscriptable object, type %d\n", po->
type_);
1832 PyErr_SetString(PyExc_TypeError, e);
1841 result = (PyObject*)ponew;
1845 if (po->
sym_->type == SECTION || po->
sym_->type == SECTIONREF) {
1867 result = Py_BuildValue(
"d", *
hoc_pxpop());
1894 PyErr_SetString(PyExc_TypeError,
"incomplete hoc pointer");
1898 PyErr_SetString(PyExc_IndexError,
"index for hoc ref must be 0");
1902 PyArg_Parse(arg,
"d", po->
u.
px_ + i);
1904 PyArg_Parse(arg,
"d", &po->
u.
x_);
1907 PyArg_Parse(arg,
"s", &ts);
1911 PyArg_Parse(arg,
"s", &ts);
1915 PyArg_Parse(arg,
"O", &tp);
1921 if (po->
ho_->ctemplate == hoc_vec_template_) {
1928 if (i >= vec_size || i < 0) {
1929 PyErr_SetString(PyExc_IndexError,
"index out of bounds");
1937 PyErr_SetString(PyExc_TypeError,
"unsubscriptable object");
1942 PyErr_SetString(PyExc_TypeError,
"wrong number of subscripts");
1949 if (po->
sym_->type == SECTION) {
1950 PyErr_SetString(PyExc_TypeError,
"not assignable");
1961 err = PyArg_Parse(arg,
"d",
hoc_pxpop()) != 1;
1970 if (PyArg_Parse(arg,
"O", &pyo) == 1) {
1981 PyErr_SetString(PyExc_TypeError,
"not assignable");
1989 static PyObject*
mkref(PyObject*
self, PyObject* args) {
1992 if (PyArg_ParseTuple(args,
"O", &pa) == 1) {
1996 PyObject* pn = PyNumber_Float(pa);
1997 result->
u.
x_ = PyFloat_AsDouble(pn);
2004 str.
set_pyerr(PyExc_TypeError,
"string arg must have only ascii characters");
2008 char* cpa = str.
c_str();
2014 return (PyObject*)
result;
2016 PyErr_SetString(PyExc_TypeError,
2017 "single arg must be number, string, or Object");
2039 return (PyObject*)
result;
2044 if (PyArg_ParseTuple(args,
"O!OO", hocobject_type, &ref, &name, &pp) == 1) {
2050 if (PyObject_TypeCheck(pp, hocobject_type)) {
2058 str.
set_pyerr(PyExc_TypeError,
"POINTER name can contain only ascii characters");
2067 PyErr_SetString(PyExc_TypeError,
"Point_process not located in a section");
2083 PyErr_SetString(PyExc_TypeError,
2084 "setpointer(_ref_hocvar, 'POINTER_name', point_process or " 2092 PyObject* po =
NULL;
2094 po = Py_BuildValue(
"O", PyLong_FromVoidPtr(ho));
2097 PyErr_SetString(PyExc_TypeError,
"HocObject does not wrap a Hoc Object");
2108 result = self_ptr < other_ptr;
2111 result = self_ptr <= other_ptr;
2114 result = self_ptr == other_ptr;
2117 result = self_ptr != other_ptr;
2120 result = self_ptr > other_ptr;
2123 result = self_ptr >= other_ptr;
2134 void* self_ptr = (
void*)(self->ho_);
2135 void* other_ptr = (
void*)other;
2136 bool are_equal =
true;
2137 if (PyObject_TypeCheck(other, hocobject_type)) {
2138 if (((
PyHocObject*)other)->type_ == self->type_) {
2139 switch(self->type_) {
2145 self_ptr = (
void*)
self;
2148 if (self->ho_ != (
void*)(((
PyHocObject*)other)->ho_)) {
2151 }
else if (op == Py_EQ) {
2155 PyErr_SetString(PyExc_TypeError,
"this comparison is undefined");
2158 self_ptr = (
void*) self->sym_;
2159 other_ptr = (
void*) (((
PyHocObject*)other)->sym_);
2162 self_ptr =
self->u.px_;
2163 other_ptr = (
void*)(((
PyHocObject*)other)->u.px_);
2167 if (op != Py_EQ && op != Py_NE) {
2169 PyErr_SetString(PyExc_TypeError,
"this comparison is undefined");
2172 if (self->ho_ != (
void*)(((
PyHocObject*)other)->ho_)) {
2183 for (
int i = 0;
i <
self->nindex_;
i++) {
2184 if (self->indices_[
i] != ((
PyHocObject*)other)->indices_[
i]) {
2188 if (are_equal == (op == Py_EQ)) {
2198 }
else if (op == Py_NE) {
2202 PyErr_SetString(PyExc_TypeError,
"this comparison is undefined");
2211 if (PyArg_ParseTuple(args,
"O", &po)) {
2212 if (PyObject_TypeCheck(po, hocobject_type)) {
2226 if (PyObject_HasAttrString(po,
"__array_interface__")) {
2227 PyObject* ai = PyObject_GetAttrString(po,
"__array_interface__");
2228 Py2NRNString typestr(PyDict_GetItemString(ai,
"typestr"));
2230 data = PyLong_AsVoidPtr(
2231 PyTuple_GetItem(PyDict_GetItemString(ai,
"data"), 0));
2233 if (PyErr_Occurred()) {
2236 pstride = PyDict_GetItemString(ai,
"strides");
2237 if (pstride == Py_None) {
2239 }
else if (PyTuple_Check(pstride)) {
2240 if (PyTuple_Size(pstride) == 1) {
2241 psize = PyTuple_GetItem(pstride, 0);
2242 if (PyLong_Check(psize)) {
2243 stride = PyLong_AsLong(psize);
2248 PyErr_SetString(PyExc_TypeError,
2249 "array_interface stride element of invalid type.");
2256 PyErr_SetString(PyExc_TypeError,
2257 "array_interface stride object of invalid type.");
2263 return static_cast<char*
>(
data);
2270 if (ho->ctemplate->sym != nrnpy_pyobj_sym_) {
2275 if (!PySequence_Check(po)) {
2276 if (!PyIter_Check(po)) {
2279 " does not support the Python Sequence or Iterator protocol");
2281 PyObject* iterator = PyObject_GetIter(po);
2282 assert(iterator != NULL);
2285 while ((p = PyIter_Next(iterator)) != NULL) {
2286 if (!PyNumber_Check(p)) {
2288 sprintf(buf,
"item %d not a number", i);
2291 hv->push_back(PyFloat_AsDouble(p));
2295 Py_DECREF(iterator);
2297 int size = PySequence_Size(po);
2304 for (
int i = 0,
j = 0;
i < size; ++
i,
j +=
stride) {
2305 x[
i] = *(
double*)(y + j);
2308 for (
int i = 0;
i < size; ++
i) {
2309 PyObject*
p = PySequence_GetItem(po,
i);
2310 if (!PyNumber_Check(p)) {
2312 sprintf(buf,
"item %d not a number",
i);
2315 x[
i] = PyFloat_AsDouble(p);
2324 static PyObject* (*vec_as_numpy)(
int,
double*);
2335 if(store_savestate_) {
2337 PyObject *args = PyTuple_New(0);
2338 PyObject*
result = PyObject_CallObject(store_savestate_, args);
2341 if (result == NULL) {
2346 delete[] (*save_data);
2348 *save_data_size = PyByteArray_Size(result);
2349 *save_data =
new char[*save_data_size];
2350 memcpy(*save_data, PyByteArray_AsString(result), *save_data_size);
2353 *save_data_size = 0;
2358 if(restore_savestate_) {
2359 PyObject *args = PyTuple_New(1);
2360 PyObject *py_data = PyByteArray_FromStringAndSize(data, size);
2362 if (py_data == NULL) {
2366 PyTuple_SetItem(args, 0, py_data);
2367 PyObject*
result = PyObject_CallObject(restore_savestate_, args);
2369 if (result == NULL) {
2374 hoc_execerror(
"SaveState:",
"Missing data restore function.");
2379 extern "C" int nrnpy_set_toplevel_callbacks(PyObject* rvp_plot0, PyObject* plotshape_plot0, PyObject* get_mech_object_0, PyObject* store_savestate, PyObject* restore_savestate) {
2380 rvp_plot = rvp_plot0;
2381 plotshape_plot = plotshape_plot0;
2382 get_mech_object_ = get_mech_object_0;
2383 store_savestate_ = store_savestate;
2384 restore_savestate_ = restore_savestate;
2392 gui_callback = new_gui_callback;
2399 const double result = PyFloat_AsDouble(pyobj);
2406 if (obj->ctemplate->sym == nrnpy_pyobj_sym_) {
2415 Py_DECREF((PyObject*) pyobj);
2421 while (
ifarg(narg)) {
2425 PyObject* args = PyTuple_New(narg + 3);
2427 PyTuple_SetItem(args, 0, pyname);
2428 for(
int iarg=0; iarg<
narg; iarg++) {
2429 const int iiarg = iarg + 1;
2432 PyTuple_SetItem(args, iarg + 3, active_obj);
2437 PyObject* py_ptr = (PyObject*) ptr_nrn;
2439 PyTuple_SetItem(args, iarg + 3, py_ptr);
2441 if (handle_strptr > 0) {
2445 PyTuple_SetItem(args, iarg + 3, py_ptr);
2448 PyTuple_SetItem(args, iarg + 3, py_str); }
2450 PyObject* py_double = PyFloat_FromDouble(*
getarg(iiarg));
2451 PyTuple_SetItem(args, iarg + 3, py_double);
2462 PyTuple_SetItem(args, 1, my_obj);
2464 if (hoc_thisobject && name[0] !=
'~') {
2471 PyTuple_SetItem(args, 2, my_obj2);
2472 PyObject* po = PyObject_CallObject(gui_callback, args);
2473 if (PyErr_Occurred()) {
2477 po = PyLong_FromLong(0);
2517 PyObject* po = (*vec_as_numpy)(size,
data);
2518 if (po != Py_None) {
2531 int size = hv->size();
2545 if (ho->ctemplate->sym != nrnpy_pyobj_sym_) {
2549 if (!PySequence_Check(po)) {
2552 if (size != PySequence_Size(po)) {
2554 "Python Sequence not same size as Vector");
2557 if ((po = PyList_New(size)) == NULL) {
2558 hoc_execerror(
"Could not create new Python List with correct size.", 0);
2569 for (
int i = 0,
j = 0;
i < size; ++
i,
j +=
stride) {
2570 *(
double*)(y + j) = x[
i];
2572 }
else if (PyList_Check(po)) {
2573 for (
int i = 0;
i < size; ++
i) {
2574 PyObject* pn = PyFloat_FromDouble(x[
i]);
2575 if (!pn || PyList_SetItem(po, i, pn) == -1) {
2577 sprintf(buf,
"%d of %d", i, size);
2582 for (
int i = 0;
i < size; ++
i) {
2583 PyObject* pn = PyFloat_FromDouble(x[
i]);
2584 if (!pn || PySequence_SetItem(po, i, pn) == -1) {
2586 sprintf(buf,
"%d of %d", i, size);
2598 PyObject*
result = PyObject_CallFunctionObjArgs(nrnpy_rvp_pyobj_callback, py_obj, NULL);
2613 PyErr_SetString(PyExc_TypeError,
"get_plotshape_variable only takes PlotShape objects");
2616 void* that = pho->
ho_->u.this_pointer;
2619 spi = ((ShapePlot*) that);
2626 Object*
sl = spi->neuron_section_list();
2628 PyObject* py_obj = (PyObject*) spi->varobj();
2633 return Py_BuildValue(
"sOffN",spi->varname(), py_obj, spi->low(), spi->high(), py_sl);
2642 PyErr_SetString(PyExc_TypeError,
2643 "HocObject: Only Vector instance can be pickled");
2649 PyObject* mod = PyImport_ImportModule(
"neuron");
2653 PyObject* obj = PyObject_GetAttrString(mod,
"_pkl");
2656 PyErr_SetString(PyExc_Exception,
"neuron module has no _pkl method.");
2660 PyObject*
ret = PyTuple_New(3);
2664 PyTuple_SET_ITEM(ret, 0, obj);
2665 PyTuple_SET_ITEM(ret, 1, Py_BuildValue(
"(N)",
PyInt_FromLong(0)));
2672 PyObject* state = PyTuple_New(4);
2673 if (state == NULL) {
2679 PyObject* str = PyBytes_FromStringAndSize((
const char*)(&x),
sizeof(
double));
2685 PyTuple_SET_ITEM(state, 1, str);
2687 str = PyBytes_FromStringAndSize((
const char*)
vector_vec(vec),
2688 vec->size() *
sizeof(double));
2694 PyTuple_SET_ITEM(state, 3, str);
2695 PyTuple_SET_ITEM(ret, 2, state);
2700 #define BYTEHEADER \ 2704 int BYTESWAP_FLAG = 0; 2705 #define BYTESWAP(_X__, _TYPE__) \ 2706 if (BYTESWAP_FLAG == 1) { \ 2707 _IN__ = (char*)&(_X__); \ 2708 for (_II__ = 0; _II__ < sizeof(_TYPE__); _II__++) { \ 2709 _OUT__[_II__] = _IN__[sizeof(_TYPE__) - _II__ - 1]; \ 2711 (_X__) = *((_TYPE__*)&_OUT__); \ 2718 PyObject* rawdata =
NULL;
2719 PyObject* endian_data;
2723 if (!PyArg_ParseTuple(args,
"(iOiO)", &version, &endian_data, &size,
2727 Py_INCREF(endian_data);
2731 if (!PyBytes_Check(rawdata) || !PyBytes_Check(endian_data)) {
2732 PyErr_SetString(PyExc_TypeError,
"pickle not returning string");
2733 Py_DECREF(endian_data);
2739 if (PyBytes_AsStringAndSize(endian_data, &datastr, &len) < 0) {
2740 Py_DECREF(endian_data);
2744 if (len !=
sizeof(
double)) {
2745 PyErr_SetString(PyExc_ValueError,
"endian_data size is not sizeof(double)");
2746 Py_DECREF(endian_data);
2751 if (*((
double*)datastr) != 2.0) {
2754 Py_DECREF(endian_data);
2756 if (PyBytes_AsStringAndSize(rawdata, &datastr, &len) < 0) {
2760 if (len != size *
sizeof(
double)) {
2761 PyErr_SetString(PyExc_ValueError,
"buffer size does not match array size");
2765 if (BYTESWAP_FLAG) {
2766 double* x = (
double*)datastr;
2767 for (
int i = 0;
i < size; ++
i) {
2771 memcpy((
char*)
vector_vec(vec), datastr, len);
2778 #if defined(HAVE_DLFCN_H) && !defined(MINGW) 2780 int rval =
dladdr((
const void*)Py_Initialize, &info);
2782 PyErr_SetString(PyExc_Exception,
"dladdr: Py_Initialize could not be matched to a shared object");
2786 PyErr_SetString(PyExc_Exception,
"dladdr: No symbol matching Py_Initialize could be found.");
2789 return Py_BuildValue(
"s", info.
dli_fname);
2799 "To allow use of an overrided base method"},
2800 {
"hocobjptr",
hocobj_vptr, METH_NOARGS,
"Hoc Object pointer as a long int"},
2802 "o1.same(o2) return True if o1 and o2 wrap the same internal HOC Object"},
2804 "More specific than __str__() or __attr__()."},
2811 {
"ref",
mkref, METH_VARARGS,
2812 "Wrap to allow call by reference in a hoc function"},
2813 {
"cas",
nrnpy_cas, METH_VARARGS,
"Return the currently accessed section."},
2815 "Return iterator over all sections."},
2816 {
"Section", (PyCFunction)
nrnpy_newsecobj, METH_VARARGS | METH_KEYWORDS,
2817 "Return a new Section"},
2819 "Assign hoc variable address to NMODL POINTER"},
2821 "Return full path to file that contains Py_Initialize()"},
2825 for (PyMethodDef* meth = toplevel_methods; meth->ml_name !=
NULL; meth++) {
2827 PyObject* nn = Py_BuildValue(
"s", meth->ml_doc);
2831 err = PyDict_SetItemString(dict, meth->ml_name, nn);
2842 nrnpy_vec_math = callback;
2847 nrnpy_rvp_pyobj_callback = callback;
2852 if (PyObject_TypeCheck(obj, hocobject_type)) {
2856 if (obj_h->
ho_->ctemplate == hoc_vec_template_) {
2865 bool potentially_valid =
false;
2868 potentially_valid =
true;
2870 potentially_valid =
true;
2873 if (!potentially_valid){
2874 Py_INCREF(Py_NotImplemented);
2875 return Py_NotImplemented;
2878 return PyObject_CallFunction(nrnpy_vec_math, strcpy(buf,
"siOO"), op, reversed, obj1, obj2);
2884 return PyObject_CallFunction(nrnpy_vec_math, strcpy(buf,
"siO"), op, 2, obj);
2886 Py_INCREF(Py_NotImplemented);
2887 return Py_NotImplemented;
2924 char endian_character = 0;
2926 PyObject* psys = PyImport_ImportModule(
"sys");
2928 PyErr_SetString(PyExc_ImportError,
2929 "Failed to import sys to determine system byteorder.");
2933 PyObject* pbo = PyObject_GetAttrString(psys,
"byteorder");
2935 PyErr_SetString(PyExc_AttributeError,
2936 "sys module does not have attribute 'byteorder'!");
2945 if (strcmp(byteorder.
c_str(),
"little") == 0) {
2946 endian_character =
'<';
2947 }
else if (strcmp(byteorder.
c_str(),
"big") == 0) {
2948 endian_character =
'>';
2950 PyErr_SetString(PyExc_RuntimeError,
"Unknown system native byteorder.");
2953 return endian_character;
2957 if (!args || args->ctemplate->sym != nrnpy_pyobj_sym_) {
2962 PyObject *iterator = PyObject_GetIter(pargs);
2965 if (iterator == NULL) {
2970 while ((item = PyIter_Next(iterator))) {
2972 hoc_execerror(
"iterable must contain only Section objects", 0);
2979 Py_DECREF(iterator);
2980 if (PyErr_Occurred()) {
3000 PyObject* modules = PyImport_GetModuleDict();
3002 PyObject* module = PyDict_GetItemString(modules,
"neuron.coreneuron");
3004 PyObject*
val = PyObject_GetAttrString(module, option);
3006 long enable = PyLong_AsLong(val);
3014 if (PyErr_Occurred()) {
3036 extern char* (*nrnpy_nrncore_arg_p_)(
double tstop);
3038 PyObject* modules = PyImport_GetModuleDict();
3040 PyObject* module = PyDict_GetItemString(modules,
"neuron.coreneuron");
3042 PyObject* callable = PyObject_GetAttrString(module,
"nrncore_arg");
3044 PyObject* ts = Py_BuildValue(
"(d)", tstop);
3046 PyObject*
arg = PyObject_CallObject(callable, ts);
3052 str.
set_pyerr(PyExc_TypeError,
"neuron.coreneuron.nrncore_arg() must return an ascii string");
3055 if (strlen(str.
c_str()) > 0) {
3056 return strdup(str.
c_str());
3063 if (PyErr_Occurred()) {
3087 char endian_character = 0;
3090 PyObject* modules = PyImport_GetModuleDict();
3091 if ((m = PyDict_GetItemString(modules,
"hoc")) != NULL && PyModule_Check(m)) {
3098 if (PyType_Ready(hocobject_type) < 0)
goto fail;
3099 Py_INCREF(hocobject_type);
3101 PyModule_AddObject(m,
"HocObject", (PyObject*)hocobject_type);
3103 topmethdict = PyDict_New();
3104 for (PyMethodDef* meth = toplevel_methods; meth->ml_name !=
NULL; meth++) {
3107 descr = PyDescr_NewMethod(hocobject_type, meth);
3109 err = PyDict_SetItemString(topmethdict, meth->ml_name, descr);
3134 assert(sym_netcon_weight);
3138 if (endian_character == 0)
goto fail;
3139 array_interface_typestr[0] = endian_character;
3142 snprintf(array_interface_typestr + 2, 3,
"%ld",
sizeof(
double));
3143 err = PyDict_SetItemString(modules,
"hoc", m);
static void hocobj_pushtop(PyHocObject *po, Symbol *sym, int ix)
PyObject * nrnpy_hoc_pop()
static const char * hocobj_docstring
static PyObject * nrnexec(PyObject *self, PyObject *args)
void *(* nrnpy_get_pyobj)(Object *obj)
static Symbol * sym_vec_x
IvocVect *(* nrnpy_vec_from_python_p_)(void *)
#define HocContextRestore
Object **(* nrnpy_gui_helper_)(const char *, Object *)
HAVE_IV.
int(* nrnpy_nrncore_file_mode_value_p_)()
value of neuron.coreneuron.file_mode as 0, 1 (-1 if error)
int hoc_is_temp_charptr(char **cpp)
NPySecObj * newpysechelp(Section *sec)
int hoc_is_str_arg(int narg)
static void hocobj_objectvar(Symbol *sym)
static PyObject * py_hocobj_math_unary(const char *op, PyObject *obj)
PyObject * toplevel_get(PyObject *subself, const char *n)
void(* nrnpy_store_savestate)(char **save_data, uint64_t *save_data_size)
void(* nrnpy_sectionlist_helper_)(void *, Object *)
static long hocobj_hash(PyHocObject *self)
Object **(* nrnpy_vec_to_python_p_)(void *)
PyHoc::IteratorState its_
PyObject * nrn_ptr_richcmp(void *self_ptr, void *other_ptr, int op)
void hoc_pushobj(Object **d)
static Object * rvp_rxd_to_callable_(Object *obj)
PyObject * nrnpy_newsecobj(PyObject *, PyObject *, PyObject *)
static int hocobj_setitem(PyObject *self, Py_ssize_t i, PyObject *arg)
static struct PyModuleDef hocmodule
static void * fcall(void *vself, void *vargs)
void hoc_l_delete(hoc_Item *)
#define ITERATE(itm, lst)
int dladdr(const void *dl_restrict, Dl_info *dl_restrict)
static char * double_array_interface(PyObject *po, long &stride)
int hoc_is_double_arg(int narg)
static Inst * save_pc(Inst *newpc)
static Object ** gui_helper_3_(const char *name, Object *obj, int handle_strptr)
static void add2topdict(PyObject *)
Symbol * hoc_lookup(const char *)
int nrnpy_vec_math_register(PyObject *callback)
char * hoc_object_name(Object *ob)
void lvappendsec_and_ref(void *sl, Section *sec)
static int setup_doc_system()
Object *(* nrnpy_rvp_rxd_to_callable)(Object *)
static void * nrnpy_hoc_bool_pop()
static char ** gui_helper_3_str_(const char *name, Object *obj, int handle_strptr)
double cable_prop_eval(Symbol *sym)
static Py_ssize_t hocobj_len(PyObject *self)
static PyObject * hocpickle_reduce(PyObject *self, PyObject *args)
static PyObject * py_hocobj_mul(PyObject *obj1, PyObject *obj2)
static Symbol * sym_mat_x
Symbol * nrnpy_pyobj_sym_
static int refuse_to_look
static void symlist2dict(Symlist *sl, PyObject *dict)
char ** hoc_pgargstr(int narg)
static PyObject * store_savestate_
void hoc_object_component()
PyObject * hocobj_call_arg(int i)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
Object **(* nrnpy_vec_as_numpy_helper_)(int, double *)
static PyObject * hocobj_baseattr(PyObject *subself, PyObject *args)
static void eval_component(PyHocObject *po, int ix)
static PyObject * cpp2refstr(char **cpp)
static double object_to_double_(Object *obj)
static PyObject * hocobj_call(PyHocObject *self, PyObject *args, PyObject *kwrds)
Section * nrn_noerr_access()
int hoc_max_builtin_class_id
double * hoc_pgetarg(int narg)
void(* nrnpy_restore_savestate)(int64_t, char *)
PyObject * nrnpy_ho2po(Object *)
double hoc_call_func(Symbol *s, int narg)
static PyObject * gui_callback
static PyObject * rvp_plot
double ** nrnpy_setpointer_helper(PyObject *, PyObject *)
static double done(void *v)
void hoc_assign_str(char **cpp, const char *buf)
static PyObject * hocobj_iternext(PyObject *self)
int hoc_is_pdouble_arg(int narg)
PyTypeObject * psection_type
static PyObject * curargs_
char get_endian_character()
void cable_prop_assign(Symbol *sym, double *pd, int op)
int nrnpy_set_gui_callback(PyObject *)
static PyObject * hocobj_getattro(PyObject *subself, PyObject *name)
void hoc_execerr_ext(const char *fmt,...)
printf style specification of hoc_execerror message.
static char array_interface_typestr[5]
static Arrayinfo * hocobj_aray(Symbol *sym, Object *ho)
Object * nrnpy_po2ho(PyObject *)
static Symbol * sym_netcon_weight
static double ref(void *v)
int const size_t const size_t n
static int araychk(Arrayinfo *a, PyHocObject *po, int ix)
static PyObject * setpointer(PyObject *self, PyObject *args)
Object * hoc_newobj1(Symbol *, int)
static PyObject * hocobj_repr(PyObject *p)
Symlist * hoc_built_in_symlist
#define BYTESWAP(_X__, _TYPE__)
Objectdata * hoc_objectdata
int nrn_pointer_assign(Prop *prop, Symbol *sym, PyObject *value)
static Symbol * getsym(char *name, Object *ho, int fail)
PyObject * nrn_hocobj_ptr(double *pd)
void hoc_obj_unref(Object *obj)
static void hocobj_pushargs_free_strings(std::vector< char *> &s2free)
static void nrnpy_store_savestate_(char **save_data, uint64_t *save_data_size)
static bool pyobj_is_vector(PyObject *obj)
static hoc_Item * next_valid_secitem(hoc_Item *q, hoc_Item *ql)
static PyHocObject * intermediate(PyHocObject *po, Symbol *sym, int ix)
static PyMethodDef toplevel_methods[]
Objectdata * hoc_objectdata_restore(Objectdata *obdsav)
int nrnpy_numbercheck(PyObject *po)
int nrnpy_set_toplevel_callbacks(PyObject *rvp_plot0, PyObject *plotshape_plot0, PyObject *get_mech_object_0, PyObject *store_savestate, PyObject *restore_savestate)
void nrn_pushsec(Section *sec)
void * hoc_pysec_name2ptr(const char *s, int eflag)
static PyObject * hocobj_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
static PyObject * hocobj_richcmp(PyHocObject *self, PyObject *other, int op)
static void nrnpy_decref_(void *pyobj)
void hoc_execerror(const char *, const char *)
PyObject_HEAD Section * sec_
static PyObject * gui_helper_3_helper_(const char *name, Object *obj, int handle_strptr)
static PyObject * py_hocobj_uabs(PyObject *obj)
PyObject * nrnpy_forall(PyObject *, PyObject *)
Symbol * ivoc_alias_lookup(const char *name, Object *ob)
Object * hoc_obj_look_inside_stack(int)
char *(* nrnpy_nrncore_arg_p_)(double tstop)
Gets the python string returned by neuron.coreneuron.nrncore_arg(tstop) return a strdup() copy of the...
static PyType_Spec nrnpy_HocObjectType_spec
PyObject_HEAD Object * ho_
static cTemplate * hoc_sectionlist_template_
static Object ** vec_as_numpy_helper(int size, double *data)
static IvocVect * nrnpy_vec_from_python(void *v)
static int hocobj_init(PyObject *subself, PyObject *args, PyObject *kwds)
bool is_python_string(PyObject *python_string)
void hoc_push_object(Object *d)
static void nrnpy_restore_savestate_(int64_t size, char *data)
Point_process * ob2pntproc_0(Object *)
double * hoc_evalpointer()
static int hocobj_pushargs(PyObject *args, std::vector< char *> &s2free)
void hoc_obj_ref(Object *obj)
int nrn_matrix_dim(void *, int)
int nrnpy_set_vec_as_numpy(PyObject *(*p)(int, double *))
static void * nrnpy_get_pyobj_(Object *obj)
static PyObject * hocobj_vptr(PyObject *pself, PyObject *args)
static PyObject * hocobj_iter(PyObject *self)
bool hoc_valid_stmt(const char *, Object *)
static PyMethodDef HocMethods[]
static PyObject * nrnpy_vec_math
static int araylen(Arrayinfo *a, PyHocObject *po)
void vector_resize(Vect *v, int n)
static void hocobj_dealloc(PyHocObject *self)
PyObject * get_plotshape_data(PyObject *sp)
void * hoc_sec_internal_name2ptr(const char *s, int eflag)
Objectdata * hoc_top_level_data
static int nrncore_file_mode_value()
return value of neuron.coreneuron.file_mode
struct Symbol::@52::@53 rng
static PyObject *(* vec_as_numpy)(int, double *)
PyObject * nrnpy_cas(PyObject *, PyObject *)
#define PyString_FromString
static int nrncore_enable_value()
return value of neuron.coreneuron.enable
Object * nrnpy_pyobject_in_obj(PyObject *)
int vector_capacity(Vect *v)
void hoc_tobj_unref(Object **)
void * fpycall(void *(*)(void *, void *), void *, void *)
static PyObject * py_hocobj_math(const char *op, PyObject *obj1, PyObject *obj2)
static PyObject * py_hocobj_sub(PyObject *obj1, PyObject *obj2)
Symlist * hoc_top_level_symlist
Neuron/Java Interface code.
static int component(PyHocObject *po)
void nrn_change_nseg(Section *, int)
int nrn_secref_nchild(Section *)
static PyObject * hocobj_name(PyObject *pself, PyObject *args)
HocStruct cTemplate * ctemplate
static Object ** nrnpy_vec_to_python(void *v)
static int hocobj_setattro(PyObject *subself, PyObject *pyname, PyObject *value)
int nrn_is_hocobj_ptr(PyObject *po, double *&pd)
static PyObject * hocpickle_setstate(PyObject *self, PyObject *args)
static void sectionlist_helper_(void *sl, Object *args)
Symbol * hoc_table_lookup(const char *, Symlist *)
char **(* nrnpy_gui_helper3_str_)(const char *, Object *, int)
int is_obj_type(Object *obj, const char *type_name)
static void * nrnpy_hoc_int_pop()
static Object ** gui_helper_(const char *name, Object *obj)
double * vector_vec(Vect *v)
int(* nrnpy_nrncore_enable_value_p_)()
value of neuron.coreneuron.enable as 0, 1 (-1 if error)
static PyObject * hoc_ac(PyObject *self, PyObject *args)
static PyObject * hocobj_getattr(PyObject *subself, PyObject *pyname)
static int set_final_from_stk(PyObject *po)
static PyObject * hocobj_getsec(Symbol *sym)
static PyObject * get_mech_object_
void(* nrnpy_decref)(void *pyobj)
static int hocobj_nonzero(PyObject *self)
static void pyobject_in_objptr(Object **, PyObject *)
static PyObject * py_hocobj_add(PyObject *obj1, PyObject *obj2)
int nrn_netcon_weight(NetCon *, double **)
void set_pyerr(PyObject *type, const char *message)
void hoc_pushpx(double *d)
int hoc_is_object_arg(int narg)
static PyObject * libpython_path(PyObject *self, PyObject *args)
void hoc_pushstr(char **d)
union hoc_Item::@55 element
PyTypeObject * hocobject_type
Object **(* nrnpy_gui_helper3_)(const char *, Object *, int)
Objectdata * hoc_objectdata_save(void)
static PyObject * topmethdict
int ivoc_list_count(Object *)
static PyObject * mkref(PyObject *self, PyObject *args)
Object ** hoc_temp_objptr(Object *)
void section_unref(Section *)
char ** hoc_temp_charptr(void)
Object ** hoc_objgetarg(int)
static PyObject * pfunc_get_docstring
int nrnpy_rvp_pyobj_callback_register(PyObject *callback)
static PyObject * nrnpy_rvp_pyobj_callback
static cTemplate * hoc_list_template_
static PyObject * iternext_sl(PyHocObject *po, hoc_Item *ql)
double(* nrnpy_object_to_double_)(Object *)
static cTemplate * hoc_vec_template_
static PyObject * py_hocobj_div(PyObject *obj1, PyObject *obj2)
static PyObject * restore_savestate_
static PyObject * hocobj_same(PyHocObject *pself, PyObject *args)
static PyObject * hocobj_getitem(PyObject *self, Py_ssize_t ix)
PyObject * nrnpy_pushsec(PyObject *)
PyObject * nrnpy_hoc2pyobject(Object *)
static PyMethodDef hocobj_methods[]
static PyObject * py_hocobj_uneg(PyObject *obj)
static PyObject * plotshape_plot
static char * nrncore_arg(double tstop)
static PyMemberDef hocobj_members[]
static int get_nrncore_opt_value(const char *option)
static PyObject * py_hocobj_upos(PyObject *obj)