[PD-cvs] pd/src desire.c,1.1.2.31,1.1.2.32

Mathieu Bouchard matju at users.sourceforge.net
Thu Oct 6 12:17:49 CEST 2005


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

Modified Files:
      Tag: devel_0_39
	desire.c 
Log Message:
adding code for observable


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.31
retrieving revision 1.1.2.32
diff -C2 -d -r1.1.2.31 -r1.1.2.32
*** desire.c	28 Sep 2005 08:32:16 -0000	1.1.2.31
--- desire.c	6 Oct 2005 10:17:46 -0000	1.1.2.32
***************
*** 3,11 ****
    This file is part of DesireData.
    Copyright (c) 2004,2005 by Mathieu Bouchard.
!   Portions Copyright (c) 1997-2001 Miller Puckette, Guenther Geiger, Krzysztof Czaja, et al
    [dropper] class is Copyright (c) 2004 Carmen Rocco
!   This software has no license yet
!   And is not covered by the license on the rest of PureData.
!   All Rights Reserved (for now)
  */
  
--- 3,13 ----
    This file is part of DesireData.
    Copyright (c) 2004,2005 by Mathieu Bouchard.
!   Copyright (c) 1997-2001 Miller Puckette.
!   Portions by Guenther Geiger, Krzysztof Czaja, Johannes Zmoelnig, Thomas Musil, etc.
!   The remains of IEMGUI Copyright (c) 2000-2001 Thomas Musil (IEM KUG Graz Austria)
    [dropper] class is Copyright (c) 2004 Carmen Rocco
! 
!   For information on usage and redistribution, and for a DISCLAIMER OF ALL
!   WARRANTIES, see the file, "LICENSE.txt," in this distribution.
  */
  
***************
*** 30,56 ****
  
  //--------------------------------------------------------------------------
- // from g_canvas.c
  
! /* Copyright (c) 1997-2001 Miller Puckette and others.
! * For information on usage and redistribution, and for a DISCLAIMER OF ALL
! * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
  
! /* this file defines the "glist" class, also known as "canvas" (the two used
! to be different but are now unified except for some fossilized names.) */
  
! /* changes by Thomas Musil IEM KUG Graz Austria 2001 */
  
! /* bug-fix: canvas_menuclose(): by Krzysztof Czaja */
! /* bug-fix: table_new(): I reversed the y-bounds  */
  
! /* IOhannes :
!  * changed the canvas_restore, so that it might accept $args as well
!  * (like "pd $0_test")
!  * so you can make multiple & distinguishable templates
!  * 1511:forum::für::umläute:2001
!  * changes marked with    IOhannes
!  */
  
!     /* LATER consider adding font size to this struct (see glist_getfont()) */
  struct _canvasenvironment
  {
--- 32,85 ----
  
  //--------------------------------------------------------------------------
  
! t_observable *observable_new (t_gobj *master) {
! 	t_observable *self = malloc(sizeof(t_observable));
! 	self->master = master;
! 	self->next = 0;
! 	self->dirty = 0;
! 	self->nobs = 0;
! 	self->obs = 0;
! 	return self;
! }
  
! /* subscribing N spies takes N*N time, but I don't care in this case */
! void observable_subscribe (t_observable *self, t_gobj *observer) {
! 	int i;
! 	for (i=0; i<self->nobs; i++) if (self->obs[i]) return;
! 	self->obs=realloc(self->obs,sizeof(t_gobj *)*(1+self->nobs));
! 	self->obs[self->nobs++] = observer;
! }
  
! void observable_unsubscribe (t_observable *self, t_gobj *observer) {
! 	int i;
! 	for (i=0; i<self->nobs; i++) if (self->obs[i]) break;
! 	if (i==self->nobs) return;
! 	self->nobs--;
! 	for (; i<self->nobs-1; i++) self->obs[i] = self->obs[i+1];
! }
  
! // if !k then suppose all of the object might have changed.
! void observable_changed (t_observable *self, const char *k) {
! 	if (!k) self->dirty=-1;
! 	if (self->dirty<0) return;
! 	self->dirty |= 1 << class_getfieldindex(self->master->g_pd,k);
! }
  
! void observable_notify (t_observable *self) {
! 	int i;
! 	for (i=0; i<self->nobs; i++) {
! 		gobj_notice(self->obs[i],self->master,self->dirty);
! 	}
! 	self->dirty = 0;
! }
  
! //--------------------------------------------------------------------------
! /* the "glist" class is also known as "canvas" (the two used
! to be different but are now unified except for some fossilized names.).
! IOhannes changed the canvas_restore, so that it might accept $args as well
! (like "pd $0_test") so you can make multiple & distinguishable templates.
! */
! 
! /* LATER consider adding font size to this struct (see glist_getfont()) */
  struct _canvasenvironment
  {
***************
*** 5186,5189 ****
--- 5215,5219 ----
  {
      t_object *ob;
+     y->g_obs = observable_new(y); /* mb: i found no better place for initing this */
      y->g_next = 0;
      if (!x->gl_list) x->gl_list = y;
***************
*** 12546,12549 ****
--- 12576,12580 ----
      class_setsavefn(c, (t_savefn)bng_savefn);
      class_sethelpsymbol(c, gensym("bng"));
+     class_setfieldnames(c, "foo bar x1 y1 class w hold break isa snd rcv lab ldx ldy fstyle fs bcol fcol lcol");
  }
  





More information about the Pd-cvs mailing list