[PD-cvs] pd/src x_list.c, NONE, 1.1 configure.in, 1.12, 1.13 g_text.c, 1.8, 1.9 g_traversal.c, 1.2, 1.3 m_conf.c, 1.1.1.3, 1.2 makefile, 1.14, 1.15 makefile.dependencies, 1.6, 1.7 makefile.in, 1.7, 1.8 makefile.nt, 1.5, 1.6 notes.txt, 1.15, 1.16 s_inter.c, 1.10, 1.11 s_midi_alsa.c, 1.2, 1.3 u_main.tk, 1.13, 1.14 x_connective.c, 1.6, 1.7

Miller Puckette millerpuckette at users.sourceforge.net
Sun Jul 24 21:41:17 CEST 2005


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

Modified Files:
	configure.in g_text.c g_traversal.c m_conf.c makefile 
	makefile.dependencies makefile.in makefile.nt notes.txt 
	s_inter.c s_midi_alsa.c u_main.tk x_connective.c 
Added Files:
	x_list.c 
Log Message:
New "list" object.
Added "addcomma", "addsemi", "adddollar", "adddollsym" messages to
message object.
worked on Mac compilation problems.



Index: g_traversal.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_traversal.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** g_traversal.c	6 Sep 2004 20:20:34 -0000	1.2
--- g_traversal.c	24 Jul 2005 19:41:14 -0000	1.3
***************
*** 91,106 ****
  }
  
- /* call this if you know the pointer is fresh but don't know if we're pointing
- to the head of a list or to real data.   Any pointer is known to be fresh
- when it appears as the argument of a message, but if your "pointer" method 
- or inlet stores it and you use it later, call gpointer_check above. */
- 
- /* LATER reconsider the above... I no longer think it's true! */
- 
- static int gpointer_ishead(const t_gpointer *gp)
- {
-     return ((gp->gp_stub->gs_which == GP_GLIST) && !gp->gp_un.gp_scalar);
- }
- 
  /* get the template for the object pointer to.  Assumes we've already checked
  freshness.  Returns 0 if head of list. */
--- 91,94 ----
***************
*** 123,128 ****
  }
  
!     /* copy a pointer to another, assuming the first one is fresh and
!     the second one hasn't yet been initialized. */
  void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto)
  {
--- 111,117 ----
  }
  
!     /* copy a pointer to another, assuming the second one hasn't yet been
!     initialized.  New gpointers should be initialized either by this
!     routine or by gpointer_init below. */
  void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto)
  {
***************
*** 133,136 ****
--- 122,127 ----
  }
  
+     /* clear a gpointer that was previously set, releasing the associted
+     gstub if this was the last reference to it. */
  void gpointer_unset(t_gpointer *gp)
  {
***************
*** 417,423 ****
          return;
      }
!     if (gpointer_ishead(gp))
      {
!         pd_error(x, "get: empty pointer");
          return;
      }
--- 408,414 ----
          return;
      }
!     if (!gpointer_check(gp, 0))
      {
!         pd_error(x, "get: stale or empty pointer");
          return;
      }
***************
*** 692,698 ****
          return;
      }
!     if (gpointer_ishead(gp))
      {
!         pd_error(x, "getsize: empty pointer");
          return;
      }
--- 683,689 ----
          return;
      }
!     if (!gpointer_check(gp, 0))
      {
!         pd_error(x, "get: stale or empty pointer");
          return;
      }
***************
*** 1034,1040 ****
          return;
      }
!     if (gpointer_ishead(gp))
      {
!         pd_error(x, "sublist: empty pointer");
          return;
      }
--- 1025,1031 ----
          return;
      }
!     if (!gpointer_check(gp, 0))
      {
!         pd_error(x, "get: stale or empty pointer");
          return;
      }

Index: g_text.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_text.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** g_text.c	2 Jul 2005 05:03:06 -0000	1.8
--- g_text.c	24 Jul 2005 19:41:14 -0000	1.9
***************
*** 333,336 ****
--- 333,368 ----
  }
  
+ static void message_addcomma(t_message *x)
+ {
+     t_atom a;
+     SETCOMMA(&a);
+     binbuf_add(x->m_text.te_binbuf, 1, &a);
+     glist_retext(x->m_glist, &x->m_text);
+ }
+ 
+ static void message_addsemi(t_message *x)
+ {
+     message_add(x, 0, 0, 0);
+ }
+ 
+ static void message_adddollar(t_message *x, t_floatarg f)
+ {
+     int n = f;
+     if (n < 0)
+         n = 0;
+     t_atom a;
+     SETDOLLAR(&a, n);
+     binbuf_add(x->m_text.te_binbuf, 1, &a);
+     glist_retext(x->m_glist, &x->m_text);
+ }
+ 
+ static void message_adddollsym(t_message *x, t_symbol *s)
+ {
+     t_atom a;
+     SETDOLLSYM(&a, s);
+     binbuf_add(x->m_text.te_binbuf, 1, &a);
+     glist_retext(x->m_glist, &x->m_text);
+ }
+ 
  static void message_click(t_message *x,
      t_floatarg xpos, t_floatarg ypos, t_floatarg shift,
***************
*** 1296,1299 ****
--- 1328,1339 ----
      class_addmethod(message_class, (t_method)message_add2, gensym("add2"),
          A_GIMME, 0);
+     class_addmethod(message_class, (t_method)message_addcomma,
+         gensym("addcomma"), 0);
+     class_addmethod(message_class, (t_method)message_addsemi,
+         gensym("addsemi"), 0);
+     class_addmethod(message_class, (t_method)message_adddollar,
+         gensym("adddollar"), A_FLOAT, 0);
+     class_addmethod(message_class, (t_method)message_adddollsym,
+         gensym("adddollsym"), A_SYMBOL, 0);
  
      messresponder_class = class_new(gensym("messresponder"), 0, 0,

Index: makefile.dependencies
===================================================================
RCS file: /cvsroot/pure-data/pd/src/makefile.dependencies,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** makefile.dependencies	16 Jul 2005 01:43:18 -0000	1.6
--- makefile.dependencies	24 Jul 2005 19:41:14 -0000	1.7
***************
*** 891,894 ****
--- 891,902 ----
    /usr/include/unistd.h /usr/include/bits/posix_opt.h \
    /usr/include/bits/confname.h /usr/include/getopt.h
+ x_list.o: x_list.c m_pd.h \
+   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/include/stddef.h \
+   /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \
+   /usr/include/gnu/stubs.h /usr/include/bits/string.h \
+   /usr/include/bits/string2.h /usr/include/endian.h \
+   /usr/include/bits/endian.h /usr/include/bits/types.h \
+   /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \
+   /usr/include/stdlib.h
  d_soundfile.o: d_soundfile.c /usr/include/unistd.h \
    /usr/include/features.h /usr/include/sys/cdefs.h \

Index: u_main.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** u_main.tk	16 Jul 2005 01:43:18 -0000	1.13
--- u_main.tk	24 Jul 2005 19:41:14 -0000	1.14
***************
*** 4008,4015 ****
      }
      if {$alsa} {
!     	label $id.in1f.l1 -text "In Channels:"
      	entry $id.in1f.x1 -textvariable midi_alsain -width 4
          pack $id.in1f.l1 $id.in1f.x1 -side left
! 	label $id.in1f.l2 -text "Out Channels:"
      	entry $id.in1f.x2 -textvariable midi_alsaout -width 4
          pack $id.in1f.l2 $id.in1f.x2 -side left
--- 4008,4015 ----
      }
      if {$alsa} {
!     	label $id.in1f.l1 -text "In Ports:"
      	entry $id.in1f.x1 -textvariable midi_alsain -width 4
          pack $id.in1f.l1 $id.in1f.x1 -side left
! 	label $id.in1f.l2 -text "Out Ports:"
      	entry $id.in1f.x2 -textvariable midi_alsaout -width 4
          pack $id.in1f.l2 $id.in1f.x2 -side left

Index: makefile.nt
===================================================================
RCS file: /cvsroot/pure-data/pd/src/makefile.nt,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** makefile.nt	8 Jul 2005 00:02:44 -0000	1.5
--- makefile.nt	24 Jul 2005 19:41:14 -0000	1.6
***************
*** 35,39 ****
      d_delay.c d_resample.c \
      x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
!     x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \
      $(SYSSRC)
  
--- 35,39 ----
      d_delay.c d_resample.c \
      x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
!     x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c x_list.c d_soundfile.c \
      $(SYSSRC)
  

Index: makefile.in
===================================================================
RCS file: /cvsroot/pure-data/pd/src/makefile.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** makefile.in	25 Jun 2005 02:49:15 -0000	1.7
--- makefile.in	24 Jul 2005 19:41:14 -0000	1.8
***************
*** 43,47 ****
      d_delay.c d_resample.c \
      x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
!     x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \
      $(SYSSRC)
  
--- 43,47 ----
      d_delay.c d_resample.c \
      x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
!     x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c x_list.c d_soundfile.c \
      $(SYSSRC)
  

Index: configure.in
===================================================================
RCS file: /cvsroot/pure-data/pd/src/configure.in,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** configure.in	16 Jul 2005 01:43:18 -0000	1.12
--- configure.in	24 Jul 2005 19:41:14 -0000	1.13
***************
*** 61,65 ****
  AC_FUNC_VPRINTF
  AC_CHECK_FUNCS(gettimeofday select socket strerror)
! 
  
  dnl Checks for libraries.
--- 61,65 ----
  AC_FUNC_VPRINTF
  AC_CHECK_FUNCS(gettimeofday select socket strerror)
! AC_FUNC_ALLOCA
  
  dnl Checks for libraries.
***************
*** 350,353 ****
  fi
  
! AC_OUTPUT(makefile)
  
--- 350,353 ----
  fi
  
! AC_OUTPUT(makefile config.h)
  

Index: makefile
===================================================================
RCS file: /cvsroot/pure-data/pd/src/makefile,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** makefile	16 Jul 2005 01:43:18 -0000	1.14
--- makefile	24 Jul 2005 19:41:14 -0000	1.15
***************
*** 43,47 ****
      d_delay.c d_resample.c \
      x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
!     x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \
      $(SYSSRC)
  
--- 43,47 ----
      d_delay.c d_resample.c \
      x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
!     x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c x_list.c d_soundfile.c \
      $(SYSSRC)
  

Index: notes.txt
===================================================================
RCS file: /cvsroot/pure-data/pd/src/notes.txt,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** notes.txt	16 Jul 2005 01:43:18 -0000	1.15
--- notes.txt	24 Jul 2005 19:41:14 -0000	1.16
***************
*** 17,20 ****
--- 17,24 ----
  ------------ 0.39 ---------
  problems:
+ windows:
+   modal dialogs confuse watchdog
+ mac:
+   .pd extension not added when saving?
  TK commands to nonexistent windows? (maybe fixed)
  array name changes don't show up on parent
***************
*** 22,25 ****
--- 26,30 ----
  what about upsampling inlet~s?  ask Pd list...
  
+ 
  flag for array to suppress printing name
  
***************
*** 41,45 ****
  
  problems:
- modal dialogs confuse watchdog
  patcher inlets don't deal with scalars (zbug.pd)
  Macintosh .pd extension not added to filenames
--- 46,49 ----
***************
*** 71,75 ****
  rename windowname-pd instead of pd-windowname
  fix copyright notices
- update portmusic to latest
  IEM guis to use queued updates
  pixel font sizes
--- 75,78 ----
***************
*** 86,90 ****
  think of a way to embed abstractions in a patch
  make watchdog work for MACOSX
- GOP bounding box object
  IEMGUIs better default font size
  search path to include both calling patch and abstraction, if different
--- 89,92 ----
***************
*** 97,101 ****
  flags to defeat pre-loading specified classes
  expr to parse exponential notation
! 
  
  data:
--- 99,103 ----
  flags to defeat pre-loading specified classes
  expr to parse exponential notation
! pipe to handle symbols&pointers (just takes floats now???)
  
  data:

Index: s_inter.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_inter.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** s_inter.c	16 Jul 2005 01:43:18 -0000	1.10
--- s_inter.c	24 Jul 2005 19:41:14 -0000	1.11
***************
*** 852,856 ****
      int stdinpipe[2];
  #endif
-     fprintf(stderr, "gui; %s\n", guidir);
      /* create an empty FD poll list */
      sys_fdpoll = (t_fdpoll *)t_getbytes(0);
--- 852,855 ----

--- NEW FILE: x_list.c ---
/* Copyright (c) 1997- 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.  */

#include "m_pd.h"
/* #include <string.h> */
#include <alloca.h>
extern t_pd *newest;

#define HAVE_ALLOCA 1   /* LATER this should be set by configure script! */
#define LIST_NGETBYTE 100 /* bigger that this we use alloc, not alloca */

/* the "list" object family.

    list append - append a list to another
    list prepend - prepend a list to another
    list split - first n elements to first outlet, rest to second outlet 
    list strip - send message with leading symbol as selector
    list length - output number of items in list
    list nth - nth item in list, counting from zero

Not sure we need these:
    list cat - build a list by accumulating elements
    list foreach - spit out elements of a list one by one
    list array - get items from a named array as a list
    list reverse - permute elements of a list back to front
    list pack - synonym for 'pack'
    list unpack - synonym for 'unpack'
    list first - output first n elements.
    list last - output last n elements
*/

/* -------------- utility functions: storage, copying  -------------- */
    /* List element for storage.  Keep an atom and, in case it's a pointer,
        an associated 'gpointer' to protect against stale pointers. */
typedef struct _listelem
{
    t_atom l_a;
    t_gpointer l_p;
} t_listelem;

typedef struct _alist
{
    t_pd l_pd;          /* object to point inlets to */
    int l_n;            /* number of items */
    t_listelem *l_vec;  /* pointer to items */
} t_alist;

#if 0 /* probably won't use this version... */
#ifdef HAVE_ALLOCA
#define LIST_ALLOCA(x, n) ( \
    (x).l_n = (n), \
    (x).l_vec = (t_listelem *)((n) < LIST_NGETBYTE ?  \
        alloca((n) * sizeof(t_listelem)) : getbytes((n) * sizeof(t_listelem))))     \
#define LIST_FREEA(x) ( \
    ((x).l_n < LIST_NGETBYTE ||
        (freebytes((x).l_vec, (x).l_n * sizeof(t_listelem)), 0)))

#else
#define LIST_ALLOCA(x, n) ( \
    (x).l_n = (n), \
    (x).l_vec = (t_listelem *)getbytes((n) * sizeof(t_listelem))) 
#define LIST_FREEA(x) (freebytes((x).l_vec, (x).l_n * sizeof(t_listelem)))
#endif
#endif

#if HAVE_ALLOCA
#define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)((n) < LIST_NGETBYTE ?  \
        alloca((n) * sizeof(t_atom)) : getbytes((n) * sizeof(t_atom))))
#define ATOMS_FREEA(x, n) ( \
    ((n) < LIST_NGETBYTE || (freebytes((x), (n) * sizeof(t_atom)), 0)))
#else
#define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)getbytes((n) * sizeof(t_atom)))
#define ATOMS_FREEA(x, n) (freebytes((x), (n) * sizeof(t_atom)))
#endif

static void atoms_copy(int argc, t_atom *from, t_atom *to)
{
    int i;
    for (i = 0; i < argc; i++)
        to[i] = from[i];
}

/* ------------- fake class to divert inlets to ----------------- */

t_class *alist_class;

static void alist_init(t_alist *x)
{
    x->l_pd = alist_class;
    x->l_n = 0;
    x->l_vec = 0;
}

static void alist_clear(t_alist *x)
{
    int i;
    for (i = 0; i < x->l_n; i++)
    {
        if (x->l_vec[i].l_a.a_type == A_POINTER)
            gpointer_unset(x->l_vec[i].l_a.a_w.w_gpointer);
    }
    if (x->l_vec)
        freebytes(x->l_vec, x->l_n * sizeof(*x->l_vec));
}

static void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    alist_clear(x);
    if (!(x->l_vec = (t_listelem *)getbytes(argc * sizeof(*x->l_vec))))
    {
        x->l_n = 0;
        error("list_alloc: out of memory");
        return;
    }
    x->l_n = argc;
    for (i = 0; i < argc; i++)
    {
        x->l_vec[i].l_a = argv[i];
        if (x->l_vec[i].l_a.a_type == A_POINTER)
            gpointer_copy(x->l_vec[i].l_a.a_w.w_gpointer, &x->l_vec[i].l_p);
    }
}

static void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    alist_clear(x);
    if (!(x->l_vec = (t_listelem *)getbytes((argc+1) * sizeof(*x->l_vec))))
    {
        x->l_n = 0;
        error("list_alloc: out of memory");
        return;
    }
    x->l_n = argc+1;
    SETSYMBOL(&x->l_vec[0].l_a, s);
    for (i = 0; i < argc; i++)
    {
        x->l_vec[i+1].l_a = argv[i];
        if (x->l_vec[i+1].l_a.a_type == A_POINTER)
            gpointer_copy(x->l_vec[i+1].l_a.a_w.w_gpointer, &x->l_vec[i+1].l_p);
    }
}

static void alist_toatoms(t_alist *x, t_atom *to)
{
    int i;
    for (i = 0; i < x->l_n; i++)
        to[i] = x->l_vec[i].l_a;
}

static void alist_setup(void)
{
    alist_class = class_new(gensym("list inlet"),
        0, 0, sizeof(t_alist), 0, 0);
    class_addlist(alist_class, alist_list);
    class_addanything(alist_class, alist_anything);
}

/* ------------- list append --------------------- */

t_class *list_append_class;

typedef struct _list_append
{
    t_object x_obj;
    t_alist x_alist;
} t_list_append;

static void *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->x_alist);
    alist_list(&x->x_alist, 0, argc, argv);
    outlet_new(&x->x_obj, &s_list);
    inlet_new(&x->x_obj, &x->x_alist.l_pd, 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 n, outc = x->x_alist.l_n + argc;
    ATOMS_ALLOCA(outv, outc);
    atoms_copy(argc, argv, outv);
    alist_toatoms(&x->x_alist, outv+argc);
    outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
    ATOMS_FREEA(outv, outc);
}

static void list_append_anything(t_list_append *x, t_symbol *s,
    int argc, t_atom *argv)
{
    t_atom *outv;
    int n, outc = x->x_alist.l_n + argc + 1;
    ATOMS_ALLOCA(outv, outc);
    SETSYMBOL(outv, s);
    atoms_copy(argc, argv, outv + 1);
    alist_toatoms(&x->x_alist, outv + 1 + argc);
    outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
    ATOMS_FREEA(outv, outc);
}

static void list_append_free(t_list_append *x)
{
    alist_clear(&x->x_alist);
}

static void list_append_setup(void)
{
    list_append_class = class_new(gensym("list append"),
        (t_newmethod)list_append_new, (t_method)list_append_free,
        sizeof(t_list_append), 0, A_GIMME, 0);
    class_addlist(list_append_class, list_append_list);
    class_addanything(list_append_class, list_append_anything);
    class_sethelpsymbol(list_append_class, &s_list);
}

/* ------------- list prepend --------------------- */

t_class *list_prepend_class;

typedef struct _list_prepend
{
    t_object x_obj;
    t_alist x_alist;
} t_list_prepend;

static void *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->x_alist);
    alist_list(&x->x_alist, 0, argc, argv);
    outlet_new(&x->x_obj, &s_list);
    inlet_new(&x->x_obj, &x->x_alist.l_pd, 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 n, outc = x->x_alist.l_n + argc;
    ATOMS_ALLOCA(outv, outc);
    alist_toatoms(&x->x_alist, outv);
    atoms_copy(argc, argv, outv + x->x_alist.l_n);
    outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
    ATOMS_FREEA(outv, outc);
}

static void list_prepend_anything(t_list_prepend *x, t_symbol *s,
    int argc, t_atom *argv)
{
    t_atom *outv;
    int n, outc = x->x_alist.l_n + argc + 1;
    ATOMS_ALLOCA(outv, outc);
    alist_toatoms(&x->x_alist, outv);
    SETSYMBOL(outv + x->x_alist.l_n, s);
    atoms_copy(argc, argv, outv + x->x_alist.l_n + 1);
    outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
    ATOMS_FREEA(outv, outc);
}

static void list_prepend_free(t_list_prepend *x)
{
    alist_clear(&x->x_alist);
}

static void list_prepend_setup(void)
{
    list_prepend_class = class_new(gensym("list prepend"),
        (t_newmethod)list_prepend_new, (t_method)list_prepend_free,
        sizeof(t_list_prepend), 0, A_GIMME, 0);
    class_addlist(list_prepend_class, list_prepend_list);
    class_addanything(list_prepend_class, list_prepend_anything);
    class_sethelpsymbol(list_prepend_class, &s_list);
}

/* ------------- list split --------------------- */

t_class *list_split_class;

typedef struct _list_split
{
    t_object x_obj;
    t_float x_f;
    t_outlet *x_out1;
    t_outlet *x_out2;
    t_outlet *x_out3;
} t_list_split;

static void *list_split_new(t_floatarg f)
{
    t_list_split *x = (t_list_split *)pd_new(list_split_class);
    x->x_out1 = outlet_new(&x->x_obj, &s_list);
    x->x_out2 = outlet_new(&x->x_obj, &s_list);
    x->x_out3 = outlet_new(&x->x_obj, &s_list);
    floatinlet_new(&x->x_obj, &x->x_f);
    x->x_f = f;
    return (x);
}

static void list_split_list(t_list_split *x, t_symbol *s,
    int argc, t_atom *argv)
{
    int n = x->x_f;
    if (n < 0)
        n = 0;
    if (argc >= n)
    {
        outlet_list(x->x_out2, &s_list, argc-n, argv+n);
        outlet_list(x->x_out1, &s_list, n, argv);
    }
    else outlet_list(x->x_out3, &s_list, argc, argv);
}

static void list_split_anything(t_list_split *x, t_symbol *s,
    int argc, t_atom *argv)
{
    t_atom *outv;
    ATOMS_ALLOCA(outv, argc+1);
    SETSYMBOL(outv, s);
    atoms_copy(argc, argv, outv + 1);
    list_split_list(x, &s_list, argc+1, outv);
    ATOMS_FREEA(outv, argc+1);
}

static void list_split_setup(void)
{
    list_split_class = class_new(gensym("list split"),
        (t_newmethod)list_split_new, 0,
        sizeof(t_list_split), 0, A_DEFFLOAT, 0);
    class_addlist(list_split_class, list_split_list);
    class_addanything(list_split_class, list_split_anything);
    class_sethelpsymbol(list_split_class, &s_list);
}

/* ------------- list trim --------------------- */

t_class *list_trim_class;

typedef struct _list_trim
{
    t_object x_obj;
} t_list_trim;

static void *list_trim_new( void)
{
    t_list_trim *x = (t_list_trim *)pd_new(list_trim_class);
    outlet_new(&x->x_obj, &s_list);
    return (x);
}

static void list_trim_list(t_list_trim *x, t_symbol *s,
    int argc, t_atom *argv)
{
    if (argc < 1 || argv[0].a_type != A_SYMBOL)
        outlet_list(x->x_obj.ob_outlet, &s_list, argc, argv);
    else outlet_anything(x->x_obj.ob_outlet, argv[0].a_w.w_symbol,
        argc-1, argv+1);
}

static void list_trim_anything(t_list_trim *x, t_symbol *s,
    int argc, t_atom *argv)
{
    outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
}

static void list_trim_setup(void)
{
    list_trim_class = class_new(gensym("list trim"),
        (t_newmethod)list_trim_new, 0,
        sizeof(t_list_trim), 0, 0);
    class_addlist(list_trim_class, list_trim_list);
    class_addanything(list_trim_class, list_trim_anything);
    class_sethelpsymbol(list_trim_class, &s_list);
}

/* ------------- list ------------------- */

static void *list_new(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
{
    if (!argc || argv[0].a_type != A_SYMBOL)
        newest = list_append_new(s, argc, argv);
    else
    {
        t_symbol *s2 = argv[0].a_w.w_symbol;
        if (s2 == gensym("append"))
            newest = list_append_new(s, argc-1, argv+1);
        else if (s2 == gensym("prepend"))
            newest = list_prepend_new(s, argc-1, argv+1);
         else if (s2 == gensym("split"))
            newest = list_split_new(atom_getfloatarg(1, argc, argv));
         else if (s2 == gensym("trim"))
            newest = list_trim_new();
        else 
        {
            error("list %s: unknown function", s2->s_name);
            newest = 0;
        }
    }
    return (newest);
}

void x_list_setup(void)
{
    alist_setup();
    list_append_setup();
    list_prepend_setup();
    list_split_setup();
    list_trim_setup();
    class_addcreator((t_newmethod)list_new, &s_list, A_GIMME, 0);
}

Index: s_midi_alsa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_midi_alsa.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** s_midi_alsa.c	16 Jul 2005 01:43:18 -0000	1.2
--- s_midi_alsa.c	24 Jul 2005 19:41:14 -0000	1.3
***************
*** 49,52 ****
--- 49,62 ----
      alsa_nmidiin = 0;
      alsa_nmidiout = 0;
+     if(nmidiin>MAXMIDIINDEV )
+       {
+         post("midi input ports reduced to maximum %d", MAXMIDIINDEV);
+         nmidiin=MAXMIDIINDEV;
+       }
+     if(nmidiout>MAXMIDIOUTDEV)
+       {
+         post("midi output ports reduced to maximum %d", MAXMIDIOUTDEV);
+         nmidiout=MAXMIDIOUTDEV;
+       }
  
      if (nmidiin>0 && nmidiout>0)
***************
*** 201,206 ****
  {
      alsa_nmidiin = alsa_nmidiout = 0;
!     snd_seq_close(midi_handle);
!     snd_midi_event_free(midiev);
  }
  
--- 211,222 ----
  {
      alsa_nmidiin = alsa_nmidiout = 0;
!     if(midi_handle)
!       {
!         snd_seq_close(midi_handle);
!         if(midiev)
!           {
!             snd_midi_event_free(midiev);
!           }
!       }
  }
  

Index: m_conf.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_conf.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -C2 -d -r1.1.1.3 -r1.2
*** m_conf.c	9 May 2003 16:03:43 -0000	1.1.1.3
--- m_conf.c	24 Jul 2005 19:41:14 -0000	1.2
***************
*** 38,41 ****
--- 38,42 ----
  void x_qlist_setup(void);
  void x_gui_setup(void);
+ void x_list_setup(void);
  void d_arithmetic_setup(void);
  void d_array_setup(void);
***************
*** 84,87 ****
--- 85,89 ----
      x_qlist_setup();
      x_gui_setup();
+     x_list_setup();
      d_arithmetic_setup();
      d_array_setup();

Index: x_connective.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/x_connective.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** x_connective.c	16 Jul 2005 01:43:18 -0000	1.6
--- x_connective.c	24 Jul 2005 19:41:15 -0000	1.7
***************
*** 506,514 ****
      {
          float f;
!         if (!argc)  /* empty lists go out reject outlet */
!         {
!             outlet_bang(x->x_rejectout);
!             return;
!         }
          f = atom_getfloat(argv);
          for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
--- 506,510 ----
      {
          float f;
!         if (!argc) return;
          f = atom_getfloat(argv);
          for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++)
***************
*** 585,590 ****
      int n;
      t_routeelement *e;
!     t_route *x;
!     
      t_atom a;
      if (argc == 0)
--- 581,585 ----
      int n;
      t_routeelement *e;
!     t_route *x = (t_route *)pd_new(route_class);
      t_atom a;
      if (argc == 0)
***************
*** 594,604 ****
          argv = &a;
      }
-     for (n = 1; n < argc; n++)
-         if (argv[n].a_type != argv[0].a_type)
-     {
-         error("route: creation with mixed argument types failed");
-         return (0);
-     }
-     x = (t_route *)pd_new(route_class);
      x->x_type = argv[0].a_type;
      x->x_nelement = argc;
--- 589,592 ----





More information about the Pd-cvs mailing list