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