NEURON
neuronapi.cpp
Go to the documentation of this file.
1 #include "neuronapi.h"
2 
3 #include "../../nrnconf.h"
4 #include "hocdec.h"
5 #include "cabcode.h"
6 #include "nrniv_mf.h"
7 #include "nrnmpi.h"
8 #include "nrnmpiuse.h"
9 #include "ocfunc.h"
10 #include "ocjump.h"
11 #include "parse.hpp"
12 #include "nrn_ansi.h"
13 #include "section.h"
14 #include "shapeplt.h"
15 #include <cstring>
16 #include <exception>
17 
18 /// A public face of hoc_Item
19 struct nrn_Item: public hoc_Item {};
20 
22  explicit SectionListIterator(nrn_Item*);
23  Section* next(void);
24  int done(void) const;
25 
26  private:
29 };
30 
32  explicit SymbolTableIterator(Symlist*);
33  Symbol* next(void);
34  int done(void) const;
35 
36  private:
38 };
39 
40 /****************************************
41  * Connections to the rest of NEURON
42  ****************************************/
43 extern int nrn_nobanner_;
44 extern int diam_changed;
45 extern int nrn_try_catch_nest_depth;
46 extern "C" void nrnpy_set_pr_etal(int (*cbpr_stdoe)(int, char*), int (*cbpass)());
47 int ivocmain_session(int, const char**, const char**, int start_session);
49 extern Object* hoc_newobj1(Symbol*, int);
50 extern std::tuple<int, const char**> nrn_mpi_setup(int argc, const char** argv);
51 
52 extern "C" {
53 
54 /****************************************
55  * Initialization
56  ****************************************/
57 
58 int nrn_init(int argc, const char** argv) {
59  nrn_nobanner_ = 1;
60  auto [final_argc, final_argv] = nrn_mpi_setup(argc, argv);
61  errno = 0;
62  return ivocmain_session(final_argc, final_argv, nullptr, 0);
63 }
64 
65 void nrn_stdout_redirect(int (*myprint)(int, char*)) {
66  // the first argument of myprint is an integer indicating the output stream
67  // if the int is 1, then stdout, else stderr
68  // the char* is the message to display
69  nrnpy_set_pr_etal(myprint, nullptr);
70 }
71 
72 /****************************************
73  * Sections
74  ****************************************/
75 
76 Section* nrn_section_new(char const* const name) {
77  auto* symbol = new Symbol;
78  auto pitm = new hoc_Item*;
79  symbol->name = strdup(name);
80  symbol->type = 1;
81  symbol->u.oboff = 0;
82  symbol->arayinfo = 0;
84  hoc_top_level_data[symbol->u.oboff].psecitm = pitm;
85  new_sections(nullptr, symbol, pitm, 1);
86  return (*pitm)->element.sec;
87 }
88 
89 void nrn_section_connect(Section* child_sec, double child_x, Section* parent_sec, double parent_x) {
90  nrn_pushsec(child_sec);
91  hoc_pushx(child_x);
92  nrn_pushsec(parent_sec);
93  hoc_pushx(parent_x);
95 }
96 
97 void nrn_section_length_set(Section* sec, const double length) {
98  // TODO: call can_change_morph(sec) to check pt3dconst_; how should we handle
99  // that?
100  // TODO: is there a named constant so we don't have to use the magic number 2?
101  sec->prop->dparam[2] = length;
102  // nrn_length_change updates 3D points if needed
103  nrn_length_change(sec, length);
104  diam_changed = 1;
105  sec->recalc_area_ = 1;
106 }
107 
109  return section_length(sec);
110 }
111 
113  return nrn_ra(sec);
114 }
115 
116 void nrn_section_Ra_set(Section* sec, double const val) {
117  // TODO: ensure val > 0
118  // TODO: is there a named constant so we don't have to use the magic number 7?
119  sec->prop->dparam[7] = val;
120  diam_changed = 1;
121  sec->recalc_area_ = 1;
122 }
123 
125  return sec->prop->dparam[4].get<double>();
126 }
127 
128 void nrn_section_rallbranch_set(Section* sec, double const val) {
129  // TODO: is there a named constant so we don't have to use the magic number 4?
130  sec->prop->dparam[4] = val;
131  diam_changed = 1;
132  sec->recalc_area_ = 1;
133 }
134 
135 char const* nrn_secname(Section* sec) {
136  return secname(sec);
137 }
138 
140  nrn_pushsec(sec);
141 }
142 
143 void nrn_section_pop(void) {
144  nrn_sec_pop();
145 }
146 
148  // TODO: throw exception if mechanism is not an insertable mechanism?
149  mech_insert1(sec, mechanism->subtype);
150 }
151 
153  if (!sec->prop) {
154  return false;
155  }
156  return true;
157 }
158 
160  section_ref(sec);
161 }
162 
165 }
166 
167 Section* nrn_cas(void) {
169  return sec;
170 }
171 
172 /****************************************
173  * Segments
174  ****************************************/
175 
176 int nrn_nseg_get(const Section* sec) {
177  // always one more node than nseg
178  return sec->nnode - 1;
179 }
180 
181 void nrn_nseg_set(Section* const sec, const int nseg) {
182  nrn_change_nseg(sec, nseg);
183 }
184 
185 void nrn_segment_diam_set(Section* const sec, const double x, const double diam) {
186  Node* const node = node_exact(sec, x);
187  // TODO: this is fine if no 3D points; does it work if there are 3D points?
188  for (auto prop = node->prop; prop; prop = prop->next) {
189  if (prop->_type == MORPHOLOGY) {
190  prop->param(0) = diam;
191  diam_changed = 1;
192  node->sec->recalc_area_ = 1;
193  break;
194  }
195  }
196 }
197 
198 double nrn_segment_diam_get(Section* const sec, const double x) {
199  // Geometry from 3d points writes diam lazily, gated per-section on
200  // recalc_area_. Mirror the range-variable read path (nrnpy_nrn.cpp) so a
201  // diam read after pt3dadd returns the 3d-derived value, not a stale default.
202  if (sec && sec->recalc_area_) {
203  nrn_area_ri(sec);
204  }
205  Node* const node = node_exact(sec, x);
206  for (auto prop = node->prop; prop; prop = prop->next) {
207  if (prop->_type == MORPHOLOGY) {
208  return prop->param(0);
209  }
210  }
211  return 0.0;
212 }
213 
214 int nrn_segment_node_index(Section* const sec, const double x) {
215  if (!sec || !sec->prop) {
216  return -1;
217  }
218  return node_exact(sec, x)->v_node_index;
219 }
220 
221 double nrn_rangevar_get(Symbol* sym, Section* sec, double x) {
222  return *nrn_rangepointer(sec, sym, x);
223 }
224 
225 void nrn_rangevar_set(Symbol* sym, Section* sec, double x, double value) {
226  *nrn_rangepointer(sec, sym, x) = value;
227 }
228 
229 void nrn_rangevar_push(Symbol* sym, Section* sec, double x) {
230  hoc_push(nrn_rangepointer(sec, sym, x));
231 }
232 
234  return static_cast<nrn_Item*>(section_list);
235 }
236 
238  // TODO: verify the obj is in fact a SectionList
239  return (nrn_Item*) obj->u.this_pointer;
240 }
241 
242 /****************************************
243  * Functions, objects, and the stack
244  ****************************************/
245 
246 Symbol* nrn_symbol(char const* const name) {
247  return hoc_lookup(name);
248 }
249 
250 int nrn_symbol_type(const Symbol* sym) {
251  // TODO: these types are in parse.hpp and are not the same between versions,
252  // so we really should wrap
253  return sym->type;
254 }
255 
256 int nrn_symbol_subtype(const Symbol* sym) {
257  return sym->subtype;
258 }
259 
260 double* nrn_symbol_dataptr(const Symbol* sym) {
261  // A NOTUSER runtime scalar (created in HOC by e.g. `x = 42`) does not store
262  // its value at sym->u.pval -- for that subtype the union member holds an
263  // object-data offset, not a pointer, so returning it hands back garbage that
264  // segfaults on dereference. The real storage is in the top-level
265  // object-data array (see the NOTUSER branch of eval() in oc/code.cpp, which
266  // reads *OPVAL(sym) == *hoc_top_level_data[sym->u.oboff].pval). Return that
267  // address so the result is a dereferenceable double*, as the name promises.
268  // Every other case (USERDOUBLE built-ins such as `t`, and the typed USER*
269  // subtypes that already alias sym->u.pval) is unchanged.
270  if (sym && sym->type == VAR && sym->subtype == NOTUSER) {
271  return hoc_top_level_data[sym->u.oboff].pval;
272  }
273  return sym->u.pval;
274 }
275 
276 bool nrn_symbol_is_array(const Symbol* sym) {
277  return sym->arayinfo != nullptr;
278 }
279 
281  hoc_pushpx(sym->u.pval);
282 }
283 
284 void nrn_double_push(double val) {
285  hoc_pushx(val);
286 }
287 
288 double nrn_double_pop(void) {
289  return hoc_xpop();
290 }
291 
292 void nrn_double_ptr_push(double* addr) {
293  hoc_pushpx(addr);
294 }
295 
296 double* nrn_double_ptr_pop(void) {
297  return hoc_pxpop();
298 }
299 
300 void nrn_str_push(char** str) {
301  hoc_pushstr(str);
302 }
303 
304 char** nrn_str_pop(void) {
305  return hoc_strpop();
306 }
307 
308 void nrn_int_push(int i) {
309  hoc_pushi(i);
310 }
311 
312 int nrn_int_pop(void) {
313  return hoc_ipop();
314 }
315 
317  hoc_push_object(obj);
318 }
319 
321  // NOTE: the returned object should be unref'd when no longer needed
322  Object** obptr = hoc_objpop();
323  Object* new_ob_ptr = *obptr;
324  new_ob_ptr->refcount++;
325  hoc_tobj_unref(obptr);
326  return new_ob_ptr;
327 }
328 
330  switch (hoc_stack_type()) {
331  case STRING:
332  return STACK_IS_STR;
333  case VAR:
334  return STACK_IS_VAR;
335  case NUMBER:
336  return STACK_IS_NUM;
337  case OBJECTVAR:
338  return STACK_IS_OBJVAR;
339  case OBJECTTMP:
340  return STACK_IS_OBJTMP;
341  case USERINT:
342  return STACK_IS_INT;
343  case SYMBOL:
344  return STACK_IS_SYM;
345  }
346  return STACK_UNKNOWN;
347 }
348 
350  switch (id) {
351  case STACK_IS_STR:
352  return "STRING";
353  case STACK_IS_VAR:
354  return "VAR";
355  case STACK_IS_NUM:
356  return "NUMBER";
357  case STACK_IS_OBJVAR:
358  return "OBJECTVAR";
359  case STACK_IS_OBJTMP:
360  return "OBJECTTMP";
361  case STACK_IS_INT:
362  return "INT";
363  case STACK_IS_SYM:
364  return "SYMBOL";
365  default:
366  return "UNKNOWN";
367  }
368 }
369 
371  return hoc_newobj1(sym, narg);
372 }
373 
374 Symbol* nrn_method_symbol(const Object* obj, char const* const name) {
375  return hoc_table_lookup(name, obj->ctemplate->symtable);
376 }
377 
378 void nrn_method_call(Object* obj, Symbol* method_sym, int narg) {
379  OcJump::execute_throw_on_exception(obj, method_sym, narg);
380 }
381 
382 void nrn_function_call(Symbol* sym, int narg) {
383  // NOTE: this differs from hoc_call_func in that the response remains on the
384  // stack
386 }
387 
389  Symbol* method_sym,
390  int narg,
391  char* error_msg,
392  size_t error_msg_size) {
393  // Initialize error message buffer
394  if (error_msg && error_msg_size > 0) {
395  error_msg[0] = '\0';
396  }
397 
398  try {
399  OcJump::execute_throw_on_exception(obj, method_sym, narg);
400  return 0; // Success
401  } catch (const std::exception& e) {
402  if (error_msg && error_msg_size > 0) {
403  strncpy(error_msg, e.what(), error_msg_size - 1);
404  error_msg[error_msg_size - 1] = '\0';
405  }
406  return 1; // Error
407  } catch (...) {
408  if (error_msg && error_msg_size > 0) {
409  strncpy(error_msg, "Unknown exception occurred", error_msg_size - 1);
410  error_msg[error_msg_size - 1] = '\0';
411  }
412  return 1; // Error
413  }
414 }
415 
416 int nrn_function_call_nothrow(Symbol* sym, int narg, char* error_msg, size_t error_msg_size) {
417  // Initialize error message buffer
418  if (error_msg && error_msg_size > 0) {
419  error_msg[0] = '\0';
420  }
421 
422  try {
424  return 0; // Success
425  } catch (const std::exception& e) {
426  if (error_msg && error_msg_size > 0) {
427  strncpy(error_msg, e.what(), error_msg_size - 1);
428  error_msg[error_msg_size - 1] = '\0';
429  }
430  return 1; // Error
431  } catch (...) {
432  if (error_msg && error_msg_size > 0) {
433  strncpy(error_msg, "Unknown exception occurred", error_msg_size - 1);
434  error_msg[error_msg_size - 1] = '\0';
435  }
436  return 1; // Error
437  }
438 }
439 
440 void nrn_object_ref(Object* obj) {
441  obj->refcount++;
442 }
443 
445  hoc_obj_unref(obj);
446 }
447 
448 char const* nrn_class_name(const Object* obj) {
449  return obj->ctemplate->sym->name;
450 }
451 
452 bool nrn_prop_exists(const Object* obj) {
453  return ob2pntproc_0(const_cast<Object*>(obj))->prop;
454 }
455 
456 double nrn_distance(Section* sec0, double x0, Section* sec1, double x1) {
457  Node* node0 = node_exact(sec0, x0);
458  Node* node1 = node_exact(sec1, x1);
459  Section* dummy_sec = nullptr;
460  Node* dummy_node = nullptr;
461  return topol_distance(sec0, node0, sec1, node1, &dummy_sec, &dummy_node);
462 }
463 
464 /****************************************
465  * Plot Shape
466  ****************************************/
467 
469  ShapePlotInterface* spi;
470  hoc_Item** my_section_list;
471  spi = ((ShapePlotInterface*) ps->u.this_pointer);
472  return spi;
473 }
474 
476  return spi->neuron_section_list();
477 }
478 
480  return spi->varname();
481 }
482 
484  return spi->low();
485 }
486 
488  return spi->high();
489 }
490 
491 /****************************************
492  * Miscellaneous
493  ****************************************/
494 int nrn_hoc_call(char const* const command) {
495  return hoc_oc(command);
496 }
497 
499  : initial(my_sectionlist)
500  , current(my_sectionlist->next) {}
501 
503  if (!current) {
504  return nullptr;
505  }
506 
507  Section* sec = nullptr;
508  while (current != initial) {
509  // Save next pointer before possibly deleting current
510  auto* q = current;
511  current = current->next;
512  sec = q->element.sec;
513 
514  // Check if the section is still valid
515  if (!sec || sec->prop == nullptr) {
516  // Unlink and delete invalid section
517  if (q->prev) {
518  q->prev->next = q->next;
519  }
520  if (q->next) {
521  q->next->prev = q->prev;
522  }
523  delete q;
524  continue; // Try next
525  }
526 
527  return sec;
528  }
529 
530  return nullptr;
531 }
532 
533 int SectionListIterator::done(void) const {
534  if (initial == current) {
535  return 1;
536  }
537  return 0;
538 }
539 
541  : current(list->first) {}
542 
544  Symbol* result = current;
545  current = current->next;
546  return result;
547 }
548 
549 int SymbolTableIterator::done(void) const {
550  if (!current) {
551  return 1;
552  }
553  return 0;
554 }
555 
556 // copy semantics isn't great, but only two data items
557 // and is cleaner to use in a for loop than having to free memory at the end
559  return new SectionListIterator(my_sectionlist);
560 }
561 
563  delete sl;
564 }
565 
567  return sl->next();
568 }
569 
571  return sl->done();
572 }
573 
575  return new SymbolTableIterator(my_symbol_table);
576 }
577 
579  delete st;
580 }
581 
583  return st->next();
584 }
585 
587  return st->done();
588 }
589 
590 int nrn_vector_capacity(const Object* vec) {
591  // TODO: throw exception if vec is not a Vector
592  return vector_capacity((IvocVect*) vec->u.this_pointer);
593 }
594 
595 double* nrn_vector_data(Object* vec) {
596  // TODO: throw exception if vec is not a Vector
597  return vector_vec((IvocVect*) vec->u.this_pointer);
598 }
599 
600 double nrn_property_get(const Object* obj, const char* name) {
601  auto sym = hoc_table_lookup(name, obj->ctemplate->symtable);
602  if (!obj->ctemplate->is_point_) {
603  hoc_pushs(sym);
604  // put the pointer for the memory location on the stack
605  obj->ctemplate->steer(obj->u.this_pointer);
606  return *hoc_pxpop();
607  } else {
608  int index = sym->u.rng.index;
609  return ob2pntproc_0(const_cast<Object*>(obj))->prop->param_legacy(index);
610  }
611 }
612 
613 double nrn_property_array_get(const Object* obj, const char* name, int i) {
614  auto sym = hoc_table_lookup(name, obj->ctemplate->symtable);
615  if (!obj->ctemplate->is_point_) {
616  hoc_pushs(sym);
617  // put the pointer for the memory location on the stack
618  obj->ctemplate->steer(obj->u.this_pointer);
619  return hoc_pxpop()[i];
620  } else {
621  int index = sym->u.rng.index;
622  return ob2pntproc_0(const_cast<Object*>(obj))->prop->param_legacy(index + i);
623  }
624 }
625 
626 void nrn_property_set(Object* obj, const char* name, double value) {
627  auto sym = hoc_table_lookup(name, obj->ctemplate->symtable);
628  if (!obj->ctemplate->is_point_) {
629  hoc_pushs(sym);
630  // put the pointer for the memory location on the stack
631  obj->ctemplate->steer(obj->u.this_pointer);
632  *hoc_pxpop() = value;
633  } else {
634  int index = sym->u.rng.index;
636  }
637 }
638 
639 void nrn_property_array_set(Object* obj, const char* name, int i, double value) {
640  auto sym = hoc_table_lookup(name, obj->ctemplate->symtable);
641  if (!obj->ctemplate->is_point_) {
642  hoc_pushs(sym);
643  // put the pointer for the memory location on the stack
644  obj->ctemplate->steer(obj->u.this_pointer);
645  hoc_pxpop()[i] = value;
646  } else {
647  int index = sym->u.rng.index;
649  }
650 }
651 
652 void nrn_property_push(Object* obj, const char* name) {
653  auto sym = hoc_table_lookup(name, obj->ctemplate->symtable);
654  if (!obj->ctemplate->is_point_) {
655  hoc_pushs(sym);
656  // put the pointer for the memory location on the stack
657  obj->ctemplate->steer(obj->u.this_pointer);
658  } else {
659  int index = sym->u.rng.index;
660  hoc_push(ob2pntproc_0(obj)->prop->param_handle_legacy(index));
661  }
662 }
663 
664 void nrn_property_array_push(Object* obj, const char* name, int i) {
665  auto sym = hoc_table_lookup(name, obj->ctemplate->symtable);
666  if (!obj->ctemplate->is_point_) {
667  hoc_pushs(sym);
668  // put the pointer for the memory location on the stack
669  obj->ctemplate->steer(obj->u.this_pointer);
670  hoc_pushpx(hoc_pxpop() + i);
671  } else {
672  int index = sym->u.rng.index;
673  hoc_push(ob2pntproc_0(obj)->prop->param_handle_legacy(index + i));
674  }
675 }
676 
677 char const* nrn_symbol_name(const Symbol* sym) {
678  return sym->name;
679 }
680 
682  // TODO: ensure sym is an object or class
683  // NOTE: to use with an object, call nrn_get_symbol(nrn_class_name(obj))
684  return sym->u.ctemplate->symtable;
685 }
686 
688  return hoc_built_in_symlist;
689 }
690 
692  return hoc_top_level_symlist;
693 }
694 
696  return sym->arayinfo->sub[0];
697 }
698 
699 // Function to register function/object in hoc
700 void nrn_register_function(void (*proc)(), const char* func_name, int type) {
701  Symbol* sym;
702  sym = hoc_install(func_name, type, 0, &hoc_top_level_symlist);
703  sym->u.u_proc->defn.pf = proc;
704  sym->u.u_proc->nauto = 0;
705  sym->u.u_proc->nobjauto = 0;
706 }
707 
708 void nrn_hoc_ret() {
709  hoc_ret();
710 }
711 
712 /****************************************
713  * Parameter-reading functions
714  ****************************************/
715 Object** nrn_objgetarg(int arg) {
716  return hoc_objgetarg(arg);
717 }
718 
719 char* nrn_gargstr(int arg) {
720  return hoc_gargstr(arg);
721 }
722 
723 double* nrn_getarg(int arg) {
724  return hoc_getarg(arg);
725 }
726 
727 std::FILE* nrn_obj_file_arg(int i) {
728  return hoc_obj_file_arg(i);
729 }
730 
731 bool nrn_ifarg(int arg) {
732  return ifarg(arg);
733 }
734 
735 
736 bool nrn_is_object_arg(int arg) {
737  return hoc_is_object_arg(arg);
738 }
739 
740 
741 bool nrn_is_str_arg(int arg) {
742  return hoc_is_str_arg(arg);
743 }
744 
745 
746 bool nrn_is_double_arg(int arg) {
747  return hoc_is_double_arg(arg);
748 }
749 
750 
751 bool nrn_is_pdouble_arg(int arg) {
752  return hoc_is_pdouble_arg(arg);
753 }
754 }
#define STRING
Definition: bbslsrv.cpp:9
const char * secname(Section *sec)
name of section (for use in error messages)
Definition: cabcode.cpp:1674
void nrn_change_nseg(Section *sec, int n)
Definition: cabcode.cpp:1482
void nrn_pushsec(Section *sec)
Definition: cabcode.cpp:130
double nrn_ra(Section *sec)
Definition: cabcode.cpp:417
double section_length(Section *sec)
Definition: cabcode.cpp:401
Section * nrn_noerr_access(void)
return 0 if no accessed section
Definition: cabcode.cpp:474
Section * nrn_sec_pop(void)
Definition: cabcode.cpp:753
void new_sections(Object *ob, Symbol *sym, Item **pitm, int size)
Definition: cabcode.cpp:304
neuron::container::data_handle< double > nrn_rangepointer(Section *sec, Symbol *s, double d)
Definition: cabcode.cpp:1274
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
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:48
#define sec
Definition: md1redef.h:20
#define i
Definition: md1redef.h:19
#define prop
Definition: md1redef.h:38
int hoc_is_object_arg(int narg)
Definition: code.cpp:876
double hoc_xpop()
Definition: code.cpp:903
void hoc_pushstr(char **d)
Definition: code.cpp:800
double * hoc_getarg(int narg)
Definition: code.cpp:1641
void hoc_ret()
void hoc_pushpx(double *d)
Definition: code.cpp:834
char * hoc_gargstr(int)
Symbol * hoc_install(const char *, int, double, Symlist **)
Definition: symbol.cpp:77
std::FILE * hoc_obj_file_arg(int i)
Definition: ocfile.cpp:47
int hoc_is_str_arg(int narg)
Definition: code.cpp:872
double * hoc_pxpop()
Definition: code.cpp:922
int hoc_ipop()
Definition: code.cpp:967
int hoc_oc(const char *buf)
Definition: hoc.cpp:1314
int hoc_is_double_arg(int narg)
Definition: code.cpp:864
void hoc_install_object_data_index(Symbol *sp)
Definition: hoc_oop.cpp:302
Symbol * hoc_lookup(const char *)
Definition: symbol.cpp:59
int hoc_is_pdouble_arg(int narg)
Definition: code.cpp:868
void hoc_obj_unref(Object *obj)
Definition: hoc_oop.cpp:1886
void hoc_pushi(int d)
Definition: code.cpp:846
void hoc_push_object(Object *d)
Definition: code.cpp:793
void hoc_push(neuron::container::generic_data_handle handle)
Definition: code.cpp:850
#define NOTUSER
Definition: hocdec.h:82
#define OBJECTTMP
Definition: hocdec.h:88
#define USERINT
Definition: hocdec.h:83
Point_process * ob2pntproc_0(Object *ob)
Definition: hocmech.cpp:89
static void initial(neuron::model_sorted_token const &, NrnThread *nt, Memb_list *ml, int type)
Definition: hocmech.cpp:181
Object ** hoc_objgetarg(int)
Definition: code.cpp:1614
static int argc
Definition: inithoc.cpp:45
static char ** argv
Definition: inithoc.cpp:46
static int narg()
Definition: ivocvect.cpp:121
Symlist * hoc_top_level_symlist
Definition: code2.cpp:677
void hoc_pushx(double)
Definition: code.cpp:779
#define MORPHOLOGY
Definition: membfunc.hpp:59
#define SYMBOL
Definition: model.h:91
const char * name
Definition: init.cpp:16
Item * next(Item *item)
Definition: list.cpp:89
double * vector_vec(IvocVect *v)
Definition: ivocvect.cpp:19
static const char * mechanism[]
Definition: capac.cpp:19
char Symbol
Definition: nrnconf.h:25
int vector_capacity(IvocVect *v)
Definition: ivocvect.cpp:16
double nrn_rangevar_get(Symbol *sym, Section *sec, double x)
Definition: neuronapi.cpp:221
void nrn_section_length_set(Section *sec, const double length)
Definition: neuronapi.cpp:97
Section * nrn_cas(void)
Definition: neuronapi.cpp:167
int diam_changed
Definition: cabcode.cpp:55
float nrn_get_plotshape_high(ShapePlotInterface *spi)
Definition: neuronapi.cpp:487
SectionListIterator * nrn_sectionlist_iterator_new(nrn_Item *my_sectionlist)
Definition: neuronapi.cpp:558
void nrn_section_pop(void)
Definition: neuronapi.cpp:143
void nrn_int_push(int i)
Definition: neuronapi.cpp:308
void nrn_section_ref(Section *sec)
Definition: neuronapi.cpp:159
Symbol * nrn_symbol(char const *const name)
Definition: neuronapi.cpp:246
void nrn_property_push(Object *obj, const char *name)
Definition: neuronapi.cpp:652
double nrn_double_pop(void)
Definition: neuronapi.cpp:288
int nrn_try_catch_nest_depth
Definition: hoc.cpp:608
SymbolTableIterator * nrn_symbol_table_iterator_new(Symlist *my_symbol_table)
Definition: neuronapi.cpp:574
void nrn_section_rallbranch_set(Section *sec, double const val)
Definition: neuronapi.cpp:128
char * nrn_gargstr(int arg)
Definition: neuronapi.cpp:719
Object * nrn_object_pop(void)
Definition: neuronapi.cpp:320
bool nrn_is_object_arg(int arg)
Definition: neuronapi.cpp:736
double nrn_section_Ra_get(Section *sec)
Definition: neuronapi.cpp:112
void nrn_nseg_set(Section *const sec, const int nseg)
Definition: neuronapi.cpp:181
int nrn_nseg_get(const Section *sec)
Definition: neuronapi.cpp:176
Symlist * nrn_top_level_symbol_table(void)
Definition: neuronapi.cpp:691
float nrn_get_plotshape_low(ShapePlotInterface *spi)
Definition: neuronapi.cpp:483
void nrn_double_ptr_push(double *addr)
Definition: neuronapi.cpp:292
void nrn_section_unref(Section *sec)
Definition: neuronapi.cpp:163
bool nrn_prop_exists(const Object *obj)
Definition: neuronapi.cpp:452
void nrn_register_function(void(*proc)(), const char *func_name, int type)
Definition: neuronapi.cpp:700
int ivocmain_session(int, const char **, const char **, int start_session)
This used to be ivocmain, the main entrypoint to the HOC interpreter.
Definition: ivocmain.cpp:361
void nrn_method_call(Object *obj, Symbol *method_sym, int narg)
Definition: neuronapi.cpp:378
void nrn_symbol_table_iterator_free(SymbolTableIterator *st)
Definition: neuronapi.cpp:578
double nrn_property_array_get(const Object *obj, const char *name, int i)
Definition: neuronapi.cpp:613
int nrn_symbol_subtype(const Symbol *sym)
Definition: neuronapi.cpp:256
Symbol * nrn_method_symbol(const Object *obj, char const *const name)
Definition: neuronapi.cpp:374
int nrn_init(int argc, const char **argv)
Definition: neuronapi.cpp:58
Object * nrn_get_plotshape_section_list(ShapePlotInterface *spi)
Definition: neuronapi.cpp:475
void nrn_section_push(Section *sec)
Definition: neuronapi.cpp:139
int nrn_int_pop(void)
Definition: neuronapi.cpp:312
Section * nrn_section_new(char const *const name)
Definition: neuronapi.cpp:76
int nrn_nobanner_
Definition: hoc.cpp:119
bool nrn_symbol_is_array(const Symbol *sym)
Definition: neuronapi.cpp:276
nrn_Item * nrn_sectionlist_data(const Object *obj)
Definition: neuronapi.cpp:237
nrn_stack_types_t nrn_stack_type(void)
Definition: neuronapi.cpp:329
char const * nrn_symbol_name(const Symbol *sym)
Definition: neuronapi.cpp:677
bool nrn_is_double_arg(int arg)
Definition: neuronapi.cpp:746
void nrn_rangevar_set(Symbol *sym, Section *sec, double x, double value)
Definition: neuronapi.cpp:225
void nrn_section_Ra_set(Section *sec, double const val)
Definition: neuronapi.cpp:116
void simpleconnectsection()
Definition: cabcode.cpp:664
std::FILE * nrn_obj_file_arg(int i)
Definition: neuronapi.cpp:727
const char * nrn_get_plotshape_varname(ShapePlotInterface *spi)
Definition: neuronapi.cpp:479
bool nrn_is_str_arg(int arg)
Definition: neuronapi.cpp:741
void nrn_stdout_redirect(int(*myprint)(int, char *))
Definition: neuronapi.cpp:65
Symbol * nrn_symbol_table_iterator_next(SymbolTableIterator *st)
Definition: neuronapi.cpp:582
int nrn_symbol_table_iterator_done(SymbolTableIterator *st)
Definition: neuronapi.cpp:586
Object ** nrn_objgetarg(int arg)
Definition: neuronapi.cpp:715
double nrn_property_get(const Object *obj, const char *name)
Definition: neuronapi.cpp:600
double nrn_section_length_get(Section *sec)
Definition: neuronapi.cpp:108
void nrn_rangevar_push(Symbol *sym, Section *sec, double x)
Definition: neuronapi.cpp:229
ShapePlotInterface * nrn_get_plotshape_interface(Object *ps)
Definition: neuronapi.cpp:468
void nrn_property_array_set(Object *obj, const char *name, int i, double value)
Definition: neuronapi.cpp:639
Object * nrn_object_new(Symbol *sym, int narg)
Definition: neuronapi.cpp:370
int nrn_function_call_nothrow(Symbol *sym, int narg, char *error_msg, size_t error_msg_size)
Definition: neuronapi.cpp:416
Symlist * nrn_symbol_table(const Symbol *sym)
Definition: neuronapi.cpp:681
void nrn_hoc_ret()
Definition: neuronapi.cpp:708
double * nrn_double_ptr_pop(void)
Definition: neuronapi.cpp:296
char const * nrn_stack_type_name(nrn_stack_types_t id)
Definition: neuronapi.cpp:349
double * nrn_symbol_dataptr(const Symbol *sym)
Definition: neuronapi.cpp:260
void nrn_segment_diam_set(Section *const sec, const double x, const double diam)
Definition: neuronapi.cpp:185
nrn_Item * nrn_allsec(void)
Definition: neuronapi.cpp:233
Symlist * nrn_global_symbol_table(void)
Definition: neuronapi.cpp:687
void nrn_section_connect(Section *child_sec, double child_x, Section *parent_sec, double parent_x)
Definition: neuronapi.cpp:89
Object * hoc_newobj1(Symbol *, int)
Definition: hoc_oop.cpp:502
double * nrn_vector_data(Object *vec)
Definition: neuronapi.cpp:595
Section * nrn_sectionlist_iterator_next(SectionListIterator *sl)
Definition: neuronapi.cpp:566
void nrn_property_array_push(Object *obj, const char *name, int i)
Definition: neuronapi.cpp:664
char const * nrn_secname(Section *sec)
Definition: neuronapi.cpp:135
void nrn_object_push(Object *obj)
Definition: neuronapi.cpp:316
int nrn_sectionlist_iterator_done(SectionListIterator *sl)
Definition: neuronapi.cpp:570
char const * nrn_class_name(const Object *obj)
Definition: neuronapi.cpp:448
int nrn_symbol_type(const Symbol *sym)
Definition: neuronapi.cpp:250
void nrn_object_ref(Object *obj)
Definition: neuronapi.cpp:440
void nrn_function_call(Symbol *sym, int narg)
Definition: neuronapi.cpp:382
int nrn_symbol_array_length(const Symbol *sym)
Definition: neuronapi.cpp:695
void nrn_property_set(Object *obj, const char *name, double value)
Definition: neuronapi.cpp:626
void nrnpy_set_pr_etal(int(*cbpr_stdoe)(int, char *), int(*cbpass)())
Definition: fileio.cpp:816
void nrn_object_unref(Object *obj)
Definition: neuronapi.cpp:444
char ** nrn_str_pop(void)
Definition: neuronapi.cpp:304
std::tuple< int, const char ** > nrn_mpi_setup(int argc, const char **argv)
A top-level initialization of MPI given argc and argv.
Definition: ivocmain.cpp:770
int nrn_segment_node_index(Section *const sec, const double x)
Definition: neuronapi.cpp:214
int nrn_vector_capacity(const Object *vec)
Definition: neuronapi.cpp:590
void nrn_double_push(double val)
Definition: neuronapi.cpp:284
double nrn_segment_diam_get(Section *const sec, const double x)
Definition: neuronapi.cpp:198
void nrn_sectionlist_iterator_free(SectionListIterator *sl)
Definition: neuronapi.cpp:562
bool nrn_section_is_active(const Section *sec)
Definition: neuronapi.cpp:152
int nrn_hoc_call(char const *const command)
Definition: neuronapi.cpp:494
void nrn_symbol_push(Symbol *sym)
Definition: neuronapi.cpp:280
void nrn_mechanism_insert(Section *sec, const Symbol *mechanism)
Definition: neuronapi.cpp:147
double nrn_section_rallbranch_get(const Section *sec)
Definition: neuronapi.cpp:124
double nrn_distance(Section *sec0, double x0, Section *sec1, double x1)
Definition: neuronapi.cpp:456
void nrn_str_push(char **str)
Definition: neuronapi.cpp:300
int nrn_method_call_nothrow(Object *obj, Symbol *method_sym, int narg, char *error_msg, size_t error_msg_size)
Definition: neuronapi.cpp:388
bool nrn_ifarg(int arg)
Definition: neuronapi.cpp:731
bool nrn_is_pdouble_arg(int arg)
Definition: neuronapi.cpp:751
double * nrn_getarg(int arg)
Definition: neuronapi.cpp:723
struct SymbolTableIterator SymbolTableIterator
Definition: neuronapi.h:21
struct SectionListIterator SectionListIterator
Definition: neuronapi.h:19
nrn_stack_types_t
Definition: neuronapi.h:25
@ STACK_UNKNOWN
Definition: neuronapi.h:33
@ STACK_IS_NUM
Definition: neuronapi.h:28
@ STACK_IS_VAR
Definition: neuronapi.h:27
@ STACK_IS_STR
Definition: neuronapi.h:26
@ STACK_IS_OBJVAR
Definition: neuronapi.h:29
@ STACK_IS_INT
Definition: neuronapi.h:31
@ STACK_IS_OBJTMP
Definition: neuronapi.h:30
@ STACK_IS_SYM
Definition: neuronapi.h:32
void nrn_area_ri(Section *sec)
Definition: treeset.cpp:752
void section_ref(Section *)
Definition: solve.cpp:520
double topol_distance(Section *, Node *, Section *, Node *, Section **, Node **)
Definition: solve.cpp:167
void section_unref(Section *)
Definition: solve.cpp:509
void nrn_length_change(Section *, double)
Definition: treeset.cpp:1205
static Node * node(Object *)
Definition: netcvode.cpp:291
size_t q
int ifarg(int)
Definition: code.cpp:1607
short index
Definition: cabvars.h:11
short type
Definition: cabvars.h:10
hoc_List * section_list
Definition: init.cpp:113
char ** hoc_strpop()
Definition: code.cpp:962
Object ** hoc_objpop()
Pop pointer to object pointer and return top elem from stack.
Definition: code.cpp:943
int hoc_stack_type()
Get the type of the top entry.
Definition: code.cpp:310
void hoc_pushs(Symbol *)
Definition: code.cpp:841
void hoc_tobj_unref(Object **)
Definition: code.cpp:160
static List * current
Definition: nrnunit.cpp:13
Objectdata * hoc_top_level_data
Definition: hoc_oop.cpp:128
static uint32_t value
Definition: scoprand.cpp:25
Symlist * hoc_built_in_symlist
Definition: symbol.cpp:28
int sub[1]
Definition: hocdec.h:63
Definition: section.h:105
Section * sec
Definition: section.h:193
int v_node_index
Definition: section.h:212
Prop * prop
Definition: section.h:190
Definition: hocdec.h:173
void * this_pointer
Definition: hocdec.h:178
int refcount
Definition: hocdec.h:174
cTemplate * ctemplate
Definition: hocdec.h:180
union Object::@47 u
static void execute_throw_on_exception(Symbol *sym, int narg)
Definition: ocjump.cpp:145
int nauto
Definition: hocdec.h:71
Inst defn
Definition: hocdec.h:67
int nobjauto
Definition: hocdec.h:72
double & param_legacy(int legacy_index)
Definition: section.h:345
short recalc_area_
Definition: section.h:61
Section * next(void)
Definition: neuronapi.cpp:502
int done(void) const
Definition: neuronapi.cpp:533
hoc_Item * current
Definition: neuronapi.cpp:28
SectionListIterator(nrn_Item *)
Definition: neuronapi.cpp:498
hoc_Item * initial
Definition: neuronapi.cpp:27
virtual const char * varname() const =0
virtual Object * neuron_section_list()=0
virtual float low()=0
virtual float high()=0
Definition: model.h:47
Proc * u_proc
Definition: hocdec.h:120
Symbol * next
Definition: hocdec.h:133
union Symbol::@28 u
short type
Definition: model.h:48
long subtype
Definition: model.h:49
cTemplate * ctemplate
Definition: hocdec.h:126
char * name
Definition: model.h:61
double * pval
Definition: hocdec.h:112
int oboff
Definition: hocdec.h:111
Arrayinfo * arayinfo
Definition: hocdec.h:130
SymbolTableIterator(Symlist *)
Definition: neuronapi.cpp:540
Symbol * next(void)
Definition: neuronapi.cpp:543
int done(void) const
Definition: neuronapi.cpp:549
Definition: hocdec.h:75
Symbol * sym
Definition: hocdec.h:147
Symlist * symtable
Definition: hocdec.h:148
int is_point_
Definition: hocdec.h:150
void(* steer)(void *)
Definition: hocdec.h:160
hoc_Item * next
Definition: hoclist.h:44
A public face of hoc_Item.
Definition: neuronapi.cpp:19
Pfrv pf
Definition: hocdec.h:43
hoc_Item ** psecitm
Definition: hocdec.h:167
double * pval
Definition: hocdec.h:164