Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19171
Modified Files: Tag: desiredata desire.c Log Message: cleanup
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.149 retrieving revision 1.1.2.217.2.150 diff -C2 -d -r1.1.2.217.2.149 -r1.1.2.217.2.150 *** desire.c 10 Jul 2007 19:35:11 -0000 1.1.2.217.2.149 --- desire.c 10 Jul 2007 20:31:18 -0000 1.1.2.217.2.150 *************** *** 387,391 **** }
- /* if there's an old one lying around free it here. This happens if an abstraction is loaded but never gets as far --- 387,390 ---- *************** *** 430,434 **** }
! t_symbol *canvas_getcurrentdir () {return canvas_getenv(canvas_getcurrent())->dir;} t_symbol *canvas_getdir(t_canvas *x) {return canvas_getenv( x)->dir;}
--- 429,433 ---- }
! t_symbol *canvas_getcurrentdir () {return canvas_getenv(canvas_getcurrent())->dir;} t_symbol *canvas_getdir(t_canvas *x) {return canvas_getenv( x)->dir;}
*************** *** 532,536 **** else if (argc==6) pd_scanargs(argc,argv,"iiiisi",&xloc,&yloc,&width,&height,&s,&vis); /* (otherwise assume we're being created from the menu.) */ - if (canvas_newdirectory->name[0]) { static long dollarzero = 1000; --- 531,534 ---- *************** *** 597,601 **** int zz; int menu = 0; - char *str; t_canvas *x = canvas_new2(); if (!*sym->name) { --- 595,598 ---- *************** *** 604,608 **** sym = gensym(buf); menu = 1; ! } else if (!strncmp((str = sym->name), "graph", 5) && (zz = atoi(str + 5)) > gcount) gcount = zz; /* in 0.34 and earlier, the pixel rectangle and the y bounds were reversed; this would behave the same, except that the dialog window would be confusing. The "correct" way is to have "py1" be the value --- 601,605 ---- sym = gensym(buf); menu = 1; ! } else if (!strncmp(sym->name,"graph",5) && (zz = atoi(sym->name+5)) > gcount) gcount = zz; /* in 0.34 and earlier, the pixel rectangle and the y bounds were reversed; this would behave the same, except that the dialog window would be confusing. The "correct" way is to have "py1" be the value *************** *** 882,888 **** t_canvas *z = canvas_getcurrent(); if (s == &s_) { ! char tabname[255]; ! t_symbol *t = gensym("table"); ! sprintf(tabname, "%s%d", t->name, tabcount++); s = gensym(tabname); } --- 879,884 ---- t_canvas *z = canvas_getcurrent(); if (s == &s_) { ! char tabname[255]; ! sprintf(tabname, "table%d", tabcount++); s = gensym(tabname); } *************** *** 1861,1865 ****
static void garray_save(t_gobj *z, t_binbuf *b) { - int style, filestyle; t_garray *x = (t_garray *)z; t_array *array = garray_getarray(x); --- 1857,1860 ---- *************** *** 1874,1879 **** return; } ! style = (int)template_getfloat(scalartemplate, gensym("style"), x->scalar->v, 0); ! filestyle = (style == PLOTSTYLE_POINTS ? 1 : (style == PLOTSTYLE_POLY ? 0 : style)); binbuf_addv(b, "ttsisi;","#X","array", x->realname, array->n, &s_float, x->saveit+2*filestyle+8*x->hidename); if (x->saveit) { --- 1869,1874 ---- return; } ! int style = (int)template_getfloat(scalartemplate, gensym("style"), x->scalar->v, 0); ! int filestyle = (style == PLOTSTYLE_POINTS ? 1 : (style == PLOTSTYLE_POLY ? 0 : style)); binbuf_addv(b, "ttsisi;","#X","array", x->realname, array->n, &s_float, x->saveit+2*filestyle+8*x->hidename); if (x->saveit) { *************** *** 1927,1931 **** /* sum of Fourier components; called from routines below */ static void garray_dofo(t_garray *x, int npoints, float dcval, int nsin, t_float *vsin, int sineflag) { ! double phase, phaseincr, fj; int yonset, i, j, elemsize; t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); --- 1922,1926 ---- /* sum of Fourier components; called from routines below */ static void garray_dofo(t_garray *x, int npoints, float dcval, int nsin, t_float *vsin, int sineflag) { ! double phase, fj; int yonset, i, j, elemsize; t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); *************** *** 1935,1939 **** post("%s: rounnding to %d points", array->templatesym->name, (npoints = (1<<ilog2(npoints)))); garray_resize(x, npoints + 3); ! phaseincr = 2. * 3.14159 / npoints; for (i=0, phase = -phaseincr; i < array->n; i++, phase += phaseincr) { double sum = dcval; --- 1930,1934 ---- post("%s: rounnding to %d points", array->templatesym->name, (npoints = (1<<ilog2(npoints)))); garray_resize(x, npoints + 3); ! double phaseincr = 2. * 3.14159 / npoints; for (i=0, phase = -phaseincr; i < array->n; i++, phase += phaseincr) { double sum = dcval; *************** *** 1946,1958 ****
static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv) { t_float *svec = (t_float *)getbytes(sizeof(t_float) * argc); ! int npoints; ! if (argc < 2) { ! pd_error(x,"sinesum: %s: need number of points and partial strengths", x->realname->name); ! return; ! } ! npoints = atom_getintarg(0,argc--,argv++); ! argv++, argc--; ! svec = (t_float *)getbytes(sizeof(t_float) * argc); for (int i=0; i < argc; i++) svec[i] = atom_getfloatarg(i, argc, argv); garray_dofo(x, npoints, 0, argc, svec, 1); --- 1941,1948 ----
static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv) { + if (argc < 2) {pd_error(x,"sinesum: %s: need number of points and partial strengths", x->realname->name); return;} t_float *svec = (t_float *)getbytes(sizeof(t_float) * argc); ! int npoints = atom_getintarg(0,argc--,argv++); ! argv++, argc--; /* is it normal that this happens a second time? */ for (int i=0; i < argc; i++) svec[i] = atom_getfloatarg(i, argc, argv); garray_dofo(x, npoints, 0, argc, svec, 1); *************** *** 1960,1971 **** } static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv) { t_float *svec = (t_float *)getbytes(sizeof(t_float) * argc); ! int npoints; ! if (argc < 2) { ! pd_error(x,"cosinesum: %s: need number of points and partial strengths", x->realname->name); ! return; ! } ! npoints = atom_getintarg(0,argc--,argv++); ! svec = (t_float *)getbytes(sizeof(t_float) * argc); for (int i=0; i < argc; i++) svec[i] = atom_getfloatarg(i, argc, argv); garray_dofo(x, npoints, 0, argc, svec, 0); --- 1950,1956 ---- } static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv) { + if (argc < 2) {pd_error(x,"cosinesum: %s: need number of points and partial strengths", x->realname->name); return;} t_float *svec = (t_float *)getbytes(sizeof(t_float) * argc); ! int npoints = atom_getintarg(0,argc--,argv++); for (int i=0; i < argc; i++) svec[i] = atom_getfloatarg(i, argc, argv); garray_dofo(x, npoints, 0, argc, svec, 0); *************** *** 2029,2033 ****
static void garray_read(t_garray *x, t_symbol *filename) { - int nelem, filedesc, i; FILE *fd; char buf[MAXPDSTRING], *bufptr; --- 2014,2017 ---- *************** *** 2035,2044 **** t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); TEMPLATE_FLOATY(x,array,) ! nelem = array->n; ! filedesc = canvas_open(canvas_getcanvas(x->canvas), filename->name, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0 || !(fd = fdopen(filedesc, "r"))) { pd_error(x,"%s: can't open", filename->name); return; } for (i=0; i < nelem; i++) { if (!fscanf(fd, "%f", (float *)(array->vec + elemsize*i) + yonset)) { --- 2019,2029 ---- t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize); TEMPLATE_FLOATY(x,array,) ! int nelem = array->n; ! int filedesc = canvas_open(canvas_getcanvas(x->canvas), filename->name, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0 || !(fd = fdopen(filedesc, "r"))) { pd_error(x,"%s: can't open", filename->name); return; } + int i; for (i=0; i < nelem; i++) { if (!fscanf(fd, "%f", (float *)(array->vec + elemsize*i) + yonset)) { *************** *** 2125,2131 **** printf("canvas_add %p %p class=%s (non-t_text)\n",x,y,y->_class->name->name); } else { - char *buf; int bufn; t_binbuf *bb = ((t_text *)y)->binbuf; if (binbuf_getvec(bb)) { binbuf_gettext(bb,&buf,&bufn); printf("canvas_add %p %p [%.*s]\n",x,y,bufn,buf); --- 2110,2116 ---- printf("canvas_add %p %p class=%s (non-t_text)\n",x,y,y->_class->name->name); } else { t_binbuf *bb = ((t_text *)y)->binbuf; if (binbuf_getvec(bb)) { + char *buf; int bufn; binbuf_gettext(bb,&buf,&bufn); printf("canvas_add %p %p [%.*s]\n",x,y,bufn,buf); *************** *** 2277,2318 ****
static void canvas_resortinlets(t_canvas *x) { ! int n=0, j, xmax, x1; ! t_gobj *y, **vec, **vp, **maxp; canvas_each(y,x) if (y->_class==vinlet_class) n++; if (n<2) return; ! vp = vec = (t_gobj **)getbytes(n*sizeof(*vec)); canvas_each(y,x) if (y->_class==vinlet_class) *vp++ = y; for (int i=n; i--;) { ! t_inlet *ip; ! for (vp = vec, xmax = -0x7fffffff, maxp = 0, j=n; j--; vp++) { if (!*vp) continue; ! x1 = ((t_text *)*vp)->x; if (x1 > xmax) {xmax = x1; maxp = vp;} } if (!maxp) break; y = *maxp; *maxp = 0; ! ip = vinlet_getit(y); ! obj_moveinletfirst(x,ip); } free(vec); } static void canvas_resortoutlets(t_canvas *x) { ! int n=0, j, xmax, x1; ! t_gobj *y, **vec, **vp, **maxp; canvas_each(y,x) if (y->_class==voutlet_class) n++; if (n<2) return; ! vp = vec = (t_gobj **)getbytes(n*sizeof(*vec)); canvas_each(y,x) if (y->_class==voutlet_class) *vp++ = y; for (int i=n; i--;) { ! t_outlet *ip; ! for (vp = vec, xmax = -0x7fffffff, maxp = 0, j=n; j--; vp++) { if (!*vp) continue; ! x1 = ((t_text *)*vp)->x; if (x1 > xmax) {xmax = x1; maxp = vp;} } if (!maxp) break; y = *maxp; *maxp = 0; ! ip = voutlet_getit(y); ! obj_moveoutletfirst(x,ip); } free(vec); --- 2262,2299 ----
static void canvas_resortinlets(t_canvas *x) { ! int n=0, j, xmax = -0x7fffffff; ! t_gobj *y, **maxp; canvas_each(y,x) if (y->_class==vinlet_class) n++; if (n<2) return; ! t_gobj **vec = (t_gobj **)getbytes(n*sizeof(*vec)), **vp = vec; canvas_each(y,x) if (y->_class==vinlet_class) *vp++ = y; for (int i=n; i--;) { ! for (vp = vec, maxp = 0, j=n; j--; vp++) { if (!*vp) continue; ! int x1 = ((t_text *)*vp)->x; if (x1 > xmax) {xmax = x1; maxp = vp;} } if (!maxp) break; y = *maxp; *maxp = 0; ! obj_moveinletfirst(x,vinlet_getit(y)); } free(vec); } static void canvas_resortoutlets(t_canvas *x) { ! int n=0, j, xmax = -0x7fffffff; ! t_gobj *y, **maxp; canvas_each(y,x) if (y->_class==voutlet_class) n++; if (n<2) return; ! t_gobj **vec = (t_gobj **)getbytes(n*sizeof(*vec)), **vp = vec; canvas_each(y,x) if (y->_class==voutlet_class) *vp++ = y; for (int i=n; i--;) { ! for (vp = vec, maxp = 0, j=n; j--; vp++) { if (!*vp) continue; ! int x1 = ((t_text *)*vp)->x; if (x1 > xmax) {xmax = x1; maxp = vp;} } if (!maxp) break; y = *maxp; *maxp = 0; ! obj_moveoutletfirst(x,voutlet_getit(y)); } free(vec); *************** *** 2589,2593 **** } else if (t->vec[i].type == DT_LIST) { while (1) { ! if (!canvas_readscalar(w->w_list, natoms, vec, p_nextmsg, 0)) break; } } --- 2570,2574 ---- } else if (t->vec[i].type == DT_LIST) { while (1) { ! if (!canvas_readscalar(w->w_canvas, natoms, vec, p_nextmsg, 0)) break; } } *************** *** 2797,2801 **** binbuf_addsemi(b); } else if (t->vec[i].type == DT_LIST) { ! canvas_writelist(w->w_list->list, b); binbuf_addsemi(b); } --- 2778,2782 ---- binbuf_addsemi(b); } else if (t->vec[i].type == DT_LIST) { ! canvas_writelist(w->w_canvas->list, b); binbuf_addsemi(b); } *************** *** 2826,2830 **** canvas_addtemplatesforscalar(arraytemplatesym, (t_word *)&a->vec[elemsize*j], p_ntemplates, p_templatevec); } else if (ds->type == DT_LIST) ! canvas_addtemplatesforlist(w->w_list->list, p_ntemplates, p_templatevec); } } --- 2807,2811 ---- canvas_addtemplatesforscalar(arraytemplatesym, (t_word *)&a->vec[elemsize*j], p_ntemplates, p_templatevec); } else if (ds->type == DT_LIST) ! canvas_addtemplatesforlist(w->w_canvas->list, p_ntemplates, p_templatevec); } } *************** *** 3483,3487 **** else if (type == DT_LIST) { /* LATER test this and get it to work */ ! wp->w_list = canvas_new(0,0,0,0); } } --- 3464,3468 ---- else if (type == DT_LIST) { /* LATER test this and get it to work */ ! wp->w_canvas = canvas_new(0,0,0,0); } } *************** *** 3509,3513 **** for (int i=0; i<t->n; i++, dt++) { if (dt->type == DT_ARRAY) pd_free(wp[i].w_array); ! else if (dt->type == DT_LIST) pd_free(wp[i].w_list); } } --- 3490,3494 ---- for (int i=0; i<t->n; i++, dt++) { if (dt->type == DT_ARRAY) pd_free(wp[i].w_array); ! else if (dt->type == DT_LIST) pd_free(wp[i].w_canvas); } } *************** *** 3876,3880 **** for (int i=0; i < scalartemplate->n; i++) { t_dataslot *ds = scalartemplate->vec + i; ! if (ds->type == DT_LIST) template_conformcanvas(tfrom, tto, conformaction, x->v[i].w_list); if (ds->type == DT_ARRAY) template_conformarray(tfrom, tto, conformaction, x->v[i].w_array); } --- 3857,3861 ---- for (int i=0; i < scalartemplate->n; i++) { t_dataslot *ds = scalartemplate->vec + i; ! if (ds->type == DT_LIST) template_conformcanvas(tfrom, tto, conformaction, x->v[i].w_canvas); if (ds->type == DT_ARRAY) template_conformarray(tfrom, tto, conformaction, x->v[i].w_array); } *************** *** 3907,3911 **** for (int j=0; j < scalartemplate->n; j++) { t_dataslot *ds = scalartemplate->vec + j; ! if (ds->type == DT_LIST) template_conformcanvas(tfrom, tto, conformaction, wp[j].w_list); if (ds->type == DT_ARRAY) template_conformarray( tfrom, tto, conformaction, wp[j].w_array); } --- 3888,3892 ---- for (int j=0; j < scalartemplate->n; j++) { t_dataslot *ds = scalartemplate->vec + j; ! if (ds->type == DT_LIST) template_conformcanvas(tfrom, tto, conformaction, wp[j].w_canvas); if (ds->type == DT_ARRAY) template_conformarray( tfrom, tto, conformaction, wp[j].w_array); } *************** *** 3968,3974 ****
t_canvas *template_findcanvas(t_template *t) { - t_gtemplate *gt; if (!t) bug("template_findcanvas"); ! if (!(gt = t->list)) return 0; return gt->owner; /* return ((t_canvas *)pd_findbyclass(t->sym, canvas_class)); */ --- 3949,3955 ----
t_canvas *template_findcanvas(t_template *t) { if (!t) bug("template_findcanvas"); ! t_gtemplate *gt = t->list; ! if (!gt) return 0; return gt->owner; /* return ((t_canvas *)pd_findbyclass(t->sym, canvas_class)); */ *************** *** 4125,4130 **** of the field so we don't have to search for it every single time we draw the object. */ ! /* note: there is also t_dataslot which plays a similar role. ! could they be merged someday? */
struct _slot { --- 4106,4110 ---- of the field so we don't have to search for it every single time we draw the object. */ ! /* note: there is also t_dataslot which plays a similar role. could they be merged someday? */
struct _slot {