Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1507
Modified Files: Tag: devel_0_39 desire.c Log Message: improved error messages and stuff
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.171 retrieving revision 1.1.2.172 diff -C2 -d -r1.1.2.171 -r1.1.2.172 *** desire.c 8 Sep 2006 20:59:03 -0000 1.1.2.171 --- desire.c 9 Sep 2006 00:26:38 -0000 1.1.2.172 *************** *** 775,780 **** canvas_pop(x, x->willvis); z = gensym("#X")->s_thing; ! if (!z) error("canvas_restore: out of context"); ! else if (*z != canvas_class) error("canvas_restore: wasn't a canvas"); else { t_canvas *x2 = (t_canvas *)z; --- 775,780 ---- canvas_pop(x, x->willvis); z = gensym("#X")->s_thing; ! if (!z) pd_error(x,"canvas_restore: out of context"); ! else if (*z != canvas_class) pd_error(x,"canvas_restore: wasn't a canvas"); else { t_canvas *x2 = (t_canvas *)z; *************** *** 1035,1038 **** --- 1035,1054 ---- /******************* redrawing data *********************/
+ static t_float fielddesc_getcoord(t_fielddesc *f, t_template *, t_word *wp, int loud); + static void fielddesc_setcoord(t_fielddesc *f, t_template *, t_word *wp, float pix, int loud); + static t_float fielddesc_cvttocoord(t_fielddesc *f, float val); + static t_template *template_new(t_symbol *sym, int argc, t_atom *argv); + static void template_free(t_template *x); + static int template_match(t_template *x1, t_template *x2); + static int template_find_field(t_template *x, t_symbol*name, int*p_onset, int*p_type, t_symbol **p_arraytype); + static t_float template_getfloat( t_template *x, t_symbol *fieldname, t_word *wp, int loud); + static void template_setfloat( t_template *x, t_symbol *fieldname, t_word *wp, t_float f, int loud); + static t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname, t_word *wp, int loud); + static void template_setsymbol(t_template *x, t_symbol *fieldname, t_word *wp, t_symbol *s, int loud); + static t_template *gtemplate_get(t_gtemplate *x); + static t_template *template_findbyname(t_symbol *s); + static t_canvas *template_findcanvas(t_template *tmpl); + static void template_notify(t_template *, t_symbol *s, int argc, t_atom *argv); + static void canvas_redraw(t_canvas *x);
*************** *** 1548,1556 **** TEMPLATE_CHECK(x,sc->sc_template,0) if (!template_find_field(template, gensym("z"), &zonset, &ztype, &zarraytype)) { ! error("array: template %s has no 'z' field", sc->sc_template->s_name); return 0; } if (ztype != DT_ARRAY) { ! error("array: template %s, 'z' field is not an array", sc->sc_template->s_name); return 0; } --- 1564,1572 ---- TEMPLATE_CHECK(x,sc->sc_template,0) if (!template_find_field(template, gensym("z"), &zonset, &ztype, &zarraytype)) { ! pd_error(x,"template %s has no 'z' field", sc->sc_template->s_name); return 0; } if (ztype != DT_ARRAY) { ! pd_error(x,"template %s, 'z' field is not an array", sc->sc_template->s_name); return 0; } *************** *** 1604,1608 **** int style = filestyle == 0 ? PLOTSTYLE_POLY : filestyle == 1 ? PLOTSTYLE_POINTS : filestyle; if (templateargsym != &s_float) { ! error("array %s: only 'float' type understood", templateargsym->s_name); return 0; } --- 1620,1624 ---- int style = filestyle == 0 ? PLOTSTYLE_POLY : filestyle == 1 ? PLOTSTYLE_POINTS : filestyle; if (templateargsym != &s_float) { ! pd_error(x,"%s: only 'float' type understood", templateargsym->s_name); return 0; } *************** *** 1610,1622 **** TEMPLATE_CHECK(gl,templatesym,0) if (!template_find_field(template, gensym("z"), &zonset, &ztype, &zarraytype)) { ! error("array: template %s has no 'z' field", templatesym->s_name); return 0; } if (ztype != DT_ARRAY) { ! error("array: template %s, 'z' field is not an array", templatesym->s_name); return 0; } if (!(ztemplate = template_findbyname(zarraytype))) { ! error("array: no template of type %s", zarraytype->s_name); return 0; } --- 1626,1638 ---- TEMPLATE_CHECK(gl,templatesym,0) if (!template_find_field(template, gensym("z"), &zonset, &ztype, &zarraytype)) { ! pd_error(x,"template %s has no 'z' field", templatesym->s_name); return 0; } if (ztype != DT_ARRAY) { ! pd_error(x,"template %s, 'z' field is not an array", templatesym->s_name); return 0; } if (!(ztemplate = template_findbyname(zarraytype))) { ! pd_error(x,"no template of type %s", zarraytype->s_name); return 0; } *************** *** 1676,1680 **** if (!a) {pd_error(x, "can't find array"); return;} if (!(scalartemplate = template_findbyname(x->scalar->sc_template))) { ! error("array: no template of type %s", x->scalar->sc_template->s_name); return; } --- 1692,1696 ---- if (!a) {pd_error(x, "can't find array"); return;} if (!(scalartemplate = template_findbyname(x->scalar->sc_template))) { ! pd_error(x,"no template of type %s", x->scalar->sc_template->s_name); return; } *************** *** 1704,1708 **** char cmdbuf[200]; t_array *a = garray_getarray_floatonly(x, &yonset, &elemsize); ! if (!a) { /* FIXME */ error("error in garray_arrayviewlist_new()");} x->listviewing = 1; sprintf(cmdbuf, "pdtk_array_listview_new %%s %s %d\n", x->realname->s_name, 0); --- 1720,1724 ---- char cmdbuf[200]; t_array *a = garray_getarray_floatonly(x, &yonset, &elemsize); ! if (!a) { /* FIXME */ pd_error(x,"error in garray_arrayviewlist_new()");} x->listviewing = 1; sprintf(cmdbuf, "pdtk_array_listview_new %%s %s %d\n", x->realname->s_name, 0); *************** *** 1718,1722 **** float yval; t_array *a = garray_getarray_floatonly(x, &yonset, &elemsize); ! if (!a) error("error in garray_arrayviewlist_new()"); if (page < 0) { page = 0; --- 1734,1738 ---- float yval; t_array *a = garray_getarray_floatonly(x, &yonset, &elemsize); ! if (!a) pd_error(x,"error in garray_arrayviewlist_new()"); if (page < 0) { page = 0; *************** *** 2022,2030 **** if (x->scalar->sc_template != gensym("pd-_float_array")) { /* LATER "save" the scalar as such */ ! pd_error(x, "can't save arrays of type %s yet", x->scalar->sc_template->s_name); return; } if (!(scalartemplate = template_findbyname(x->scalar->sc_template))) { ! error("array: no template of type %s", x->scalar->sc_template->s_name); return; } --- 2038,2046 ---- if (x->scalar->sc_template != gensym("pd-_float_array")) { /* LATER "save" the scalar as such */ ! pd_error(x,"can't save arrays of type %s yet", x->scalar->sc_template->s_name); return; } if (!(scalartemplate = template_findbyname(x->scalar->sc_template))) { ! pd_error(x,"no template of type %s", x->scalar->sc_template->s_name); return; } *************** *** 2061,2065 **** TEMPLATE_FLOATY(x,a,0) if (elemsize != sizeof(t_word)) { ! error("%s: has more than one field", x->realname); return 0; } --- 2077,2081 ---- TEMPLATE_FLOATY(x,a,0) if (elemsize != sizeof(t_word)) { ! pd_error(x,"%s: has more than one field", x->realname); return 0; } *************** *** 2199,2203 **** if ((filedesc = open_via_path(canvas_getdir(canvas_getcanvas(x->canvas))->s_name, filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0 || !(fd = fdopen(filedesc, "r"))) { ! error("%s: can't open", filename->s_name); return; } --- 2215,2219 ---- if ((filedesc = open_via_path(canvas_getdir(canvas_getcanvas(x->canvas))->s_name, filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0 || !(fd = fdopen(filedesc, "r"))) { ! pd_error(x,"%s: can't open", filename->s_name); return; } *************** *** 2842,2846 **** t_template *template = template_findbyname(templatesym); if (!template) { ! error("%s: no such template", templatesym->s_name); *p_nextmsg = natoms; return; --- 2858,2862 ---- t_template *template = template_findbyname(templatesym); if (!template) { ! pd_error(x,"%s: no such template", templatesym->s_name); *p_nextmsg = natoms; return; *************** *** 2855,2859 **** t_template *arraytemplate = template_findbyname(arraytemplatesym); if (!arraytemplate) { ! error("%s: no such template", arraytemplatesym->s_name); } else while (1) { --- 2871,2875 ---- t_template *arraytemplate = template_findbyname(arraytemplatesym); if (!arraytemplate) { ! pd_error(x,"%s: no such template", arraytemplatesym->s_name); } else while (1) { *************** *** 2893,2897 **** *p_nextmsg = nextmsg + 1; if (!(template = template_findbyname(templatesym))) { ! error("canvas_read: %s: no such template", templatesym->s_name); *p_nextmsg = natoms; return 0; --- 2909,2913 ---- *p_nextmsg = nextmsg + 1; if (!(template = template_findbyname(templatesym))) { ! pd_error(x,"canvas_read: %s: no such template", templatesym->s_name); *p_nextmsg = natoms; return 0; *************** *** 2899,2903 **** sc = scalar_new(x, templatesym); if (!sc) { ! error("couldn't create scalar "%s"", templatesym->s_name); *p_nextmsg = natoms; return 0; --- 2915,2919 ---- sc = scalar_new(x, templatesym); if (!sc) { ! pd_error(x,"couldn't create scalar "%s"", templatesym->s_name); *p_nextmsg = natoms; return 0; *************** *** 2956,2965 **** t_freebytes(templateargs, sizeof (*templateargs) * ntemplateargs); if (!(existtemplate = template_findbyname(templatesym))) { ! error("%s: template not found in current patch", templatesym->s_name); template_free(newtemplate); return; } if (!template_match(existtemplate, newtemplate)) { ! error("%s: template doesn't match current one", templatesym->s_name); template_free(newtemplate); return; --- 2972,2981 ---- t_freebytes(templateargs, sizeof (*templateargs) * ntemplateargs); if (!(existtemplate = template_findbyname(templatesym))) { ! pd_error(x,"%s: template not found in current patch", templatesym->s_name); template_free(newtemplate); return; } if (!template_match(existtemplate, newtemplate)) { ! pd_error(x,"%s: template doesn't match current one", templatesym->s_name); template_free(newtemplate); return; *************** *** 2976,2980 **** int cr = 0; if (!strcmp(format->s_name, "cr")) cr = 1; ! else if (*format->s_name) error("canvas_read: unknown flag: %s", format->s_name);
if (binbuf_read_via_path(b, filename->s_name, canvas_getdir(canvas)->s_name, cr)) { --- 2992,2996 ---- int cr = 0; if (!strcmp(format->s_name, "cr")) cr = 1; ! else if (*format->s_name) pd_error(x,"canvas_read: unknown flag: %s", format->s_name);
if (binbuf_read_via_path(b, filename->s_name, canvas_getdir(canvas)->s_name, cr)) { *************** *** 3019,3023 **** } } ! if (!newone) error("couldn't update properties (perhaps a format problem?)"); else if (!oldone) bug("data_properties: couldn't find old element"); else { --- 3035,3039 ---- } } ! if (!newone) pd_error(x,"couldn't update properties (perhaps a format problem?)"); else if (!oldone) bug("data_properties: couldn't find old element"); else { *************** *** 3182,3189 **** canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING); if (!strcmp(format->s_name, "cr")) cr = 1; ! else if (*format->s_name) error("qlist_read: unknown flag: %s", format->s_name); b = canvas_writetobinbuf(x, 1); if (b) { ! if (binbuf_write(b, buf, "", cr)) error("%s: write failed", filename->s_name); binbuf_free(b); } --- 3198,3205 ---- canvas_makefilename(canvas, filename->s_name, buf, MAXPDSTRING); if (!strcmp(format->s_name, "cr")) cr = 1; ! else if (*format->s_name) pd_error(x,"canvas_write: unknown flag: %s", format->s_name); b = canvas_writetobinbuf(x, 1); if (b) { ! if (binbuf_write(b, buf, "", cr)) pd_error(x,"%s: write failed", filename->s_name); binbuf_free(b); } *************** *** 4071,4075 **** /* -- templates, the active ingredient in gtemplates defined below. ------- */
! t_template *template_new(t_symbol *templatesym, int argc, t_atom *argv) { t_template *x = (t_template *)pd_new(template_class); x->n = 0; --- 4087,4091 ---- /* -- templates, the active ingredient in gtemplates defined below. ------- */
! static t_template *template_new(t_symbol *templatesym, int argc, t_atom *argv) { t_template *x = (t_template *)pd_new(template_class); x->n = 0; *************** *** 4129,4173 **** }
! t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp, int loud) { ! int onset, type; ! t_symbol *arraytype; ! float val = 0; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_FLOAT) val = *(t_float *)(((char *)wp) + onset); ! else if (loud) error("%s.%s: not a number", x->sym->s_name, fieldname->s_name); ! } ! else if (loud) error("%s.%s: no such field", x->sym->s_name, fieldname->s_name); return val; } ! ! t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname, t_word *wp, int loud) { ! int onset, type; ! t_symbol *arraytype; ! t_symbol *val = &s_; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_SYMBOL) val = *(t_symbol **)(((char *)wp) + onset); ! else if (loud) error("%s.%s: not a symbol", x->sym->s_name, fieldname->s_name); ! } ! else if (loud) error("%s.%s: no such field", x->sym->s_name, fieldname->s_name); return val; } ! void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp, t_float f, int loud) { ! int onset, type; ! t_symbol *arraytype; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_FLOAT) *(t_float *)(((char *)wp) + onset) = f; ! else if (loud) error("%s.%s: not a number", x->sym->s_name, fieldname->s_name); ! } ! else if (loud) error("%s.%s: no such field", x->sym->s_name, fieldname->s_name); } ! ! void template_setsymbol(t_template *x, t_symbol *fieldname, t_word *wp, t_symbol *s, int loud) { ! int onset, type; ! t_symbol *arraytype; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_SYMBOL) *(t_symbol **)(((char *)wp) + onset) = s; ! else if (loud) error("%s.%s: not a symbol", x->sym->s_name, fieldname->s_name); ! } ! else if (loud) error("%s.%s: no such field", x->sym->s_name, fieldname->s_name); }
--- 4145,4177 ---- }
! static t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp, int loud) { ! int onset, type; t_symbol *arraytype; float val = 0; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_FLOAT) val = *(t_float *)(((char *)wp) + onset); ! else if (loud) pd_error(x,"%s.%s: not a number", x->sym->s_name, fieldname->s_name); ! } else if (loud) pd_error(x,"%s.%s: no such field", x->sym->s_name, fieldname->s_name); return val; } ! static t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname, t_word *wp, int loud) { ! int onset, type; t_symbol *arraytype; t_symbol *val = &s_; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_SYMBOL) val = *(t_symbol **)(((char *)wp) + onset); ! else if (loud) pd_error(x,"%s.%s: not a symbol", x->sym->s_name, fieldname->s_name); ! } else if (loud) pd_error(x,"%s.%s: no such field", x->sym->s_name, fieldname->s_name); return val; } ! static void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp, t_float f, int loud) { ! int onset, type; t_symbol *arraytype; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_FLOAT) *(t_float *)(((char *)wp) + onset) = f; ! else if (loud) pd_error(x,"%s.%s: not a number", x->sym->s_name, fieldname->s_name); ! } else if (loud) pd_error(x,"%s.%s: no such field", x->sym->s_name, fieldname->s_name); } ! static void template_setsymbol(t_template *x, t_symbol *fieldname, t_word *wp, t_symbol *s, int loud) { ! int onset, type; t_symbol *arraytype; if (template_find_field(x, fieldname, &onset, &type, &arraytype)) { if (type == DT_SYMBOL) *(t_symbol **)(((char *)wp) + onset) = s; ! else if (loud) pd_error(x,"%s.%s: not a symbol", x->sym->s_name, fieldname->s_name); ! } else if (loud) pd_error(x,"%s.%s: no such field", x->sym->s_name, fieldname->s_name); }
*************** *** 4175,4179 **** one (x1). It's OK if x1 has additional scalar elements but not (yet) arrays or lists. This is used for reading in "data files". */ ! int template_match(t_template *x1, t_template *x2) { int i; if (x1->n < x2->n) return 0; --- 4179,4183 ---- one (x1). It's OK if x1 has additional scalar elements but not (yet) arrays or lists. This is used for reading in "data files". */ ! static int template_match(t_template *x1, t_template *x2) { int i; if (x1->n < x2->n) return 0; *************** *** 4199,4203 **** LATER deal with graphics updates too... */
! /* conform the word vector of a scalar to the new template */ static void template_conformwords(t_template *tfrom, t_template *tto, int *conformaction, t_word *wfrom, t_word *wto) { --- 4203,4207 ---- LATER deal with graphics updates too... */
! /* conform the word vector of a scalar to the new template */ static void template_conformwords(t_template *tfrom, t_template *tto, int *conformaction, t_word *wfrom, t_word *wto) { *************** *** 4214,4218 **** }
! /* conform a scalar, recursively conforming sublists and arrays */ static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto, int *conformaction, t_canvas *canvas, t_scalar *scfrom) { --- 4218,4222 ---- }
! /* conform a scalar, recursively conforming sublists and arrays */ static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto, int *conformaction, t_canvas *canvas, t_scalar *scfrom) { *************** *** 4409,4413 **** if (!template_match(x, y)) { /* Are there "struct" objects upholding this template? */ if (x->t_list) { ! error("%s: template mismatch", templatesym->s_name); } else { template_conform(x, y); --- 4413,4417 ---- if (!template_match(x, y)) { /* Are there "struct" objects upholding this template? */ if (x->t_list) { ! pd_error(x,"%s: template mismatch", templatesym->s_name); } else { template_conform(x, y); *************** *** 4612,4616 **** else fielddesc_setfloat_const(fd, argv->a_w.w_float); } - static void fielddesc_setsymbolarg(t_fielddesc *fd, int argc, t_atom *argv) { if (argc <= 0) fielddesc_setsymbol_const(fd, &s_); --- 4616,4619 ---- *************** *** 4620,4627 **** fd->u.varsym = argv->a_w.w_symbol; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; ! } ! else fielddesc_setsymbol_const(fd, &s_); } - static void fielddesc_setarrayarg(t_fielddesc *fd, int argc, t_atom *argv) { if (argc <= 0) fielddesc_setfloat_const(fd, 0); --- 4623,4628 ---- fd->u.varsym = argv->a_w.w_symbol; fd->min = fd->max = fd->scrmin = fd->scrmax = fd->quantum = 0; ! } else fielddesc_setsymbol_const(fd, &s_); } static void fielddesc_setarrayarg(t_fielddesc *fd, int argc, t_atom *argv) { if (argc <= 0) fielddesc_setfloat_const(fd, 0); *************** *** 4635,4646 **** /* getting and setting values via fielddescs -- note confusing names; the above are setting up the fielddesc itself. */ - static t_float fielddesc_getfloat(t_fielddesc *f, t_template *template, 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(template, f->u.varsym, wp, loud); - return f->u.f; - }
! /* convert a variable's value to a screen coordinate via its fielddesc */ ! t_float fielddesc_cvttocoord(t_fielddesc *f, float val) { float coord, extreme, div; if (f->max == f->min) return val; --- 4636,4642 ---- /* getting and setting values via fielddescs -- note confusing names; the above are setting up the fielddesc itself. */
! /* convert a variable's value to a screen coordinate via its fielddesc */ ! static t_float fielddesc_cvttocoord(t_fielddesc *f, float val) { float coord, extreme, div; if (f->max == f->min) return val; *************** *** 4652,4662 **** }
! /* read a variable via fielddesc and convert to screen coordinate */ ! t_float fielddesc_getcoord(t_fielddesc *f, t_template *template, 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 fielddesc_cvttocoord(f, template_getfloat(template, f->u.varsym, wp, loud)); return f->u.f; } ! static t_symbol *fielddesc_getsymbol(t_fielddesc *f, t_template *template, t_word *wp, int loud) { if (f->type!=A_SYMBOL) {if (loud) error("numeric data field used as symbol"); return &s_;} --- 4648,4662 ---- }
! /* read a variable via fielddesc and convert to screen coordinate */ ! static t_float fielddesc_getcoord(t_fielddesc *f, t_template *template, 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 fielddesc_cvttocoord(f, template_getfloat(template, f->u.varsym, wp, loud)); return f->u.f; } ! static t_float fielddesc_getfloat(t_fielddesc *f, t_template *template, 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(template, f->u.varsym, wp, loud); ! return f->u.f; ! } static t_symbol *fielddesc_getsymbol(t_fielddesc *f, t_template *template, t_word *wp, int loud) { if (f->type!=A_SYMBOL) {if (loud) error("numeric data field used as symbol"); return &s_;} *************** *** 4665,4684 **** }
! /* convert from a screen coordinate to a variable value */ ! float fielddesc_cvtfromcoord(t_fielddesc *f, float coord) { ! float val; ! if (f->scrmax == f->scrmin) val = coord; else { float div = (f->max - f->min)/(f->scrmax - f->scrmin); float extreme; ! val = f->min + (coord - f->scrmin) * div; if (f->quantum != 0) val = ((int)((val/f->quantum) + 0.5)) * f->quantum; ! extreme = (f->min < f->max ? f->min : f->max); if (val<extreme) val=extreme; ! extreme = (f->min > f->max ? f->min : f->max); if (val>extreme) val=extreme; } - return val; }
! void fielddesc_setcoord(t_fielddesc *f, t_template *template, t_word *wp, float coord, int loud) { if (f->type == A_FLOAT && f->var) { float val = fielddesc_cvtfromcoord(f, coord); --- 4665,4683 ---- }
! /* convert from a screen coordinate to a variable value */ ! static float fielddesc_cvtfromcoord(t_fielddesc *f, float coord) { ! if (f->scrmax == f->scrmin) return coord; else { float div = (f->max - f->min)/(f->scrmax - f->scrmin); float extreme; ! float val = f->min + (coord - f->scrmin) * div; if (f->quantum != 0) val = ((int)((val/f->quantum) + 0.5)) * f->quantum; ! extreme = f->min<f->max ? f->min : f->max; if (val<extreme) val=extreme; ! extreme = f->min>f->max ? f->min : f->max; if (val>extreme) val=extreme; ! return val; } }
! static void fielddesc_setcoord(t_fielddesc *f, t_template *template, t_word *wp, float coord, int loud) { if (f->type == A_FLOAT && f->var) { float val = fielddesc_cvtfromcoord(f, coord); *************** *** 5868,5874 **** t_word *vec; TEMPLATE_CHECK(x,x->templatesym,) ! if (!gpointer_check(gp, 0)) {pd_error(x, "set: empty pointer"); return;} if (gpointer_gettemplatesym(gp) != x->templatesym) { ! pd_error(x, "set %s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(gp)->s_name); return; --- 5867,5873 ---- t_word *vec; TEMPLATE_CHECK(x,x->templatesym,) ! if (!gpointer_check(gp, 0)) {pd_error(x, "empty pointer"); return;} if (gpointer_gettemplatesym(gp) != x->templatesym) { ! pd_error(x, "%s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(gp)->s_name); return; *************** *** 5936,5942 **** int elemsize, type;
! if (!gpointer_check(gparent, 0)) {pd_error(x, "element: empty pointer"); return;} if (gpointer_gettemplatesym(gparent) != x->templatesym) { ! pd_error(x, "element %s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(gparent)->s_name); return; --- 5935,5941 ---- int elemsize, type;
! if (!gpointer_check(gparent, 0)) {pd_error(x, "empty pointer"); return;} if (gpointer_gettemplatesym(gparent) != x->templatesym) { ! pd_error(x, "%s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(gparent)->s_name); return; *************** *** 5946,5955 **** TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(template, fieldsym, &onset, &type, &elemtemplatesym)) { ! pd_error(x, "element: couldn't find array field %s", fieldsym->s_name); return; } if (type != DT_ARRAY) {pd_error(x, "element: field %s not of type array", fieldsym->s_name); return;} if (!(elemtemplate = template_findbyname(elemtemplatesym))) { ! pd_error(x, "element: couldn't find field template %s", elemtemplatesym->s_name); return; } --- 5945,5954 ---- TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(template, fieldsym, &onset, &type, &elemtemplatesym)) { ! pd_error(x, "couldn't find array field %s", fieldsym->s_name); return; } if (type != DT_ARRAY) {pd_error(x, "element: field %s not of type array", fieldsym->s_name); return;} if (!(elemtemplate = template_findbyname(elemtemplatesym))) { ! pd_error(x, "couldn't find field template %s", elemtemplatesym->s_name); return; } *************** *** 5995,6005 **** TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(template, fieldsym, &onset, &type, &elemtemplatesym)) { ! pd_error(x, "getsize: couldn't find array field %s", fieldsym->s_name); return; } ! if (type != DT_ARRAY) {pd_error(x, "getsize: field %s not of type array", fieldsym->s_name); return;} ! if (!gpointer_check(gp, 0)) {pd_error(x, "get: stale or empty pointer"); return;} if (gpointer_gettemplatesym(gp) != x->templatesym) { ! pd_error(x, "getsize %s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(gp)->s_name); return; --- 5994,6004 ---- TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(template, fieldsym, &onset, &type, &elemtemplatesym)) { ! pd_error(x, "couldn't find array field %s", fieldsym->s_name); return; } ! if (type != DT_ARRAY) {pd_error(x, "field %s not of type array", fieldsym->s_name); return;} ! if (!gpointer_check(gp, 0)) {pd_error(x, "stale or empty pointer"); return;} if (gpointer_gettemplatesym(gp) != x->templatesym) { ! pd_error(x, "%s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(gp)->s_name); return; *************** *** 6041,6047 **** t_gpointer *gp = &x->gp; t_gstub *gs = gp->gp_stub; ! if (!gpointer_check(&x->gp, 0)) {pd_error(x, "setsize: empty pointer"); return;} if (gpointer_gettemplatesym(&x->gp) != x->templatesym) { ! pd_error(x, "setsize %s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(&x->gp)->s_name); return; } --- 6040,6046 ---- t_gpointer *gp = &x->gp; t_gstub *gs = gp->gp_stub; ! if (!gpointer_check(&x->gp, 0)) {pd_error(x, "empty pointer"); return;} if (gpointer_gettemplatesym(&x->gp) != x->templatesym) { ! pd_error(x, "%s: got wrong template (%s)", x->templatesym->s_name, gpointer_gettemplatesym(&x->gp)->s_name); return; } *************** *** 6049,6058 **** TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(template, fieldsym, &onset, &type, &elemtemplatesym)) { ! pd_error(x,"setsize: couldn't find array field %s", fieldsym->s_name); return; } ! if (type != DT_ARRAY) {pd_error(x,"setsize: field %s not of type array", fieldsym->s_name); return;} if (!(elemtemplate = template_findbyname(elemtemplatesym))) { ! pd_error(x,"element: couldn't find field template %s", elemtemplatesym->s_name); return; } --- 6048,6057 ---- TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(template, fieldsym, &onset, &type, &elemtemplatesym)) { ! pd_error(x,"couldn't find array field %s", fieldsym->s_name); return; } ! if (type != DT_ARRAY) {pd_error(x,"field %s not of type array", fieldsym->s_name); return;} if (!(elemtemplate = template_findbyname(elemtemplatesym))) { ! pd_error(x,"couldn't find field template %s", elemtemplatesym->s_name); return; } *************** *** 6063,6071 **** if (newsize < 1) newsize = 1; if (newsize == nitems) return; - - /* erase the array before resizing it. If we belong to a scalar it's easy, but if we belong to an element of another - array we have to search back until we get to a scalar to erase. - When graphics updates become queueable this may fall apart... */
if (gs->gs_which == GP_GLIST) { if (canvas_isvisible(gs->gs_un.gs_glist)) sys_mgui((t_gobj *)(gp->gp_un.gp_scalar),"delete",""); --- 6062,6069 ---- if (newsize < 1) newsize = 1; if (newsize == nitems) return;
+ /* erase the array before resizing it. If we belong to a scalar it's easy, + but if we belong to an element of another array we have to search back until we get to a + scalar to erase. When graphics updates become queueable this may fall apart... */ if (gs->gs_which == GP_GLIST) { if (canvas_isvisible(gs->gs_un.gs_glist)) sys_mgui((t_gobj *)(gp->gp_un.gp_scalar),"delete",""); *************** *** 6076,6081 **** sys_mgui((t_gobj *)(o->gp.gp_un.gp_scalar), "delete",""); } /* now do the resizing and, if growing, initialize new scalars */ - /* aligned resizing */ array->vec = (char *)resizealignedbytes(array->vec, elemsize * nitems, elemsize * newsize); array->n = newsize; --- 6074,6079 ---- sys_mgui((t_gobj *)(o->gp.gp_un.gp_scalar), "delete",""); } + /* now do the resizing and, if growing, initialize new scalars */ array->vec = (char *)resizealignedbytes(array->vec, elemsize * nitems, elemsize * newsize); array->n = newsize; *************** *** 6086,6093 **** word_init((t_word *)newelem, elemtemplate, gp); newelem += elemsize; - /* post("new %lx %lx, ntypes %d", newelem, *(int *)newelem, ntypes); */ } } - /* redraw again. */ if (gs->gs_which == GP_GLIST) { if (canvas_isvisible(gs->gs_un.gs_glist)) gobj_changed((t_gobj *)(gp->gp_un.gp_scalar),0); --- 6084,6089 ---- *************** *** 6150,6157 **** t_canvas *canvas; TEMPLATE_CHECK(x,x->templatesym,) ! if (!gs) {pd_error(x, "append: no current pointer"); return;} ! if (gs->gs_which != GP_GLIST) {pd_error(x, "append: lists only, not arrays"); return;} canvas = gs->gs_un.gs_glist; ! if (canvas->valid != gp->gp_valid) {pd_error(x, "append: stale pointer"); return;} if (!nitems) return; x->variables[0].f = f; --- 6146,6153 ---- t_canvas *canvas; TEMPLATE_CHECK(x,x->templatesym,) ! if (!gs) {pd_error(x, "no current pointer"); return;} ! if (gs->gs_which != GP_GLIST) {pd_error(x, "lists only, not arrays"); return;} canvas = gs->gs_un.gs_glist; ! if (canvas->valid != gp->gp_valid) {pd_error(x, "stale pointer"); return;} if (!nitems) return; x->variables[0].f = f; *************** *** 6206,6215 **** t_word *w; TEMPLATE_CHECK(x,x->templatesym,) ! if (!gpointer_check(gp, 0)) {pd_error(x, "get: stale or empty pointer"); return;} if (!template_find_field(template, x->fieldsym, &onset, &type, &dummy)) { ! pd_error(x, "sublist: couldn't find field %s", x->fieldsym->s_name); return; } ! if (type != DT_LIST) {pd_error(x, "sublist: field %s not of type list", x->fieldsym->s_name); return;} if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w; else w = gp->gp_un.gp_scalar->sc_vec; --- 6202,6211 ---- t_word *w; TEMPLATE_CHECK(x,x->templatesym,) ! if (!gpointer_check(gp, 0)) {pd_error(x, "stale or empty pointer"); return;} if (!template_find_field(template, x->fieldsym, &onset, &type, &dummy)) { ! pd_error(x, "couldn't find field %s", x->fieldsym->s_name); return; } ! if (type != DT_LIST) {pd_error(x, "field %s not of type list", x->fieldsym->s_name); return;} if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w; else w = gp->gp_un.gp_scalar->sc_vec; *************** *** 6726,6730 **** int i; t_symbol *name = atom_getsymbol(argv); ! if (sscanf(name->s_name,"!x%lx",(long*)&o)<1) {error("gargamel was here"); return;} for (i=0; i<argc-1; i++) str[i] = atom_getfloat(argv+i+1); str[argc-1]=0; --- 6722,6726 ---- int i; t_symbol *name = atom_getsymbol(argv); ! if (sscanf(name->s_name,"!x%lx",(long*)&o)<1) {pd_error(x,"gargamel was here"); return;} for (i=0; i<argc-1; i++) str[i] = atom_getfloat(argv+i+1); str[argc-1]=0; *************** *** 6735,6739 **** static void canvas_object_moveto(t_canvas *x, t_symbol *name, t_floatarg px, t_floatarg py) { t_text *o; ! if (sscanf(name->s_name,"!x%lx",(long*)&o)<1) {error("gargamel was here"); return;} o->te_xpix = (int)px; o->te_ypix = (int)py; --- 6731,6735 ---- static void canvas_object_moveto(t_canvas *x, t_symbol *name, t_floatarg px, t_floatarg py) { t_text *o; ! if (sscanf(name->s_name,"!x%lx",(long*)&o)<1) {pd_error(x,"gargamel was here"); return;} o->te_xpix = (int)px; o->te_ypix = (int)py; *************** *** 6742,6746 **** static void canvas_object_delete(t_canvas *x, t_symbol *name) { t_text *o; ! if (sscanf(name->s_name,"!x%lx",(long*)&o)<1) {error("gargamel was here"); return;} canvas_delete(x,(t_gobj *)o); gobj_changed(x,0); --- 6738,6742 ---- static void canvas_object_delete(t_canvas *x, t_symbol *name) { t_text *o; ! if (sscanf(name->s_name,"!x%lx",(long*)&o)<1) {pd_error(x,"gargamel was here"); return;} canvas_delete(x,(t_gobj *)o); gobj_changed(x,0); *************** *** 6768,6773 **** //t_binbuf *b; int i; ! if (argc<1) {error("not enough args"); return;} ! if (argv[0].a_type != A_FLOAT) {error("$1 must be float"); return;} i = atom_getfloat(argv); /* --- 6764,6769 ---- //t_binbuf *b; int i; ! if (argc<1) {pd_error(x,"not enough args"); return;} ! if (argv[0].a_type != A_FLOAT) {pd_error(x,"$1 must be float"); return;} i = atom_getfloat(argv); /*