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