Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31958
Modified Files: Tag: desiredata kernel.c Log Message: t_binbuf becomes < t_pd
Index: kernel.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v retrieving revision 1.1.2.34 retrieving revision 1.1.2.35 diff -C2 -d -r1.1.2.34 -r1.1.2.35 *** kernel.c 9 Jan 2007 19:39:15 -0000 1.1.2.34 --- kernel.c 9 Jan 2007 21:19:53 -0000 1.1.2.35 *************** *** 688,693 **** };
! t_inlet *t_object:: in(int n) {t_inlet *i; while(n--) i=i->next; return i;} ! t_outlet *t_object::out(int n) {t_outlet *o; while(n--) o=o->o_next; return o;}
t_class *wire_class; --- 688,693 ---- };
! t_inlet *t_object:: in(int n) {t_inlet *i= inlet; while(n--) i=i->next; return i;} ! t_outlet *t_object::out(int n) {t_outlet *o=outlet; while(n--) o=o->o_next; return o;}
t_class *wire_class; *************** *** 1626,1640 **** }
! struct _binbuf { int n; int capa; /* capacity: how much n may grow without reallocating */ ! t_atom *vec; };
t_binbuf *binbuf_new(void) { ! t_binbuf *x = (t_binbuf *)malloc(sizeof(*x)); x->n = 0; x->capa = 1; ! x->vec = (t_atom *)malloc(1*sizeof(t_atom)); return x; } --- 1626,1641 ---- }
! static t_class *binbuf_class; ! struct _binbuf : t_pd { int n; int capa; /* capacity: how much n may grow without reallocating */ ! t_atom *v; };
t_binbuf *binbuf_new(void) { ! t_binbuf *x = (t_binbuf *)pd_new(binbuf_class); x->n = 0; x->capa = 1; ! x->v = (t_atom *)malloc(1*sizeof(t_atom)); return x; } *************** *** 1642,1656 **** /* caution: capa >= x->n and capa >= 1 too */ static void binbuf_capa(t_binbuf *x, int capa) { ! x->vec = (t_atom *)realloc(x->vec, capa*sizeof(*x->vec)); x->capa = capa; }
! void binbuf_free(t_binbuf *x) {free(x->vec); free(x);}
t_binbuf *binbuf_duplicate(t_binbuf *y) { t_binbuf *x = (t_binbuf *)malloc(sizeof(*x)); x->capa = x->n = y->n; ! x->vec = (t_atom *)malloc(x->n * sizeof(*x->vec)); ! memcpy(x->vec, y->vec, x->n * sizeof(*x->vec)); return x; } --- 1643,1657 ---- /* caution: capa >= x->n and capa >= 1 too */ static void binbuf_capa(t_binbuf *x, int capa) { ! x->v = (t_atom *)realloc(x->v, capa*sizeof(*x->v)); x->capa = capa; }
! void binbuf_free(t_binbuf *x) {free(x->v); free(x);}
t_binbuf *binbuf_duplicate(t_binbuf *y) { t_binbuf *x = (t_binbuf *)malloc(sizeof(*x)); x->capa = x->n = y->n; ! x->v = (t_atom *)malloc(x->n * sizeof(*x->v)); ! memcpy(x->v,y->v,x->n*sizeof(*x->v)); return x; } *************** *** 1658,1662 **** void binbuf_clear(t_binbuf *x) { x->n = 0; ! x->vec = (t_atom *)realloc(x->vec, 4); x->capa = 4; } --- 1659,1663 ---- void binbuf_clear(t_binbuf *x) { x->n = 0; ! x->v = (t_atom *)realloc(x->v,4); x->capa = 4; } *************** *** 1777,1781 **** while (t!=end) { t = sys_syntax ? binbuf_text_matju(x,t,end) : binbuf_text_miller(x,t,end); ! if (x->n && x->vec[x->n-1].a_type == A_SEMI) { binbuf_eval(x,0,0,0); binbuf_clear(x); --- 1778,1782 ---- while (t!=end) { t = sys_syntax ? binbuf_text_matju(x,t,end) : binbuf_text_miller(x,t,end); ! if (x->n && x->v[x->n-1].a_type == A_SEMI) { binbuf_eval(x,0,0,0); binbuf_clear(x); *************** *** 1790,1794 **** int length = 0; char string[MAXPDSTRING]; ! t_atom *ap = x->vec; int indx; for (indx = x->n; indx--; ap++) { --- 1791,1795 ---- int length = 0; char string[MAXPDSTRING]; ! t_atom *ap = x->v; int indx; for (indx = x->n; indx--; ap++) { *************** *** 1817,1822 **** void binbuf_add(t_binbuf *x, int argc, t_atom *argv) { int newsize = x->n + argc; ! t_atom *ap = (t_atom *)realloc(x->vec, newsize * sizeof(*x->vec)); ! x->vec = ap; ap += x->n; for (int i = argc; i--; ap++) *ap = *(argv++); --- 1818,1823 ---- void binbuf_add(t_binbuf *x, int argc, t_atom *argv) { int newsize = x->n + argc; ! t_atom *ap = (t_atom *)realloc(x->v,newsize*sizeof(*x->v)); ! x->v = ap; ap += x->n; for (int i = argc; i--; ap++) *ap = *(argv++); *************** *** 1860,1865 **** void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y) { t_binbuf *z = binbuf_new(); ! binbuf_add(z, y->n, y->vec); ! t_atom *ap = z->vec; for (int i=0; i < z->n; i++, ap++) { char tbuf[MAXPDSTRING]; --- 1861,1866 ---- void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y) { t_binbuf *z = binbuf_new(); ! binbuf_add(z, y->n, y->v); ! t_atom *ap = z->v; for (int i=0; i < z->n; i++, ap++) { char tbuf[MAXPDSTRING]; *************** *** 1881,1885 **** } } ! binbuf_add(x, z->n, z->vec); }
--- 1882,1886 ---- } } ! binbuf_add(x, z->n, z->v); }
*************** *** 1896,1906 **** int newsize = x->n + argc, i; t_atom *ap; ! ap = (t_atom *)realloc(x->vec, newsize * sizeof(*x->vec)); if (!ap) { error("binbuf_addmessage: out of space"); return; } ! x->vec = ap; ! for (ap = x->vec + x->n, i = argc; i--; ap++) { if (argv->a_type == A_SYMBOL) { char *str = argv->a_symbol->name, *str2; --- 1897,1907 ---- int newsize = x->n + argc, i; t_atom *ap; ! ap = (t_atom *)realloc(x->v,newsize*sizeof(*x->v)); if (!ap) { error("binbuf_addmessage: out of space"); return; } ! x->v = ap; ! for (ap = x->v + x->n, i = argc; i--; ap++) { if (argv->a_type == A_SYMBOL) { char *str = argv->a_symbol->name, *str2; *************** *** 1938,1943 **** startedpost = 1; } ! postatom(1, x->vec + i); ! newline = !! x->vec[i].a_type == A_SEMI; } if (startedpost) endpost(); --- 1939,1944 ---- startedpost = 1; } ! postatom(1, x->v + i); ! newline = !! x->v[i].a_type == A_SEMI; } if (startedpost) endpost(); *************** *** 1945,1949 ****
int binbuf_getnatom(t_binbuf *x) {return x->n;} ! t_atom *binbuf_getvec(t_binbuf *x) {return x->vec;}
int canvas_getdollarzero(void); --- 1946,1950 ----
int binbuf_getnatom(t_binbuf *x) {return x->n;} ! t_atom *binbuf_getvec(t_binbuf *x) {return x->v;}
int canvas_getdollarzero(void); *************** *** 2039,2043 **** static t_atom mstack[MSTACKSIZE], *msp = mstack, *ems = mstack+MSTACKSIZE; t_atom *stackwas = msp; ! t_atom *at = x->vec; int ac = x->n; int nargs; --- 2040,2044 ---- static t_atom mstack[MSTACKSIZE], *msp = mstack, *ems = mstack+MSTACKSIZE; t_atom *stackwas = msp; ! t_atom *at = x->v; int ac = x->n; int nargs; *************** *** 2245,2249 **** goto fail; } ! for (ap = x->vec, indx = x->n; indx--; ap++) { int length; /* estimate how many characters will be needed. Printing out --- 2246,2250 ---- goto fail; } ! for (ap = x->v, indx = x->n; indx--; ap++) { int length; /* estimate how many characters will be needed. Printing out *************** *** 2300,2304 **** static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd) { t_binbuf *newb = binbuf_new(); ! t_atom *vec = oldb->vec; t_int n = oldb->n, nextindex, stackdepth = 0, stack[MAXSTACK], nobj = 0, i; t_atom outmess[MAXSTACK], *nextmess; --- 2301,2305 ---- static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd) { t_binbuf *newb = binbuf_new(); ! t_atom *vec = oldb->v; t_int n = oldb->n, nextindex, stackdepth = 0, stack[MAXSTACK], nobj = 0, i; t_atom outmess[MAXSTACK], *nextmess; *************** *** 2503,2507 **** for (indexin = 0; indexin <= inbuf->n - searchbuf->n; indexin++) { for (nmatched = 0; nmatched < searchbuf->n; nmatched++) { ! t_atom *a1 = &inbuf->vec[indexin + nmatched], *a2 = &searchbuf->vec[nmatched]; if (a1->a_type != a2->a_type || a1->a_type == A_SYMBOL && a1->a_symbol != a2->a_symbol || --- 2504,2508 ---- for (indexin = 0; indexin <= inbuf->n - searchbuf->n; indexin++) { for (nmatched = 0; nmatched < searchbuf->n; nmatched++) { ! t_atom *a1 = &inbuf->v[indexin + nmatched], *a2 = &searchbuf->v[nmatched]; if (a1->a_type != a2->a_type || a1->a_type == A_SYMBOL && a1->a_symbol != a2->a_symbol || *************** *** 2566,2569 **** --- 2567,2572 ---- class_addlist(bindlist_class, (t_method)bindlist_list); class_addanything(bindlist_class, (t_method)bindlist_anything); + binbuf_class = class_new(gensym("__alist"), (t_newmethod)binbuf_new, + (t_method)binbuf_free, sizeof(t_binbuf), CLASS_PD, A_GIMME, 0); wire_class = class_new(gensym("__wire"), (t_newmethod)wire_new, (t_method)wire_free, sizeof(t_wire), CLASS_GOBJ, A_GIMME, 0);