From 4d68d5d045b975d50adba6bf40fa63264a7224b9 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Mon, 3 Jan 2005 18:01:32 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r2456, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/tb/; revision=2457 --- join/README | 6 +++ join/join.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ join/makefile | 94 +++++++++++++++++++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 join/README create mode 100644 join/join.c create mode 100644 join/makefile (limited to 'join') diff --git a/join/README b/join/README new file mode 100644 index 0000000..5175792 --- /dev/null +++ b/join/README @@ -0,0 +1,6 @@ +the message to the inlet will be sent to the outlet during the +next idle callback of the scheduler. it doesn't matter, which thread the +message was coming from. messages from the main pd thread will be +rescheduled. + +requirement: pd>=devel_0_38 \ No newline at end of file diff --git a/join/join.c b/join/join.c new file mode 100644 index 0000000..fd7b5ad --- /dev/null +++ b/join/join.c @@ -0,0 +1,155 @@ +/* +* +* detatch +* Copyright (C) 2005 Tim Blechmann +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; see the file COPYING. If not, write to +* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +*/ + +#include "m_pd.h" + +static t_class *join_class; + +typedef struct _join +{ + t_object x_obj; + t_outlet * x_outlet; +} join_t; + + +static join_t * join_new(void) +{ + join_t *x = (join_t*) pd_new(join_class); + + x->x_outlet = outlet_new(&x->x_obj, NULL); + return x; +} + + +static t_int join_bang_callback(t_int * argv) +{ + outlet_bang((t_outlet*)argv[0]); + return 0; +} + +static void join_bang(join_t * x) +{ + t_int* argv = getbytes(sizeof(t_int*)); + argv[0] = (t_int)x->x_outlet; + set_callback(join_bang_callback, argv, 1); +} + + +static t_int join_pointer_callback(t_int * argv) +{ + outlet_pointer((t_outlet*)argv[0], (t_gpointer*)argv[1]); + return 0; +} + +static void join_pointer(join_t * x, t_gpointer * gp) +{ + t_int* argv = getbytes(2*sizeof(t_int*)); + argv[0] = (t_int)x->x_outlet; + argv[1] = (t_int)gp; + + set_callback(join_pointer_callback, argv, 2); +} + + +static t_int join_float_callback(t_int * argv) +{ + outlet_float((t_outlet*)argv[0], (t_float)argv[1]); + return 0; +} + +static void join_float(join_t * x, t_float f) +{ + t_int* argv = getbytes(2*sizeof(t_int*)); + argv[0] = (t_int)x->x_outlet; + argv[1] = (t_int)f; + + set_callback(join_float_callback, argv, 2); +} + + +static t_int join_symbol_callback(t_int * argv) +{ + outlet_symbol((t_outlet*)argv[0], (t_symbol*)argv[1]); + return 0; +} + +static void join_symbol(join_t * x, t_symbol * s) +{ + t_int* argv = getbytes(2*sizeof(t_int*)); + argv[0] = (t_int)x->x_outlet; + argv[1] = (t_int)s; + + set_callback(join_symbol_callback, argv, 2); +} + +static t_int join_list_callback(t_int * argv) +{ + outlet_list((t_outlet*)argv[0], 0, (int)argv[1], (t_atom*)argv[2]); + freebytes ((t_atom*)argv[2], (int)argv[1] * sizeof(t_atom)); + return 0; +} + +static void join_list(join_t * x, t_symbol * s, int argc, t_atom* largv) +{ + t_int* argv = getbytes(3*sizeof(t_int*)); + t_atom* copied_argv = copybytes(largv, argc * sizeof(t_atom)); + + argv[0] = (t_int)x->x_outlet; + argv[1] = (t_int)argc; + argv[2] = (t_int)copied_argv; + + set_callback(join_list_callback, argv, 3); +} + + +static t_int join_anything_callback(t_int * argv) +{ + outlet_anything((t_outlet*)argv[0], &s_list, + (int)argv[1], (t_atom*)argv[2]); + freebytes ((t_atom*)argv[2], (int)argv[1] * sizeof(t_atom)); + return 0; +} + +static void join_anything(join_t * x, t_symbol * s, int argc, t_atom* largv) +{ + t_int* argv = getbytes(3*sizeof(t_int*)); + t_atom* copied_argv = copybytes(largv, argc * sizeof(t_atom)); + + argv[0] = (t_int)x->x_outlet; + argv[1] = (t_int)argc; + argv[2] = (t_int)copied_argv; + + set_callback(join_anything_callback, argv, 3); +} + + +void join_setup(void) +{ + join_class = class_new(gensym("join"), (t_newmethod)join_new, + NULL, sizeof(join_t), + CLASS_DEFAULT, 0); + class_addbang(join_class, join_bang); + class_addfloat(join_class, join_float); + class_addpointer(join_class, join_pointer); + class_addsymbol(join_class, join_symbol); + class_addlist(join_class, join_list); + class_addanything(join_class, join_anything); +} diff --git a/join/makefile b/join/makefile new file mode 100644 index 0000000..bcad613 --- /dev/null +++ b/join/makefile @@ -0,0 +1,94 @@ +NAME=join +CSYM=join + +current: pd_linux + +# ----------------------- NT ----------------------- + +pd_nt: $(NAME).dll + +.SUFFIXES: .dll + +PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo +VC="C:\Program Files\Microsoft Visual Studio\Vc98" + +PDNTINCLUDE = /I. /I..\..\src /I$(VC)\include + +PDNTLDIR = $(VC)\lib +PDNTLIB = $(PDNTLDIR)\libc.lib \ + $(PDNTLDIR)\oldnames.lib \ + $(PDNTLDIR)\kernel32.lib \ + ..\..\bin\pd.lib + +.c.dll: + cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c + link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB) + +# ----------------------- IRIX 5.x ----------------------- + +pd_irix5: $(NAME).pd_irix5 + +.SUFFIXES: .pd_irix5 + +SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 + +SGIINCLUDE = -I../../src + +.c.pd_irix5: + $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c + ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o + rm $*.o + +# ----------------------- IRIX 6.x ----------------------- + +pd_irix6: $(NAME).pd_irix6 + +.SUFFIXES: .pd_irix6 + +SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ + -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ + -Ofast=ip32 + +.c.pd_irix6: + $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c + ld -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o + rm $*.o + +# ----------------------- LINUX i386 ----------------------- + +pd_linux: $(NAME).pd_linux + +.SUFFIXES: .pd_linux + +LINUXCFLAGS = -DPD -O3 -fPIC -funroll-loops -fomit-frame-pointer \ + -Wall -W -Wshadow -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch + +LINUXINCLUDE = -I../../../src + +LSTRIP = strip --strip-unneeded -R .note -R .comment + +.c.pd_linux: + cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c + cc -Wl,-export_dynamic --shared -o $*.pd_linux $*.o -lm + $(LSTRIP) $*.pd_linux + rm -f $*.o + +# ----------------------- Mac OSX ----------------------- + +pd_darwin: $(NAME).pd_darwin + +.SUFFIXES: .pd_darwin + +DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ + -Wno-unused -Wno-parentheses -Wno-switch + +.c.pd_darwin: + $(CC) $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c + $(CC) -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o + rm -f $*.o + +# ---------------------------------------------------------- + +clean: + rm -f *.o *.pd_* so_locations -- cgit v1.2.1