[PD-cvs] externals/zexy/src packel.c,1.4,1.5

IOhannes m zmölnig zmoelnig at users.sourceforge.net
Thu May 10 15:57:58 CEST 2007


Update of /cvsroot/pure-data/externals/zexy/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25187

Modified Files:
	packel.c 
Log Message:
allow to query multiple values at once


Index: packel.c
===================================================================
RCS file: /cvsroot/pure-data/externals/zexy/src/packel.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** packel.c	14 Mar 2007 09:08:56 -0000	1.4
--- packel.c	10 May 2007 13:57:56 -0000	1.5
***************
*** 35,51 ****
  {
    t_object x_obj;
!   t_float position;
  } t_packel;
  
- static void packel_list(t_packel *x, t_symbol *s, int argc, t_atom *argv)
- {
-   int mypos = x->position;
  
!   if (mypos) {
      t_atom *current;
!     int pos = (mypos < 0)?(argc+mypos):(mypos-1);
  
      if(argc==0){
!       if (pos==0||pos==-1)outlet_bang(x->x_obj.ob_outlet);
        return;
      }
--- 35,59 ----
  {
    t_object x_obj;
!   t_float *position;
!   int count;
! 
!   t_inlet**x_inlet;
!   t_outlet**x_outlet;
! 
!   int x_warningflag;
  } t_packel;
  
  
! static void packel_outelement(t_packel*x, int id, t_symbol*s,int argc, t_atom*argv)
! {
!   t_outlet*out=x->x_outlet[id];
!   int index= x->position[id];
!  
!   if (index) {
      t_atom *current;
!     int pos = (index < 0)?(argc+index):(index-1);
  
      if(argc==0){
!       if (pos==0||pos==-1)outlet_bang(out);
        return;
      }
***************
*** 56,74 ****
  
      switch (current->a_type) {
-     case A_FLOAT:
-       outlet_float(x->x_obj.ob_outlet, atom_getfloat(current));
-       break;
-     case A_SYMBOL:
-       outlet_symbol(x->x_obj.ob_outlet, atom_getsymbol(current));
-       break;
-     case A_POINTER:
-       outlet_pointer(x->x_obj.ob_outlet, current->a_w.w_gpointer);
-       break;
      case A_NULL:
!       outlet_bang(x->x_obj.ob_outlet);
      default:
! 	  ;
      }
!   } else outlet_list(x->x_obj.ob_outlet, s, argc, argv);
  }
  
--- 64,81 ----
  
      switch (current->a_type) {
      case A_NULL:
!       outlet_bang(out);
      default:
!       outlet_list(out, gensym("list"), 1, current);
      }
!   } else outlet_list(out, s, argc, argv); 
! }
! 
! static void packel_list(t_packel *x, t_symbol *s, int argc, t_atom *argv)
! {
!   int c=x->count;
!   while(--c>=0) {
!     packel_outelement(x, c, s, argc, argv);
!   }
  }
  
***************
*** 78,81 ****
--- 85,93 ----
    int i;
  
+   if(x->x_warningflag){
+     pd_error(x, "deprecation warning: you should only use lists for list data");
+     x->x_warningflag=0;
+   }
+ 
    for (i = 0; i < argc; i++)
      av2[i + 1] = argv[i];
***************
*** 85,94 ****
  }
  
! static void *packel_new(t_floatarg f)
  {
    t_packel *x = (t_packel *)pd_new(packel_class);
!   outlet_new(&x->x_obj, 0);
!   floatinlet_new(&x->x_obj, &x->position);
!   x->position = (int) f;
  
    return (x);
--- 97,141 ----
  }
  
! 
! static void packel_free(t_packel *x)
! {
!   int i=0;
! 
!   for(i=0; i<x->count; i++) {
!     if(x->x_inlet &&x->x_inlet [i])inlet_free (x->x_inlet [i]);
!     if(x->x_outlet&&x->x_outlet[i])outlet_free(x->x_outlet[i]);
!   }
! 
!   if(x->position)freebytes(x->position, x->count*sizeof(t_float));
!   if(x->x_inlet)   freebytes(x->x_inlet, x->count*sizeof(t_inlet*));
!   if(x->x_outlet)  freebytes(x->x_outlet, x->count*sizeof(t_outlet*));
! 
! }
! 
! 
! static void *packel_new(t_symbol*s, int argc, t_atom*argv)
  {
    t_packel *x = (t_packel *)pd_new(packel_class);
!   
!   x->count=(argc>0)?argc:1;
! 
!   x->position=(t_float*)getbytes(x->count*sizeof(t_float));
!   x->x_inlet=(t_inlet**)getbytes(x->count*sizeof(t_inlet*));
!   x->x_outlet=(t_outlet**)getbytes(x->count*sizeof(t_outlet*));
! 
!   if(argc<1) {
!     x->position[0]=0.f;
!     x->x_inlet[0]=floatinlet_new(&x->x_obj, x->position);
!     x->x_outlet[0]=outlet_new(&x->x_obj, 0);
!   } else {
!     int i=0;
!     for(i=0; i<x->count; i++) {
!       x->position[i]=atom_getfloat(argv+i);
!       x->x_inlet   [i]=floatinlet_new(&x->x_obj, x->position+i);
!       x->x_outlet  [i]=outlet_new(&x->x_obj, 0);
!     }
!   }
!   x->x_warningflag=1;
! 
  
    return (x);
***************
*** 97,102 ****
  void packel_setup(void)
  {
!   packel_class = class_new(gensym("packel"), (t_newmethod)packel_new, 
! 			   0, sizeof(t_packel), 0, A_DEFFLOAT, 0);
  
    class_addlist  (packel_class, packel_list);
--- 144,151 ----
  void packel_setup(void)
  {
!   packel_class = class_new(gensym("packel"), 
!                            (t_newmethod)packel_new, (t_method)packel_free, 
!                            sizeof(t_packel), 0,
!                            A_GIMME, 0);
  
    class_addlist  (packel_class, packel_list);





More information about the Pd-cvs mailing list