Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19646
Modified Files:
Tag: desiredata
desire.c
Log Message:
introducing t_boxes, t_gobj::next()
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.218
retrieving revision 1.1.2.217.2.219
diff -C2 -d -r1.1.2.217.2.218 -r1.1.2.217.2.219
*** desire.c 17 Aug 2007 18:35:07 -0000 1.1.2.217.2.218
--- desire.c 18 Aug 2007 01:10:50 -0000 1.1.2.217.2.219
***************
*** 42,46 ****
*/
! #define canvas_each(CHILD,CANVAS) for(t_gobj *CHILD=(CANVAS)->list; CHILD; CHILD=CHILD->g_next)
#define canvases_each(CANVAS) for(t_canvas *CANVAS=canvas_list; CANVAS; CANVAS=CANVAS->gl_next)
#define canvas_wires_each(WIRE,TRAV,CANVAS) \
--- 42,46 ----
*/
! #define canvas_each(CHILD,CANVAS) for(t_gobj *CHILD=(CANVAS)->list; CHILD; CHILD=CHILD->next())
#define canvases_each(CANVAS) for(t_canvas *CANVAS=canvas_list; CANVAS; CANVAS=CANVAS->gl_next)
#define canvas_wires_each(WIRE,TRAV,CANVAS) \
***************
*** 74,77 ****
--- 74,99 ----
//--------------------------------------------------------------------------
+
+ t_class *boxes_class;
+
+ struct t_boxes : t_gobj {
+ t_gobj *list;
+ //std::map<>
+ t_gobj *first() {return list;}
+ //t_gobj *next(t_gobj *x) {return x->dix->nekst;}
+ t_gobj *next(t_gobj *x) {return x->dix->next;}
+ };
+
+ t_boxes *boxes_new() {
+ t_boxes *self = (t_boxes *)pd_new(boxes_class);
+ self->list = 0;
+ L return self;
+ }
+
+ void boxes_free(t_boxes *self) {}
+
+ t_gobj *_gobj::next() {return this->g_next;}
+
+ //--------------------------------------------------------------------------
// t_appendix: an extension to t_gobj made by matju so that all t_gobj's may have new fields
// without sacrificing binary compat with externals compiled for PureMSP.
***************
*** 476,481 ****
while (outno == t->nout) {
t_object *ob = 0;
! t_gobj *y = t->from ? t->from->g_next : t->canvas->list;
! for (; y; y = y->g_next) if ((ob = pd_checkobject(y))) break;
if (!ob) return 0;
t->from = ob;
--- 498,503 ----
while (outno == t->nout) {
t_object *ob = 0;
! t_gobj *y = t->from ? t->from->next() : t->canvas->list;
! for (; y; y = y->next()) if ((ob = pd_checkobject(y))) break;
if (!ob) return 0;
t->from = ob;
***************
*** 1000,1007 ****
}
! #define canvas_each2(CHILD,CANVAS) for(CHILD=&(CANVAS)->list; *CHILD; CHILD=&(*CHILD)->g_next)
/* just a raw remove, no other business */
/* doesn't work (why?) */
static t_gobj *canvas_remove_nth(t_canvas *x, int n) {
t_gobj **y;
canvas_each2(y,x) {
--- 1022,1030 ----
}
! //#define canvas_each2(CHILD,CANVAS) for(CHILD=&(CANVAS)->list; *CHILD; CHILD=&(*CHILD)->next())
/* just a raw remove, no other business */
/* doesn't work (why?) */
static t_gobj *canvas_remove_nth(t_canvas *x, int n) {
+ /*
t_gobj **y;
canvas_each2(y,x) {
***************
*** 1009,1018 ****
if (!n) {
t_gobj *z = *y;
! *y = z->g_next;
! z->g_next = 0;
return z;
} else n--;
}
return 0;
}
--- 1032,1042 ----
if (!n) {
t_gobj *z = *y;
! *y = z->next();
! z->next() = 0;
return z;
} else n--;
}
return 0;
+ */
}
***************
*** 1020,1031 ****
/* doesn't work (why?) */
static void canvas_insert_nth(t_canvas *x, int n, t_gobj *nu) {
t_gobj **y;
canvas_each2(y,x) if (!n) {
t_gobj *z = *y;
*y = nu;
! nu->g_next = z;
return;
} else n--;
*y = nu;
}
--- 1044,1057 ----
/* doesn't work (why?) */
static void canvas_insert_nth(t_canvas *x, int n, t_gobj *nu) {
+ /*
t_gobj **y;
canvas_each2(y,x) if (!n) {
t_gobj *z = *y;
*y = nu;
! nu->next() = z;
return;
} else n--;
*y = nu;
+ */
}
***************
*** 1053,1057 ****
/* we're going to remake the object, so "g" will go stale. Get its index here,
and afterward restore g. Also, the replacement will be at the end of the list,
! so we don't do g = g->g_next in this case. */
int j = canvas_getindex(gl, g);
int hadwindow = gl->havewindow;
--- 1079,1083 ----
/* we're going to remake the object, so "g" will go stale. Get its index here,
and afterward restore g. Also, the replacement will be at the end of the list,
! so we don't do g = g->next() in this case. */
int j = canvas_getindex(gl, g);
int hadwindow = gl->havewindow;
***************
*** 1063,1067 ****
canvas_doreload(c,name,dir,except);
}
! g = g->g_next;
}
}
--- 1089,1093 ----
canvas_doreload(c,name,dir,except);
}
! g = g->next();
}
}
***************
*** 1356,1360 ****
t_array *array = garray_getarray(x);
t_canvas *gl = x->canvas;
! if (gl->list == x && !x->g_next) {
vmess(gl,gensym("bounds"),"ffff",0.,gl->y1, double(style == PLOTSTYLE_POINTS || n == 1 ? n : n-1), gl->y2);
/* close any dialogs that might have the wrong info now... */
--- 1382,1386 ----
t_array *array = garray_getarray(x);
t_canvas *gl = x->canvas;
! if (gl->list == x && !x->next()) {
vmess(gl,gensym("bounds"),"ffff",0.,gl->y1, double(style == PLOTSTYLE_POINTS || n == 1 ? n : n-1), gl->y2);
/* close any dialogs that might have the wrong info now... */
***************
*** 1978,1982 ****
if (!x->list) x->list = y; else {
t_gobj *y2;
! for (y2 = x->list; y2->g_next; y2=y2->g_next) {}
y2->g_next = y;
}
--- 2004,2008 ----
if (!x->list) x->list = y; else {
t_gobj *y2;
! for (y2 = x->list; y2->next(); y2=y2->next()) {}
y2->g_next = y;
}
***************
*** 1994,2000 ****
canvas_deletelinesfor(x,(t_text *)y);
if (x->list == y) {
! x->list = y->g_next;
} else {
! canvas_each(g,x) if (g->g_next == y) {g->g_next = y->g_next; break;}
}
/* BUG: should call gobj_onsubscribe here, to flush the zombie */
--- 2020,2026 ----
canvas_deletelinesfor(x,(t_text *)y);
if (x->list == y) {
! x->list = y->next();
} else {
! canvas_each(g,x) if (g->next() == y) {g->g_next = y->next(); break;}
}
/* BUG: should call gobj_onsubscribe here, to flush the zombie */
***************
*** 2034,2037 ****
--- 2060,2064 ----
static t_gobj *canvas_merge(t_canvas *x, t_gobj *g1, t_gobj *g2) {
+ /*
t_gobj *g = 0, *g9 = 0;
float f1 = g1 ? gobj_getxforsort(g1) : 0;
***************
*** 2040,2044 ****
if (g1 && !(g2 && f1>f2)) {
if (g9) {g9->g_next = g1; g9 = g1;} else g9 = g = g1;
! if ((g1 = g1->g_next)) f1 = gobj_getxforsort(g1);
g9->g_next = 0;
continue;
--- 2067,2071 ----
if (g1 && !(g2 && f1>f2)) {
if (g9) {g9->g_next = g1; g9 = g1;} else g9 = g = g1;
! if ((g1 = g1->next())) f1 = gobj_getxforsort(g1);
g9->g_next = 0;
continue;
***************
*** 2046,2050 ****
if (g1 || g2) {
if (g9) {g9->g_next = g2; g9 = g2;} else g9 = g = g2;
! if ((g2 = g2->g_next)) f2 = gobj_getxforsort(g2);
g9->g_next = 0;
continue;
--- 2073,2077 ----
if (g1 || g2) {
if (g9) {g9->g_next = g2; g9 = g2;} else g9 = g = g2;
! if ((g2 = g2->next())) f2 = gobj_getxforsort(g2);
g9->g_next = 0;
continue;
***************
*** 2053,2064 ****
}
return g;
}
static t_gobj *canvas_dosort(t_canvas *x, t_gobj *g, int nitems) {
t_gobj *g2, *g3;
int n1 = nitems/2, n2 = nitems - n1, i;
if (nitems < 2) return g;
! for (g2 = g, i = n1-1; i--; g2 = g2->g_next) {}
! g3 = g2->g_next;
g2->g_next = 0;
g = canvas_dosort(x, g, n1);
--- 2080,2094 ----
}
return g;
+ */
}
+ /*
static t_gobj *canvas_dosort(t_canvas *x, t_gobj *g, int nitems) {
t_gobj *g2, *g3;
int n1 = nitems/2, n2 = nitems - n1, i;
if (nitems < 2) return g;
! int i=n1-1;
! for (g2 = g; i--; g2 = g2->next()) {}
! g3 = g2->next();
g2->g_next = 0;
g = canvas_dosort(x, g, n1);
***************
*** 2078,2081 ****
--- 2108,2112 ----
if (foo) x->list = canvas_dosort(x, x->list, nitems);
}
+ */
static t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s, t_symbol* h) {
***************
*** 2500,2511 ****
if (ntotal) {
int nnew = 1;
! for (y = x->list; (y2 = y->g_next); y = y2, nnew++) if (nnew == ntotal) {
newone = y2;
! y->g_next = y2->g_next;
break;
}
} else {
newone = x->list;
! x->list = newone->g_next;
}
}
--- 2531,2542 ----
if (ntotal) {
int nnew = 1;
! for (y = x->list; (y2 = y->next()); y = y2, nnew++) if (nnew == ntotal) {
newone = y2;
! y->g_next = y2->next();
break;
}
} else {
newone = x->list;
! x->list = newone->next();
}
}
***************
*** 2516,2521 ****
int nnew = 1;
canvas_each(y,x) {
! if (nnew == scindex || !y->g_next) {
! newone->g_next = y->g_next;
y->g_next = newone;
goto didit;
--- 2547,2552 ----
int nnew = 1;
canvas_each(y,x) {
! if (nnew == scindex || !y->next()) {
! newone->g_next = y->next();
y->g_next = newone;
goto didit;
***************
*** 2585,2589 ****
static void canvas_writelist(t_gobj *y, t_binbuf *b) {
! for (; y; y = y->g_next) if (y->_class==scalar_class) {
t_scalar *z = (t_scalar *)y;
canvas_writescalar(z->t, z->v, b, 0);
--- 2616,2620 ----
static void canvas_writelist(t_gobj *y, t_binbuf *b) {
! for (; y; y = y->next()) if (y->_class==scalar_class) {
t_scalar *z = (t_scalar *)y;
canvas_writescalar(z->t, z->v, b, 0);
***************
*** 2612,2616 ****
static void canvas_addtemplatesforlist(t_gobj *y, int *p_ntemplates, t_symbol ***p_templatevec) {
! for (; y; y = y->g_next) if (y->_class == scalar_class) {
t_scalar *z = (t_scalar *)y;
canvas_addtemplatesforscalar(z->t, z->v, p_ntemplates, p_templatevec);
--- 2643,2647 ----
static void canvas_addtemplatesforlist(t_gobj *y, int *p_ntemplates, t_symbol ***p_templatevec) {
! for (; y; y = y->next()) if (y->_class == scalar_class) {
t_scalar *z = (t_scalar *)y;
canvas_addtemplatesforscalar(z->t, z->v, p_ntemplates, p_templatevec);
***************
*** 3578,3585 ****
if (canvas->list == scfrom) {
canvas->list = x;
! x->g_next = scfrom->g_next;
} else {
! for (t_gobj *y2, *y = canvas->list; (y2 = y->g_next); y = y2) if (y2 == scfrom) {
! x->g_next = y2->g_next;
y->g_next = x;
goto nobug;
--- 3609,3616 ----
if (canvas->list == scfrom) {
canvas->list = x;
! x->g_next = scfrom->next();
} else {
! for (t_gobj *y2, *y = canvas->list; (y2 = y->next()); y = y2) if (y2 == scfrom) {
! x->g_next = y2->next();
y->g_next = x;
goto nobug;
***************
*** 4674,4679 ****
t_gobj *gobj = gp->scalar;
if (!gobj) gobj = canvas->list;
! else gobj = gobj->g_next;
! while (gobj && (gobj->_class != scalar_class || wantselected)) gobj = gobj->g_next;
if (gobj) {
t_typedout *to = x->typedout;
--- 4705,4710 ----
t_gobj *gobj = gp->scalar;
if (!gobj) gobj = canvas->list;
! else gobj = gobj->next();
! while (gobj && (gobj->_class != scalar_class || wantselected)) gobj = gobj->next();
if (gobj) {
t_typedout *to = x->typedout;
***************
*** 5064,5068 ****
if (!sc) {error("%s: couldn't create scalar", x->templatesym->name); return;}
t_scalar *oldsc = gp->scalar;
! if (oldsc) {sc->g_next = oldsc->g_next; oldsc->g_next = sc;}
else {sc->g_next = canvas->list; canvas->list = sc;}
gobj_changed(sc,0);
--- 5095,5099 ----
if (!sc) {error("%s: couldn't create scalar", x->templatesym->name); return;}
t_scalar *oldsc = gp->scalar;
! if (oldsc) {sc->g_next = oldsc->next(); oldsc->g_next = sc;}
else {sc->g_next = canvas->list; canvas->list = sc;}
gobj_changed(sc,0);
***************
*** 6808,6812 ****
class_addmethod2(c,graph_ylabel,"ylabel","*");
class_addmethod2(c,graph_array,"array","sfsF");
! class_addmethod2(c,canvas_sort,"sort","");
// dd-specific
class_addmethod2(c,canvas_object_moveto,"object_moveto","sff");
--- 6839,6843 ----
class_addmethod2(c,graph_ylabel,"ylabel","*");
class_addmethod2(c,graph_array,"array","sfsF");
! //class_addmethod2(c,canvas_sort,"sort","");
// dd-specific
class_addmethod2(c,canvas_object_moveto,"object_moveto","sff");
***************
*** 6898,6901 ****
--- 6929,6936 ----
}
+ extern "C" void boxes_init() {
+ boxes_class = class_new2("__boxes",boxes_new,boxes_free,sizeof(t_boxes),CLASS_GOBJ,"");
+ }
+
static void desire_setup() {
t_class *c;