hoclist.h

Go to the documentation of this file.
00001 /* /local/src/master/nrn/src/oc/list.h,v 1.3 1997/08/29 21:03:44 hines Exp */
00002 /*
00003 list.h,v
00004  * Revision 1.3  1997/08/29  21:03:44  hines
00005  * administrative modifications to prepare for distribution.
00006  *
00007  * Revision 1.2  1995/02/13  20:17:30  hines
00008  * small mods for portability
00009  *
00010  * Revision 1.1.1.1  1994/10/12  17:22:03  hines
00011  * NEURON 3.0 distribution
00012  *
00013  * Revision 2.81  1994/04/27  11:21:31  hines
00014  * support for ivoc/SRC/checkpoint.c
00015  * usage is checkpoint("filename")
00016  * then ivoc filename ...
00017  * so far only for oc
00018  *
00019  * Revision 2.43  1993/04/20  08:40:23  hines
00020  * lists can have void* elements (use insertvoid lappendvoid VOIDITM(q) )
00021  *
00022  * Revision 1.2  92/10/27  12:08:16  hines
00023  * list.c list.h moved from nrnoc to oc
00024  * all templates maintain a list of their objects
00025  * 
00026  * Revision 1.1  92/10/27  11:40:17  hines
00027  * Initial revision
00028  * 
00029  * Revision 3.9  92/09/23  13:13:07  hines
00030  * list.h stuff prefixed by hoc so doesn't conflict with InterViews List
00031  * 
00032  * Revision 2.83  92/08/11  12:39:17  hines
00033  * list.h can be included in c++ files
00034  * 
00035  * Revision 2.75  92/08/07  16:12:00  hines
00036  * sections as objects. nsection and section gone. now list of sections
00037  * in nmodl list style in its place. vectorization no longer optional
00038  * probably many bugs at this point but all examples run correctly.
00039  * Need tests with complete code coverage.
00040  * 
00041  * Revision 1.1  92/08/06  14:38:42  hines
00042  * Initial revision
00043  * 
00044 */
00045 
00046 #ifndef hoc_list_h
00047 #define hoc_list_h
00048 
00049 #if HOC_L_LIST
00050 #define stralloc  hoc_l_stralloc
00051 #define newitem      hoc_l_newitem
00052 #define newlist      hoc_l_newlist
00053 #define freelist  hoc_l_freelist
00054 #define next      hoc_l_next
00055 #define prev      hoc_l_prev
00056 #define insertstr hoc_l_insertstr
00057 #define insertitem   hoc_l_insertitem
00058 #define insertlist   hoc_l_insertlist
00059 #define insertsym hoc_l_insertsym
00060 #define insertsec hoc_l_insertsec
00061 #define insertobj hoc_l_insertobj
00062 #define insertvoid   hoc_l_insertvoid
00063 #define linsertsym   hoc_l_linsertsym
00064 #define linsertstr   hoc_l_linsertstr
00065 #define lappendsym   hoc_l_lappendsym
00066 #define lappendstr   hoc_l_lappendstr
00067 #define lappenditem  hoc_l_lappenditem
00068 #define lappendlst   hoc_l_lappendlst
00069 #define lappendsec   hoc_l_lappendsec
00070 #define lappendobj   hoc_l_lappendobj
00071 #define lappendvoid  hoc_l_lappendvoid
00072 #define delete    hoc_l_delete
00073 #define delitems  hoc_l_delitems
00074 #define move      hoc_l_move
00075 #define movelist  hoc_l_movelist
00076 #define replacstr hoc_l_replacstr
00077 #define Item      hoc_Item
00078 #define List      hoc_List
00079 
00080 typedef struct hoc_Item    hoc_List;      /* list of mixed items */
00081 #else
00082 #define hoc_List struct hoc_Item
00083 #endif
00084 
00085 typedef struct hoc_Item {
00086    union {
00087          struct hoc_Item *itm;
00088          hoc_List *lst;
00089          char *str;
00090          struct Symbol *sym;
00091          struct Section* sec;
00092          struct Object* obj;
00093          void* vd;
00094    }  element; /* pointer to the actual item */
00095    struct hoc_Item    *next;
00096    struct hoc_Item    *prev;
00097    short           itemtype;
00098 }               hoc_Item;
00099 #define ITEM0  (hoc_Item *)0
00100 #define LIST0  (hoc_List *)0
00101 
00102 #define ITERATE(itm,lst) for (itm = (lst)->next; itm != (lst); itm = itm->next)
00103 /*
00104  * this is convenient way to get the element pointer if you know what type
00105  * the item is 
00106  */
00107 #define SYM(q) ((q)->element.sym)
00108 #define STR(q) ((q)->element.str)
00109 #define ITM(q) ((q)->element.itm)
00110 #define LST(q) ((q)->element.lst)
00111 #define hocSEC(q) ((q)->element.sec)
00112 #define OBJ(q) ((q)->element.obj)
00113 #define VOIDITM(q)   ((q)->element.vd)
00114 
00115 /* types not defined in parser */
00116 #define ITEM   2
00117 #define LIST   3
00118 #define VOIDPOINTER  4
00119 /*
00120  * An item type, STRING is also used as an item type 
00121  */
00122 
00123 #ifdef __cplusplus
00124 
00125 extern char* hoc_l_stralloc(char*, char* release=nil);
00126 extern hoc_List* hoc_l_newlist();
00127 extern hoc_Item* hoc_l_insertstr(hoc_Item*, char*);
00128 extern hoc_Item* hoc_l_insertsym(hoc_Item*, Symbol*);
00129 extern hoc_Item* hoc_l_insertitem(hoc_Item*, hoc_Item*);
00130 extern hoc_Item* hoc_l_insertlist(hoc_Item*, hoc_List*);
00131 extern hoc_Item* hoc_l_insertsec(hoc_Item*, Section*);
00132 extern hoc_Item* hoc_l_insertvoid(hoc_Item*, void*);
00133 
00134 extern hoc_Item* hoc_l_linsertstr(hoc_List*, char*);
00135 extern hoc_Item* hoc_l_linsertsym(hoc_List*, Symbol*);
00136 
00137 extern hoc_Item* hoc_l_lappendstr(hoc_List*, char*);
00138 extern hoc_Item* hoc_l_lappendsym(hoc_List*, Symbol*);
00139 extern hoc_Item* hoc_l_lappenditem(hoc_List*, hoc_Item*);
00140 extern hoc_Item* hoc_l_lappendlst(hoc_List*, hoc_List*);
00141 extern hoc_Item* hoc_l_lappendsec(hoc_List*, Section*);
00142 extern hoc_Item* hoc_l_lappendvoid(hoc_List*, void*);
00143 extern hoc_Item* hoc_l_lappendobj(hoc_List*, Object*);
00144 
00145 extern void hoc_l_freelist(hoc_List**);
00146 extern hoc_Item* hoc_l_next(hoc_Item*);
00147 extern hoc_Item* hoc_l_prev(hoc_Item*);
00148 extern void hoc_l_delete(hoc_Item*);
00149 extern void hoc_l_move(hoc_Item*, hoc_Item*, hoc_Item*);
00150 extern void hoc_l_movelist(hoc_Item*, hoc_Item*, hoc_List*);
00151 extern void hoc_l_replacstr(hoc_Item*, char*);
00152 
00153 #else
00154 extern char
00155       *hoc_l_stralloc();   /* copies string to new space */
00156 
00157 extern hoc_List
00158       *hoc_l_newlist(); /* begins new empty list */
00159 extern hoc_Item
00160       *hoc_l_insertstr(),  /* before a known Item */
00161       *hoc_l_insertsym(),
00162       *hoc_l_insertsec(),
00163       *hoc_l_insertobj(),
00164       *hoc_l_insertvoid(),
00165       *hoc_l_linsertstr(), /* prepend to list */
00166       *hoc_l_lappendstr(), /* append to list */
00167       *hoc_l_linsertsym(),
00168       *hoc_l_lappendsym(),
00169       *hoc_l_lappenditem(),
00170       *hoc_l_lappendlst(),
00171       *hoc_l_lappendsec(),
00172       *hoc_l_lappendobj(),
00173       *hoc_l_lappendvoid(),
00174       *hoc_l_next(), /* not used but should be instead of q->next */
00175       *hoc_l_prev();
00176 
00177 /* the following is to get lint to shut up */
00178 #if LINT
00179 #undef assert
00180 #define assert(arg)  {if (arg) ;}   /* so fprintf doesn't give lint */
00181 extern char    *clint;
00182 extern int      ilint;
00183 extern hoc_Item    *qlint;
00184 #define Insertstr qlint = insertstr
00185 #define Insertsym qlint = insertsym
00186 #define Insertsec qlint = insertsec
00187 #define Linsertsym   qlint = linsertsym
00188 #define Linsertstr   qlint = linsertstr
00189 #define Lappendsym   qlint = lappendsym
00190 #define Lappendstr   qlint = lappendstr
00191 #define Lappenditem  qlint = lappenditem
00192 #define Lappendlst   qlint = lappendlst
00193 #define Lappendsec   qlint = lappendsec
00194 #else
00195 #define Insertstr insertstr
00196 #define Insertsym insertsym
00197 #define Insertsec insertsec
00198 #define Linsertsym   linsertsym
00199 #define Linsertstr   linsertstr
00200 #define Lappendsym   lappendsym
00201 #define Lappendstr   lappendstr
00202 #define Lappenditem  lappenditem
00203 #define Lappendlst   lappendlst
00204 #define Lappendsec   lappendsec
00205 #endif
00206 #endif
00207 #endif
Generated on Mon Jun 13 08:10:27 2011 for NEURON by  doxygen 1.6.3