[PD-cvs] pd/src kernel.c, 1.1.2.36, 1.1.2.37 builtins.c, 1.1.2.14, 1.1.2.15

Mathieu Bouchard matju at users.sourceforge.net
Tue Jan 9 23:13:04 CET 2007


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

Modified Files:
      Tag: desiredata
	kernel.c builtins.c 
Log Message:
merged t_list and t_alist


Index: kernel.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v
retrieving revision 1.1.2.36
retrieving revision 1.1.2.37
diff -C2 -d -r1.1.2.36 -r1.1.2.37
*** kernel.c	9 Jan 2007 21:41:05 -0000	1.1.2.36
--- kernel.c	9 Jan 2007 22:13:01 -0000	1.1.2.37
***************
*** 1626,1630 ****
  }
  
! static t_class *binbuf_class;
  
  t_binbuf *binbuf_new(void) {
--- 1626,1630 ----
  }
  
! t_class *binbuf_class;
  
  t_binbuf *binbuf_new(void) {
***************
*** 2562,2566 ****
      class_addlist(bindlist_class, (t_method)bindlist_list);
      class_addanything(bindlist_class, (t_method)bindlist_anything);
!     binbuf_class = class_new(gensym("__alist"), (t_newmethod)binbuf_new,
  	(t_method)binbuf_free2, sizeof(t_binbuf), CLASS_PD, A_GIMME, 0);
      wire_class = class_new(gensym("__wire"), (t_newmethod)wire_new,
--- 2562,2566 ----
      class_addlist(bindlist_class, (t_method)bindlist_list);
      class_addanything(bindlist_class, (t_method)bindlist_anything);
!     binbuf_class = class_new(gensym("__list"), (t_newmethod)binbuf_new,
  	(t_method)binbuf_free2, sizeof(t_binbuf), CLASS_PD, A_GIMME, 0);
      wire_class = class_new(gensym("__wire"), (t_newmethod)wire_new,

Index: builtins.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -C2 -d -r1.1.2.14 -r1.1.2.15
*** builtins.c	9 Jan 2007 19:59:19 -0000	1.1.2.14
--- builtins.c	9 Jan 2007 22:13:01 -0000	1.1.2.15
***************
*** 640,649 ****
  /* -------------- utility functions: storage, copying  -------------- */
  
- /* damn like binbuf */
- typedef struct t_alist : t_pd {
-     int n;            /* number of items */
-     t_atom *v;  /* pointer to items */
- };
- 
  #if HAVE_ALLOCA
  #define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)((n) < LIST_NGETBYTE ?  \
--- 640,643 ----
***************
*** 661,677 ****
  
  /* ------------- fake class to divert inlets to ----------------- */
! t_class *alist_class;
! static void alist_init(t_alist *x) {
!     x->_class = alist_class;
!     x->n = 0;
!     x->v = 0;
! }
! static void alist_clear(t_alist *x) {
!     for (int i = 0; i < x->n; i++)
!         if (x->v[i].a_type == A_POINTER) gpointer_unset(x->v[i].a_w.w_gpointer);
!     if (x->v) free(x->v);
! }
! static void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv) {
!     alist_clear(x);
      x->v = (t_atom *)getbytes(argc * sizeof(*x->v));
      if (!x->v) {x->n = 0; error("list_alloc: out of memory"); return;}
--- 655,660 ----
  
  /* ------------- fake class to divert inlets to ----------------- */
! static void alist_list(t_binbuf *x, t_symbol *s, int argc, t_atom *argv) {
!     binbuf_clear(x);
      x->v = (t_atom *)getbytes(argc * sizeof(*x->v));
      if (!x->v) {x->n = 0; error("list_alloc: out of memory"); return;}
***************
*** 679,684 ****
      for (int i = 0; i < argc; i++) x->v[i] = argv[i];
  }
! static void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv) {
!     alist_clear(x);
      x->v = (t_atom *)getbytes((argc+1) * sizeof(*x->v));
      if (!x->v) {x->n = 0; error("list_alloc: out of memory"); return;}
--- 662,667 ----
      for (int i = 0; i < argc; i++) x->v[i] = argv[i];
  }
! static void alist_anything(t_binbuf *x, t_symbol *s, int argc, t_atom *argv) {
!     binbuf_clear(x);
      x->v = (t_atom *)getbytes((argc+1) * sizeof(*x->v));
      if (!x->v) {x->n = 0; error("list_alloc: out of memory"); return;}
***************
*** 687,717 ****
      for (int i = 0; i < argc; i++) x->v[i+1] = argv[i];
  }
! static void alist_toatoms(t_alist *x, t_atom *to) {
!     for (int i = 0; i < x->n; i++) to[i] = x->v[i];
! }
! static void alist_setup() {
!     alist_class = class_new2("list inlet",0,0,sizeof(t_alist),0,"");
!     class_addlist(alist_class, alist_list);
!     class_addanything(alist_class, alist_anything);
! }
  
  t_class *list_append_class;
  struct t_list_append : t_object {
!     t_alist alist;
  };
  static t_pd *list_append_new(t_symbol *s, int argc, t_atom *argv) {
      t_list_append *x = (t_list_append *)pd_new(list_append_class);
!     alist_init(&x->alist);
!     alist_list(&x->alist, 0, argc, argv);
      outlet_new(x, &s_list);
!     inlet_new(x,&x->alist, 0, 0);
      return x;
  }
  static void list_append_list(t_list_append *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist.n + argc;
      ATOMS_ALLOCA(outv, outc);
      atoms_copy(argc, argv, outv);
!     alist_toatoms(&x->alist, outv+argc);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
--- 670,693 ----
      for (int i = 0; i < argc; i++) x->v[i+1] = argv[i];
  }
! static void alist_toatoms(t_binbuf *x, t_atom *to) {for (size_t i=0; i<x->n; i++) to[i] = x->v[i];}
  
  t_class *list_append_class;
  struct t_list_append : t_object {
!     t_binbuf *alist;
  };
  static t_pd *list_append_new(t_symbol *s, int argc, t_atom *argv) {
      t_list_append *x = (t_list_append *)pd_new(list_append_class);
!     x->alist = binbuf_new();
!     alist_list(x->alist, 0, argc, argv);
      outlet_new(x, &s_list);
!     inlet_new(x,x->alist, 0, 0);
      return x;
  }
  static void list_append_list(t_list_append *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist->n + argc;
      ATOMS_ALLOCA(outv, outc);
      atoms_copy(argc, argv, outv);
!     alist_toatoms(x->alist, outv+argc);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
***************
*** 719,731 ****
  static void list_append_anything(t_list_append *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist.n + argc + 1;
      ATOMS_ALLOCA(outv, outc);
      SETSYMBOL(outv, s);
      atoms_copy(argc, argv, outv + 1);
!     alist_toatoms(&x->alist, outv + 1 + argc);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
  }
! static void list_append_free(t_list_append *x) {alist_clear(&x->alist);}
  static void list_append_setup() {
      list_append_class = class_new2("list append",list_append_new,list_append_free,sizeof(t_list_append),0,"*");
--- 695,707 ----
  static void list_append_anything(t_list_append *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist->n + argc + 1;
      ATOMS_ALLOCA(outv, outc);
      SETSYMBOL(outv, s);
      atoms_copy(argc, argv, outv + 1);
!     alist_toatoms(x->alist, outv + 1 + argc);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
  }
! static void list_append_free(t_list_append *x) {binbuf_free(x->alist);}
  static void list_append_setup() {
      list_append_class = class_new2("list append",list_append_new,list_append_free,sizeof(t_list_append),0,"*");
***************
*** 737,756 ****
  t_class *list_prepend_class;
  struct t_list_prepend : t_object {
!     t_alist alist;
  };
  static t_pd *list_prepend_new(t_symbol *s, int argc, t_atom *argv) {
      t_list_prepend *x = (t_list_prepend *)pd_new(list_prepend_class);
!     alist_init(&x->alist);
!     alist_list(&x->alist, 0, argc, argv);
      outlet_new(x, &s_list);
!     inlet_new(x, &x->alist, 0, 0);
      return x;
  }
  static void list_prepend_list(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist.n + argc;
      ATOMS_ALLOCA(outv, outc);
!     alist_toatoms(&x->alist, outv);
!     atoms_copy(argc, argv, outv + x->alist.n);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
--- 713,732 ----
  t_class *list_prepend_class;
  struct t_list_prepend : t_object {
!     t_binbuf *alist;
  };
  static t_pd *list_prepend_new(t_symbol *s, int argc, t_atom *argv) {
      t_list_prepend *x = (t_list_prepend *)pd_new(list_prepend_class);
!     x->alist = binbuf_new();
!     alist_list(x->alist, 0, argc, argv);
      outlet_new(x, &s_list);
!     inlet_new(x,x->alist,0,0);
      return x;
  }
  static void list_prepend_list(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist->n + argc;
      ATOMS_ALLOCA(outv, outc);
!     alist_toatoms(x->alist, outv);
!     atoms_copy(argc, argv, outv + x->alist->n);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
***************
*** 758,770 ****
  static void list_prepend_anything(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist.n + argc + 1;
      ATOMS_ALLOCA(outv, outc);
!     alist_toatoms(&x->alist, outv);
!     SETSYMBOL(outv + x->alist.n, s);
!     atoms_copy(argc, argv, outv + x->alist.n + 1);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
  }
! static void list_prepend_free(t_list_prepend *x) {alist_clear(&x->alist);}
  static void list_prepend_setup() {
      list_prepend_class = class_new2("list prepend",list_prepend_new,list_prepend_free,sizeof(t_list_prepend),0,"*");
--- 734,746 ----
  static void list_prepend_anything(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) {
      t_atom *outv;
!     int outc = x->alist->n + argc + 1;
      ATOMS_ALLOCA(outv, outc);
!     alist_toatoms(x->alist, outv);
!     SETSYMBOL(outv + x->alist->n, s);
!     atoms_copy(argc, argv, outv + x->alist->n + 1);
      outlet_list(x->outlet, &s_list, outc, outv);
      ATOMS_FREEA(outv, outc);
  }
! static void list_prepend_free(t_list_prepend *x) {binbuf_free(x->alist);}
  static void list_prepend_setup() {
      list_prepend_class = class_new2("list prepend",list_prepend_new,list_prepend_free,sizeof(t_list_prepend),0,"*");
***************
*** 3217,3221 ****
      key_setup();
  
!     alist_setup();
      list_append_setup();
      list_prepend_setup();
--- 3193,3199 ----
      key_setup();
  
! extern t_class *binbuf_class;
!     class_addlist(binbuf_class, alist_list);
!     class_addanything(binbuf_class, alist_anything);
      list_append_setup();
      list_prepend_setup();





More information about the Pd-cvs mailing list