Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19571
Modified Files: Tag: desiredata desire.c Log Message: use anon union in t_slot
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.150 retrieving revision 1.1.2.217.2.151 diff -C2 -d -r1.1.2.217.2.150 -r1.1.2.217.2.151 *** desire.c 10 Jul 2007 20:31:18 -0000 1.1.2.217.2.150 --- desire.c 10 Jul 2007 20:32:36 -0000 1.1.2.217.2.151 *************** *** 4115,4119 **** t_symbol *s; /* the field is a constant symbol */ t_symbol *varsym; /* the field is variable and this is the name */ ! } u; float min,max; float scrmin,scrmax; /* min and max screen values */ --- 4115,4119 ---- t_symbol *s; /* the field is a constant symbol */ t_symbol *varsym; /* the field is variable and this is the name */ ! }; float min,max; float scrmin,scrmax; /* min and max screen values */ *************** *** 4122,4130 ****
static void slot_setfloat_const(t_slot *fd, float f) { ! fd->type = A_FLOAT; fd->var = 0; fd->u.f = f; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } static void slot_setsymbol_const(t_slot *fd, t_symbol *s) { ! fd->type = A_SYMBOL; fd->var = 0; fd->u.s = s; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } --- 4122,4130 ----
static void slot_setfloat_const(t_slot *fd, float f) { ! fd->type = A_FLOAT; fd->var = 0; fd->f = f; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } static void slot_setsymbol_const(t_slot *fd, t_symbol *s) { ! fd->type = A_SYMBOL; fd->var = 0; fd->s = s; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } *************** *** 4135,4139 **** fd->var = 1; if (!(s1 = strchr(s->name, '(')) || !(s2 = strchr(s->name, ')')) || s1>s2) { ! fd->u.varsym = s; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } else { --- 4135,4139 ---- fd->var = 1; if (!(s1 = strchr(s->name, '(')) || !(s2 = strchr(s->name, ')')) || s1>s2) { ! fd->varsym = s; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } else { *************** *** 4141,4145 **** strncpy(strbuf, s->name, cpy); strbuf[cpy] = 0; ! fd->u.varsym = gensym(strbuf); got = sscanf(s1, "(%f:%f)(%f:%f)(%f)", &fd->min, &fd->max, &fd->scrmin, &fd->scrmax, &fd->quantum); if (got < 2) goto fail; --- 4141,4145 ---- strncpy(strbuf, s->name, cpy); strbuf[cpy] = 0; ! fd->varsym = gensym(strbuf); got = sscanf(s1, "(%f:%f)(%f:%f)(%f)", &fd->min, &fd->max, &fd->scrmin, &fd->scrmax, &fd->quantum); if (got < 2) goto fail; *************** *** 4174,4178 **** fd->type = A_SYMBOL; fd->var = 1; ! fd->u.varsym = argv->a_symbol; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } else slot_setsymbol_const(fd, &s_); --- 4174,4178 ---- fd->type = A_SYMBOL; fd->var = 1; ! fd->varsym = argv->a_symbol; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; } else slot_setsymbol_const(fd, &s_); *************** *** 4183,4187 **** fd->type = A_ARRAY; fd->var = 1; ! fd->u.varsym = argv->a_symbol; } else slot_setfloat_const(fd, argv->a_float); } --- 4183,4187 ---- fd->type = A_ARRAY; fd->var = 1; ! fd->varsym = argv->a_symbol; } else slot_setfloat_const(fd, argv->a_float); } *************** *** 4203,4218 **** static t_float slot_getcoord(t_slot *f, t_template *t, t_word *wp, int loud) { if (f->type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;} ! if (f->var) return slot_cvttocoord(f, template_getfloat(t, f->u.varsym, wp, loud)); ! return f->u.f; } static t_float slot_getfloat(t_slot *f, t_template *t, t_word *wp, int loud) { if (f->type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;} ! if (f->var) return template_getfloat(t, f->u.varsym, wp, loud); ! return f->u.f; } static t_symbol *slot_getsymbol(t_slot *f, t_template *t, t_word *wp, int loud) { if (f->type!=A_SYMBOL) {if (loud) error("numeric data field used as symbol"); return &s_;} ! if (f->var) return template_getsymbol(t, f->u.varsym, wp, loud); ! return f->u.s; }
--- 4203,4218 ---- static t_float slot_getcoord(t_slot *f, t_template *t, t_word *wp, int loud) { if (f->type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;} ! if (f->var) return slot_cvttocoord(f, template_getfloat(t, f->varsym, wp, loud)); ! return f->f; } static t_float slot_getfloat(t_slot *f, t_template *t, t_word *wp, int loud) { if (f->type!=A_FLOAT) {if (loud) error("symbolic data field used as number"); return 0;} ! if (f->var) return template_getfloat(t, f->varsym, wp, loud); ! return f->f; } static t_symbol *slot_getsymbol(t_slot *f, t_template *t, t_word *wp, int loud) { if (f->type!=A_SYMBOL) {if (loud) error("numeric data field used as symbol"); return &s_;} ! if (f->var) return template_getsymbol(t, f->varsym, wp, loud); ! return f->s; }
*************** *** 4234,4238 **** if (f->type == A_FLOAT && f->var) { float val = slot_cvtfromcoord(f, coord); ! template_setfloat(t, f->u.varsym, wp, val, loud); } else { if (loud) error("attempt to set constant or symbolic data field to a number"); --- 4234,4238 ---- if (f->type == A_FLOAT && f->var) { float val = slot_cvtfromcoord(f, coord); ! template_setfloat(t, f->varsym, wp, val, loud); } else { if (loud) error("attempt to set constant or symbolic data field to a number"); *************** *** 4301,4305 **** return; } ! viswas = x->vis.u.f!=0; if ((f!=0 && viswas) || (f==0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); --- 4301,4305 ---- return; } ! viswas = x->vis.f!=0; if ((f!=0 && viswas) || (f==0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); *************** *** 4474,4478 **** return; } ! viswas = x->vis.u.f!=0; if ((f!=0 && viswas) || (f==0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); --- 4474,4478 ---- return; } ! viswas = x->vis.f!=0; if ((f!=0 && viswas) || (f==0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); *************** *** 4493,4502 **** return -1; } ! if (!template_find_field(ownertemplate, x->data.u.varsym, &arrayonset, &type, &elemtemplatesym)) { ! pd_error(x,"%s: no such field", x->data.u.varsym->name); return -1; } if (type != DT_ARRAY) { ! pd_error(x,"%s: not an array", x->data.u.varsym->name); return -1; } --- 4493,4502 ---- return -1; } ! if (!template_find_field(ownertemplate, x->data.varsym, &arrayonset, &type, &elemtemplatesym)) { ! pd_error(x,"%s: no such field", x->data.varsym->name); return -1; } if (type != DT_ARRAY) { ! pd_error(x,"%s: not an array", x->data.varsym->name); return -1; } *************** *** 4537,4541 **** *elemsizep = elemtemplate->n * sizeof(t_word); #define FOO(f,name,onset) \ ! varname = f && f->var ? f->u.varsym : gensym(name); \ if (!template_find_field(elemtemplate,varname,&onset,&type,&dummy) || type!=DT_FLOAT) onset=-1; FOO(yslot,"y",*yonsetp) --- 4537,4541 ---- *elemsizep = elemtemplate->n * sizeof(t_word); #define FOO(f,name,onset) \ ! varname = f && f->var ? f->varsym : gensym(name); \ if (!template_find_field(elemtemplate,varname,&onset,&type,&dummy) || type!=DT_FLOAT) onset=-1; FOO(yslot,"y",*yonsetp) *************** *** 4764,4768 **** return; } ! viswas = (x->vis.u.f != 0); if ((f != 0 && viswas) || (f == 0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); --- 4764,4768 ---- return; } ! viswas = (x->vis.f != 0); if ((f != 0 && viswas) || (f == 0 && !viswas)) return; canvas_redrawallfortemplatecanvas(x->canvas, 2); *************** *** 4826,4830 **** if (dn.symbol) {post("drawnumber_motion: symbol"); return;} dn.ycumulative -= dy; ! template_setfloat(dn.t, f->u.varsym, dn.wp, dn.ycumulative, 1); if (dn.scalar) gobj_changed(dn.scalar); else gobj_changed(dn.array); } --- 4826,4830 ---- if (dn.symbol) {post("drawnumber_motion: symbol"); return;} dn.ycumulative -= dy; ! template_setfloat(dn.t, f->varsym, dn.wp, dn.ycumulative, 1); if (dn.scalar) gobj_changed(dn.scalar); else gobj_changed(dn.array); } *************** *** 4845,4849 **** /* key entry for a symbol field */ if (dn.firstkey) sbuf[0] = 0; ! else strncpy(sbuf, template_getsymbol(dn.t, f->u.varsym, dn.wp, 1)->name, MAXPDSTRING); sbuf[MAXPDSTRING-1] = 0; if (key == '\b') { --- 4845,4849 ---- /* key entry for a symbol field */ if (dn.firstkey) sbuf[0] = 0; ! else strncpy(sbuf, template_getsymbol(dn.t, f->varsym, dn.wp, 1)->name, MAXPDSTRING); sbuf[MAXPDSTRING-1] = 0; if (key == '\b') { *************** *** 4857,4861 **** float newf; if (dn.firstkey) sbuf[0] = 0; ! else sprintf(sbuf, "%g", template_getfloat(dn.t, f->u.varsym, dn.wp, 1)); dn.firstkey = (key == '\n'); if (key == '\b') { --- 4857,4861 ---- float newf; if (dn.firstkey) sbuf[0] = 0; ! else sprintf(sbuf, "%g", template_getfloat(dn.t, f->varsym, dn.wp, 1)); dn.firstkey = (key == '\n'); if (key == '\b') { *************** *** 4866,4870 **** } if (sscanf(sbuf, "%g", &newf) < 1) newf = 0; ! template_setfloat(dn.t, f->u.varsym, dn.wp, newf, 1); if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at); if (dn.scalar) gobj_changed(dn.scalar,0); else gobj_changed(dn.array,0); --- 4866,4870 ---- } if (sscanf(sbuf, "%g", &newf) < 1) newf = 0; ! template_setfloat(dn.t, f->varsym, dn.wp, newf, 1); if (dn.scalar) template_notifyforscalar(dn.t, dn.canvas, dn.scalar, gensym("change"), 1, &at); if (dn.scalar) gobj_changed(dn.scalar,0); else gobj_changed(dn.array,0);