[PD-cvs] pd/src builtins.c,1.1.2.41,1.1.2.42

Mathieu Bouchard matju at users.sourceforge.net
Fri Jul 20 10:10:57 CEST 2007


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

Modified Files:
      Tag: desiredata
	builtins.c 
Log Message:
merged both [select] classes together


Index: builtins.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v
retrieving revision 1.1.2.41
retrieving revision 1.1.2.42
diff -C2 -d -r1.1.2.41 -r1.1.2.42
*** builtins.c	20 Jul 2007 07:28:59 -0000	1.1.2.41
--- builtins.c	20 Jul 2007 08:10:55 -0000	1.1.2.42
***************
*** 1295,1314 ****
  /* -------------------------- select ------------------------------ */
  
! static t_class *sel1_class;
! struct t_sel1 : t_object {
!     t_atom atom;
! };
! static void sel1_float(t_sel1 *x, t_float f) {
!     if (x->atom.a_type==A_FLOAT  && f == x->atom.a_float)  outlet_bang(x->out(0)); else outlet_float(x->out(1),f);
! }
! static void sel1_symbol(t_sel1 *x, t_symbol *s) {
!     if (x->atom.a_type==A_SYMBOL && s == x->atom.a_symbol) outlet_bang(x->out(0)); else outlet_symbol(x->out(1),s);
! }
! static t_class *sel2_class;
  struct t_selectelement {
      t_atom a;
      t_outlet *out;
  };
! struct t_sel2 : t_object {
      t_int nelement;
      t_selectelement *vec;
--- 1295,1304 ----
  /* -------------------------- select ------------------------------ */
  
! static t_class *select_class;
  struct t_selectelement {
      t_atom a;
      t_outlet *out;
  };
! struct t_select : t_object {
      t_int nelement;
      t_selectelement *vec;
***************
*** 1317,1363 ****
  #define select_each(e,x) for (t_selectelement *e = x->vec;e;e=0) for (int nelement = x->nelement; nelement--; e++)
  
! static void sel2_float(t_sel2 *x, t_float f) {
!     select_each(e,x) if (e->a.a_type==A_FLOAT ) if (e->a.a_float==f)  {outlet_bang(e->out); return;}
      outlet_float(x->rejectout, f);
  }
! static void sel2_symbol(t_sel2 *x, t_symbol *s) {
!     select_each(e,x) if (e->a.a_type==A_SYMBOL) if (e->a.a_symbol==s) {outlet_bang(e->out); return;}
      outlet_symbol(x->rejectout, s);
  }
! static void sel2_free(t_sel2 *x) {free(x->vec);}
  static void *select_new(t_symbol *s, int argc, t_atom *argv) {
      if (argc == 0) {
-        t_atom a;
          argc = 1;
          SETFLOAT(&a, 0);
!         argv = &a;
      }
!     if (argc == 1) {
!         t_sel1 *x = (t_sel1 *)pd_new(sel1_class);
!         x->atom = *argv;
!         outlet_new(x, &s_bang);
!         if (argv->a_type == A_FLOAT) {floatinlet_new(x, &x->atom.a_float ); outlet_new(x, &s_float);}
!         else                        {symbolinlet_new(x, &x->atom.a_symbol); outlet_new(x, &s_symbol);}
!         return x;
!     } else {
!         t_sel2 *x = (t_sel2 *)pd_new(sel2_class);
!         x->nelement = argc;
!         x->vec = (t_selectelement *)getbytes(argc * sizeof(*x->vec));
!         t_selectelement *e = x->vec;
!         for (int n = 0; n < argc; n++, e++) {
!             e->out = outlet_new(x, &s_bang);
!             e->a = argv[n];
!         }
!         x->rejectout = outlet_new(x, &s_float);
!         return x;
      }
  }
  void select_setup() {
!     sel1_class = class_new2("select",0,0,sizeof(t_sel1),0,"");
!     class_addfloat(sel1_class, sel1_float);
!     class_addsymbol(sel1_class, sel1_symbol);
!     sel2_class = class_new2("select",0,sel2_free,sizeof(t_sel2),0,"");
!     class_addfloat(sel2_class, sel2_float);
!     class_addsymbol(sel2_class, sel2_symbol);
      class_addcreator2("select",select_new,"*");
      class_addcreator2("sel",   select_new,"*");
--- 1307,1341 ----
  #define select_each(e,x) for (t_selectelement *e = x->vec;e;e=0) for (int nelement = x->nelement; nelement--; e++)
  
! static void select_float(t_select *x, t_float f) {
!     select_each(e,x) if (e->a.a_type==A_FLOAT  && e->a.a_float==f)  {outlet_bang(e->out); return;}
      outlet_float(x->rejectout, f);
  }
! static void select_symbol(t_select *x, t_symbol *s) {
!     select_each(e,x) if (e->a.a_type==A_SYMBOL && e->a.a_symbol==s) {outlet_bang(e->out); return;}
      outlet_symbol(x->rejectout, s);
  }
! static void select_free(t_select *x) {free(x->vec);}
  static void *select_new(t_symbol *s, int argc, t_atom *argv) {
+     t_atom a;
      if (argc == 0) {
          argc = 1;
          SETFLOAT(&a, 0);
!         argv = new t_atom[1];
      }
!     t_select *x = (t_select *)pd_new(select_class);
!     x->nelement = argc;
!     x->vec = (t_selectelement *)getbytes(argc * sizeof(*x->vec));
!     t_selectelement *e = x->vec;
!     for (int n = 0; n < argc; n++, e++) {
!         e->out = outlet_new(x, &s_bang);
!         e->a = argv[n];
      }
+     x->rejectout = outlet_new(x, &s_float);
+     return x;
  }
  void select_setup() {
!     select_class = class_new2("select",0,select_free,sizeof(t_select),0,"");
!     class_addfloat(select_class, select_float);
!     class_addsymbol(select_class, select_symbol);
      class_addcreator2("select",select_new,"*");
      class_addcreator2("sel",   select_new,"*");





More information about the Pd-cvs mailing list