Commit fb67c5b5 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'list-store'

parents 606d4482 88cb3664
...@@ -12,18 +12,16 @@ BUILDLAYOUT_DIR = $(cvs_root_dir)/packages ...@@ -12,18 +12,16 @@ BUILDLAYOUT_DIR = $(cvs_root_dir)/packages
include $(BUILDLAYOUT_DIR)/Makefile.buildlayout include $(BUILDLAYOUT_DIR)/Makefile.buildlayout
# if machine has dpkg-deb, build a Debian package # if machine has dpkg-deb, build a Debian package
#ifeq ($(shell test -x /usr/bin/dpkg-deb && echo YES),YES) ifeq ($(shell test -x /usr/bin/dpkg-deb && echo YES),YES)
# PACKAGE_TYPE = deb PACKAGE_TYPE = deb
#else else
# PACKAGE_TYPE = tarbz2 PACKAGE_TYPE = tarbz2
#endif endif
# for command-line UNIX versions, you need to install Pd into the same # for command-line UNIX versions, you need to install Pd into the same
# directory as $(prefix) otherwise Pd won't be able to find extra, doc, etc. # directory as $(prefix) otherwise Pd won't be able to find extra, doc, etc.
ifeq ($(PACKAGE_TYPE),deb) ifeq ($(PACKAGE_TYPE),deb)
prefix = /usr prefix = /usr
# generates the dependencies for all externals and pd itself
PACKAGE_DEPENDS := $(shell find $(DESTDIR) \( -name "*.pd_linux" -or -name pd-gui -or -wholename \*bin/pd \) -print0 | xargs -0 dpkg-shlibdeps -O | sed 's|shlibs:Depends=|, |' )
else else
prefix = /usr/local prefix = /usr/local
endif endif
...@@ -160,6 +158,9 @@ deb: debstage ...@@ -160,6 +158,9 @@ deb: debstage
cp $(packages_src)/linux_make/debian/control $(DESTDIR)/DEBIAN cp $(packages_src)/linux_make/debian/control $(DESTDIR)/DEBIAN
cp $(packages_src)/linux_make/debian/pd-l2ork.postrm $(DESTDIR)/DEBIAN cp $(packages_src)/linux_make/debian/pd-l2ork.postrm $(DESTDIR)/DEBIAN
cp $(packages_src)/linux_make/debian/pd-l2ork.postinst $(DESTDIR)/DEBIAN cp $(packages_src)/linux_make/debian/pd-l2ork.postinst $(DESTDIR)/DEBIAN
# generate the dependencies for all externals and pd itself
$(eval PACKAGE_DEPENDS := $(shell find $(DESTDIR) \( -name "*.pd_linux" -or -name pd-gui -or -wholename \*bin/pd \) -print0 | xargs -0 dpkg-shlibdeps -O | sed 's|shlibs:Depends=|, |' ))
# set build architecture and version for the package # set build architecture and version for the package
sed -i 's|^Version:.*|Version: $(DEB_PD_VERSION)|' \ sed -i 's|^Version:.*|Version: $(DEB_PD_VERSION)|' \
$(DESTDIR)/DEBIAN/control $(DESTDIR)/DEBIAN/control
...@@ -279,7 +280,7 @@ test_locations: ...@@ -279,7 +280,7 @@ test_locations:
@echo "EXAMPLESDIR $(examplesdir)" @echo "EXAMPLESDIR $(examplesdir)"
@echo -------------------------------------------------- @echo --------------------------------------------------
# @echo "PACKAGE_DEPENDS $(PACKAGE_DEPENDS)" # @echo "PACKAGE_DEPENDS $(PACKAGE_DEPENDS)"
# @echo -------------------------------------------------- @echo --------------------------------------------------
autoconf --version autoconf --version
@echo -------------------------------------------------- @echo --------------------------------------------------
make --version make --version
......
...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu> ...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu>
Homepage: http://l2ork.music.vt.edu Homepage: http://l2ork.music.vt.edu
Package: pd-l2ork Package: pd-l2ork
Architecture: i386 Architecture: i386
Depends: libc6, xterm | x-terminal-emulator, libasound2, libjack-jackd2-0, libbluetooth3, libgl1-mesa-glx, libgl1-mesa-dri, libglu1-mesa, libftgl2, libgmerlin0, libgmerlin-avdec1, libavifile-0.7c2, libmpeg3-1 | libmpeg3-2, libquicktime2, libv4l-0, libraw1394-11, libdc1394-22, libfftw3-3, libvorbis0a, libmp3lame0, libspeex1, libgsl0ldbl | libgsl2, python, libsmpeg0, libjpeg62, libflite1, libgsm1, libxv1, fluid-soundfont-gm, byacc Depends: python, fluid-soundfont-gm
Provides: pd-l2ork Provides: pd-l2ork
Installed-Size: 90624 Installed-Size: 90624
Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2 Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2
......
...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu> ...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu>
Homepage: http://l2ork.music.vt.edu Homepage: http://l2ork.music.vt.edu
Package: pd-l2ork Package: pd-l2ork
Architecture: i386 Architecture: i386
Depends: libc6, xterm | x-terminal-emulator, libasound2, libjack-jackd2-0, libbluetooth3, libgl1-mesa-glx, libgl1-mesa-dri, libglu1-mesa, libftgl2, libgmerlin0, libgmerlin-avdec1, libavifile-0.7c2, libmpeg3-1 | libmpeg3-2, libquicktime2, libv4l-0, libraw1394-11, libdc1394-22, libfftw3-3, libvorbis0a, libmp3lame0, libspeex1, libgsl0ldbl | libgsl2, python, libsmpeg0, libjpeg62, libflite1, libgsm1, libxv1, fluid-soundfont-gm, byacc Depends: python, fluid-soundfont-gm
Provides: pd-l2ork Provides: pd-l2ork
Installed-Size: 90624 Installed-Size: 90624
Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2 Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2
......
...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu> ...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu>
Homepage: http://l2ork.music.vt.edu Homepage: http://l2ork.music.vt.edu
Package: pd-l2ork Package: pd-l2ork
Architecture: i386 Architecture: i386
Depends: xterm | x-terminal-emulator, libasound2, libjack-jackd2-0, libbluetooth3, libgl1-mesa-glx, libglu1-mesa, libftgl2, libgmerlin0, libgmerlin-avdec1, libavifile-0.7c2, libmpeg3-1 | libmpeg3-2, libquicktime2, libv4l-0, libraw1394-11, libdc1394-22, libfftw3-3, libvorbis0a, libmp3lame0, libspeex1, libgsl0ldbl, python, libsmpeg0, libjpeg62, tkpng, libflite1, libgsm1, libxv1, fluid-soundfont-gm, byacc Depends: python, fluid-soundfont-gm
Provides: pd-l2ork Provides: pd-l2ork
Installed-Size: 90624 Installed-Size: 90624
Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2 Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2
......
...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu> ...@@ -6,7 +6,7 @@ Maintainer: Ivica Ico Bukvic <ico@vt.edu>
Homepage: http://l2ork.music.vt.edu Homepage: http://l2ork.music.vt.edu
Package: pd-l2ork Package: pd-l2ork
Architecture: i386 Architecture: i386
Depends: xterm | x-terminal-emulator, libc6 (>= 2.1.5), libasound2, libjack-jackd2-0, libbluetooth3, libgl1-mesa-glx, libgl1-mesa-dri, libglu1-mesa, libglew1.5, libmagick++4, libftgl2, libgmerlin0, libgmerlin-avdec1, libavifile-0.7c2, libmpeg3-1, libquicktime2, libv4l-0, libraw1394-11, libdc1394-22, libfftw3-3, libvorbis0a, libmp3lame0, libspeex1, libgsl0ldbl, python, libsmpeg0, libjpeg62, libflite1, libgsm1 Depends: python, fluid-soundfont-gm
Provides: pd-l2ork Provides: pd-l2ork
Installed-Size: 90624 Installed-Size: 90624
Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2 Recommends: xdg-utils, pulseaudio-utils, tap-plugins, ladspa-foo-plugins, invada-studio-plugins-ladspa, blepvco, swh-plugins, mcp-plugins, cmt, blop, slv2-jack, omins, ubuntustudio-audio-plugins, rev-plugins, dssi-utils, vco-plugins, wah-plugins, fil-plugins, mda-lv2
......
...@@ -46,7 +46,7 @@ void sys_doflags( void); ...@@ -46,7 +46,7 @@ void sys_doflags( void);
#ifdef UNIX #ifdef UNIX
#define USER_CONFIG_DIR ".pd-l2ork" #define USER_CONFIG_DIR ".purr-data"
static char *sys_prefbuf; static char *sys_prefbuf;
......
...@@ -440,7 +440,7 @@ EXTERN void alist_init(t_alist *x); ...@@ -440,7 +440,7 @@ EXTERN void alist_init(t_alist *x);
EXTERN void alist_clear(t_alist *x); EXTERN void alist_clear(t_alist *x);
EXTERN void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv); EXTERN void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv);
EXTERN void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv); EXTERN void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv);
EXTERN void alist_toatoms(t_alist *x, t_atom *to); EXTERN void alist_toatoms(t_alist *x, t_atom *to, int onset, int count);
EXTERN void alist_clone(t_alist *x, t_alist *y); EXTERN void alist_clone(t_alist *x, t_alist *y, int onset, int count);
#endif /* __s_stuff_h_ */ #endif /* __s_stuff_h_ */
...@@ -79,21 +79,33 @@ void alist_init(t_alist *x) ...@@ -79,21 +79,33 @@ void alist_init(t_alist *x)
void alist_clear(t_alist *x) void alist_clear(t_alist *x)
{ {
if (x->l_n) int i;
for (i = 0; i < x->l_n; i++)
{ {
int i; if (x->l_vec[i].l_a.a_type == A_POINTER)
for (i = 0; i < x->l_n; i++) 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_copyin(t_alist *x, t_symbol *s, int argc, t_atom *argv,
int where)
{
int i, j;
for (i = 0, j = where; i < argc; i++, j++)
{
x->l_vec[j].l_a = argv[i];
if (x->l_vec[j].l_a.a_type == A_POINTER)
{ {
if (x->l_vec[i].l_a.a_type == A_POINTER) x->l_npointer++;
gpointer_unset(x->l_vec[i].l_a.a_w.w_gpointer); gpointer_copy(x->l_vec[j].l_a.a_w.w_gpointer, &x->l_vec[j].l_p);
x->l_vec[j].l_a.a_w.w_gpointer = &x->l_vec[j].l_p;
} }
if (x->l_vec)
freebytes(x->l_vec, x->l_n * sizeof(*x->l_vec));
} }
x->l_n = 0;
x->l_npointer = 0;
} }
/* set contents to a list */
void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv) void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv)
{ {
int i; int i;
...@@ -118,6 +130,7 @@ void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv) ...@@ -118,6 +130,7 @@ void alist_list(t_alist *x, t_symbol *s, int argc, t_atom *argv)
} }
} }
/* set contents to an arbitrary non-list message */
void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv) void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv)
{ {
int i; int i;
...@@ -143,32 +156,32 @@ void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv) ...@@ -143,32 +156,32 @@ void alist_anything(t_alist *x, t_symbol *s, int argc, t_atom *argv)
} }
} }
void alist_toatoms(t_alist *x, t_atom *to) void alist_toatoms(t_alist *x, t_atom *to, int onset, int count)
{ {
int i; int i;
for (i = 0; i < x->l_n; i++) for (i = 0; i < count; i++)
to[i] = x->l_vec[i].l_a; to[i] = x->l_vec[onset + i].l_a;
} }
void alist_clone(t_alist *x, t_alist *y, int onset, int count)
void alist_clone(t_alist *x, t_alist *y)
{ {
int i; int i;
y->l_pd = alist_class; y->l_pd = alist_class;
y->l_n = x->l_n; y->l_n = count;
y->l_npointer = x->l_npointer; y->l_npointer = 0;
if (!(y->l_vec = (t_listelem *)getbytes(y->l_n * sizeof(*y->l_vec)))) if (!(y->l_vec = (t_listelem *)getbytes(y->l_n * sizeof(*y->l_vec))))
{ {
y->l_n = 0; y->l_n = 0;
error("list_alloc: out of memory"); error("list_alloc: out of memory");
} }
else for (i = 0; i < x->l_n; i++) else for (i = 0; i < count; i++)
{ {
y->l_vec[i].l_a = x->l_vec[i].l_a; y->l_vec[i].l_a = x->l_vec[onset + i].l_a;
if (y->l_vec[i].l_a.a_type == A_POINTER) if (y->l_vec[i].l_a.a_type == A_POINTER)
{ {
gpointer_copy(y->l_vec[i].l_a.a_w.w_gpointer, &y->l_vec[i].l_p); gpointer_copy(y->l_vec[i].l_a.a_w.w_gpointer, &y->l_vec[i].l_p);
y->l_vec[i].l_a.a_w.w_gpointer = &y->l_vec[i].l_p; y->l_vec[i].l_a.a_w.w_gpointer = &y->l_vec[i].l_p;
y->l_npointer++;
} }
} }
} }
...@@ -205,20 +218,22 @@ static void list_append_list(t_list_append *x, t_symbol *s, ...@@ -205,20 +218,22 @@ static void list_append_list(t_list_append *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
t_atom *outv; t_atom *outv;
int outc = x->x_alist.l_n + argc; int n, outc;
n = x->x_alist.l_n;
outc = n + argc;
XL_ATOMS_ALLOCA(outv, outc); XL_ATOMS_ALLOCA(outv, outc);
atoms_copy(argc, argv, outv); atoms_copy(argc, argv, outv);
if (x->x_alist.l_npointer) if (x->x_alist.l_npointer)
{ {
t_alist y; t_alist y;
alist_clone(&x->x_alist, &y); alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv+argc); alist_toatoms(&y, outv+argc, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
alist_clear(&y); alist_clear(&y);
} }
else else
{ {
alist_toatoms(&x->x_alist, outv+argc); alist_toatoms(&x->x_alist, outv+argc, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
} }
XL_ATOMS_FREEA(outv, outc); XL_ATOMS_FREEA(outv, outc);
...@@ -228,21 +243,23 @@ static void list_append_anything(t_list_append *x, t_symbol *s, ...@@ -228,21 +243,23 @@ static void list_append_anything(t_list_append *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
t_atom *outv; t_atom *outv;
int outc = x->x_alist.l_n + argc + 1; int n, outc;
n = x->x_alist.l_n;
outc = n + argc + 1;
XL_ATOMS_ALLOCA(outv, outc); XL_ATOMS_ALLOCA(outv, outc);
SETSYMBOL(outv, s); SETSYMBOL(outv, s);
atoms_copy(argc, argv, outv + 1); atoms_copy(argc, argv, outv + 1);
if (x->x_alist.l_npointer) if (x->x_alist.l_npointer)
{ {
t_alist y; t_alist y;
alist_clone(&x->x_alist, &y); alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv + 1 + argc); alist_toatoms(&y, outv + 1 + argc, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
alist_clear(&y); alist_clear(&y);
} }
else else
{ {
alist_toatoms(&x->x_alist, outv + 1 + argc); alist_toatoms(&x->x_alist, outv + 1 + argc, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
} }
XL_ATOMS_FREEA(outv, outc); XL_ATOMS_FREEA(outv, outc);
...@@ -309,20 +326,22 @@ static void list_cat_list(t_list_cat *x, t_symbol *s, ...@@ -309,20 +326,22 @@ static void list_cat_list(t_list_cat *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
t_atom *outv; t_atom *outv;
int outc = x->x_alist.l_n + argc; int n, outc;
n = x->x_alist.l_n;
outc = n + argc;
XL_ATOMS_ALLOCA(outv, outc); XL_ATOMS_ALLOCA(outv, outc);
atoms_copy(argc, argv, outv + x->x_alist.l_n); atoms_copy(argc, argv, outv + x->x_alist.l_n);
if (x->x_alist.l_npointer) if (x->x_alist.l_npointer)
{ {
t_alist y; t_alist y;
alist_clone(&x->x_alist, &y); alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv); alist_toatoms(&y, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
alist_clear(&y); alist_clear(&y);
} }
else else
{ {
alist_toatoms(&x->x_alist, outv); alist_toatoms(&x->x_alist, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
} }
alist_list(&x->x_alist, s, outc, outv); alist_list(&x->x_alist, s, outc, outv);
...@@ -333,21 +352,23 @@ static void list_cat_anything(t_list_cat *x, t_symbol *s, ...@@ -333,21 +352,23 @@ static void list_cat_anything(t_list_cat *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
t_atom *outv; t_atom *outv;
int outc = x->x_alist.l_n + argc + 1; int n, outc;
n = x->x_alist.l_n;
outc = n + argc + 1;
XL_ATOMS_ALLOCA(outv, outc); XL_ATOMS_ALLOCA(outv, outc);
SETSYMBOL(outv + x->x_alist.l_n, s); SETSYMBOL(outv + x->x_alist.l_n, s);
atoms_copy(argc, argv, outv + x->x_alist.l_n + 1); atoms_copy(argc, argv, outv + x->x_alist.l_n + 1);
if (x->x_alist.l_npointer) if (x->x_alist.l_npointer)
{ {
t_alist y; t_alist y;
alist_clone(&x->x_alist, &y); alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv); alist_toatoms(&y, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
alist_clear(&y); alist_clear(&y);
} }
else else
{ {
alist_toatoms(&x->x_alist, outv); alist_toatoms(&x->x_alist, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
} }
if (x->x_alist.l_n <= 1) if (x->x_alist.l_n <= 1)
...@@ -406,20 +427,22 @@ static void list_prepend_list(t_list_prepend *x, t_symbol *s, ...@@ -406,20 +427,22 @@ static void list_prepend_list(t_list_prepend *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
t_atom *outv; t_atom *outv;
int outc = x->x_alist.l_n + argc; int n, outc;
n = x->x_alist.l_n;
outc = n + argc;
XL_ATOMS_ALLOCA(outv, outc); XL_ATOMS_ALLOCA(outv, outc);
atoms_copy(argc, argv, outv + x->x_alist.l_n); atoms_copy(argc, argv, outv + n);
if (x->x_alist.l_npointer) if (x->x_alist.l_npointer)
{ {
t_alist y; t_alist y;
alist_clone(&x->x_alist, &y); alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv); alist_toatoms(&y, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
alist_clear(&y); alist_clear(&y);
} }
else else
{ {
alist_toatoms(&x->x_alist, outv); alist_toatoms(&x->x_alist, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
} }
XL_ATOMS_FREEA(outv, outc); XL_ATOMS_FREEA(outv, outc);
...@@ -431,21 +454,23 @@ static void list_prepend_anything(t_list_prepend *x, t_symbol *s, ...@@ -431,21 +454,23 @@ static void list_prepend_anything(t_list_prepend *x, t_symbol *s,
int argc, t_atom *argv) int argc, t_atom *argv)
{ {
t_atom *outv; t_atom *outv;
int outc = x->x_alist.l_n + argc + 1; int n, outc;
n = x->x_alist.l_n;
outc = n + argc + 1;
XL_ATOMS_ALLOCA(outv, outc); XL_ATOMS_ALLOCA(outv, outc);
SETSYMBOL(outv + x->x_alist.l_n, s); SETSYMBOL(outv + n, s);
atoms_copy(argc, argv, outv + x->x_alist.l_n + 1); atoms_copy(argc, argv, outv + n + 1);
if (x->x_alist.l_npointer) if (x->x_alist.l_npointer)
{ {
t_alist y; t_alist y;
alist_clone(&x->x_alist, &y); alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv); alist_toatoms(&y, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
alist_clear(&y); alist_clear(&y);
} }
else else
{ {
alist_toatoms(&x->x_alist, outv); alist_toatoms(&x->x_alist, outv, 0, n);
outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv); outlet_list(x->x_obj.ob_outlet, &s_list, outc, outv);
} }
XL_ATOMS_FREEA(outv, outc); XL_ATOMS_FREEA(outv, outc);
...@@ -468,6 +493,162 @@ static void list_prepend_setup(void) ...@@ -468,6 +493,162 @@ static void list_prepend_setup(void)
} }
/* ------------- list store --------------------- */
t_class *list_store_class;
typedef struct _list_store
{
t_object x_obj;
t_alist x_alist;
t_outlet *x_out1;
t_outlet *x_out2;
} t_list_store;
static void *list_store_new(t_symbol *s, int argc, t_atom *argv)
{
t_list_store *x = (t_list_store *)pd_new(list_store_class);
alist_init(&x->x_alist);
alist_list(&x->x_alist, 0, argc, argv);
x->x_out1 = outlet_new(&x->x_obj, &s_list);
x->x_out2 = outlet_new(&x->x_obj, &s_bang);
inlet_new(&x->x_obj, &x->x_alist.l_pd, 0, 0);
return (x);
}
static void list_store_list(t_list_store *x, t_symbol *s,
int argc, t_atom *argv)
{
t_atom *outv;
int n, outc;
n = x->x_alist.l_n;
outc = n + argc;
ATOMS_ALLOCA(outv, outc);
atoms_copy(argc, argv, outv);
if (x->x_alist.l_npointer)
{
t_alist y;
alist_clone(&x->x_alist, &y, 0, n);
alist_toatoms(&y, outv+argc, 0, n);
outlet_list(x->x_out1, &s_list, outc, outv);
alist_clear(&y);
}
else
{
alist_toatoms(&x->x_alist, outv+argc, 0, n);
outlet_list(x->x_out1, &s_list, outc, outv);
}
ATOMS_FREEA(outv, outc);
}
/* function to restore gpointers after the list has moved in memory */
static void list_store_restore_gpointers(t_list_store *x, int offset, int count)
{
t_listelem *vec = x->x_alist.l_vec + offset;
while (count--)
{
if (vec->l_a.a_type == A_POINTER)
vec->l_a.a_w.w_gpointer = &vec->l_p;
vec++;
}
}
static void list_store_append(t_list_store *x, t_symbol *s,
int argc, t_atom *argv)
{
t_listelem *oldptr = x->x_alist.l_vec;
if (!(x->x_alist.l_vec = (t_listelem *)resizebytes(x->x_alist.l_vec,
(x->x_alist.l_n) * sizeof(*x->x_alist.l_vec),
(x->x_alist.l_n + argc) * sizeof(*x->x_alist.l_vec))))
{
x->x_alist.l_n = 0;
error("list: out of memory");
return;
}
/* fix gpointers if resizebytes() has moved the alist in memory */
if (x->x_alist.l_vec != oldptr && x->x_alist.l_npointer)
list_store_restore_gpointers(x, 0, x->x_alist.l_n);
alist_copyin(&x->x_alist, s, argc, argv, x->x_alist.l_n);
x->x_alist.l_n += argc;
}
static void list_store_prepend(t_list_store *x, t_symbol *s,
int argc, t_atom *argv)
{