[PD-cvs] pd/src desire.c, 1.1.2.217.2.219, 1.1.2.217.2.220 desire.h, 1.1.2.49.2.48, 1.1.2.49.2.49 kernel.c, 1.1.2.86, 1.1.2.87 m_pd.h, 1.4.4.11.2.33.2.74, 1.4.4.11.2.33.2.75

Mathieu Bouchard matju at users.sourceforge.net
Sat Aug 18 04:26:30 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13971

Modified Files:
      Tag: desiredata
	desire.c desire.h kernel.c m_pd.h 
Log Message:
canvas's "list" field replaced by "boxes" field (encapsulated linked list)


Index: m_pd.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v
retrieving revision 1.4.4.11.2.33.2.74
retrieving revision 1.4.4.11.2.33.2.75
diff -C2 -d -r1.4.4.11.2.33.2.74 -r1.4.4.11.2.33.2.75
*** m_pd.h	17 Aug 2007 23:33:08 -0000	1.4.4.11.2.33.2.74
--- m_pd.h	18 Aug 2007 02:26:28 -0000	1.4.4.11.2.33.2.75
***************
*** 252,260 ****
     and non-DesireData systems. The equivalent in the Tcl side is really part of every view object. */
  typedef struct t_appendix {
! #ifdef NO_NEXT
! 	struct _gobj *pas_touche;
! #else
! 	struct _gobj *next; /* big hack. this is the donut hole as cut from _gobj */
! #endif
  	t_canvas *canvas; /* the holder of this object */
  /* actual observable */
--- 252,256 ----
     and non-DesireData systems. The equivalent in the Tcl side is really part of every view object. */
  typedef struct t_appendix {
! 	struct _gobj *next; // donut hole
  	t_canvas *canvas; /* the holder of this object */
  /* actual observable */

Index: kernel.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v
retrieving revision 1.1.2.86
retrieving revision 1.1.2.87
diff -C2 -d -r1.1.2.86 -r1.1.2.87
*** kernel.c	17 Aug 2007 08:23:42 -0000	1.1.2.86
--- kernel.c	18 Aug 2007 02:26:28 -0000	1.1.2.87
***************
*** 2303,2306 ****
--- 2303,2307 ----
  void conf_init();
  void glob_init();
+ void boxes_init();
  void garray_init();
  void pd_init() {
***************
*** 2328,2331 ****
--- 2329,2333 ----
      conf_init();
      glob_init();
+     boxes_init();
      garray_init();
  }

Index: desire.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.h,v
retrieving revision 1.1.2.49.2.48
retrieving revision 1.1.2.49.2.49
diff -C2 -d -r1.1.2.49.2.48 -r1.1.2.49.2.49
*** desire.h	17 Aug 2007 23:33:08 -0000	1.1.2.49.2.48
--- desire.h	18 Aug 2007 02:26:28 -0000	1.1.2.49.2.49
***************
*** 157,165 ****
      t_object gl_obj;         /* header in case we're a [pd] or abstraction */
  #endif
- #ifdef NO_NEXT
-     t_gobj *gotohell;
- #else
-     t_gobj *list; /* DIE */
- #endif
      t_canvas *owner;         /* parent canvas, supercanvas, or 0 if none */
      int pixwidth, pixheight; /* width in pixels (on parent, if a graph) */
--- 157,160 ----

Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.219
retrieving revision 1.1.2.217.2.220
diff -C2 -d -r1.1.2.217.2.219 -r1.1.2.217.2.220
*** desire.c	18 Aug 2007 01:10:50 -0000	1.1.2.217.2.219
--- desire.c	18 Aug 2007 02:26:25 -0000	1.1.2.217.2.220
***************
*** 26,29 ****
--- 26,30 ----
  #include <sys/time.h>
  #include <sstream>
+ #include <map>
  
  #ifdef MSW
***************
*** 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) \
--- 43,48 ----
  */
  
! #define boxes_each(CHILD,BOXES)   for(t_gobj *CHILD=(BOXES)->first(); CHILD; CHILD=CHILD->next())
! #define canvas_each(CHILD,CANVAS)   for(t_gobj *CHILD=(CANVAS)->boxes->first(); 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) \
***************
*** 78,95 ****
  
  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;}
--- 80,119 ----
  
  struct t_boxes : t_gobj {
+ private:
  	t_gobj *list;
! 	std::map<int,t_gobj *> future_use;
! public:
! 	t_boxes() : list(0) {}
! 	size_t size() {
! 		size_t n=0;
! 		boxes_each(g,this) n++;
! 		return n;
! 	}
  	t_gobj *first() {return list;}
! 	t_gobj *last()  {
! 		t_gobj *r = first();
! 		if (!r) return 0;
! 		while (r->next()) r=r->next();
! 		return r;
! 	}
! 	t_gobj *next(t_gobj *x) {return x->g_next;}
! 	void add(t_gobj *x) { /* will rely on x->index in the future */
! 		t_gobj *r = last();
! 		if (r) r->g_next = x; else list = x;
! 		x->g_next = 0;
! 	}
! 	void remove_by_value(t_gobj *x) {
! 		if (list == x) list = x->next();
! 		else boxes_each(g,this) if (g->next() == x) {g->g_next = x->next(); break;}
! 	}
  };
  
  t_boxes *boxes_new() {
  	t_boxes *self = (t_boxes *)pd_new(boxes_class);
! 	new(self) t_boxes;
  L	return self;
  }
  
! void boxes_free(t_boxes *self) {self->~t_boxes();}
  
  t_gobj *_gobj::next() {return this->g_next;}
***************
*** 498,502 ****
          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;
--- 522,526 ----
          while (outno == t->nout) {
              t_object *ob = 0;
!             t_gobj *y = t->from ? t->from->next() : t->canvas->boxes->first();
              for (; y; y = y->next()) if ((ob = pd_checkobject(y))) break;
              if (!ob) return 0;
***************
*** 525,528 ****
--- 549,553 ----
      x->ylabel = (t_symbol **)getbytes(0);
      // only manage this canvas if it's not one of the 3 invisible builtin canvases
+     x->boxes = boxes_new();
      return x;
  }
***************
*** 698,702 ****
      if (canvas_whichfind == x) canvas_whichfind = 0;
      t_gobj *y;
!     while ((y = x->list)) canvas_delete(x, y);
      canvas_vis(x, 0);
      if (x->name != s_Pd) pd_unbind(x,canvas_makebindsym(x->name));
--- 723,727 ----
      if (canvas_whichfind == x) canvas_whichfind = 0;
      t_gobj *y;
!     while ((y = x->boxes->first())) canvas_delete(x, y);
      canvas_vis(x, 0);
      if (x->name != s_Pd) pd_unbind(x,canvas_makebindsym(x->name));
***************
*** 1073,1077 ****
  static void canvas_doreload(t_canvas *gl, t_symbol *name, t_symbol *dir, t_gobj *except) {
      int i=0, nobj = canvas_getindex(gl, 0);  /* number of objects */
!     for (t_gobj *g = gl->list; g && i < nobj; i++) {
  	if (g != except && g->_class == canvas_class) {
  	    t_canvas *c = (t_canvas *)g;
--- 1098,1102 ----
  static void canvas_doreload(t_canvas *gl, t_symbol *name, t_symbol *dir, t_gobj *except) {
      int i=0, nobj = canvas_getindex(gl, 0);  /* number of objects */
!     for (t_gobj *g = gl->boxes->first(); g && i < nobj; i++) {
  	if (g != except && g->_class == canvas_class) {
  	    t_canvas *c = (t_canvas *)g;
***************
*** 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... */
--- 1407,1411 ----
      t_array *array = garray_getarray(x);
      t_canvas *gl = x->canvas;
!     if (gl->boxes->first() == 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... */
***************
*** 2002,2010 ****
      y->g_next = 0;
      y->dix->index = x->next_o_index++;
!     if (!x->list) x->list = y; else {
! 	t_gobj *y2;
! 	for (y2 = x->list; y2->next(); y2=y2->next()) {}
!         y2->g_next = y;
!     }
      if (x->gop && !x->goprect && pd_checkobject(y)) SET(goprect,1);
      if (class_isdrawcommand(y->_class))
--- 2027,2031 ----
      y->g_next = 0;
      y->dix->index = x->next_o_index++;
!     x->boxes->add(y);
      if (x->gop && !x->goprect && pd_checkobject(y)) SET(goprect,1);
      if (class_isdrawcommand(y->_class))
***************
*** 2019,2027 ****
      if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(canvas_getcanvas(x)->name)), 2);
      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 */
      pd_free(y);
--- 2040,2044 ----
      if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(canvas_getcanvas(x)->name)), 2);
      canvas_deletelinesfor(x,(t_text *)y);
!     x->boxes->remove_by_value(y);
      /* BUG: should call gobj_onsubscribe here, to flush the zombie */
      pd_free(y);
***************
*** 2034,2045 ****
      int dspstate = 0, suspended = 0;
      t_symbol *dspsym = gensym("dsp");
!     while ((y = x->list)) {
!         /* to avoid unnecessary DSP resorting, we suspend DSP only if we find a DSP object. */
!         if (!suspended && pd_checkobject(y) && zgetfn(y,dspsym)) {
!             dspstate = canvas_suspend_dsp();
!             suspended = 1;
!         }
!         canvas_delete(x, y);
!     }
      if (suspended) canvas_resume_dsp(dspstate);
  }
--- 2051,2057 ----
      int dspstate = 0, suspended = 0;
      t_symbol *dspsym = gensym("dsp");
!     /* to avoid unnecessary DSP resorting, we suspend DSP only if we find a DSP object. */
!     canvas_each(y,x) if (!suspended && pd_checkobject(y) && zgetfn(y,dspsym)) {dspstate = canvas_suspend_dsp(); suspended=1;}
!     while ((y = x->boxes->first())) x->boxes->remove_by_value(y);
      if (suspended) canvas_resume_dsp(dspstate);
  }
***************
*** 2334,2338 ****
      t_canvas *x = (t_canvas *)z;
      float newxpix = graph_lastxpix + dx, newypix = graph_lastypix + dy;
!     t_garray *a = (t_garray *)x->list;
      int oldx = int(0.5 + canvas_pixelstox(x, graph_lastxpix));
      int newx = int(0.5 + canvas_pixelstox(x, newxpix));
--- 2346,2350 ----
      t_canvas *x = (t_canvas *)z;
      float newxpix = graph_lastxpix + dx, newypix = graph_lastypix + dy;
!     t_garray *a = (t_garray *)x->boxes->first();
      int oldx = int(0.5 + canvas_pixelstox(x, graph_lastxpix));
      int newx = int(0.5 + canvas_pixelstox(x, newxpix));
***************
*** 2518,2563 ****
     we delete the scalar and put the new thing in its place on the list. */
  void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b) {
!     int ntotal=0, scindex=-1;
!     t_gobj *y, *y2 = 0, *newone, *oldone = 0;
!     canvas_each(y,x) {
!         if (y==sc) {scindex = ntotal; oldone = y;}
!         ntotal++;
!     }
!     if (scindex == -1) bug("data_properties: scalar disappeared");
      canvas_readfrombinbuf(x, b, "properties dialog", 0);
-     newone = 0;
-     if (scindex >= 0) {
-         /* take the new object off the list */
-         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();
- 	}
-     }
-     if (!newone) {error("couldn't update properties (perhaps a format problem?)"); return;}
-     if (!oldone) {bug("data_properties: couldn't find old element"); return;}
-     canvas_delete(x, oldone);
-     if (scindex > 0) {
- 	int nnew = 1;
-         canvas_each(y,x) {
-           if (nnew == scindex || !y->next()) {
-             newone->g_next = y->next();
-             y->g_next = newone;
-             goto didit;
-           }
- 	  nnew++;
- 	}
-         bug("data_properties: can't reinsert");
-     } else {
- 	newone->g_next = x->list;
- 	x->list = newone;
-     }
- didit:;
  }
  
--- 2530,2539 ----
     we delete the scalar and put the new thing in its place on the list. */
  void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b) {
! //    t_gobj *oldone = 0;
! //    t_gobj *newone = 0;
!     x->boxes->remove_by_value(sc);
! //    if (!newone) {error("couldn't update properties (perhaps a format problem?)"); return;}
! //    if (!oldone) {bug("data_properties: couldn't find old element"); return;}
      canvas_readfrombinbuf(x, b, "properties dialog", 0);
  }
  
***************
*** 2609,2613 ****
              binbuf_addsemi(b);
          } else if (t->vec[i].type == DT_CANVAS) {
!             canvas_writelist(w->w_canvas->list, b);
              binbuf_addsemi(b);
          }
--- 2585,2589 ----
              binbuf_addsemi(b);
          } else if (t->vec[i].type == DT_CANVAS) {
!             canvas_writelist(w->w_canvas->boxes->first(), b);
              binbuf_addsemi(b);
          }
***************
*** 2638,2642 ****
                  canvas_addtemplatesforscalar(arraytemplatesym, (t_word *)&a->vec[elemsize*j], p_ntemplates, p_templatevec);
          } else if (ds->type == DT_CANVAS)
!             canvas_addtemplatesforlist(w->w_canvas->list, p_ntemplates, p_templatevec);
      }
  }
--- 2614,2618 ----
                  canvas_addtemplatesforscalar(arraytemplatesym, (t_word *)&a->vec[elemsize*j], p_ntemplates, p_templatevec);
          } else if (ds->type == DT_CANVAS)
!             canvas_addtemplatesforlist(w->w_canvas->boxes->first(), p_ntemplates, p_templatevec);
      }
  }
***************
*** 3607,3622 ****
          template_conformwords(tfrom, tto, conformaction, scfrom->v, x->v);
          /* replace the old one with the new one in the list */
!         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;
!             }
!             bug("template_conformscalar");
!         nobug: ;
!         }
          pd_free(scfrom);
          scalartemplate = tto;
--- 3583,3588 ----
          template_conformwords(tfrom, tto, conformaction, scfrom->v, x->v);
          /* replace the old one with the new one in the list */
! 	canvas->boxes->remove_by_value(scfrom);
! 	canvas->boxes->add(x);
          pd_free(scfrom);
          scalartemplate = tto;
***************
*** 4704,4708 ****
      /* if (wantselected && !canvas_isvisible(canvas)) {error("next: next-selected only works for a visible window"); return;} */
      t_gobj *gobj = gp->scalar;
!     if (!gobj) gobj = canvas->list;
      else gobj = gobj->next();
      while (gobj && (gobj->_class != scalar_class || wantselected)) gobj = gobj->next();
--- 4670,4674 ----
      /* if (wantselected && !canvas_isvisible(canvas)) {error("next: next-selected only works for a visible window"); return;} */
      t_gobj *gobj = gp->scalar;
!     if (!gobj) gobj = canvas->boxes->first();
      else gobj = gobj->next();
      while (gobj && (gobj->_class != scalar_class || wantselected)) gobj = gobj->next();
***************
*** 5094,5100 ****
      t_scalar *sc = scalar_new(canvas,x->templatesym);
      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);
      gp->scalar = sc;
--- 5060,5064 ----
      t_scalar *sc = scalar_new(canvas,x->templatesym);
      if (!sc) {error("%s: couldn't create scalar", x->templatesym->name); return;}
!     canvas->boxes->add(sc);
      gobj_changed(sc,0);
      gp->scalar = sc;





More information about the Pd-cvs mailing list