Skip to content

Commit

Permalink
Some PROP_PY_INDEX dependent fragments need #if USE_PYTHON wrapper. (#…
Browse files Browse the repository at this point in the history
…772)

* Some PROP_PY_INDEX dependent fragments need #if USE_PYTHON wrapper.
  • Loading branch information
nrnhines committed Dec 10, 2020
1 parent bac383e commit d5a65c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nrnoc/cabcode.c
Expand Up @@ -300,7 +300,9 @@ Section* nrnpy_newsection(void* v) {
Item* itm;
Section* sec;
sec = new_section((Object*)0, (Symbol*)0, 0);
#if USE_PYTHON
sec->prop->dparam[PROP_PY_INDEX]._pvoid = v;
#endif
itm = lappendsec(section_list, sec);
sec->prop->dparam[8].itm = itm;
return sec;
Expand All @@ -318,6 +320,7 @@ void delete_section(void) {
hoc_retpushx(0.0);
return;
}
#if USE_PYTHON
if (sec->prop->dparam[PROP_PY_INDEX]._pvoid) { /* Python Section */
/* the Python Section will be a zombie section with a pointer
to an invalid Section*.
Expand All @@ -328,6 +331,7 @@ void delete_section(void) {
hoc_retpushx(0.0);
return;
}
#endif
if (!sec->prop->dparam[0].sym) {
hoc_execerror("Cannot delete an unnamed hoc section", (char*)0);
}
Expand Down
4 changes: 4 additions & 0 deletions src/nrnoc/secref.c
Expand Up @@ -67,10 +67,12 @@ static double s_unname(void* v) {
hoc_Item** pitm;
Section* sec;
sec = (Section*)v;
#if USE_PYTHON
/* Python Sections cannot be unnamed, return 0.0 */
if (sec->prop && sec->prop->dparam[PROP_PY_INDEX]._pvoid) {
return 0.0;
}
#endif
pitm = sec2pitm(sec);
*pitm = (hoc_Item*)0;
sec->prop->dparam[0].sym = (Symbol*)0;
Expand All @@ -97,10 +99,12 @@ static double s_rename(void* v) {
Printf("SectionRef[???].sec is a deleted section\n");
return 0.;
}
#if USE_PYTHON
/* Python Sections cannot be renamed, return 0.0 */
if (sec->prop->dparam[PROP_PY_INDEX]._pvoid) {
return 0.;
}
#endif
qsec = sec->prop->dparam[8].itm;
if (sec->prop->dparam[0].sym) {
Printf("%s must first be unnamed\n", secname(sec));
Expand Down

0 comments on commit d5a65c6

Please sign in to comment.