NEURON
hocdec.h
Go to the documentation of this file.
1 
2 #ifndef hocdec_h
3 #define hocdec_h
4 #define INCLUDEHOCH 1
5 #define OOP 1
6 
7 
8 #include <stdio.h>
9 #include "nrnapi.h"
10 #include "hocassrt.h" /* hoc_execerror instead of abort */
11 #include "nrnassrt.h" /* assert in case of side effects (eg. scanf) */
12 #include <string.h>
13 
14 #define gargstr hoc_gargstr
15 #define getarg hoc_getarg
16 
17 /* the dec alpha cxx doesn't understand struct foo* inside a struct */
18 
19 #if defined(__cplusplus)
20 #define HocStruct /**/
21 #define HocTypedef /**/
22 #define HocUnion /**/
23 union Inst;
24 struct Symbol;
25 struct Arrayinfo;
26 struct Proc;
27 struct Symlist;
28 union Datum;
29 struct cTemplate;
30 union Objectdata;
31 struct Object;
32 struct hoc_Item;
33 #else
34 #define HocStruct struct
35 #define HocUnion union
36 #define HocTypedef typedef
37 #endif
38 
39 typedef int (*Pfri)(void);
40 typedef void (*Pfrv)(void);
41 typedef double (*Pfrd)(void);
42 typedef struct Object** (*Pfro)(void);
43 typedef const char** (*Pfrs)(void);
44 
45 typedef int (*Pfri_vp)(void*);
46 typedef void (*Pfrv_vp)(void*);
47 typedef double (*Pfrd_vp)(void*);
48 typedef struct Object** (*Pfro_vp)(void*);
49 typedef const char** (*Pfrs_vp)(void*);
50 
51 typedef union Inst { /* machine instruction list type */
62  void* ptr;
63  int i;
64 } Inst;
65 
66 #define STOP (Inst *)0
67 
68 typedef struct Arrayinfo { /* subscript info for arrays */
69  unsigned *a_varn; /* dependent variable number for array elms */
70  int nsub; /* number of subscripts */
71  int refcount; /* because one object always uses symbol's */
72  int sub[1]; /* subscript range */
73 } Arrayinfo;
74 
75 typedef struct Proc {
76  Inst defn; /* FUNCTION, PROCEDURE, FUN_BLTIN */
77  unsigned long size; /* length of instruction list */
78  HocStruct Symlist *list; /* For constants and strings */
79  /* not used by FUN_BLTIN */
80  int nauto; /* total # local variables */
81  int nobjauto; /* the last of these are pointers to objects */
82 } Proc;
83 
84 typedef struct Symlist {
87 }Symlist;
88 
89 typedef char *Upoint;
90 
91 # define NOTUSER 0
92 # define USERINT 1 /* For subtype */
93 # define USERDOUBLE 2
94 #define USERPROPERTY 3 /* for newcable non-range variables */
95 #define USERFLOAT 4 /* John Miller's NEMO uses floats */
96 #if NEMO
97 #define NEMONODE 5 /* looks syntactically like vector */
98 #define NEMOAREA 6 /* looks like vector */
99 #endif
100 #define SYMBOL 7 /* for stack type */
101 #define OBJECTTMP 8 /* temporary object on stack */
102 #define STKOBJ_UNREF 9 /* already unreffed temporary object on stack */
103 #define DYNAMICUNITS 10 /* {modern, legacy} units pair */
104 #define CPLUSOBJECT 16 /* c++ registered class */
105 #define JAVAOBJECT 32 /* c++ registered class */
106 /* above two are bits, next must start at 64 */
107 #define OBJECTALIAS 1
108 #define VARALIAS 2
109 
110 typedef struct HocSymExtension {
111  float *parmlimits; /* some variables have suggested bounds */
112  char* units;
113  float tolerance; /* some states have cvode absolute tolerance */
115 
116 typedef struct Symbol { /* symbol table entry */
117  char *name;
118  short type;
119  short subtype; /* Flag for user integers */
120 /**
121  * Note: `public` is a reserved keyword. Keeping following __cplusplus comments a bit longer
122  * for future reference, with upcoming work for NMODL + eventual mod files to support cpp.
123  */
124 //#if defined(__cplusplus)
125  short cpublic; /* flag set public variable */
126 //#else
127 // short public; /* flag set public variable */
128 //#endif
129  short defined_on_the_fly;/* moved here because otherwize gcc and borland do not align the same way */
130  union {
131  int oboff; /* offset into object data pointer space */
132 #if 0 /* these are now found via oboff. */
133  char *str; /* STRING */
134  HocStruct Object **objvar; /* possibly an array of object variables */
135 #endif
136  double *pval; /* User defined doubles - also for alias to scalar */
137  HocStruct Object* object_; /* alias to an object */
138  char *cstr; /* constant string */
139  double *pnum; /* Numbers */
140  int *pvalint; /* User defined integers */
141  float *pvalfloat; /* User defined floats */
142  int u_auto; /* stack offset # for AUTO variable */
143  double (*ptr)(double); /* if BLTIN */ //TODO: double as parameter?
145  struct {
146  short type; /* Membrane type to find Prop */
147  int index; /* prop->param[index] */
148  }rng;
149  HocStruct Symbol **ppsym; /* Pointer to symbol pointer array */
150 //#if defined(__cplusplus)
152 //#else
153 // HocStruct cTemplate *template;
154 //#endif
155  HocStruct Symbol* sym; /* for external */
156  } u;
157  unsigned s_varn; /* dependent variable number - 0 means indep */
158  Arrayinfo *arayinfo; /* ARRAY information if null then scalar */
159  HocSymExtension* extra; /* additions to symbol allow compatibility
160  with old nmodl dll's */
161  HocStruct Symbol *next; /* to link to another */
162 } Symbol;
163 #define ISARRAY(arg) (arg->arayinfo != (Arrayinfo *)0)
164 
165 
166 #ifndef hoc_list_h
167 #if defined(__cplusplus)
168 #define hoc_List struct hoc_Item
169 #else
170 typedef struct hoc_Item hoc_List;
171 #define List hoc_List
172 #define Item hoc_Item
173 #endif
174 #endif
175 
176 typedef union Datum { /* interpreter stack type */
177  double val;
179  int i;
180  double *pval; /* first used with Eion in NEURON */
182  HocStruct Object *obj; /* sections keep this to construct a name */
183  char **pstr;
186  void* _pvoid; /* not used on stack, see nrnoc/point.cpp */
187 } Datum;
188 
189 #if OOP
190 //#if defined(__cplusplus)
191 typedef struct cTemplate {
192 //#else
193 //typedef struct Template {
194 //#endif
198  int is_point_; /* actually the pointtype > 0 if a point process */
199  Symbol *init; /* null if there is no initialization function */
200  Symbol *unref; /* null if there is no function to call when refcount is decremented */
201  int index; /* next unique integer used for name for section */
202  int count; /* how many of this kind of object */
203  hoc_List* olist; /* list of all instances */
204  int id;
205  void* observers; /* hook to c++ ClassObservable */
206  void* (*constructor)(struct Object*);
207  void (*destructor)(void*);
208  void (*steer)(void*); /* normally nil */
209  int (*checkpoint)(void**);
210 //#if defined(__cplusplus)
211 } cTemplate;
212 //#else
213 //}
214 //#endif
215 
216 typedef union Objectdata{
217  double *pval; /* pointer to array of doubles, usually just 1 */
218  char **ppstr; /* pointer to pointer to string ,allows vectors someday*/
219  HocStruct Object **pobj; /* pointer to array of object pointers, usually just 1*/
220  HocStruct hoc_Item** psecitm; /* array of pointers to section items, usually just 1 */
221  hoc_List** plist; /* array of pointers to linked lists */
223  void* _pvoid; /* Point_process */
224 }Objectdata;
225 
226 typedef struct Object {
227  int refcount; /* how many object variables point to this */
228  int index; /* unique integer used for names of sections */
229  union {
230  Objectdata *dataspace; /* Points to beginning of object's data */
231  void* this_pointer; /* the c++ object */
232  }u;
233 #if defined(__cplusplus)
234  cTemplate *ctemplate;
235 #else
236  cTemplate *template;
237 #endif
238  void* aliases; /* more convenient names for e.g. Vector or List elements dynamically created by this object*/
239  HocStruct hoc_Item* itm_me;/* this object in the template list */
240  HocStruct hoc_Item* secelm_; /* last of a set of contiguous section_list items used by forall */
241  void* observers; /* hook to c++ ObjObservable */
242  short recurse; /* to stop infinite recursions */
243  short unref_recurse_cnt; /* free only after last return from unref callback */
244 } Object;
245 #endif
246 
247 typedef struct { /* User Functions */
248  const char *name;
250 } VoidFunc;
251 
252 typedef struct { /* User Double Scalars */
253  const char *name;
254  double *pdoub;
255 } DoubScal;
256 
257 typedef struct { /* User Vectors */
258  const char *name;
259  double *pdoub;
260  int index1;
261 } DoubVec;
262 
263 typedef struct { /* recommended limits for symbol values */
264  const char *name;
265  float bnd[2];
266 } HocParmLimits;
267 
268 typedef struct { /* recommended tolerance for CVODE */
269  const char *name;
270  float tolerance;
272 
273 typedef struct { /* units for symbol values */
274  const char *name;
275  char *units;
276 } HocParmUnits;
277 
278 #include "oc_ansi.h"
279 
280 #if defined(__cplusplus)
281 extern "C" {
282 #endif
283 
284 extern void* emalloc(size_t n);
285 extern void* ecalloc(size_t n, size_t size);
286 extern void* erealloc(void* ptr, size_t n);
287 
288 #if defined(__cplusplus)
289 }
290 #endif
291 
292 
294 extern Inst *hoc_pc;
295 
296 extern Objectdata *hoc_objectdata;
298 extern Object* hoc_thisobject;
299 extern Symlist* hoc_symlist;
302 extern Objectdata *hoc_objectdata_save(void);
304 #define OPVAL(sym) hoc_objectdata[sym->u.oboff].pval
305 #define OPSTR(sym) hoc_objectdata[sym->u.oboff].ppstr
306 #define OPOBJ(sym) hoc_objectdata[sym->u.oboff].pobj
307 #define OPSECITM(sym) hoc_objectdata[sym->u.oboff].psecitm
308 #define OPLIST(sym) hoc_objectdata[sym->u.oboff].plist
309 #define OPARINFO(sym) hoc_objectdata[sym->u.oboff + 1].arayinfo
310 
311 #if LINT
312 #undef assert
313 #define assert(arg) {if (arg) ;} /* so fprintf doesn't give lint */
314 #undef IGNORE
315 #define IGNORE(arg) {if(arg);}
316 #define LINTUSE(arg) {if(arg);}
317 char *cplint;
318 int ilint;
319 #define Strcat cplint = strcat
320 #define Strncat cplint = strncat
321 #define Strcpy cplint = strcpy
322 #define Strncpy cplint = strncpy
323 #define Sprintf cplint = sprintf
324 #define Printf ilint = printf
325 #else
326 #if defined(__TURBOC__)
327 #undef IGNORE
328 #define IGNORE
329 #else
330 #undef IGNORE
331 #define IGNORE(arg) arg
332 #endif
333 #define LINTUSE(arg)
334 #define Strcat strcat
335 #define Strncat strncat
336 #define Strcpy strcpy
337 #define Strncpy strncpy
338 #define Sprintf sprintf
339 #define Printf nrnpy_pr
340 #endif
341 
342 /* EINTR handling for LINDA */
343 #if LINDA
344 #include <errno.h>
345 #define ERRCHK(c1) {errno=EINTR;while(errno==EINTR){errno=0;c1}}
346 
347 #else
348 #define ERRCHK(c1) c1
349 #endif
350 
351 #define IFGUI if (hoc_usegui){
352 #define ENDGUI }
353 
354 extern int hoc_usegui; /* when 0 does not make interviews calls */
355 extern int nrn_istty_;
356 extern int parallel_sub; /* for use with parallel neuron (see parallel.cl) */
357 
358 #define NOT_PARALLEL_SUB(c1) {if (!parallel_sub) c1}
359 
360 /* Enter handling for PVM NJP 11/21/94 */
361 #ifdef PVM
362 extern int init_parallel( );
363 int num_procs;
364 int *tids;
365 int node_num;
366 int mytid;
367 #endif
368 
369 
370 #endif
Pfro_vp pfo_vp
Definition: hocdec.h:58
float * parmlimits
Definition: hocdec.h:111
Definition: hocdec.h:84
void * emalloc(size_t n)
Definition: symbol.cpp:203
union Inst Inst
void * ecalloc(size_t n, size_t size)
Definition: symbol.cpp:221
int dataspace_size
Definition: hocdec.h:197
HocStruct Symbol * sym
Definition: hocdec.h:61
char * units
Definition: hocdec.h:112
struct Arrayinfo Arrayinfo
short type
Definition: cabvars.h:10
Symlist * hoc_built_in_symlist
Definition: symbol.cpp:39
void * erealloc(void *ptr, size_t n)
Definition: symbol.cpp:267
void * _pvoid
Definition: hocdec.h:186
Symbol * sym
Definition: hocdec.h:195
Inst * hoc_prog
float tolerance
Definition: hocdec.h:113
hoc_List ** plist
Definition: hocdec.h:221
#define HocUnion
Definition: hocdec.h:35
Objectdata * hoc_objectdata_save(void)
Definition: hoc_oop.cpp:143
float * pvalfloat
Definition: hocdec.h:141
int nsub
Definition: hocdec.h:70
HocStruct Symbol * sym
Definition: hocdec.h:155
double * pval
Definition: hocdec.h:180
Symlist * symtable
Definition: hocdec.h:196
void
Pfro pfo
Definition: hocdec.h:54
HocStruct Symbol * last
Definition: hocdec.h:86
void * this_pointer
Definition: hocdec.h:231
Objectdata * hoc_top_level_data
Definition: hoc_oop.cpp:134
const char **(* Pfrs_vp)(void *)
Definition: hocdec.h:49
unsigned long size
Definition: hocdec.h:77
double * pdoub
Definition: hocdec.h:259
HocStruct Symlist * list
Definition: hocdec.h:78
int i
Definition: hocdec.h:179
short unref_recurse_cnt
Definition: hocdec.h:243
struct Symlist Symlist
Arrayinfo * arayinfo
Definition: hocdec.h:222
Definition: hocdec.h:51
hoc_List * olist
Definition: hocdec.h:203
int refcount
Definition: hocdec.h:71
struct Object Object
Inst * hoc_progbase
const char * name
Definition: hocdec.h:264
double * pdoub
Definition: hocdec.h:254
HocStruct Object ** pobj
Definition: hocdec.h:181
const char * name
Definition: hocdec.h:274
static List * bnd[4]
Definition: partial.cpp:160
int index
Definition: hocdec.h:147
struct Object **(* Pfro_vp)(void *)
Definition: hocdec.h:48
unsigned s_varn
Definition: hocdec.h:157
void * observers
Definition: hocdec.h:241
int refcount
Definition: hocdec.h:227
char * units
Definition: hocdec.h:275
int * pvalint
Definition: hocdec.h:140
struct Object **(* Pfro)(void)
Definition: hocdec.h:42
double(* Pfrd)(void)
Definition: hocdec.h:41
int nrn_istty_
Definition: hoc.cpp:870
struct HocSymExtension HocSymExtension
struct Proc Proc
int const size_t const size_t n
Definition: nrngsl.h:12
int(* Pfri)(void)
Definition: hocdec.h:39
HocStruct Symbol ** ppsym
Definition: hocdec.h:149
static void destructor(void *v)
Definition: seclist.cpp:40
double * pval
Definition: hocdec.h:217
Objectdata * dataspace
Definition: hocdec.h:230
HocStruct Object ** pobj
Definition: hocdec.h:219
union Objectdata Objectdata
int nauto
Definition: hocdec.h:80
Arrayinfo * arayinfo
Definition: hocdec.h:158
HocStruct hoc_Item * itm_me
Definition: hocdec.h:239
int parallel_sub
Definition: parallel.cpp:30
HocStruct Object * obj
Definition: hocdec.h:182
double(* Pfrd_vp)(void *)
Definition: hocdec.h:47
int hoc_usegui
Definition: hoc.cpp:148
int
Definition: nrnmusic.cpp:71
Pfrs_vp pfs_vp
Definition: hocdec.h:59
Symbol * init
Definition: hocdec.h:199
HocStruct hoc_Item * secelm_
Definition: hocdec.h:240
Objectdata * hoc_objectdata_restore(Objectdata *)
Definition: hoc_oop.cpp:153
const char * name
Definition: hocdec.h:253
Proc * u_proc
Definition: hocdec.h:144
double * pval
Definition: hocdec.h:136
Inst defn
Definition: hocdec.h:76
char ** ppstr
Definition: hocdec.h:218
char * cstr
Definition: hocdec.h:138
int index
Definition: hocdec.h:201
char ** pstr
Definition: hocdec.h:183
Definition: model.h:57
const char **(* Pfrs)(void)
Definition: hocdec.h:43
HocStruct Object * object_
Definition: hocdec.h:137
HocSymExtension * extra
Definition: hocdec.h:159
Symbol * unref
Definition: hocdec.h:200
char * name
Definition: init.cpp:16
int is_point_
Definition: hocdec.h:198
hoc_List * lst
Definition: hocdec.h:185
int nobjauto
Definition: hocdec.h:81
Inst * hoc_prog_parse_recover
int oboff
Definition: hocdec.h:131
Pfrd_vp pfd_vp
Definition: hocdec.h:57
double(* func)(double)
Definition: hoc_init.cpp:111
int index1
Definition: hocdec.h:260
HocStruct Symbol * next
Definition: hocdec.h:161
struct cTemplate cTemplate
const char * name
Definition: hocdec.h:248
#define HocStruct
Definition: hocdec.h:34
int id
Definition: hocdec.h:204
Pfrv pf
Definition: hocdec.h:52
int(* Pfri_vp)(void *)
Definition: hocdec.h:45
Symbol * sym
Definition: hocdec.h:178
union Datum Datum
short cpublic
Note: public is a reserved keyword.
Definition: hocdec.h:125
Pfrd pfd
Definition: hocdec.h:53
struct Symbol Symbol
int u_auto
Definition: hocdec.h:142
HocStruct hoc_Item ** psecitm
Definition: hocdec.h:220
HocStruct hoc_Item * itm
Definition: hocdec.h:184
Definition: hocdec.h:226
HocStruct cTemplate * ctemplate
Definition: hocdec.h:151
short defined_on_the_fly
Definition: hocdec.h:129
const char * name
Definition: hocdec.h:269
const char * name
Definition: hocdec.h:258
short subtype
Definition: hocdec.h:119
Objectdata * hoc_objectdata
Definition: hoc_oop.cpp:133
void(* Pfrv)(void)
Definition: hocdec.h:40
Pfrv_vp pfv_vp
Definition: hocdec.h:56
Symlist * hoc_top_level_symlist
Neuron/Java Interface code.
Definition: symbol.cpp:41
short recurse
Definition: hocdec.h:242
Inst * hoc_pc
void * observers
Definition: hocdec.h:205
void(* Pfrv_vp)(void *)
Definition: hocdec.h:46
Object * hoc_thisobject
Definition: hoc_oop.cpp:132
float tolerance
Definition: hocdec.h:270
HOC interpreter function declarations (included by hocdec.h)
void * ptr
Definition: hocdec.h:62
void * _pvoid
Definition: hocdec.h:223
int count
Definition: hocdec.h:202
Definition: hocdec.h:176
double val
Definition: hocdec.h:177
Definition: hocdec.h:75
int index
Definition: hocdec.h:228
unsigned * a_varn
Definition: hocdec.h:69
double * pnum
Definition: hocdec.h:139
Pfrs pfs
Definition: hocdec.h:55
int i
Definition: hocdec.h:63
char * Upoint
Definition: hocdec.h:89
Inst * hoc_progp
HocStruct Symbol * first
Definition: hocdec.h:85
void * aliases
Definition: hocdec.h:238
Symlist * hoc_symlist
HocUnion Inst * in
Definition: hocdec.h:60