NEURON
nrnmenu.cpp
Go to the documentation of this file.
1 
2 #include <../../nrnconf.h>
3 
4 #include <cstdio>
5 #include <cstring>
6 
7 #if HAVE_IV
8 #include "secbrows.h"
9 #include "ivoc.h"
10 #endif
11 #include "cabcode.h"
12 #include "code.h"
13 #include "nrniv_mf.h"
14 #include "nrnoc2iv.h"
15 #include "nrnpy.h"
16 #include "nrnmenu.h"
17 #include "classreg.h"
18 #include "gui-redirect.h"
19 
20 // from nrnoc
21 #include "membfunc.h"
22 #include "parse.hpp"
24 extern Symbol** pointsym;
25 extern int nrn_has_net_event_cnt_;
26 extern int* nrn_has_net_event_;
27 extern short* nrn_is_artificial_;
28 extern char* pnt_map;
29 
30 // to nrnoc
31 void nrnallsectionmenu();
32 void nrnallpointmenu();
33 void nrnsecmenu();
34 void nrnglobalmechmenu();
35 void nrnmechmenu();
36 void nrnpointmenu();
37 
39 
40 #if HAVE_IV
41 static void pnodemenu(Prop* p1, double, int type, const char* path, MechSelector* = NULL);
42 static void mech_menu(Prop* p1, double, int type, const char* path, MechSelector* = NULL);
43 static void point_menu(Object*, int);
44 #endif
45 
47  TRY_GUI_REDIRECT_DOUBLE("nrnallsectionmenu", NULL);
48 
49 #if HAVE_IV
50  if (hoc_usegui) {
52  }
53 #endif
54 
55  hoc_retpushx(1.);
56 }
57 
58 void nrnsecmenu() {
59  TRY_GUI_REDIRECT_DOUBLE("nrnsecmenu", NULL);
60 #if HAVE_IV
61  if (hoc_usegui) {
62  double x;
63  Section* sec = NULL;
64  if (hoc_is_object_arg(1)) { // x = -1 not allowed
65  nrn_seg_or_x_arg(1, &sec, &x);
67  } else {
68  x = chkarg(1, -1., 1.);
69  }
70  section_menu(x, (int) chkarg(2, 1., 3.));
71  if (sec) {
72  nrn_popsec();
73  }
74  }
75 #endif
76  hoc_retpushx(1.);
77 }
78 
79 static bool has_globals(const char* name) {
80  Symbol* sp;
81  char suffix[100];
82  Sprintf(suffix, "_%s", name);
83  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
84  if (sp->type == VAR && sp->subtype == USERDOUBLE && strstr(sp->name, suffix)) {
85  return true;
86  }
87  }
88  return false;
89 }
90 
92  TRY_GUI_REDIRECT_DOUBLE("nrnglobalmechmenu", NULL);
93 #if HAVE_IV
94  if (hoc_usegui) {
95  Symbol* sp;
96  char* s;
97  char buf[200];
98  char suffix[100];
99  if (!ifarg(1)) {
100  hoc_ivmenu("Mechanisms (Globals)");
101  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
102  if (sp->type == MECHANISM && sp->subtype != MORPHOLOGY && has_globals(sp->name)) {
103  Sprintf(buf, "nrnglobalmechmenu(\"%s\")", sp->name);
104  hoc_ivbutton(sp->name, buf);
105  }
106  }
107  hoc_ivmenu(0);
108  hoc_retpushx(1.);
109  return;
110  }
111  char* name = gargstr(1);
112  Sprintf(suffix, "_%s", name);
113  if (ifarg(2) && *getarg(2) == 0.) {
114  int cnt = 0;
115  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
116  if (sp->type == VAR && sp->subtype == USERDOUBLE &&
117  (s = strstr(sp->name, suffix)) != 0 && s[strlen(suffix)] == '\0') {
118  ++cnt;
119  }
120  }
121  hoc_retpushx(double(cnt));
122  return;
123  }
124  Sprintf(buf, "%s (Globals)", name);
125  hoc_ivpanel(buf);
126  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
127  if (sp->type == VAR && sp->subtype == USERDOUBLE &&
128  (s = strstr(sp->name, suffix)) != 0 && s[strlen(suffix)] == '\0') {
129  if (is_array(*sp)) {
130  char n[50];
131  int i;
132  Arrayinfo* a = sp->arayinfo;
133  for (i = 0; i < a->sub[0]; i++) {
134  if (i > 5)
135  break;
136  Sprintf(buf, "%s[%d]", sp->name, i);
137  Sprintf(n, "%s[%d]", sp->name, i);
138  hoc_ivpvalue(n, hoc_val_handle(buf), false, sp->extra);
139  }
140  } else {
141  hoc_ivvalue(sp->name, sp->name, 1);
142  }
143  }
144  }
145  hoc_ivpanelmap();
146  }
147 #endif
148  hoc_retpushx(1.);
149 }
150 
151 void nrnmechmenu() {
152  hoc_retpushx(1.);
153 }
154 
155 #if HAVE_IV
156 void section_menu(double x1, int type, MechSelector* ms) {
157  char buf[200];
158  const char* name;
159  Section* sec;
160  Prop* p;
161  Node* node;
162  double x;
163  String btype;
164  CopyString sname;
165 
166  switch (type) {
167  case nrnocCONST:
168  btype = "(Parameters)";
169  break;
170  case STATE:
171  btype = "(States)";
172  break;
173  case 2:
174  btype = "(Assigned)";
175  break;
176  }
177 
178  sec = chk_access();
179  name = secname(sec);
180 
181  if (x1 >= 0) {
182  node = node_exact(sec, x1);
183  x = nrn_arc_position(sec, node);
184  Sprintf(buf, "%s(%g) %s", name, x, btype.string());
185  } else {
186  Sprintf(buf, "%s(0 - 1) %s", name, btype.string());
187  node = sec->pnode[0];
188  x = nrn_arc_position(sec, node);
189  sname = hoc_section_pathname(sec);
190  // printf("returned %s\n", sname.string());
191  }
192  hoc_ivpanel(buf);
193  hoc_ivlabel(buf);
194  if (type == nrnocCONST) {
195  if (x1 < 0) {
196  Sprintf(buf, "nseg = %d", sec->nnode - 1);
197  hoc_ivlabel(buf);
198  Sprintf(buf, "%s.L", sname.string());
199  if (sec->npt3d) {
200  hoc_ivvaluerun("L", buf, "define_shape()", 1);
201  } else {
202  hoc_ivvalue("L", buf, 1);
203  }
204  Sprintf(buf, "%s.Ra += 0", sname.string());
205  hoc_ivpvaluerun("Ra",
208  &(sec->prop->dparam[7].literal_value<double>())},
209  buf,
210  1,
211  0,
212  hoc_var_extra("Ra"));
213  p = sec->prop;
214  if (p->dparam[4].literal_value<double>() != 1) {
215  hoc_ivpvaluerun("Rall",
218  &(sec->prop->dparam[4].literal_value<double>())},
219  "diam_changed = 1",
220  1,
221  0,
222  hoc_var_extra("rallbranch"));
223  }
224  }
225  } else {
226  if (x1 < 0) {
227  Sprintf(buf, "%s.%s", sname.string(), "v");
228  hoc_ivvalue("v", buf);
229  } else {
230  Sprintf(buf, "v(%g)", x);
231  hoc_ivpvalue("v", hoc_val_handle(buf), false, hoc_lookup("v")->extra);
232  }
233  }
234 
235  p = node->prop;
236  if (x1 < 0) {
237  pnodemenu(p, x, type, sname.string(), ms);
238  } else {
239  pnodemenu(p, x, type, 0, ms);
240  }
241  hoc_ivpanelmap();
242 }
243 
244 static void pnodemenu(Prop* p1, double x, int type, const char* path, MechSelector* ms) {
245  if (!p1) {
246  return;
247  }
248  pnodemenu(p1->next, x, type, path, ms); /*print in insert order*/
249  if (memb_func[p1->_type].is_point) {
250  return;
251  } else {
252  mech_menu(p1, x, type, path, ms);
253  }
254 }
255 #endif
256 
257 #if HAVE_IV
258 static bool nrn_is_const(const char* path, const char* name) {
259  char buf[256];
260  Sprintf(buf,
261  "%s for (hoc_ac_) if (hoc_ac_ > 0 && hoc_ac_ < 1) if (%s(hoc_ac_) != %s(.5)) {hoc_ac_ "
262  "= 0 break}\n",
263  path,
264  name,
265  name);
266  Oc oc;
267  oc.run(buf);
268  return (hoc_ac_ != 0.);
269 }
270 #endif
271 
272 #if HAVE_IV
273 static void mech_menu(Prop* p1, double x, int type, const char* path, MechSelector* ms) {
274  Symbol *sym, *vsym;
275  int i, j;
276  char buf[200];
277  bool deflt;
278 
279  if (ms && !ms->is_selected(p1->_type)) {
280  return;
281  }
282  if (type == nrnocCONST) {
283  deflt = true;
284  } else {
285  deflt = false;
286  }
287  sym = memb_func[p1->_type].sym;
288  if (sym->s_varn) {
289  for (j = 0; j < sym->s_varn; j++) {
290  vsym = sym->u.ppsym[j];
291  if (nrn_vartype(vsym) == type) {
292  if (vsym->type == RANGEVAR) {
293  if (is_array(*vsym)) {
294  char n[50];
295  Arrayinfo* a = vsym->arayinfo;
296  for (i = 0; i < a->sub[0]; i++) {
297  if (i > 5)
298  break;
299  Sprintf(n, "%s[%d]", vsym->name, i);
300  if (path) {
301  if (nrn_is_const(path, n)) {
302  Sprintf(buf, "%s.%s", path, n);
303  hoc_ivvalue(n, buf, deflt);
304  } else {
305  Sprintf(buf, "%s is not constant", n);
306  hoc_ivlabel(buf);
307  }
308  } else {
309  Sprintf(buf, "%s[%d](%g)", vsym->name, i, x);
311  }
312  }
313  } else {
314  if (path) {
315  if (nrn_is_const(path, vsym->name)) {
316  Sprintf(buf, "%s.%s", path, vsym->name);
317  hoc_ivvalue(vsym->name, buf, deflt);
318  } else {
319  Sprintf(buf, "%s is not constant", vsym->name);
320  hoc_ivlabel(buf);
321  }
322  } else {
323  Sprintf(buf, "%s(%g)", vsym->name, x);
324  if (p1->_type == MORPHOLOGY) {
325  Section* sec = chk_access();
326  char buf2[200];
327  Sprintf(buf2, "%s.Ra += 0", secname(sec));
329  vsym->name, hoc_val_handle(buf), buf2, 1, 0, vsym->extra);
330  } else {
332  }
333  }
334  }
335  }
336  }
337  }
338  }
339 }
340 #endif
341 
343  TRY_GUI_REDIRECT_DOUBLE("nrnallpointmenu", NULL);
344 #if HAVE_IV
345  if (hoc_usegui) {
346  int i;
347  double x = n_memb_func - 1;
348  Symbol *sp, *psym;
349  char buf[200];
350  hoc_Item* q;
351 
352  if (!ifarg(1)) {
353  hoc_ivmenu("Point Processes");
354  for (i = 1; (sp = pointsym[i]) != (Symbol*) 0; i++) {
355  Sprintf(buf, "nrnallpointmenu(%d)", i);
356  hoc_ivbutton(sp->name, buf);
357  }
358  hoc_ivmenu(0);
359  hoc_retpushx(1.);
360  return;
361  }
362 
363  i = (int) chkarg(1, 0., x);
364  if ((psym = pointsym[i]) != (Symbol*) 0) {
365  hoc_ivpanel(psym->name);
367  assert(sp && sp->type == TEMPLATE);
368 
369  bool locmenu = false;
370  ITERATE(q, sp->u.ctemplate->olist) { // are there any
371  hoc_ivmenu("locations");
372  locmenu = true;
373  break;
374  }
375 
376  bool are_globals = false;
377  char suffix[100];
378  Sprintf(suffix, "_%s", sp->name);
379  for (Symbol* stmp = hoc_built_in_symlist->first; stmp; stmp = stmp->next) {
380  if (stmp->type == VAR && stmp->subtype == USERDOUBLE &&
381  strstr(stmp->name, suffix)) {
382  are_globals = true;
383  break;
384  }
385  }
386 
387  ITERATE(q, sp->u.ctemplate->olist) {
388  Object* ob = OBJ(q);
389  Point_process* pp = ob2pntproc(ob);
390  if (pp->sec) {
391  Sprintf(buf, "nrnpointmenu(%p)", ob);
393  }
394  }
395  if (locmenu) {
396  hoc_ivmenu(0);
397  }
398  if (are_globals) {
399  Sprintf(buf, "nrnglobalmechmenu(\"%s\")", psym->name);
400  hoc_ivbutton("Globals", buf);
401  }
402  hoc_ivpanelmap();
403  }
404  }
405 #endif
406  hoc_retpushx(1.);
407 }
408 
409 void nrnpointmenu() {
410  TRY_GUI_REDIRECT_DOUBLE("nrnpointmenu", NULL);
411 #if HAVE_IV
412  if (hoc_usegui) {
413  Object* ob;
414  if (hoc_is_object_arg(1)) {
415  ob = *hoc_objgetarg(1);
416  } else {
417  ob = (Object*) ((size_t) (*getarg(1)));
418  }
420  if (!sym || sym->type != MECHANISM || !memb_func[sym->subtype].is_point) {
421  hoc_execerror(ob->ctemplate->sym->name, "not a point process");
422  }
423  int make_label = 1;
424  if (ifarg(2)) {
425  make_label = int(chkarg(2, -1., 1.));
426  }
427  point_menu(ob, make_label);
428  }
429 #endif
430  hoc_retpushx(1.);
431 }
432 
433 #if HAVE_IV
434 static void point_menu(Object* ob, int make_label) {
435  Point_process* pp = ob2pntproc(ob);
436  int k, m;
437  Symbol *psym, *vsym;
438  char buf[200];
439  bool deflt;
440 
441  if (pp->sec) {
442  Sprintf(buf, "%s at ", hoc_object_name(ob));
443  strcat(buf, sec_and_position(pp->sec, pp->node));
444  } else {
445  Sprintf(buf, "%s", hoc_object_name(ob));
446  }
447  hoc_ivpanel(buf);
448 
449 
450  if (make_label == 1) {
451  hoc_ivlabel(buf);
452  } else if (make_label == 0) {
454  } else if (make_label == -1) { // i.e. do neither
455  k = 0;
456  }
457  psym = pointsym[pnt_map[pp->prop->_type]];
458 
459 #if 0
460  switch (type) {
461  case nrnocCONST:
462  Sprintf(buf,"%s[%d] (Parameters)", psym->name, j);
463  break;
464  case STATE:
465  Sprintf(buf,"%s[%d] (States)", psym->name, j);
466  break;
467  case 2:
468  Sprintf(buf,"%s[%d] (Assigned)", psym->name, j);
469  break;
470  }
471 #endif
472 
473  if (psym->s_varn) {
474  for (k = 0; k < psym->s_varn; k++) {
475  vsym = psym->u.ppsym[k];
476  int vartype = nrn_vartype(vsym);
477  if (vartype == NMODLRANDOM) { // skip
478  continue;
479  }
480  if (vartype == nrnocCONST) {
481  deflt = true;
482  } else {
483  deflt = false;
484  }
485  if (is_array(*vsym)) {
486  Arrayinfo* a = vsym->arayinfo;
487  for (m = 0; m < vsym->arayinfo->sub[0]; m++) {
488  if (m > 5)
489  break;
490  Sprintf(buf, "%s[%d]", vsym->name, m);
491  auto pd = point_process_pointer(pp, vsym, m);
492  if (pd) {
493  hoc_ivpvalue(buf, pd, deflt, vsym->extra);
494  }
495  }
496  } else {
498  }
499  }
500  }
501 
502  hoc_ivpanelmap();
503 }
504 #endif
505 
506 //-----------------------
507 // MechanismStandard
509 
510 static double ms_panel(void* v) {
511  TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("MechanismStandard.panel", ms_class_sym_, v);
512 #if HAVE_IV
513  if (hoc_usegui) {
514  char* label = NULL;
515  if (ifarg(1)) {
516  label = gargstr(1);
517  }
518  ((MechanismStandard*) v)->panel(label);
519  }
520 #endif
521  return 0.;
522 }
523 static double ms_action(void* v) {
524  char* a = 0;
525  Object* pyact = NULL;
526  if (ifarg(1)) {
527  if (hoc_is_str_arg(1)) {
528  a = gargstr(1);
529  } else {
530  pyact = *hoc_objgetarg(1);
531  }
532  }
533  ((MechanismStandard*) v)->action(a, pyact);
534  return 0.;
535 }
536 
537 static double ms_out(void* v) {
539  if (ifarg(1)) {
540  if (hoc_is_double_arg(1)) {
541  double x = chkarg(1, 0, 1);
542  m->out(chk_access(), x);
543  } else {
544  Object* o = *hoc_objgetarg(1);
545  if (is_obj_type(o, "MechanismStandard")) {
547  } else if (is_point_process(o)) {
548  m->out(ob2pntproc(o));
549  } else if (nrnpy_ob_is_seg && (*nrnpy_ob_is_seg)(o)) {
550  double x;
551  Section* sec;
552  nrn_seg_or_x_arg(1, &sec, &x);
553  m->out(sec, x);
554  } else {
555  hoc_execerror("Object arg must be MechanismStandard or a Point Process, not",
556  hoc_object_name(o));
557  }
558  }
559  } else {
560  m->out(chk_access());
561  }
562  return 0.;
563 }
564 
565 static double ms_in(void* v) {
567  if (ifarg(1)) {
568  if (hoc_is_double_arg(1)) {
569  double x = chkarg(1, 0, 1);
570  m->in(chk_access(), x);
571  } else {
572  Object* o = *hoc_objgetarg(1);
573  if (is_obj_type(o, "MechanismStandard")) {
575  } else if (is_point_process(o)) {
576  m->in(ob2pntproc(o));
577  } else if (nrnpy_ob_is_seg && (*nrnpy_ob_is_seg)(o)) {
578  double x;
579  Section* sec;
580  nrn_seg_or_x_arg(1, &sec, &x);
581  m->in(sec, x);
582  } else {
584  "Object arg must be MechanismStandard or a Point Process or a nrn.Segment, not",
585  hoc_object_name(o));
586  }
587  }
588  } else {
589  m->in(chk_access());
590  }
591  return 0.;
592 }
593 
594 static double ms_set(void* v) {
595  int i = 0;
596  if (ifarg(3)) { // array index
597  i = int(*getarg(3));
598  }
599  ((MechanismStandard*) v)->set(gargstr(1), *getarg(2), i);
600  return 0.;
601 }
602 static double ms_get(void* v) {
603  int i = 0;
604  if (ifarg(2)) { // array index
605  i = int(*getarg(2));
606  }
607  return ((MechanismStandard*) v)->get(gargstr(1), i);
608 }
609 static double ms_count(void* v) {
611  return ((MechanismStandard*) v)->count();
612 }
613 static double ms_is_array(void* v) {
614  auto* ms = static_cast<MechanismStandard*>(v);
616  return ms->is_array((int) chkarg(1, 0, ms->count() - 1));
617 }
618 static double ms_name(void* v) {
619  const char* n;
620  int rval = 0;
622  if (ifarg(2)) {
623  n = ms->name((int) chkarg(2, 0, ms->count() - 1), rval);
624  } else {
625  n = ms->name();
626  }
629  return double(rval);
630 }
631 
632 static double ms_save(void* v) {
633 #if HAVE_IV
634  std::ostream* o = Oc::save_stream;
635  if (o) {
636  ((MechanismStandard*) v)->save(gargstr(1), o);
637  }
638 #endif
639  return 0.;
640 }
641 
642 static void* ms_cons(Object* ob) {
643  int vartype = nrnocCONST;
644  if (ifarg(2)) {
645  // 0 means all
646  vartype = int(chkarg(2, -1, STATE));
647  }
648  MechanismStandard* m = new MechanismStandard(gargstr(1), vartype);
649  m->ref();
650  m->msobj_ = ob;
651  return (void*) m;
652 }
653 
654 static void ms_destruct(void* v) {
656 }
657 
658 static Member_func ms_members[] = {{"panel", ms_panel},
659  {"action", ms_action},
660  {"in", ms_in},
661  {"_in", ms_in},
662  {"out", ms_out},
663  {"set", ms_set},
664  {"get", ms_get},
665  {"count", ms_count},
666  {"is_array", ms_is_array},
667  {"name", ms_name},
668  {"save", ms_save},
669  {nullptr, nullptr}};
670 
672  class2oc("MechanismStandard", ms_cons, ms_destruct, ms_members, nullptr, nullptr);
673  ms_class_sym_ = hoc_lookup("MechanismStandard");
674 }
675 
676 MechanismStandard::MechanismStandard(const char* name, int vartype) {
677  msobj_ = NULL;
678  glosym_ = NULL;
679  np_ = new NrnProperty(name);
680  name_cnt_ = 0;
681  vartype_ = vartype; // vartype=0 means all but not globals, -1 means globals
682  offset_ = 0;
683  if (vartype_ == -1) {
684  char suffix[100];
685  char* s;
686  Sprintf(suffix, "_%s", name);
687  Symbol* sp;
688  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
689  if (sp->type == VAR && sp->subtype == USERDOUBLE &&
690  (s = strstr(sp->name, suffix)) != 0 && s[strlen(suffix)] == '\0') {
691  ++name_cnt_;
692  }
693  }
694  glosym_ = new Symbol*[name_cnt_];
695  int i = 0;
696  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
697  if (sp->type == VAR && sp->subtype == USERDOUBLE &&
698  (s = strstr(sp->name, suffix)) != 0 && s[strlen(suffix)] == '\0') {
699  glosym_[i] = sp;
700  ++i;
701  }
702  }
703  } else {
704  for (Symbol* sym = np_->first_var(); np_->more_var(); sym = np_->next_var()) {
705  int type = nrn_vartype(sym);
706  if (type < vartype) {
707  ++offset_;
708  } else if (vartype == 0 || type == vartype) {
709  ++name_cnt_;
710  }
711  }
712  }
713  action_ = "";
714  pyact_ = NULL;
715 }
717  if (pyact_) {
719  }
720  if (glosym_) {
721  delete[] glosym_;
722  }
723  delete np_;
724 }
726  return name_cnt_;
727 }
729  const Symbol* s = np_->var(i + offset_);
730  return s->arayinfo;
731 }
732 const char* MechanismStandard::name() const {
733  return np_->name();
734 }
735 const char* MechanismStandard::name(int i, int& size) const {
736  Symbol* s;
737  if (vartype_ == -1) {
738  s = glosym_[i];
739  } else {
740  s = np_->var(i + offset_);
741  }
742  size = hoc_total_array_data(s, 0);
743  return s->name;
744 }
745 
746 void MechanismStandard::panel(const char* label) {
747 #if HAVE_IV
748  mschk("panel");
749  char buf[256];
750  int i;
751  Symbol* sym;
752  hoc_ivpanel("MechanismStandard");
753  if (label) {
754  hoc_ivlabel(label);
755  } else {
756  hoc_ivlabel(np_->name());
757  }
758  for (sym = np_->first_var(), i = 0; np_->more_var(); sym = np_->next_var(), ++i) {
759  if (vartype_ == 0 || nrn_vartype(sym) == vartype_) {
760  Object* pyactval = NULL;
761  int size = hoc_total_array_data(sym, 0);
762  if (pyact_) {
765  hoc_pushx(double(i));
766  hoc_pushx(0.0);
768  } else {
769  Sprintf(buf, "hoc_ac_ = %d %s", i, action_.c_str());
770  }
771  hoc_ivvaluerun_ex(sym->name,
772  NULL,
773  np_->pval(sym, 0),
774  NULL,
775  pyact_ ? NULL : buf,
776  pyactval,
777  true,
778  false,
779  true,
780  sym->extra);
781  if (pyactval) {
782  hoc_obj_unref(pyactval);
783  }
784  int j;
785  for (j = 1; j < size; ++j) {
786  ++i;
787  if (pyact_) {
790  hoc_pushx(double(i));
791  hoc_pushx(double(j));
793  } else {
794  Sprintf(buf, "hoc_ac_ = %d %s", i, action_.c_str());
795  }
796  char buf2[200];
797  Sprintf(buf2, "%s[%d]", sym->name, j);
798  hoc_ivvaluerun_ex(buf2,
799  NULL,
800  np_->pval(sym, j),
801  NULL,
802  pyact_ ? NULL : buf,
803  pyact_,
804  true,
805  false,
806  true,
807  sym->extra);
808  if (pyactval) {
809  hoc_obj_unref(pyactval);
810  }
811  }
812  }
813  }
814  hoc_ivpanelmap();
815 #endif
816 }
817 void MechanismStandard::action(const char* action, Object* pyact) {
818  mschk("action");
819  action_ = action ? action : "";
820  if (pyact) {
821  pyact_ = pyact;
822  hoc_obj_ref(pyact);
823  }
824 }
825 void MechanismStandard::set(const char* name, double val, int index) {
826  mschk("set");
827  const Symbol* s = np_->findsym(name);
828  if (s) {
829  *np_->pval(s, index) = val;
830  } else {
831  hoc_execerror(name, "not in this property");
832  }
833 }
834 double MechanismStandard::get(const char* name, int index) {
835  mschk("get");
836  const Symbol* s = np_->findsym(name);
837  if (!s) {
838  hoc_execerror(name, "not in this property");
839  }
840  auto const pval = np_->pval(s, index);
841  if (!pval) {
842  return -1e300;
843  }
844  return *pval;
845 }
846 
848  mschk("in");
849  int i = 0;
850  if (x >= 0) {
851  i = node_index(sec, x);
852  }
853  Prop* p = nrn_mechanism(np_->type(), sec->pnode[i]);
854  np_->copy(false, p, sec->pnode[i], vartype_);
855 }
857  mschk("in");
858  np_->copy(false, pp->prop, pp->node, vartype_);
859 }
861  mschk("in");
862  ms->np_->copy_out(*np_, vartype_);
863 }
864 
866  mschk("out");
867  if (x < 0) {
868  for (int i = 0; i < sec->nnode; ++i) {
869  Prop* p = nrn_mechanism(np_->type(), sec->pnode[i]);
870  np_->copy(true, p, sec->pnode[i], vartype_);
871  }
872  } else {
873  int i = node_index(sec, x);
874  Prop* p = nrn_mechanism(np_->type(), sec->pnode[i]);
875  np_->copy(true, p, sec->pnode[i], vartype_);
876  }
877 }
879  mschk("out");
880  np_->copy(true, pp->prop, pp->node, vartype_);
881 }
883  mschk("out");
884  np_->copy_out(*ms->np_, vartype_);
885 }
886 
887 void MechanismStandard::save(const char* obref, std::ostream* po) {
888  mschk("save");
889  std::ostream& o = *po;
890  o << obref << " = new MechanismStandard(\"" << np_->name() << "\")" << std::endl;
891  for (Symbol* sym = np_->first_var(); np_->more_var(); sym = np_->next_var()) {
892  if (vartype_ == 0 || nrn_vartype(sym) == vartype_) {
893  int i, cnt = hoc_total_array_data(sym, 0);
894  for (i = 0; i < cnt; ++i) {
895  o << obref << ".set(\"" << sym->name << "\", " << *np_->pval(sym, i) << ", " << i
896  << ")" << std::endl;
897  }
898  }
899  }
900 }
901 
902 void MechanismStandard::mschk(const char* s) {
903  if (vartype_ == -1) {
904  hoc_execerror(s, " MechanismStandard method not implemented for GLOBAL type");
905  }
906 }
907 
908 /*
909 help MembraneType
910 listin nrniv
911 Provides a way of iterating over all membrane mechanisms or point
912 processes and allows selection via a menu or under hoc control.
913 
914 mt = new MembraneType(0)
915 The object can be considered a list of all the available continuous
916 membrane mechanisms. eg "hh", "pas", "extracellular". that can
917 be inserted into a section.
918 
919 mt = new MembraneType(1)
920 The object can be considered a list of all available Point Processes.
921 eg. PulseStim, AlphaSynapse, VClamp.
922 
923 To print the names of all mechanisms in this object list try:
924 strdef mname
925 for i=0,mt.count() {
926  mt.select(i)
927  mt.selected(mname)
928  print mname
929 }
930 
931 help select
932 mt.select("name")
933 mt.select(i)
934 selects either the named mechanism or the i'th mechanism in the list.
935 
936 help selected
937 i = mt.selected([strdef])
938 returns the index of the current selection. If present, strarg is assigned
939 to the name of the current selection.
940 
941 help make
942 mt.make()
943 For continuous mechanisms. Inserts selected mechanism into currently
944 accessed section.
945 
946 help remove
947 mt.remove()
948 For continuous mechanisms. Deletes selected mechanism from currently
949 accessed section. A nop if the mechanism is not in the section.
950 
951 help make
952 mt.make(objectvar)
953 For point processes. The arg becomes a reference to a new point process
954 of type given by the selection.
955 Note that the newly created point process is not located in any section.
956 Note that if objectvar was the only reference to another object then
957 that object is destroyed.
958 
959 help count
960 i = mt.count()
961 The number of different mechanisms in the list.
962 
963 help menu
964 mt.menu()
965 Inserts a special menu into the currently open xpanel. The menu
966 label always reflects the current selection. Submenu items are indexed
967 according to position with the first item being item 0. When the mouse
968 button is released on a submenu item that item becomes the selection
969 and the action (if any) is executed.
970 
971 help action
972 mt.action("command")
973 The action to be executed when a submenu item is selected.
974 */
976 
977 static double mt_select(void* v) {
978  MechanismType* mt = (MechanismType*) v;
979  if (hoc_is_double_arg(1)) {
980  mt->select(int(chkarg(1, -1, mt->count() - 1)));
981  } else if (hoc_is_str_arg(1)) {
982  mt->select(gargstr(1));
983  }
984  return 0.;
985 }
986 static double mt_selected(void* v) {
987  MechanismType* mt = (MechanismType*) v;
988  int i = mt->selected_item();
989  if (ifarg(1)) {
991  }
993  return double(i);
994 }
995 static double mt_internal_type(void* v) {
996  MechanismType* mt = (MechanismType*) v;
997  return double(mt->internal_type());
998 }
999 static double mt_make(void* v) {
1000  MechanismType* mt = (MechanismType*) v;
1001  if (mt->is_point()) {
1002  mt->point_process(hoc_objgetarg(1));
1003  } else {
1004  mt->insert(chk_access());
1005  }
1006  return 0.;
1007 }
1008 static double mt_remove(void* v) {
1009  MechanismType* mt = (MechanismType*) v;
1010  mt->remove(chk_access());
1011  return 0.;
1012 }
1013 static double mt_count(void* v) {
1014  MechanismType* mt = (MechanismType*) v;
1016  return double(mt->count());
1017 }
1018 static double mt_menu(void* v) {
1019  TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("MechanismType.menu", mt_class_sym_, v);
1020 #if HAVE_IV
1021  if (hoc_usegui) {
1022  MechanismType* mt = (MechanismType*) v;
1023  mt->menu();
1024  }
1025 #endif
1026  return 0.;
1027 }
1028 static double mt_action(void* v) {
1029  MechanismType* mt = (MechanismType*) v;
1030  if (hoc_is_str_arg(1)) {
1031  mt->action(gargstr(1), NULL);
1032  } else {
1033  mt->action(NULL, *hoc_objgetarg(1));
1034  }
1035  return 0.;
1036 }
1037 static double mt_is_target(void* v) {
1038  MechanismType* mt = (MechanismType*) v;
1040  return double(mt->is_netcon_target(int(chkarg(1, 0, mt->count()))));
1041 }
1042 static double mt_has_net_event(void* v) {
1043  MechanismType* mt = (MechanismType*) v;
1045  return double(mt->has_net_event(int(chkarg(1, 0, mt->count()))));
1046 }
1047 static double mt_is_artificial(void* v) {
1048  MechanismType* mt = (MechanismType*) v;
1050  return double(mt->is_artificial(int(chkarg(1, 0, mt->count()))));
1051 }
1052 static double mt_is_ion(void* v) {
1053  auto* mt = static_cast<MechanismType*>(v);
1055  return double(mt->is_ion());
1056 }
1057 
1058 static Object** mt_pp_begin(void* v) {
1059  MechanismType* mt = (MechanismType*) v;
1060  Point_process* pp = mt->pp_begin();
1061  Object* obj = NULL;
1062  if (pp) {
1063  obj = pp->ob;
1064  }
1065  return hoc_temp_objptr(obj);
1066 }
1067 
1068 static Object** mt_pp_next(void* v) {
1069  MechanismType* mt = (MechanismType*) v;
1070  Point_process* pp = mt->pp_next();
1071  Object* obj = NULL;
1072  if (pp) {
1073  obj = pp->ob;
1074  }
1075  return hoc_temp_objptr(obj);
1076 }
1077 
1078 extern const char** nrn_nmodl_text_;
1079 static const char** mt_code(void* v) {
1080  static const char* nullstr = "";
1081  MechanismType* mt = (MechanismType*) v;
1082  int type = mt->internal_type();
1083  const char** p = nrn_nmodl_text_ + type;
1084  if (*p) {
1085  return p;
1086  }
1087  return &nullstr;
1088 }
1089 
1090 extern const char** nrn_nmodl_filename_;
1091 static const char** mt_file(void* v) {
1092  static const char* nullstr = "";
1093  MechanismType* mt = (MechanismType*) v;
1094  int type = mt->internal_type();
1095  const char** p = nrn_nmodl_filename_ + type;
1096  if (*p) {
1097  return p;
1098  }
1099  return &nullstr;
1100 }
1101 
1102 static void* mt_cons(Object* obj) {
1103  MechanismType* mt = new MechanismType(int(chkarg(1, 0, 1)));
1104  mt->ref();
1105  mt->mtobj_ = obj;
1106  return (void*) mt;
1107 }
1108 static void mt_destruct(void* v) {
1109  MechanismType* mt = (MechanismType*) v;
1110  mt->unref();
1111 }
1112 static Member_func mt_members[] = {{"select", mt_select},
1113  {"selected", mt_selected},
1114  {"make", mt_make},
1115  {"remove", mt_remove},
1116  {"count", mt_count},
1117  {"menu", mt_menu},
1118  {"action", mt_action},
1119  {"is_netcon_target", mt_is_target},
1120  {"has_net_event", mt_has_net_event},
1121  {"is_artificial", mt_is_artificial},
1122  {"is_ion", mt_is_ion},
1123  {"internal_type", mt_internal_type},
1124  {0, 0}};
1126  {"pp_next", mt_pp_next},
1127  {0, 0}};
1128 static Member_ret_str_func mt_retstr_func[] = {{"code", mt_code}, {"file", mt_file}, {0, 0}};
1131  mt_class_sym_ = hoc_lookup("MechanismType");
1132 }
1133 
1134 /* static */ class MechTypeImpl {
1135  private:
1136  friend class MechanismType;
1138  int* type_;
1139  int count_;
1140  int select_;
1141  std::string action_;
1146 };
1147 
1148 typedef Symbol* PSym;
1149 
1151  mti_ = new MechTypeImpl;
1153  mti_->count_ = 0;
1154  int i;
1155  for (i = 2; i < n_memb_func; ++i) {
1156  if (point_process == memb_func[i].is_point) {
1157  ++mti_->count_;
1158  }
1159  }
1160  mti_->type_ = new int[mti_->count_];
1161  int j = 0;
1162  for (i = 2; i < n_memb_func; ++i) {
1163  if (point_process == memb_func[i].is_point) {
1164  mti_->type_[j] = i;
1165  ++j;
1166  }
1167  }
1168  mti_->pyact_ = NULL;
1169  action("", NULL);
1170  select(0);
1171 }
1173  if (mti_->pyact_) {
1175  }
1176  delete[] mti_->type_;
1177  delete mti_;
1178 }
1180  return mti_->is_point_;
1181 }
1182 
1184  if (!mti_->is_point_) {
1185  hoc_execerror("Not a MechanismType(1)", 0);
1186  }
1187  mti_->sec_iter_ = chk_access();
1189  mti_->p_iter_ = 0;
1190  if (mti_->sec_iter_->parentnode) {
1191  mti_->inode_iter_ = -1;
1193  }
1194  if (!mti_->p_iter_) {
1195  mti_->inode_iter_ = 0;
1196  mti_->p_iter_ = mti_->sec_iter_->pnode[0]->prop;
1197  }
1198  Point_process* pp = pp_next(); // note that p_iter is the one looked at and then incremented
1199  return pp;
1200 }
1201 
1203  Point_process* pp = NULL;
1204  bool done = mti_->p_iter_ == 0;
1205  while (!done) {
1206  if (mti_->p_iter_->_type == mti_->type_[mti_->select_]) {
1207  pp = mti_->p_iter_->dparam[1].get<Point_process*>();
1208  done = true;
1209  // but if it does not belong to this section
1210  if (pp->sec != mti_->sec_iter_) {
1211  pp = NULL;
1212  done = false;
1213  }
1214  }
1215  mti_->p_iter_ = mti_->p_iter_->next;
1216  while (!mti_->p_iter_) {
1217  ++mti_->inode_iter_;
1218  if (mti_->inode_iter_ >= mti_->sec_iter_->nnode) {
1219  done = true;
1220  break; // really at the end
1221  } else {
1223  }
1224  }
1225  }
1226  return pp;
1227 }
1228 
1230  int j = mti_->type_[i];
1231  return pnt_receive[j] ? true : false;
1232 }
1233 
1235  int j = mti_->type_[i];
1236  int k;
1237  for (k = 0; k < nrn_has_net_event_cnt_; ++k) {
1238  if (nrn_has_net_event_[k] == j) {
1239  return true;
1240  }
1241  }
1242  return false;
1243 }
1244 
1246  int j = mti_->type_[i];
1247  return (nrn_is_artificial_[j] ? true : false);
1248 }
1249 
1251  return nrn_is_ion(internal_type());
1252 }
1253 
1254 void MechanismType::select(const char* name) {
1255  for (int i = 0; i < mti_->count_; ++i) {
1256  if (strcmp(name, memb_func[mti_->type_[i]].sym->name) == 0) {
1257  select(i);
1258  break;
1259  }
1260  }
1261 }
1263  Symbol* sym = memb_func[mti_->type_[selected_item()]].sym;
1264  return sym->name;
1265 }
1267  return mti_->type_[selected_item()];
1268 }
1269 
1271  if (!mti_->is_point_) {
1273  }
1274 }
1276  if (!mti_->is_point_) {
1278  }
1279 }
1280 
1282 
1284  Symbol* sym = memb_func[mti_->type_[selected_item()]].sym;
1285  hoc_dec_refcount(o);
1286  *o = nrn_new_pointprocess(sym);
1287  (*o)->refcount = 1;
1288 }
1289 
1290 void MechanismType::action(const char* action, Object* pyact) {
1291  mti_->action_ = action ? action : "";
1292  if (pyact) {
1293  hoc_obj_ref(pyact);
1294  }
1295  if (mti_->pyact_) {
1297  mti_->pyact_ = NULL;
1298  }
1299  mti_->pyact_ = pyact;
1300 }
1302 #if HAVE_IV
1303  char buf[200];
1304  Oc oc;
1305  oc.run("{xmenu(\"MechType\")}\n");
1306  for (int i = 0; i < mti_->count_; ++i) {
1307  Symbol* s = memb_func[mti_->type_[i]].sym;
1308  if (s->subtype != MORPHOLOGY) {
1309  if (mti_->pyact_) {
1312  hoc_pushx(double(i));
1314  hoc_ivbutton(s->name, NULL, pyactval);
1315  hoc_obj_unref(pyactval);
1316  } else {
1317  Sprintf(
1318  buf, "xbutton(\"%s\", \"hoc_ac_=%d %s\")\n", s->name, i, mti_->action_.c_str());
1319  oc.run(buf);
1320  }
1321  }
1322  }
1323  oc.run("{xmenu()}\n");
1324 #endif
1325 }
1326 
1328  return mti_->count_;
1329 }
1331  return mti_->select_;
1332 }
1334  if (index < 0) {
1335  mti_->select_ = index;
1336  } else if (index >= count()) {
1337  mti_->select_ = count() - 1;
1338  } else {
1339  mti_->select_ = index;
1340  }
1341 }
ReceiveFunc * pnt_receive
Definition: init.cpp:155
Section * chk_access()
Definition: cabcode.cpp:449
const char * secname(Section *sec)
name of section (for use in error messages)
Definition: cabcode.cpp:1674
void mech_uninsert1(Section *sec, Symbol *s)
Definition: cabcode.cpp:898
void nrn_pushsec(Section *sec)
Definition: cabcode.cpp:130
void nrn_parent_info(Section *s)
Definition: cabcode.cpp:1589
double nrn_arc_position(Section *sec, Node *node)
Definition: cabcode.cpp:1755
Prop * nrn_mechanism(int type, Node *nd)
Definition: cabcode.cpp:1038
int node_index(Section *sec, double x)
returns nearest index to x
Definition: cabcode.cpp:1406
const char * sec_and_position(Section *sec, Node *nd)
Definition: cabcode.cpp:1773
void nrn_popsec(void)
Definition: cabcode.cpp:154
char * hoc_section_pathname(Section *sec)
Definition: cabcode.cpp:1728
Node * node_exact(Section *sec, double x)
like node_index but give proper node when x is 0 or 1 as well as in between
Definition: cabcode.cpp:1800
void mech_insert1(Section *sec, int type)
Definition: cabcode.cpp:852
Object * pyact_
Definition: nrnmenu.cpp:1142
Section * sec_iter_
Definition: nrnmenu.cpp:1143
Prop * p_iter_
Definition: nrnmenu.cpp:1145
bool is_point_
Definition: nrnmenu.cpp:1137
std::string action_
Definition: nrnmenu.cpp:1141
std::string action_
Definition: nrnmenu.h:41
void mschk(const char *)
Definition: nrnmenu.cpp:902
void in(Section *, double x=-1.)
Definition: nrnmenu.cpp:847
virtual ~MechanismStandard()
Definition: nrnmenu.cpp:716
void out(Section *, double x=-1.)
Definition: nrnmenu.cpp:865
MechanismStandard(const char *, int vartype)
Definition: nrnmenu.cpp:676
NrnProperty * np_
Definition: nrnmenu.h:37
Object * msobj_
Definition: nrnmenu.h:35
void save(const char *, std::ostream *)
Definition: nrnmenu.cpp:887
void action(const char *, Object *pyact)
Definition: nrnmenu.cpp:817
const char * name() const
Definition: nrnmenu.cpp:732
void set(const char *, double val, int arrayindex=0)
Definition: nrnmenu.cpp:825
double get(const char *, int arrayindex=0)
Definition: nrnmenu.cpp:834
Object * pyact_
Definition: nrnmenu.h:42
bool is_array(int) const
Definition: nrnmenu.cpp:728
Symbol ** glosym_
Definition: nrnmenu.h:43
void panel(const char *label=NULL)
Definition: nrnmenu.cpp:746
void point_process(Object **)
Definition: nrnmenu.cpp:1283
virtual ~MechanismType()
Definition: nrnmenu.cpp:1172
const char * selected()
Definition: nrnmenu.cpp:1262
Point_process * pp_begin()
Definition: nrnmenu.cpp:1183
Object * mtobj_
Definition: nrnmenu.h:72
bool is_netcon_target(int)
Definition: nrnmenu.cpp:1229
void remove(Section *)
Definition: nrnmenu.cpp:1275
MechanismType(bool point_process)
Definition: nrnmenu.cpp:1150
Point_process * pp_next()
Definition: nrnmenu.cpp:1202
void select(const char *)
Definition: nrnmenu.cpp:1254
int selected_item()
Definition: nrnmenu.cpp:1330
bool is_point()
Definition: nrnmenu.cpp:1179
int internal_type()
Definition: nrnmenu.cpp:1266
MechTypeImpl * mti_
Definition: nrnmenu.h:74
bool is_artificial(int)
Definition: nrnmenu.cpp:1245
bool has_net_event(int)
Definition: nrnmenu.cpp:1234
void insert(Section *)
Definition: nrnmenu.cpp:1270
void action(const char *, Object *pyact)
Definition: nrnmenu.cpp:1290
bool is_ion()
Definition: nrnmenu.cpp:1250
Symbol * findsym(const char *rangevar)
Definition: ndatclas.cpp:235
Symbol * var(int)
Definition: ndatclas.cpp:151
Symbol * first_var()
Definition: ndatclas.cpp:129
const char * name() const
Definition: ndatclas.cpp:121
int type() const
Definition: ndatclas.cpp:125
bool copy_out(NrnProperty &dest, int vartype=0)
Definition: ndatclas.cpp:228
Symbol * next_var()
Definition: ndatclas.cpp:142
bool more_var()
Definition: ndatclas.cpp:134
neuron::container::data_handle< double > pval(const Symbol *, int index)
Definition: ndatclas.cpp:249
bool copy(bool to_prop, Prop *dest, Node *nd_dest, int vartype=0)
Definition: ndatclas.cpp:163
Definition: ivoc.h:36
int run(int argc, const char **argv)
static std::ostream * save_stream
Definition: ivoc.h:77
virtual void ref() const
Definition: resource.cpp:42
virtual void unref() const
Definition: resource.cpp:47
static void make_section_browser()
void class2oc(const char *, ctor_f *cons, dtor_f *destruct, Member_func *, Member_ret_obj_func *, Member_ret_str_func *)
Definition: hoc_oop.cpp:1631
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:48
char * gargstr(int narg)
Definition: code2.cpp:227
static char * stmp[HOC_TEMP_CHARPTR_SIZE]
Definition: code.cpp:714
HocReturnType hoc_return_type_code
Definition: code.cpp:42
#define cnt
Definition: tqueue.hpp:44
#define pval
Definition: md1redef.h:40
#define v
Definition: md1redef.h:11
#define sec
Definition: md1redef.h:20
#define i
Definition: md1redef.h:19
ms
Definition: extargs.h:1
double chkarg(int, double low, double high)
Definition: code2.cpp:626
static RNG::key_type k
Definition: nrnran123.cpp:9
#define NMODLRANDOM
Definition: modl.h:226
char buf[512]
Definition: init.cpp:13
int hoc_is_object_arg(int narg)
Definition: code.cpp:876
HocSymExtension * hoc_var_extra(const char *name)
Definition: code2.cpp:38
size_t hoc_total_array_data(const Symbol *s, Objectdata *obd)
Definition: hoc_oop.cpp:95
neuron::container::data_handle< double > hoc_val_handle(std::string_view s)
Definition: code2.cpp:715
int hoc_is_str_arg(int narg)
Definition: code.cpp:872
void hoc_assign_str(char **cpp, const char *buf)
Definition: code.cpp:2263
int is_obj_type(Object *obj, const char *type_name)
Definition: hoc_oop.cpp:2110
int hoc_is_double_arg(int narg)
Definition: code.cpp:864
void hoc_retpushx(double x)
Definition: hocusr.cpp:154
double hoc_ac_
Definition: hoc_init.cpp:222
void hoc_obj_ref(Object *obj)
Definition: hoc_oop.cpp:1844
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:73
void hoc_dec_refcount(Object **pobj)
Definition: hoc_oop.cpp:1850
Symbol * hoc_lookup(const char *)
Definition: symbol.cpp:59
void hoc_obj_unref(Object *obj)
Definition: hoc_oop.cpp:1881
void hoc_push_object(Object *d)
Definition: code.cpp:793
char ** hoc_pgargstr(int narg)
Definition: code.cpp:1623
#define TRY_GUI_REDIRECT_DOUBLE(name, obj)
Definition: gui-redirect.h:47
#define TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE(name, sym, v)
Definition: gui-redirect.h:16
int hoc_usegui
Definition: hoc.cpp:121
#define assert(ex)
Definition: hocassrt.h:24
#define USERDOUBLE
Definition: hocdec.h:84
#define getarg
Definition: hocdec.h:17
bool is_array(const Symbol &sym)
Definition: hocdec.h:136
#define OBJ(q)
Definition: hoclist.h:88
Point_process * ob2pntproc(Object *ob)
Definition: hocmech.cpp:99
Object ** hoc_objgetarg(int)
Definition: code.cpp:1614
static const char * nullstr
Definition: ivocvect.cpp:186
void hoc_pushx(double)
Definition: code.cpp:779
#define MORPHOLOGY
Definition: membfunc.hpp:59
#define nrnocCONST
Definition: membfunc.hpp:63
#define STATE
Definition: membfunc.hpp:65
#define ITERATE(itm, lst)
Definition: model.h:18
const char * name
Definition: init.cpp:16
void hoc_execerror(const char *s1, const char *s2)
Definition: nrnoc_aux.cpp:39
int nrn_is_ion(int)
constexpr do_not_search_t do_not_search
Definition: data_handle.hpp:11
impl_ptrs methods
Collection of pointers to functions with python-version-specific implementations.
Definition: nrnpy.cpp:21
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.
Definition: wrap_sprintf.h:14
static char suffix[256]
Definition: nocpout.cpp:135
int is_point_process(Object *)
Definition: point.cpp:370
void nrn_seg_or_x_arg(int iarg, Section **psec, double *px)
Definition: point.cpp:170
static Node * node(Object *)
Definition: netcvode.cpp:291
int const size_t const size_t n
Definition: nrngsl.h:10
size_t q
size_t p
size_t j
s
Definition: multisend.cpp:521
neuron::container::data_handle< double > point_process_pointer(Point_process *, Symbol *, int)
Definition: point.cpp:239
int ifarg(int)
Definition: code.cpp:1607
const char ** nrn_nmodl_filename_
Definition: init.cpp:189
void MechanismStandard_reg()
Definition: nrnmenu.cpp:671
static void * mt_cons(Object *obj)
Definition: nrnmenu.cpp:1102
short * nrn_is_artificial_
Definition: init.cpp:214
static double mt_is_ion(void *v)
Definition: nrnmenu.cpp:1052
static double ms_is_array(void *v)
Definition: nrnmenu.cpp:613
static void * ms_cons(Object *ob)
Definition: nrnmenu.cpp:642
static double ms_action(void *v)
Definition: nrnmenu.cpp:523
static const char ** mt_code(void *v)
Definition: nrnmenu.cpp:1079
void nrnmechmenu()
Definition: nrnmenu.cpp:151
static void ms_destruct(void *v)
Definition: nrnmenu.cpp:654
static Symbol * ms_class_sym_
Definition: nrnmenu.cpp:508
static Object ** mt_pp_begin(void *v)
Definition: nrnmenu.cpp:1058
static bool has_globals(const char *name)
Definition: nrnmenu.cpp:79
static Member_func ms_members[]
Definition: nrnmenu.cpp:658
static double mt_remove(void *v)
Definition: nrnmenu.cpp:1008
Symbol * PSym
Definition: nrnmenu.cpp:1148
static double mt_selected(void *v)
Definition: nrnmenu.cpp:986
void nrnallsectionmenu()
Definition: nrnmenu.cpp:46
static double ms_panel(void *v)
Definition: nrnmenu.cpp:510
int nrn_has_net_event_cnt_
Definition: init.cpp:160
static double mt_menu(void *v)
Definition: nrnmenu.cpp:1018
static double mt_count(void *v)
Definition: nrnmenu.cpp:1013
static Member_ret_obj_func mt_retobj_members[]
Definition: nrnmenu.cpp:1125
static double mt_internal_type(void *v)
Definition: nrnmenu.cpp:995
static double mt_make(void *v)
Definition: nrnmenu.cpp:999
static double mt_select(void *v)
Definition: nrnmenu.cpp:977
int * nrn_has_net_event_
Definition: init.cpp:161
static double mt_action(void *v)
Definition: nrnmenu.cpp:1028
char * pnt_map
Definition: init.cpp:150
static double ms_save(void *v)
Definition: nrnmenu.cpp:632
static double mt_is_target(void *v)
Definition: nrnmenu.cpp:1037
static Object ** mt_pp_next(void *v)
Definition: nrnmenu.cpp:1068
void nrnallpointmenu()
Definition: nrnmenu.cpp:342
void nrnpointmenu()
Definition: nrnmenu.cpp:409
static double mt_has_net_event(void *v)
Definition: nrnmenu.cpp:1042
static double ms_out(void *v)
Definition: nrnmenu.cpp:537
static Member_func mt_members[]
Definition: nrnmenu.cpp:1112
static Symbol * mt_class_sym_
Definition: nrnmenu.cpp:975
Object * nrn_new_pointprocess(Symbol *)
Definition: point.cpp:46
static double mt_is_artificial(void *v)
Definition: nrnmenu.cpp:1047
void MechanismType_reg()
Definition: nrnmenu.cpp:1129
static const char ** mt_file(void *v)
Definition: nrnmenu.cpp:1091
void nrnsecmenu()
Definition: nrnmenu.cpp:58
static double ms_set(void *v)
Definition: nrnmenu.cpp:594
Symbol ** pointsym
Definition: init.cpp:148
static Member_ret_str_func mt_retstr_func[]
Definition: nrnmenu.cpp:1128
static double ms_get(void *v)
Definition: nrnmenu.cpp:602
static double ms_name(void *v)
Definition: nrnmenu.cpp:618
const char ** nrn_nmodl_text_
Definition: init.cpp:184
int(* nrnpy_ob_is_seg)(Object *)
Definition: nrnmenu.cpp:38
Symlist * hoc_built_in_symlist
Definition: symbol.cpp:28
void nrnglobalmechmenu()
Definition: nrnmenu.cpp:91
static double ms_in(void *v)
Definition: nrnmenu.cpp:565
static double ms_count(void *v)
Definition: nrnmenu.cpp:609
static void mt_destruct(void *v)
Definition: nrnmenu.cpp:1108
short index
Definition: cabvars.h:11
std::vector< Memb_func > memb_func
Definition: init.cpp:145
short type
Definition: cabvars.h:10
int nrn_vartype(const Symbol *sym)
Definition: eion.cpp:503
int n_memb_func
Definition: init.cpp:448
static Object * callable_with_args(Object *ho, int narg)
Definition: nrnpy_p2h.cpp:397
static int point_process
Definition: nrnunit.cpp:12
void hoc_ivvalue(CChar *name, CChar *variable, bool deflt=false, Object *pyvar=0)
void hoc_ivpvalue(CChar *name, neuron::container::data_handle< double >, bool deflt=false, HocSymExtension *extra=NULL)
void hoc_ivpvaluerun(CChar *name, neuron::container::data_handle< double >, CChar *action, bool deflt=false, bool canrun=false, HocSymExtension *extra=NULL)
void hoc_ivbutton(CChar *name, CChar *action, Object *pyact=0)
void hoc_ivmenu(CChar *, bool add2menubar=false)
void hoc_ivpanelmap(int scroll=-1)
void hoc_ivvaluerun(CChar *name, CChar *variable, CChar *action, bool deflt=false, bool canrun=false, bool usepointer=false, Object *pyvar=0, Object *pyact=0)
void hoc_ivvaluerun_ex(CChar *name, CChar *var, neuron::container::data_handle< double > pvar, Object *pyvar, CChar *action, Object *pyact, bool deflt=false, bool canrun=false, bool usepointer=false, HocSymExtension *extra=NULL)
void hoc_ivpanel(CChar *, bool h=false)
void hoc_ivlabel(CChar *)
static double done(void *v)
Definition: ocbbs.cpp:251
static Symbol * vsym
Definition: occvode.cpp:42
void section_menu(double, int, MechSelector *=NULL)
#define NULL
Definition: spdefs.h:105
Object ** hoc_temp_objptr(Object *)
Definition: code.cpp:151
int sub[1]
Definition: hocdec.h:63
Definition: section.h:105
Prop * prop
Definition: section.h:190
Definition: hocdec.h:173
void * this_pointer
Definition: hocdec.h:178
cTemplate * ctemplate
Definition: hocdec.h:180
union Object::@47 u
A point process is computed just like regular mechanisms.
Definition: section_fwd.hpp:77
Section * sec
Definition: section_fwd.hpp:78
Definition: section.h:231
Datum * dparam
Definition: section.h:247
short _type
Definition: section.h:244
Prop * next
Definition: section.h:243
Node * parentnode
Definition: section.h:58
short nnode
Definition: section.h:52
Node ** pnode
Definition: section.h:59
Definition: model.h:47
Symbol * next
Definition: hocdec.h:133
union Symbol::@28 u
Symbol ** ppsym
Definition: hocdec.h:125
short type
Definition: model.h:48
long subtype
Definition: model.h:49
cTemplate * ctemplate
Definition: hocdec.h:126
unsigned s_varn
Definition: hocdec.h:129
char * name
Definition: model.h:61
HocSymExtension * extra
Definition: hocdec.h:131
Arrayinfo * arayinfo
Definition: hocdec.h:130
Definition: hocdec.h:75
Symbol * first
Definition: hocdec.h:76
Symbol * sym
Definition: hocdec.h:147
Symlist * symtable
Definition: hocdec.h:148
hoc_List * olist
Definition: hocdec.h:155
T get() const
Explicit conversion to any T.
Object *(* callable_with_args)(Object *, int narg)
Definition: nrnpy.h:26