Update of /cvsroot/pure-data/externals/miXed/cyclone/hammer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22158/cyclone/hammer
Modified Files: Table.c coll.c funbuff.c Log Message:
Index: funbuff.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/funbuff.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** funbuff.c 11 Sep 2003 09:04:32 -0000 1.2 --- funbuff.c 25 Apr 2004 10:37:27 -0000 1.3 *************** *** 445,449 **** x->x_valueset = 0; x->x_pointer = 0; ! x->x_pointerset = 0; x->x_lastdelta = 0; x->x_embedflag = 0; --- 445,449 ---- x->x_valueset = 0; x->x_pointer = 0; ! x->x_pointerset = 0; /* CHECKME, rename to intraversal? */ x->x_lastdelta = 0; x->x_embedflag = 0;
Index: coll.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/coll.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** coll.c 20 Apr 2004 13:55:28 -0000 1.5 --- coll.c 25 Apr 2004 10:37:27 -0000 1.6 *************** *** 1,3 **** ! /* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2002-2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 17,20 **** --- 17,24 ---- #define COLL_DEBUG
+ enum { COLL_HEADRESET, + COLL_HEADNEXT, COLL_HEADPREV, /* distinction not used, currently */ + COLL_HEADDELETED }; + typedef struct _collelem { *************** *** 42,47 **** t_collelem *c_first; t_collelem *c_last; ! t_collelem *c_ahead; ! t_collelem *c_back; } t_collcommon;
--- 46,51 ---- t_collelem *c_first; t_collelem *c_last; ! t_collelem *c_head; ! int c_headstate; } t_collcommon;
*************** *** 185,192 **** else cc->c_last = ep->e_prev; ! if (cc->c_ahead == ep) ! cc->c_ahead = ep->e_next; ! if (cc->c_back == ep) ! cc->c_back = ep->e_prev; }
--- 189,198 ---- else cc->c_last = ep->e_prev; ! if (cc->c_head == ep) ! { ! cc->c_head = ep->e_next; /* asymmetric, LATER rethink */ ! cc->c_headstate = COLL_HEADDELETED; ! } ! }
*************** *** 223,227 **** while (ep1 = ep2); cc->c_first = cc->c_last = 0; ! cc->c_ahead = cc->c_back = 0; collcommon_modified(cc, 1); } --- 229,234 ---- while (ep1 = ep2); cc->c_first = cc->c_last = 0; ! cc->c_head = 0; ! cc->c_headstate = COLL_HEADRESET; collcommon_modified(cc, 1); } *************** *** 582,587 **** { t_binbuf *bb; - int ac; - t_atom *av; char buf[MAXPDSTRING]; if (!fn && !(fn = cc->c_filename)) /* !fn: 'readagain' */ --- 589,592 ---- *************** *** 762,766 **** cc->c_embedflag = 0; cc->c_first = cc->c_last = 0; ! cc->c_ahead = cc->c_back = 0; return (cc); } --- 767,772 ---- cc->c_embedflag = 0; cc->c_first = cc->c_last = 0; ! cc->c_head = 0; ! cc->c_headstate = COLL_HEADRESET; return (cc); } *************** *** 1204,1235 **** }
static void coll_next(t_coll *x) { t_collcommon *cc = x->x_common; ! if (!cc->c_ahead && !(cc->c_ahead = cc->c_first)) ! return; ! coll_keyoutput(x, cc->c_ahead); ! if (cc->c_selfmodified && !cc->c_ahead) ! return; ! coll_dooutput(x, cc->c_ahead->e_size, cc->c_ahead->e_data); ! /* LATER think why c74 updates the heads prior to sendout ! (it seems so clumsy...) */ ! if (!cc->c_ahead && !(cc->c_ahead = cc->c_first)) ! { ! cc->c_back = 0; ! return; ! } ! if (cc->c_ahead->e_next) ! { ! cc->c_ahead = cc->c_ahead->e_next; ! if (!(cc->c_back = cc->c_ahead->e_prev)) /* LATER rethink */ ! cc->c_back = cc->c_last; ! } ! else { ! /* CHECKED wraping */ ! cc->c_back = cc->c_ahead; ! cc->c_ahead = 0; } }
--- 1210,1239 ---- }
+ /* CHECKED traversal direction change is consistent with the general rule: + 'next' always outputs e_next of a previous output, and 'prev' always + outputs e_prev, whether preceded by 'prev', or by 'next'. This is + currently implemented by pre-updating of the head (which is inhibited + if there was no previous output, i.e. after 'goto', 'end', or collection + initialization). CHECKME again. */ + static void coll_next(t_coll *x) { t_collcommon *cc = x->x_common; ! if (cc->c_headstate != COLL_HEADRESET && ! cc->c_headstate != COLL_HEADDELETED) /* asymmetric, LATER rethink */ { ! if (cc->c_head) ! cc->c_head = cc->c_head->e_next; ! if (!cc->c_head && !(cc->c_head = cc->c_first)) /* CHECKED wrapping */ ! return; } + else if (!cc->c_head && !(cc->c_head = cc->c_first)) + return; + cc->c_headstate = COLL_HEADNEXT; + coll_keyoutput(x, cc->c_head); + if (cc->c_head) + coll_dooutput(x, cc->c_head->e_size, cc->c_head->e_data); + else if (!cc->c_selfmodified) + bug("coll_next"); /* LATER rethink */ }
*************** *** 1237,1265 **** { t_collcommon *cc = x->x_common; ! if (!cc->c_back && !(cc->c_back = cc->c_last)) ! return; ! coll_keyoutput(x, cc->c_back); ! if (cc->c_selfmodified && !cc->c_back) ! return; ! coll_dooutput(x, cc->c_back->e_size, cc->c_back->e_data); ! /* LATER think why c74 updates the heads prior to sendout ! (it seems so clumsy...) */ ! if (!cc->c_back && !(cc->c_back = cc->c_last)) ! { ! cc->c_ahead = 0; ! return; ! } ! if (cc->c_back->e_prev) ! { ! cc->c_back = cc->c_back->e_prev; ! if (!(cc->c_ahead = cc->c_back->e_next)) /* LATER rethink */ ! cc->c_ahead = cc->c_first; ! } ! else { ! /* CHECKED wraping */ ! cc->c_ahead = cc->c_back; ! cc->c_back = 0; } }
--- 1241,1259 ---- { t_collcommon *cc = x->x_common; ! if (cc->c_headstate != COLL_HEADRESET) { ! if (cc->c_head) ! cc->c_head = cc->c_head->e_prev; ! if (!cc->c_head && !(cc->c_head = cc->c_last)) /* CHECKED wrapping */ ! return; } + else if (!cc->c_head && !(cc->c_head = cc->c_first)) + return; + cc->c_headstate = COLL_HEADPREV; + coll_keyoutput(x, cc->c_head); + if (cc->c_head) + coll_dooutput(x, cc->c_head->e_size, cc->c_head->e_data); + else if (!cc->c_selfmodified) + bug("coll_prev"); /* LATER rethink */ }
*************** *** 1267,1271 **** { t_collcommon *cc = x->x_common; ! cc->c_back = cc->c_ahead = cc->c_last; }
--- 1261,1266 ---- { t_collcommon *cc = x->x_common; ! cc->c_head = cc->c_last; ! cc->c_headstate = COLL_HEADRESET; }
*************** *** 1276,1280 **** t_collelem *ep = coll_findkey(x, av, s); if (ep) ! x->x_common->c_back = x->x_common->c_ahead = ep; } else loud_messarg((t_pd *)x, s); --- 1271,1279 ---- t_collelem *ep = coll_findkey(x, av, s); if (ep) ! { ! t_collcommon *cc = x->x_common; ! cc->c_head = ep; ! cc->c_headstate = COLL_HEADRESET; ! } } else loud_messarg((t_pd *)x, s);
Index: Table.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/hammer/Table.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Table.c 23 Apr 2004 11:25:52 -0000 1.4 --- Table.c 25 Apr 2004 10:37:27 -0000 1.5 *************** *** 62,66 **** { t_object x_ob; ! t_canvas *x_canvas; t_symbol *x_name; t_tablecommon *x_common; --- 62,66 ---- { t_object x_ob; ! t_canvas *x_glist; t_symbol *x_name; t_tablecommon *x_common; *************** *** 93,98 **** t_table *x; for (x = cc->c_refs; x; x = x->x_next) ! if (x->x_canvas && glist_isvisible(x->x_canvas)) ! canvas_dirty(x->x_canvas, 1); } } --- 93,98 ---- t_table *x; for (x = cc->c_refs; x; x = x->x_next) ! if (x->x_glist && glist_isvisible(x->x_glist)) ! canvas_dirty(x->x_glist, 1); } } *************** *** 224,230 **** --- 224,258 ---- }
+ /* LATER binary files */ static void tablecommon_doread(t_tablecommon *cc, t_symbol *fn, t_canvas *cv) { /* FIXME */ + t_binbuf *bb = binbuf_new(); + int ac; + t_atom *av; + char buf[MAXPDSTRING]; + if (!fn) + return; /* CHECKME complaint */ + if (cv || (cv = cc->c_lastcanvas)) /* !cv: 'read' w/o arg */ + canvas_makefilename(cv, fn->s_name, buf, MAXPDSTRING); + else + { + strncpy(buf, fn->s_name, MAXPDSTRING); + buf[MAXPDSTRING-1] = 0; + } + binbuf_read(bb, buf, "", 0); + if ((ac = binbuf_getnatom(bb)) && + (av = binbuf_getvec(bb)) && + av->a_type == A_SYMBOL && + av->a_w.w_symbol == gensym("table")) + { + post("Table: %s read successful", fn->s_name); /* CHECKME */ + /* FIXME */ + } + #if 0 /* FIXME */ + else /* CHECKME complaint */ + loud_error((t_pd *)cc, "invalid file %s", fn->s_name); + #endif + binbuf_free(bb); }
*************** *** 236,240 **** static void tablecommon_dowrite(t_tablecommon *cc, t_symbol *fn, t_canvas *cv) { ! /* FIXME */ }
--- 264,284 ---- static void tablecommon_dowrite(t_tablecommon *cc, t_symbol *fn, t_canvas *cv) { ! t_binbuf *bb = binbuf_new(); ! char buf[MAXPDSTRING]; ! int ndx, *ptr; ! if (!fn) ! return; /* CHECKME complaint */ ! if (cv || (cv = cc->c_lastcanvas)) /* !cv: 'write' w/o arg */ ! canvas_makefilename(cv, fn->s_name, buf, MAXPDSTRING); ! else ! { ! strncpy(buf, fn->s_name, MAXPDSTRING); ! buf[MAXPDSTRING-1] = 0; ! } ! binbuf_addv(bb, "s", gensym("table")); ! for (ndx = 0, ptr = cc->c_table; ndx < cc->c_length; ndx++, ptr++) ! binbuf_addv(bb, "i", *ptr); ! binbuf_write(bb, buf, "", 0); ! binbuf_free(bb); }
*************** *** 366,370 **** pd_bind(&cc->c_pd, name); /* LATER rethink canvas unpredictability */ ! tablecommon_doread(cc, name, x->x_canvas); } else --- 410,414 ---- pd_bind(&cc->c_pd, name); /* LATER rethink canvas unpredictability */ ! tablecommon_doread(cc, name, x->x_glist); } else *************** *** 642,659 **** }
- /* FIXME arguments (from, to) */ - /* CHECKED no remote dumping, symbol args bashed to 0 */ static void table_dump(t_table *x, t_symbol *s, int ac, t_atom *av) { t_tablecommon *cc = x->x_common; t_outlet *out = ((t_object *)x)->ob_outlet; ! int ndx; ! /* The usual way of traversing the table by incrementing a pointer is ! not robust, because calling outlet_float() may invalidate the pointer. ! The test below is simpler than generic selfmod detection ala coll, ! but behaviour may be different. LATER revisit, consider asserting ! invariance of cc->c_table and cc->c_length, instead. */ ! for (ndx = 0; ndx < cc->c_length; ndx++) ! outlet_float(out, (t_float)cc->c_table[ndx]); }
--- 686,718 ---- }
static void table_dump(t_table *x, t_symbol *s, int ac, t_atom *av) { t_tablecommon *cc = x->x_common; + int thelength = cc->c_length; + int *thetable = cc->c_table; t_outlet *out = ((t_object *)x)->ob_outlet; ! int ndx, nmx, *ptr; ! /* CHECKED optional arguments: from, to, Negative 'from' causes ! invalid output, symbols are bashed to zero for both arguments, ! inconsistent warnings, etc. -- no strict emulation attempted below. */ ! if (ac && av->a_type == A_FLOAT) ! ndx = tablecommon_getindex(cc, (int)av->a_w.w_float); ! else ! ndx = 0; ! if (ac > 1 && av[1].a_type == A_FLOAT) ! nmx = tablecommon_getindex(cc, (int)av[1].a_w.w_float); ! else ! nmx = thelength - 1; ! for (ptr = thetable + ndx; ndx <= nmx; ndx++, ptr++) ! { ! /* Plain traversing by incrementing a pointer is not robust, ! because calling outlet_float() may invalidate the pointer. ! Continous storage does not require generic selfmod detection ! (ala coll), so we can get away with the simpler test below. */ ! if (cc->c_length != thelength || cc->c_table != thetable) ! break; ! /* CHECKED no remote dumping */ ! outlet_float(out, (t_float)*ptr); ! } }
*************** *** 670,674 **** t_tablecommon *cc = x->x_common; if (s && s != &s_) ! tablecommon_doread(cc, s, x->x_canvas); else hammerpanel_open(cc->c_filehandle, 0); --- 729,733 ---- t_tablecommon *cc = x->x_common; if (s && s != &s_) ! tablecommon_doread(cc, s, x->x_glist); else hammerpanel_open(cc->c_filehandle, 0); *************** *** 679,685 **** t_tablecommon *cc = x->x_common; if (s && s != &s_) ! tablecommon_dowrite(cc, s, x->x_canvas); else - /* CHECKED default name is plain `Untitled' */ hammerpanel_save(cc->c_filehandle, 0, 0); } --- 738,743 ---- t_tablecommon *cc = x->x_common; if (s && s != &s_) ! tablecommon_dowrite(cc, s, x->x_glist); else hammerpanel_save(cc->c_filehandle, 0, 0); } *************** *** 710,713 **** --- 768,772 ---- /* LATER prepend "table: " */ hammereditor_open(cc->c_filehandle, + /* CHECKED default name is plain `Untitled' */ x->x_name ? x->x_name->s_name : "Untitled"); while (count--) *************** *** 755,759 **** warned = 1; } ! x->x_canvas = canvas_getcurrent(); x->x_valueset = 0; x->x_head = 0; --- 814,818 ---- warned = 1; } ! x->x_glist = canvas_getcurrent(); x->x_valueset = 0; x->x_head = 0;