Update of /cvsroot/pure-data/externals/zexy/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7099
Modified Files: fifop.c lifop.c Log Message: added an "info"-outlet,which bangs when the {lf}ifo is empty by sending an [info( message, you can query the total number of elements currently on the stack
Index: fifop.c =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/fifop.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fifop.c 15 Jun 2005 15:58:14 -0000 1.6 --- fifop.c 4 Dec 2005 12:44:33 -0000 1.7 *************** *** 45,48 **** --- 45,49 ---- t_fifop_list *fifo_end; struct _fifop_prioritylist *next; + unsigned long counter; } t_fifop_prioritylist;
*************** *** 52,55 **** --- 53,57 ---- t_fifop_prioritylist *fifo_list; t_float priority; /* current priority */ + t_outlet *x_out, *x_infout; } t_fifop;
*************** *** 82,85 **** --- 84,88 ---- result->fifo_end=0; result->next=0; + result->counter=0;
/* insert it into the list of priority lists */ *************** *** 137,140 **** --- 140,144 ---- fifoprio->fifo_end =entry; } + fifoprio->counter++; return 0; } *************** *** 164,173 **** --- 168,181 ----
if(!(pfifo=getFifo(x->fifo_list))){ + outlet_bang(x->x_infout); return; } if(!(fifo=pfifo->fifo_start)){ + outlet_bang(x->x_infout); return; }
+ pfifo->counter--; + pfifo->fifo_start=fifo->next; if(0==pfifo->fifo_start){ *************** *** 186,195 ****
/* output the list */ ! outlet_list(x->x_obj.ob_outlet, &s_list, argc, argv);
/* free the list */ freebytes(argv, argc*sizeof(t_atom)); }
static void fifop_free(t_fifop *x) { --- 194,216 ----
/* output the list */ ! outlet_list(x->x_out, &s_list, argc, argv);
/* free the list */ freebytes(argv, argc*sizeof(t_atom)); } + static void fifop_query(t_fifop*x) + { + unsigned long counter=0; + t_fifop_prioritylist*pfifo=x->fifo_list;
+ while(pfifo!=NULL){ + counter+=pfifo->counter; + pfifo=pfifo->next; + } + + verbose(1, "%d elements in fifo", (int)counter); + + outlet_float(x->x_infout, (t_float)counter); + } static void fifop_free(t_fifop *x) { *************** *** 218,221 **** --- 239,245 ---- } x->fifo_list=0; + + outlet_free(x->x_out); + outlet_free(x->x_infout); }
*************** *** 224,229 **** t_fifop *x = (t_fifop *)pd_new(fifop_class);
- outlet_new(&x->x_obj, 0); floatinlet_new(&x->x_obj, &x->priority);
x->fifo_list = 0; --- 248,254 ---- t_fifop *x = (t_fifop *)pd_new(fifop_class);
floatinlet_new(&x->x_obj, &x->priority); + x->x_out =outlet_new(&x->x_obj, gensym("list" )); + x->x_infout=outlet_new(&x->x_obj, gensym("float"));
x->fifo_list = 0; *************** *** 240,243 **** --- 265,269 ---- class_addbang (fifop_class, fifop_bang); class_addlist (fifop_class, fifop_list); + class_addmethod (fifop_class, (t_method)fifop_query, gensym("info"), A_NULL);
class_sethelpsymbol(fifop_class, gensym("zexy/fifop"));
Index: lifop.c =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/lifop.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** lifop.c 15 Jun 2005 15:50:08 -0000 1.4 --- lifop.c 4 Dec 2005 12:44:33 -0000 1.5 *************** *** 44,47 **** --- 44,48 ---- t_lifop_list *lifo_start; struct _lifop_prioritylist *next; + unsigned long counter; } t_lifop_prioritylist; typedef struct _lifop *************** *** 50,53 **** --- 51,55 ---- t_lifop_prioritylist *lifo_list; t_float priority; /* current priority */ + t_outlet *x_out, *x_infout; } t_lifop;
*************** *** 77,80 **** --- 79,83 ---- result->priority=priority; result->lifo_start=0; + result->counter=0;
/* insert it into the list of priority lists */ *************** *** 120,123 **** --- 123,127 ---- entry->next=lifoprio->lifo_start; lifoprio->lifo_start=entry; + lifoprio->counter++;
return 0; *************** *** 148,157 **** --- 152,165 ----
if(!(plifo=getLifo(x->lifo_list))){ + outlet_bang(x->x_infout); return; } if(!(lifo=plifo->lifo_start)){ + outlet_bang(x->x_infout); return; }
+ plifo->counter--; + plifo->lifo_start=lifo->next;
*************** *** 168,177 ****
/* output the list */ ! outlet_list(x->x_obj.ob_outlet, &s_list, argc, argv);
/* free the list */ freebytes(argv, argc*sizeof(t_atom)); }
static void lifop_free(t_lifop *x) { --- 176,198 ----
/* output the list */ ! outlet_list(x->x_out, &s_list, argc, argv);
/* free the list */ freebytes(argv, argc*sizeof(t_atom)); } + static void lifop_query(t_lifop*x) + { + unsigned long counter=0; + t_lifop_prioritylist*plifo=x->lifo_list;
+ while(plifo!=NULL){ + counter+=plifo->counter; + plifo=plifo->next; + } + + verbose(1, "%d elements in lifo", (int)counter); + + outlet_float(x->x_infout, (t_float)counter); + } static void lifop_free(t_lifop *x) { *************** *** 199,202 **** --- 220,226 ---- } x->lifo_list=0; + + outlet_free(x->x_out); + outlet_free(x->x_infout); }
*************** *** 205,210 **** t_lifop *x = (t_lifop *)pd_new(lifop_class);
- outlet_new(&x->x_obj, 0); floatinlet_new(&x->x_obj, &x->priority);
x->lifo_list = 0; --- 229,235 ---- t_lifop *x = (t_lifop *)pd_new(lifop_class);
floatinlet_new(&x->x_obj, &x->priority); + x->x_out=outlet_new(&x->x_obj, gensym("list")); + x->x_infout=outlet_new(&x->x_obj, gensym("float"));
x->lifo_list = 0; *************** *** 221,224 **** --- 246,250 ---- class_addbang (lifop_class, lifop_bang); class_addlist (lifop_class, lifop_list); + class_addmethod (lifop_class, (t_method)lifop_query, gensym("info"), A_NULL);
class_sethelpsymbol(lifop_class, gensym("zexy/lifop"));