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