PyObject* nrnpy_cas(PyObject* self, PyObject* args) { Section* sec = chk_access(); //printf("nrnpy_cas %s\n", secname(sec)); section_ref(sec); NPySecObj* pysec = NULL; if (sec->prop->dparam[PROP_PY_INDEX]._pvoid) { pysec = (NPySecObj*)sec->prop->dparam[PROP_PY_INDEX]._pvoid; Py_INCREF(pysec); assert(pysec->sec_ == sec); }else{ pysec = (NPySecObj*)psection_type->tp_alloc(psection_type, 0); pysec->sec_ = sec; pysec->name_ = 0; pysec->cell_ = 0; } return (PyObject*)pysec; }
fsyn() { int i; if (nrn_nthread > 1) { hoc_execerror("fsyn does not allow threads", ""); } i = chkarg(1, 0., 10000.); if (ifarg(2)) { if (i >= maxstim) { hoc_execerror("index out of range", (char *)0); } pstim[i].loc = chkarg(2, 0., 1.); pstim[i].delay = chkarg(3, 0., 1e21); pstim[i].duration = chkarg(4, 0., 1e21); pstim[i].mag = *getarg(5); pstim[i].erev = *getarg(6); pstim[i].sec = chk_access(); section_ref(pstim[i].sec); stim_record(i); } else { free_syn(); maxstim = i; if (maxstim) { pstim = (Stimulus *)emalloc((unsigned)(maxstim * sizeof(Stimulus))); } for (i = 0; i<maxstim; i++) { pstim[i].loc = 0; pstim[i].mag = 0.; pstim[i].delay = 1e20; pstim[i].duration = 0.; pstim[i].erev = 0.; pstim[i].sec = 0; stim_record(i); } } ret(0.); }
bool SaveState::check(bool warn) { hoc_Item* qsec; int isec; if (nsec_ != section_count) { if (warn) { fprintf(stderr, "SaveState warning: %d sections exist but saved %d\n", section_count, nsec_); } return false; } if (nroot_ != nrn_global_ncell) { if (warn) { fprintf(stderr, "SaveState warning: %d cells exist but saved %d\n", nrn_global_ncell, nroot_); } return false; } if (nsec_ && ss_[0].sec == NULL) { // got the data from a read isec = 0; ForAllSections(sec) ss_[isec].sec = sec; section_ref(ss_[isec].sec); ++isec; } }
NrnSectionImpl::NrnSectionImpl(Section* sec) { sec_ = sec; section_ref(sec); }
void NrnSection::section(Section* sec) { section_ref(sec); section_unref(npi_->sec_); npi_->sec_ = sec; }