hoc.h
Go to the documentation of this file.00001
00002 #ifndef hoc_h
00003 #define hoc_h
00004 #define INCLUDEHOCH 1
00005 #define OOP 1
00006
00007 #include "hocassrt.h"
00008 #include <string.h>
00009 #include "redef.h"
00010
00011
00012
00013 #if defined(__cplusplus)
00014 #define HocStruct
00015 #define HocTypedef
00016 #define HocUnion
00017 union Inst;
00018 struct Symbol;
00019 struct Arrayinfo;
00020 struct Proc;
00021 struct Symlist;
00022 union Datum;
00023 struct cTemplate;
00024 union Objectdata;
00025 struct Object;
00026 struct hoc_Item;
00027 #else
00028 #define HocStruct struct
00029 #define HocUnion union
00030 #define HocTypedef typedef
00031 #endif
00032
00033 #if MAC && defined(__cplusplus)
00034 typedef int (*Pfri)(...);
00035 typedef double (*Pfrd)(...);
00036 typedef struct Object** (*Pfro)(...);
00037 typedef char** (*Pfrs)(...);
00038 #else
00039 typedef int (*Pfri)();
00040 typedef double (*Pfrd)();
00041 typedef struct Object** (*Pfro)();
00042 typedef char** (*Pfrs)();
00043 #endif
00044 typedef union Inst {
00045 Pfri pf;
00046 Pfrd pfd;
00047 Pfro pfo;
00048 Pfrs pfs;
00049 HocUnion Inst *in;
00050 HocStruct Symbol *sym;
00051 int i;
00052 } Inst;
00053
00054 #define STOP (Inst *)0
00055
00056 typedef struct Arrayinfo {
00057 unsigned *a_varn;
00058 int nsub;
00059 int refcount;
00060 int sub[1];
00061 } Arrayinfo;
00062
00063 typedef struct Proc {
00064 Inst defn;
00065 unsigned long size;
00066 HocStruct Symlist *list;
00067
00068 int nauto;
00069 int nobjauto;
00070 } Proc;
00071
00072 typedef struct Symlist {
00073 HocStruct Symbol *first;
00074 HocStruct Symbol *last;
00075 }Symlist;
00076
00077 typedef char *Upoint;
00078
00079 # define NOTUSER 0
00080 # define USERINT 1
00081 # define USERDOUBLE 2
00082 #define USERPROPERTY 3
00083 #define USERFLOAT 4
00084 #if NEMO
00085 #define NEMONODE 5
00086 #define NEMOAREA 6
00087 #endif
00088 #define SYMBOL 7
00089 #define OBJECTTMP 8
00090 #define CPLUSOBJECT 16
00091 #define JAVAOBJECT 32
00092
00093 #define OBJECTALIAS 1
00094 #define VARALIAS 2
00095
00096 typedef struct HocSymExtension {
00097 float *parmlimits;
00098 char* units;
00099 float tolerance;
00100 }HocSymExtension;
00101
00102 typedef struct Symbol {
00103 char *name;
00104 short type;
00105 short subtype;
00106 #if defined(__cplusplus)
00107 short cpublic;
00108 #else
00109 short public;
00110 #endif
00111 short defined_on_the_fly;
00112 union {
00113 int oboff;
00114 #if 0
00115 char *str;
00116 HocStruct Object **objvar;
00117 #endif
00118 double *pval;
00119 HocStruct Object* object_;
00120 char *cstr;
00121 double *pnum;
00122 int *pvalint;
00123 float *pvalfloat;
00124 int u_auto;
00125 double (*ptr)();
00126 Proc *u_proc;
00127 struct {
00128 short type;
00129 int index;
00130 }rng;
00131 HocStruct Symbol **ppsym;
00132 #if defined(__cplusplus)
00133 HocStruct cTemplate *ctemplate;
00134 #else
00135 HocStruct Template *template;
00136 #endif
00137 HocStruct Symbol* sym;
00138 } u;
00139 unsigned s_varn;
00140 Arrayinfo *arayinfo;
00141 HocSymExtension* extra;
00142
00143 HocStruct Symbol *next;
00144 } Symbol;
00145 #if !defined(__cplusplus)
00146 extern Symbol *install(), *lookup();
00147 #endif
00148 #define ISARRAY(arg) (arg->arayinfo != (Arrayinfo *)0)
00149
00150
00151 #ifndef hoc_list_h
00152 #if defined(__cplusplus)
00153 #define hoc_List struct hoc_Item
00154 #else
00155 typedef struct hoc_Item hoc_List;
00156 #define List hoc_List
00157 #define Item hoc_Item
00158 #endif
00159 #endif
00160
00161 typedef union Datum {
00162 double val;
00163 Symbol *sym;
00164 int i;
00165 double *pval;
00166 HocStruct Object **pobj;
00167 HocStruct Object *obj;
00168 char **pstr;
00169 HocStruct hoc_Item* itm;
00170 hoc_List* lst;
00171 void* _pvoid;
00172 } Datum;
00173
00174 #if OOP
00175 #if defined(__cplusplus)
00176 typedef struct cTemplate {
00177 #else
00178 typedef struct Template {
00179 #endif
00180 Symbol *sym;
00181 Symlist *symtable;
00182 int dataspace_size;
00183 int is_point_;
00184 Symbol *init;
00185 Symbol *unref;
00186 int index;
00187 int count;
00188 hoc_List* olist;
00189 int id;
00190 void* observers;
00191 #if defined(__cplusplus)
00192 void* (*constructor)(Object*);
00193 void (*destructor)(void*);
00194 void (*steer)(void*);
00195 int (*checkpoint)(void**);
00196 } cTemplate;
00197 #else
00198 void* (*constructor)();
00199 void (*destructor)();
00200 void (*steer)();
00201 int (*checkpoint)();
00202 } Template;
00203 #endif
00204
00205 typedef union Objectdata{
00206 double *pval;
00207 char **ppstr;
00208 HocStruct Object **pobj;
00209 HocStruct hoc_Item** psecitm;
00210 hoc_List** plist;
00211 Arrayinfo* arayinfo;
00212 void* _pvoid;
00213 }Objectdata;
00214
00215 typedef struct Object {
00216 int refcount;
00217 int index;
00218 union {
00219 Objectdata *dataspace;
00220 void* this_pointer;
00221 }u;
00222 #if defined(__cplusplus)
00223 cTemplate *ctemplate;
00224 #else
00225 Template *template;
00226 #endif
00227 void* aliases;
00228 HocStruct hoc_Item* itm_me;
00229 HocStruct hoc_Item* secelm_;
00230 void* observers;
00231 short recurse;
00232 short unref_recurse_cnt;
00233 } Object;
00234 #endif
00235
00236 typedef struct {
00237 char *name;
00238 int (*func)();
00239 } IntFunc;
00240
00241 typedef struct {
00242 char *name;
00243 double *pdoub;
00244 } DoubScal;
00245
00246 typedef struct {
00247 char *name;
00248 double *pdoub;
00249 int index1;
00250 } DoubVec;
00251
00252 typedef struct {
00253 char *name;
00254 float bnd[2];
00255 } HocParmLimits;
00256
00257 typedef struct {
00258 char *name;
00259 float tolerance;
00260 } HocStateTolerance;
00261
00262 typedef struct {
00263 char *name;
00264 char *units;
00265 } HocParmUnits;
00266
00267 extern double xpop();
00268 extern Symbol *spop();
00269
00270 #if defined(__cplusplus)
00271 extern double *getarg(int);
00272 extern char *gargstr(int);
00273 #else
00274 extern double *getarg();
00275 extern char *gargstr();
00276 #endif
00277
00278 extern void* nrn_cacheline_alloc(void** memptr, size_t size);
00279 extern void* nrn_cacheline_calloc(void** memptr, size_t nmemb, size_t size);
00280
00281 #define emalloc(arg) hoc_Emalloc(arg), hoc_malchk()
00282 #define ecalloc(arg1,arg2) hoc_Ecalloc(arg1,arg2), hoc_malchk()
00283 #define erealloc(arg1,arg2) hoc_Erealloc(arg1,arg2), hoc_malchk()
00284
00285 #if defined(__cplusplus)
00286 extern void* hoc_Emalloc(unsigned long);
00287 extern void* hoc_Ecalloc(unsigned long, unsigned long);
00288 extern void* hoc_Erealloc(void*, unsigned long);
00289 extern void hoc_malchk();
00290 #else
00291 #if LINT
00292 extern double *hoc_Emalloc(), *hoc_Ecalloc(), *hoc_Erealloc();
00293 #else
00294 extern char *hoc_Emalloc(), *hoc_Ecalloc(), *hoc_Erealloc();
00295 #endif
00296 #endif
00297
00298 extern Inst *progp, *progbase, *prog, *prog_parse_recover, *Code(), *pc;
00299
00300 extern Objectdata *hoc_objectdata;
00301 extern Objectdata *hoc_objectdata_save();
00302 #if defined(__cplusplus)
00303 extern Objectdata* hoc_objectdata_restore(Objectdata*);
00304 #else
00305 extern Objectdata* hoc_objectdata_restore();
00306 #endif
00307 #define OPVAL(sym) hoc_objectdata[sym->u.oboff].pval
00308 #define OPSTR(sym) hoc_objectdata[sym->u.oboff].ppstr
00309 #define OPOBJ(sym) hoc_objectdata[sym->u.oboff].pobj
00310 #define OPSECITM(sym) hoc_objectdata[sym->u.oboff].psecitm
00311 #define OPLIST(sym) hoc_objectdata[sym->u.oboff].plist
00312 #define OPARINFO(sym) hoc_objectdata[sym->u.oboff + 1].arayinfo
00313
00314 #if LINT
00315 #undef assert
00316 #define assert(arg) {if (arg) ;}
00317 #undef IGNORE
00318 #define IGNORE(arg) {if(arg);}
00319 #define LINTUSE(arg) {if(arg);}
00320 char *cplint;
00321 int ilint;
00322 #define Strcat cplint = strcat
00323 #define Strncat cplint = strncat
00324 #define Strcpy cplint = strcpy
00325 #define Strncpy cplint = strncpy
00326 #define Sprintf cplint = sprintf
00327 #define Printf ilint = printf
00328 #define Fprintf ilint = fprintf
00329 #else
00330 #if defined(__TURBOC__)
00331 #undef IGNORE
00332 #define IGNORE
00333 #else
00334 #undef IGNORE
00335 #define IGNORE(arg) arg
00336 #endif
00337 #define LINTUSE(arg)
00338 #define Strcat strcat
00339 #define Strncat strncat
00340 #define Strcpy strcpy
00341 #define Strncpy strncpy
00342 #define Sprintf sprintf
00343 #define Printf printf
00344 #define Fprintf fprintf
00345 #endif
00346
00347 #endif
00348
00349
00350 #if LINDA
00351 #include <errno.h>
00352 #define ERRCHK(c1) {errno=EINTR;while(errno==EINTR){errno=0;c1}}
00353
00354 #else
00355 #define ERRCHK(c1) c1
00356 #endif
00357
00358 #define IFGUI if (hoc_usegui){
00359 #define ENDGUI }
00360
00361 extern int hoc_usegui;
00362 extern int nrn_istty_;
00363 extern int parallel_sub;
00364
00365 #define NOT_PARALLEL_SUB(c1) {if (!parallel_sub) c1}
00366
00367
00368 #ifdef PVM
00369 extern int init_parallel( );
00370 int num_procs;
00371 int *tids;
00372 int node_num;
00373 int mytid;
00374 #endif
00375