Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions child.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@
}

VERBATIM
static subtree(sec, sym) Section* sec; Symbol* sym; {
/* NEURON >= 9: Section is incomplete in MOD translation units; use accessors.
NEURON < 9: full Section definition is available (section.h). */
#if NRN_VERSION_GTEQ(9, 0, 0)
#define SEC_CHILD(s) _nrn_mechanism_get_child(s)
#define SEC_SIBLING(s) _nrn_mechanism_get_sibling(s)
#else
#define SEC_CHILD(s) ((s)->child)
#define SEC_SIBLING(s) ((s)->sibling)
#endif

static void subtree(Section* sec, Symbol* sym) {
Section* child;

nrn_pushsec(sec); /* move these three (sec becomes child) */
hoc_run_stmt(sym); /* into the loop to do only the first level */
nrn_popsec();

for (child = sec->child; child; child = child->sibling) {
for (child = SEC_CHILD(sec); child; child = SEC_SIBLING(child)) {
subtree(child, sym);
}
}
Expand All @@ -29,13 +39,13 @@
PROCEDURE subtree_traverse_all() {
VERBATIM
{
Section* chk_access();
Symbol* hoc_parse_stmt();
/* Do not redeclare chk_access / hoc_parse_stmt here: in C++ (NEURON 9+)
a local Symbol* hoc_parse_stmt(); is a zero-arg overload that hides the real API. */
Symlist* symlist = (Symlist*)0;
subtree(chk_access(), hoc_parse_stmt(gargstr(1), &symlist));
/* if following not executed (ie hoc error in statement),
some memory will leak */
hoc_free_list(&symlist);
}
ENDVERBATIM
}
}
20 changes: 14 additions & 6 deletions childa.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ NEURON {
}

VERBATIM
static subtree(sec, sym) Section* sec; Symbol* sym; {
/* NEURON >= 9: Section is incomplete in MOD translation units; use accessors.
NEURON < 9: full Section definition is available (section.h). */
#if NRN_VERSION_GTEQ(9, 0, 0)
#define SEC_CHILD(s) _nrn_mechanism_get_child(s)
#define SEC_SIBLING(s) _nrn_mechanism_get_sibling(s)
#else
#define SEC_CHILD(s) ((s)->child)
#define SEC_SIBLING(s) ((s)->sibling)
#endif

static void subtree(Section* sec, Symbol* sym) {
Section* child;



for (child = sec->child; child; child = child->sibling) {
for (child = SEC_CHILD(sec); child; child = SEC_SIBLING(child)) {
nrn_pushsec(child); /* move these three (sec becomes child) */
hoc_run_stmt(sym); /* into the loop to do only the first level */
nrn_popsec();
Expand All @@ -30,8 +38,8 @@ ENDVERBATIM
PROCEDURE subtree_traverse() {
VERBATIM
{
Section* chk_access();
Symbol* hoc_parse_stmt();
/* Do not redeclare chk_access / hoc_parse_stmt here: in C++ (NEURON 9+)
a local Symbol* hoc_parse_stmt(); is a zero-arg overload that hides the real API. */
Symlist* symlist = (Symlist*)0;
subtree(chk_access(), hoc_parse_stmt(gargstr(1), &symlist));
/* if following not executed (ie hoc error in statement),
Expand Down