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 /* the dec alpha cxx doesn't understand struct foo* inside a struct */
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 { /* machine instruction list type */
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  { /* subscript info for arrays */
00057    unsigned *a_varn; /* dependent variable number for array elms */
00058    int   nsub;    /* number of subscripts */
00059    int   refcount;   /* because one object always uses symbol's */
00060    int   sub[1];     /* subscript range */
00061 } Arrayinfo;
00062 
00063 typedef struct Proc {
00064    Inst  defn; /* FUNCTION, PROCEDURE, FUN_BLTIN */
00065    unsigned long size;  /* length of instruction list */
00066    HocStruct Symlist *list;   /* For constants and strings */
00067             /* not used by FUN_BLTIN */
00068    int   nauto;      /* total # local variables */
00069    int   nobjauto;   /* the last of these are pointers to objects */
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  /* For subtype */
00081 # define USERDOUBLE  2
00082 #define     USERPROPERTY   3  /* for newcable non-range variables */
00083 #define     USERFLOAT   4  /* John Miller's NEMO uses floats */
00084 #if NEMO
00085 #define     NEMONODE 5  /* looks syntactically like vector */
00086 #define     NEMOAREA 6  /* looks like vector */
00087 #endif
00088 #define     SYMBOL      7  /* for stack type */
00089 #define     OBJECTTMP   8  /* temporary object on stack */
00090 #define     CPLUSOBJECT 16 /* c++ registered class */
00091 #define     JAVAOBJECT  32 /* c++ registered class */
00092 /* above two are bits, next must start at 64 */
00093 #define OBJECTALIAS 1
00094 #define VARALIAS 2
00095 
00096 typedef struct HocSymExtension {
00097    float *parmlimits;   /* some variables have suggested bounds */
00098    char* units;
00099    float tolerance;  /* some states have cvode absolute tolerance */
00100 }HocSymExtension;
00101 
00102 typedef struct Symbol { /* symbol table entry */
00103    char  *name;
00104    short type;
00105    short subtype; /* Flag for user integers */
00106 #if defined(__cplusplus)
00107    short cpublic;    /* flag set public variable */
00108 #else
00109    short public;     /* flag set public variable */
00110 #endif
00111    short defined_on_the_fly;/* moved here because otherwize gcc and borland do not align the same way */
00112    union {
00113       int   oboff;   /* offset into object data pointer space */
00114 #if 0 /* these are now found via oboff. */
00115       char  *str;    /* STRING */
00116       HocStruct Object **objvar; /* possibly an array of object variables */
00117 #endif
00118       double   *pval;      /* User defined doubles - also for alias to scalar */
00119       HocStruct Object* object_; /* alias to an object */
00120       char  *cstr;      /* constant string */
00121       double   *pnum;      /* Numbers */
00122       int   *pvalint;   /* User defined integers */
00123       float *pvalfloat; /* User defined floats */
00124       int   u_auto;     /* stack offset # for AUTO variable */
00125       double   (*ptr)();   /* if BLTIN */
00126       Proc  *u_proc;
00127       struct {
00128          short type; /* Membrane type to find Prop */
00129          int index;  /* prop->param[index] */
00130       }rng;
00131       HocStruct Symbol **ppsym;  /* Pointer to symbol pointer array */
00132 #if defined(__cplusplus)
00133       HocStruct cTemplate *ctemplate;
00134 #else
00135       HocStruct Template *template;
00136 #endif
00137       HocStruct Symbol* sym;  /* for external */
00138    } u;
00139    unsigned   s_varn;   /* dependent variable number - 0 means indep */
00140    Arrayinfo *arayinfo; /* ARRAY information if null then scalar */
00141    HocSymExtension* extra; /* additions to symbol allow compatibility
00142                with old nmodl dll's */
00143    HocStruct Symbol  *next;   /* to link to another */
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 {   /* interpreter stack type */
00162    double   val;
00163    Symbol   *sym;
00164    int i;
00165    double   *pval;   /* first used with Eion in NEURON */
00166    HocStruct Object **pobj;
00167    HocStruct Object *obj;  /* sections keep this to construct a name */
00168    char  **pstr;
00169    HocStruct hoc_Item* itm;
00170    hoc_List* lst;
00171    void* _pvoid;  /* not used on stack, see nrnoc/point.c */
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_; /* actually the pointtype > 0 if a point process */
00184    Symbol *init;  /* null if there is no initialization function */
00185    Symbol *unref;  /* null if there is no function to call when refcount is decremented */
00186    int index;  /* next  unique integer used for name for section */
00187    int count;  /* how many of this kind of object */
00188    hoc_List* olist;  /* list of all instances */
00189    int id;
00190    void* observers;  /* hook to c++ ClassObservable */
00191 #if defined(__cplusplus)
00192    void* (*constructor)(Object*);
00193    void (*destructor)(void*);
00194    void (*steer)(void*);   /* normally nil */
00195    int (*checkpoint)(void**);
00196 } cTemplate;
00197 #else
00198    void* (*constructor)();
00199    void (*destructor)();
00200    void (*steer)();  /* point processes have member variables */
00201    int (*checkpoint)();
00202 } Template;
00203 #endif
00204 
00205 typedef union Objectdata{
00206    double *pval;  /* pointer to array of doubles, usually just 1 */
00207    char **ppstr;  /* pointer to pointer to string ,allows vectors someday*/
00208    HocStruct Object **pobj;   /* pointer to array of object pointers, usually just 1*/
00209    HocStruct hoc_Item** psecitm;   /* array of pointers to section items, usually just 1 */
00210    hoc_List** plist; /* array of pointers to linked lists */
00211    Arrayinfo* arayinfo;
00212    void* _pvoid;     /* Point_process */
00213 }Objectdata;
00214 
00215 typedef struct Object {
00216    int refcount;     /* how many object variables point to this */
00217    int index;     /* unique integer used for names of sections */
00218    union {
00219    Objectdata *dataspace;  /* Points to beginning of object's data */
00220    void* this_pointer;  /* the c++ object */
00221    }u;
00222 #if defined(__cplusplus)
00223    cTemplate *ctemplate;
00224 #else
00225    Template *template;
00226 #endif
00227    void* aliases; /* more convenient names for e.g. Vector or List elements dynamically created by this object*/
00228    HocStruct hoc_Item* itm_me;/* this object in the template list */
00229    HocStruct hoc_Item* secelm_; /* last of a set of contiguous section_list items used by forall */
00230    void* observers;  /* hook to c++ ObjObservable */
00231    short recurse;    /* to stop infinite recursions */
00232    short unref_recurse_cnt; /* free only after last return from unref callback */
00233 } Object;
00234 #endif
00235 
00236 typedef struct {     /* User Functions */
00237    char  *name;
00238    int   (*func)();
00239 } IntFunc;
00240 
00241 typedef struct {     /* User Double Scalars */
00242    char  *name;
00243    double   *pdoub;
00244 } DoubScal;
00245 
00246 typedef struct {     /* User Vectors */
00247    char  *name;
00248    double   *pdoub;
00249    int   index1;
00250 } DoubVec;
00251 
00252 typedef struct {     /* recommended limits for symbol values */
00253    char  *name;
00254    float bnd[2];
00255 } HocParmLimits;
00256 
00257 typedef struct {     /* recommended tolerance for CVODE */
00258    char  *name;
00259    float tolerance;
00260 } HocStateTolerance;
00261 
00262 typedef struct {     /* units for symbol values */
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) ;}   /* so fprintf doesn't give lint */
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 /* EINTR handling for LINDA */
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; /* when 0 does not make interviews calls */
00362 extern int nrn_istty_;
00363 extern int parallel_sub; /* for use with parallel neuron (see parallel.cl) */
00364 
00365 #define NOT_PARALLEL_SUB(c1)  {if (!parallel_sub) c1}
00366 
00367 /* Enter handling for PVM  NJP 11/21/94 */
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 
Generated on Mon Jun 13 08:10:27 2011 for NEURON by  doxygen 1.6.3