[PD-cvs] pd/src desire.c,1.1.2.202,1.1.2.203

Mathieu Bouchard matju at users.sourceforge.net
Tue Nov 28 00:23:28 CET 2006


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

Modified Files:
      Tag: devel_0_39
	desire.c 
Log Message:
macros for doing casts in pd_bind pd_unbind pd_free


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.202
retrieving revision 1.1.2.203
diff -C2 -d -r1.1.2.202 -r1.1.2.203
*** desire.c	27 Nov 2006 14:06:01 -0000	1.1.2.202
--- desire.c	27 Nov 2006 23:23:24 -0000	1.1.2.203
***************
*** 82,85 ****
--- 82,89 ----
  t_symbol *s_empty, *s_pd, *s_Pd;
  
+ #define   pd_free(a)     pd_free((t_pd *)(a))
+ #define   pd_bind(a,b)   pd_bind((t_pd *)(a),b)
+ #define pd_unbind(a,b) pd_unbind((t_pd *)(a),b)
+ 
  //--------------------------------------------------------------------------
  // t_appendix: an extension to t_gobj made by matju so that
***************
*** 301,305 ****
  	clock_free(self->clock);
  	queue_free(self->q);
! 	pd_free((t_pd *)self);
  }
  
--- 305,309 ----
  	clock_free(self->clock);
  	queue_free(self->q);
! 	pd_free(self);
  }
  
***************
*** 419,425 ****
  static void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir) {
      t_symbol *bs = canvas_makebindsym(x->name);
!     if (x->name!=s_Pd) pd_unbind((t_pd *)x, bs);
      x->name = s;
!     if (x->name!=s_Pd)   pd_bind((t_pd *)x, bs);
      if (dir && dir != &s_) canvas_getenv(x)->dir = dir;
      gobj_changed(x,0);
--- 423,429 ----
  static void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir) {
      t_symbol *bs = canvas_makebindsym(x->name);
!     if (x->name!=s_Pd) pd_unbind(x, bs);
      x->name = s;
!     if (x->name!=s_Pd)   pd_bind(x, bs);
      if (dir && dir != &s_) canvas_getenv(x)->dir = dir;
      gobj_changed(x,0);
***************
*** 527,531 ****
      x->owner = owner;
      x->name = *s->s_name ? s : canvas_newfilename ? canvas_newfilename : s_Pd;
!     if (x->name != s_Pd) pd_bind((t_pd *)x, canvas_makebindsym(x->name));
      x->loading = 1;
      x->goprect = 0; /* no GOP rectangle unless it's turned on later */
--- 531,535 ----
      x->owner = owner;
      x->name = *s->s_name ? s : canvas_newfilename ? canvas_newfilename : s_Pd;
!     if (x->name != s_Pd) pd_bind(x, canvas_makebindsym(x->name));
      x->loading = 1;
      x->goprect = 0; /* no GOP rectangle unless it's turned on later */
***************
*** 598,602 ****
      x->font =  (canvas_getcurrent() ? canvas_getcurrent()->font : sys_defaultfont);
      x->screenx1 = x->screeny1 = 0; x->screenx2 = 450; x->screeny2 = 300;
!     if (x->name != s_Pd) pd_bind((t_pd *)x, canvas_makebindsym(x->name));
      x->owner = g;
      x->isgraph = 1;
--- 602,606 ----
      x->font =  (canvas_getcurrent() ? canvas_getcurrent()->font : sys_defaultfont);
      x->screenx1 = x->screeny1 = 0; x->screenx2 = 450; x->screeny2 = 300;
!     if (x->name != s_Pd) pd_bind(x, canvas_makebindsym(x->name));
      x->owner = g;
      x->isgraph = 1;
***************
*** 719,723 ****
      canvas_vis(x, 0);
      sys_mgui(x,"delete","");
!     if (x->name != s_Pd) pd_unbind((t_pd *)x, canvas_makebindsym(x->name));
      if (x->env) {
          freebytes(x->env->argv, x->env->argc * sizeof(t_atom));
--- 723,727 ----
      canvas_vis(x, 0);
      sys_mgui(x,"delete","");
!     if (x->name != s_Pd) pd_unbind(x,canvas_makebindsym(x->name));
      if (x->env) {
          freebytes(x->env->argv, x->env->argc * sizeof(t_atom));
***************
*** 1253,1257 ****
  
  void canvas_close(t_canvas *x) {
!     if (x->owner) canvas_vis(x, 0); else pd_free((t_pd *)x);
  }
  
--- 1257,1261 ----
  
  void canvas_close(t_canvas *x) {
!     if (x->owner) canvas_vis(x, 0); else pd_free(x);
  }
  
***************
*** 1369,1375 ****
  
  static void canvas_restoreconnections(t_canvas *x) {
!     pd_bind((t_pd *)x, gensym("#X"));
      binbuf_eval(x->connectbuf, 0, 0, 0);
!     pd_unbind((t_pd *)x, gensym("#X"));
  }
  
--- 1373,1379 ----
  
  static void canvas_restoreconnections(t_canvas *x) {
!     pd_bind(x,gensym("#X"));
      binbuf_eval(x->connectbuf, 0, 0, 0);
!     pd_unbind(x,gensym("#X"));
  }
  
***************
*** 1528,1532 ****
      x->realname = s;
      x->realname = canvas_realizedollar(gl, s);
!     pd_bind(&x->x_gobj.g_pd, x->realname);
      x->usedindsp = 0;
      x->saveit = saveit;
--- 1532,1536 ----
      x->realname = s;
      x->realname = canvas_realizedollar(gl, s);
!     pd_bind(x,x->realname);
      x->usedindsp = 0;
      x->saveit = saveit;
***************
*** 1629,1634 ****
      template_setfloat(t, gensym("linewidth"), x->scalar->sc_vec, style==PLOTSTYLE_POINTS?2:1, 1);
      t_pd *x2 = pd_findbyclass(gensym("#A"), garray_class);
!     if (x2) pd_unbind(x2, gensym("#A"));
!     pd_bind(&x->x_gobj.g_pd, gensym("#A"));
      garray_redraw(x);
      return x;
--- 1633,1638 ----
      template_setfloat(t, gensym("linewidth"), x->scalar->sc_vec, style==PLOTSTYLE_POINTS?2:1, 1);
      t_pd *x2 = pd_findbyclass(gensym("#A"), garray_class);
!     if (x2) pd_unbind(x2,gensym("#A"));
!     pd_bind(x,gensym("#A"));
      garray_redraw(x);
      return x;
***************
*** 1682,1688 ****
              if (x->listviewing) garray_arrayviewlist_close(x);
              x->realname = argname;
!             pd_unbind(&x->x_gobj.g_pd, x->realname);
              x->realname = canvas_realizedollar(x->canvas, argname);
!             pd_bind(&x->x_gobj.g_pd, x->realname);
              /* redraw the whole canvas, just so the name change shows up */
              if (x->canvas->havewindow) canvas_redraw(x->canvas);
--- 1686,1692 ----
              if (x->listviewing) garray_arrayviewlist_close(x);
              x->realname = argname;
!             pd_unbind(x,x->realname);
              x->realname = canvas_realizedollar(x->canvas, argname);
!             pd_bind(x,x->realname);
              /* redraw the whole canvas, just so the name change shows up */
              if (x->canvas->havewindow) canvas_redraw(x->canvas);
***************
*** 1737,1744 ****
      if (x->listviewing) garray_arrayviewlist_close(x);
      gfxstub_deleteforkey(x);
!     pd_unbind(&x->x_gobj.g_pd, x->realname);
      /* LATER find a way to get #A unbound earlier (at end of load?) */
      while ((x2 = pd_findbyclass(gensym("#A"), garray_class))) pd_unbind(x2, gensym("#A"));
!     pd_free(&x->scalar->sc_gobj.g_pd);
  }
  
--- 1741,1748 ----
      if (x->listviewing) garray_arrayviewlist_close(x);
      gfxstub_deleteforkey(x);
!     pd_unbind(x,x->realname);
      /* LATER find a way to get #A unbound earlier (at end of load?) */
      while ((x2 = pd_findbyclass(gensym("#A"), garray_class))) pd_unbind(x2, gensym("#A"));
!     pd_free(x);
  }
  
***************
*** 2141,2146 ****
  static void garray_rename(t_garray *x, t_symbol *s) {
      if (x->listviewing) garray_arrayviewlist_close(x);
!     pd_unbind(&x->x_gobj.g_pd, x->realname);
!     pd_bind(&x->x_gobj.g_pd, x->realname = x->realname = s);
      garray_redraw(x);
  }
--- 2145,2151 ----
  static void garray_rename(t_garray *x, t_symbol *s) {
      if (x->listviewing) garray_arrayviewlist_close(x);
!     pd_unbind(x,x->realname);
!     x->realname = s;
!     pd_bind(x,x->realname);
      garray_redraw(x);
  }
***************
*** 2314,2318 ****
  	canvas_each(g,x) if (g->g_next == y) {g->g_next = y->g_next; break;}
      }
!     pd_free(&y->g_pd);
      if (chkdsp) canvas_update_dsp();
      if (drawcommand)
--- 2319,2323 ----
  	canvas_each(g,x) if (g->g_next == y) {g->g_next = y->g_next; break;}
      }
!     pd_free(y);
      if (chkdsp) canvas_update_dsp();
      if (drawcommand)
***************
*** 2711,2715 ****
      x->who = who;
      x->sym = sym;
!     pd_bind((t_pd *)x, sym);
      return x;
  }
--- 2716,2720 ----
      x->who = who;
      x->sym = sym;
!     pd_bind(x,sym);
      return x;
  }
***************
*** 2717,2726 ****
  /* cleanup routine; delete any resources we have */
  static void guiconnect_free(t_guiconnect *x) {
!     if (x->sym) pd_unbind((t_pd *)x, x->sym);
      if (x->clock) clock_free(x->clock);
  }
  
  /* this is called when the clock times out to indicate the GUI should be gone by now. */
! static void guiconnect_tick(t_guiconnect *x) {pd_free(&x->o.ob_pd);}
  
  /* the target calls this to disconnect.  If the gui has "signed off"
--- 2722,2731 ----
  /* cleanup routine; delete any resources we have */
  static void guiconnect_free(t_guiconnect *x) {
!     if (x->sym) pd_unbind(x,x->sym);
      if (x->clock) clock_free(x->clock);
  }
  
  /* this is called when the clock times out to indicate the GUI should be gone by now. */
! static void guiconnect_tick(t_guiconnect *x) {pd_free(x);}
  
  /* the target calls this to disconnect.  If the gui has "signed off"
***************
*** 2728,2732 ****
     or for a timeout. */
  static void guiconnect_notarget(t_guiconnect *x, double timedelay) {
!     if (!x->sym) pd_free((t_pd *)x);
      else {
          x->who = 0;
--- 2733,2737 ----
     or for a timeout. */
  static void guiconnect_notarget(t_guiconnect *x, double timedelay) {
!     if (!x->sym) pd_free(x);
      else {
          x->who = 0;
***************
*** 2747,2753 ****
      a timeout after which the guiconnect will disappear.) */
  static void guiconnect_signoff(t_guiconnect *x) {
!     if (!x->who) pd_free((t_pd *)x);
      else {
!         pd_unbind((t_pd *)x, x->sym);
          x->sym = 0;
      }
--- 2752,2758 ----
      a timeout after which the guiconnect will disappear.) */
  static void guiconnect_signoff(t_guiconnect *x) {
!     if (!x->who) pd_free(x);
      else {
!         pd_unbind(x,x->sym);
          x->sym = 0;
      }
***************
*** 4029,4033 ****
      if (templatesym->s_name) {
          x->sym = templatesym;
!         pd_bind(&x->t_pdobj, x->sym);
      }
      else x->sym = templatesym;
--- 4034,4038 ----
      if (templatesym->s_name) {
          x->sym = templatesym;
!         pd_bind(x,x->sym);
      }
      else x->sym = templatesym;
***************
*** 4145,4149 ****
          nobug: ;
          }
!         pd_free((t_pd *)scfrom);
          scalartemplate = tto;
      } else {
--- 4150,4154 ----
          nobug: ;
          }
!         pd_free(scfrom);
          scalartemplate = tto;
      } else {
***************
*** 4293,4301 ****
              } else {
                  template_conform(x, y);
!                 pd_free(&x->t_pdobj);
                  template_new(templatesym, argc, argv);
              }
          }
!         pd_free(&y->t_pdobj);
      } else template_new(templatesym, argc, argv);
      return 0;
--- 4298,4306 ----
              } else {
                  template_conform(x, y);
!                 pd_free(x);
                  template_new(templatesym, argc, argv);
              }
          }
!         pd_free(y);
      } else template_new(templatesym, argc, argv);
      return 0;
***************
*** 4304,4308 ****
  /* here we assume someone has already cleaned up all instances of this. */
  void template_free(t_template *x) {
!     if (*x->sym->s_name) pd_unbind(&x->t_pdobj, x->sym);
      t_freebytes(x->vec, x->n * sizeof(*x->vec));
  }
--- 4309,4313 ----
  /* here we assume someone has already cleaned up all instances of this. */
  void template_free(t_template *x) {
!     if (*x->sym->s_name) pd_unbind(x,x->sym);
      t_freebytes(x->vec, x->n * sizeof(*x->vec));
  }
***************
*** 4344,4351 ****
                  /* conform everyone to the new template */
                  template_conform(t, y);
!                 pd_free(&t->t_pdobj);
                  t = template_new(sym, argc, argv);
              }
!             pd_free(&y->t_pdobj);
              t->t_list = x;
              canvas_redrawallfortemplate(t, 1);
--- 4349,4356 ----
                  /* conform everyone to the new template */
                  template_conform(t, y);
!                 pd_free(t);
                  t = template_new(sym, argc, argv);
              }
!             pd_free(y);
              t->t_list = x;
              canvas_redrawallfortemplate(t, 1);
***************
*** 4390,4395 ****
              t_template *z = template_new(&s_, x->argc, x->argv);
              template_conform(t, z);
!             pd_free(&t->t_pdobj);
!             pd_free(&z->t_pdobj);
              z = template_new(x->sym, x->argc, x->argv);
              z->t_list = x->x_next;
--- 4395,4400 ----
              t_template *z = template_new(&s_, x->argc, x->argv);
              template_conform(t, z);
!             pd_free(t);
!             pd_free(z);
              z = template_new(x->sym, x->argc, x->argv);
              z->t_list = x->x_next;
***************
*** 6283,6289 ****
      x->te_width = width;
      x->wherelabel = (int)wherelabel&3;
!     if (*x->rcv->s_name) pd_unbind((t_pd *)x, canvas_realizedollar(x->canvas, x->rcv));
      x->rcv = rcv;
!     if (*x->rcv->s_name) pd_bind(  (t_pd *)x, canvas_realizedollar(x->canvas, x->rcv));
      x->snd = snd;
      x->expanded_to = canvas_realizedollar(x->canvas, x->snd);
--- 6288,6294 ----
      x->te_width = width;
      x->wherelabel = (int)wherelabel&3;
!     if (*x->rcv->s_name) pd_unbind(x, canvas_realizedollar(x->canvas, x->rcv));
      x->rcv = rcv;
!     if (*x->rcv->s_name) pd_bind(  x, canvas_realizedollar(x->canvas, x->rcv));
      x->snd = snd;
      x->expanded_to = canvas_realizedollar(x->canvas, x->snd);
***************
*** 6318,6322 ****
  
  static void gatom_free(t_gatom *x) {
!     if (*x->rcv->s_name) pd_unbind((t_pd *)x, canvas_realizedollar(x->canvas, x->rcv));
      gfxstub_deleteforkey(x);
  }
--- 6323,6327 ----
  
  static void gatom_free(t_gatom *x) {
!     if (*x->rcv->s_name) pd_unbind(x, canvas_realizedollar(x->canvas, x->rcv));
      gfxstub_deleteforkey(x);
  }
***************
*** 6507,6513 ****
      if (rcv==s_empty) rcv=0;
      if (rcv==x->rcv) return;
!     if(x->rcv) pd_unbind((t_pd *)x, x->rcv);
      x->rcv = rcv;
!     if(rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,"rcv");
  }
--- 6512,6518 ----
      if (rcv==s_empty) rcv=0;
      if (rcv==x->rcv) return;
!     if(x->rcv) pd_unbind(x,x->rcv);
      x->rcv = rcv;
!     if(x->rcv)   pd_bind(x,x->rcv);
      gobj_changed(x,"rcv");
  }
***************
*** 6785,6789 ****
  	x->fcol = 0x000000;
  	x->lcol = 0x000000;
! 	pd_bind((t_pd *)x,pd_makebindsym((t_pd *)x));
  	return x;
  }
--- 6790,6794 ----
  	x->fcol = 0x000000;
  	x->lcol = 0x000000;
! 	pd_bind(x,pd_makebindsym((t_pd *)x));
  	return x;
  }
***************
*** 6874,6878 ****
      bng_check_minmax(x);
      iemgui_constrain(x);
!     if (x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 6879,6883 ----
      bng_check_minmax(x);
      iemgui_constrain(x);
!     if (x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 6890,6894 ****
  
  static void iemgui_free(t_iemgui *x) {
!     if(x->rcv) pd_unbind((t_pd *)x, x->rcv);
      gfxstub_deleteforkey(x);
  }
--- 6895,6899 ----
  
  static void iemgui_free(t_iemgui *x) {
!     if(x->rcv) pd_unbind(x,x->rcv);
      gfxstub_deleteforkey(x);
  }
***************
*** 6963,6967 ****
      if (!x->nonzero) x->nonzero=1.0;
      iemgui_constrain(x);
!     if (x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 6968,6972 ----
      if (!x->nonzero) x->nonzero=1.0;
      iemgui_constrain(x);
!     if (x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 7094,7098 ****
      if (!radio_pickle(x,&foo)) return;
      iemgui_constrain(x);
!     if (x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 7099,7103 ----
      if (!radio_pickle(x,&foo)) return;
      iemgui_constrain(x);
!     if (x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 7228,7232 ****
      slider_check_minmax(x);
      slider_check_width(x, isvert(x) ? x->h : x->w);
!     if(x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 7233,7237 ----
      slider_check_minmax(x);
      slider_check_width(x, isvert(x) ? x->h : x->w);
!     if(x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 7346,7350 ****
      nbcheck_minmax(x);
      x->w = MAX(x->w,1);
!     if (x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 7351,7355 ----
      nbcheck_minmax(x);
      x->w = MAX(x->w,1);
!     if (x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 7452,7456 ****
      if (!vu_pickle(x,&foo)) return;
      iemgui_constrain(x);
!     if(x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 7457,7461 ----
      if (!vu_pickle(x,&foo)) return;
      iemgui_constrain(x);
!     if(x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 7524,7528 ****
      x->at[0].a_type = x->at[1].a_type = A_FLOAT; //???
      iemgui_constrain(x);
!     if (x->rcv) pd_bind((t_pd *)x, x->rcv);
      gobj_changed(x,0);
  }
--- 7529,7533 ----
      x->at[0].a_type = x->at[1].a_type = A_FLOAT; //???
      iemgui_constrain(x);
!     if (x->rcv) pd_bind(x,x->rcv);
      gobj_changed(x,0);
  }
***************
*** 7581,7585 ****
      if (!dropper_pickle(x,&foo)) return;
      x->h = x->w;
!     if (x->rcv) pd_bind((t_pd *)x, x->rcv);
      iemgui_constrain(x);
      gobj_changed(x,0);
--- 7586,7590 ----
      if (!dropper_pickle(x,&foo)) return;
      x->h = x->w;
!     if (x->rcv) pd_bind(x,x->rcv);
      iemgui_constrain(x);
      gobj_changed(x,0);





More information about the Pd-cvs mailing list