From 6adfba996c34b2c78515e8a50ad5928188d78612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Thu, 7 Feb 2008 23:05:57 +0000 Subject: reorganizing svn path=/trunk/; revision=9376 --- extensions/xgui/xgui-lib/recv2.c | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 extensions/xgui/xgui-lib/recv2.c (limited to 'extensions/xgui/xgui-lib/recv2.c') diff --git a/extensions/xgui/xgui-lib/recv2.c b/extensions/xgui/xgui-lib/recv2.c new file mode 100644 index 00000000..f49e374c --- /dev/null +++ b/extensions/xgui/xgui-lib/recv2.c @@ -0,0 +1,80 @@ +/* Copyright (c) 2002 Damien HENRY. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* recv2 */ + +#include "m_pd.h" + +static t_class *recv2_class; + +typedef struct _recv2 +{ + t_object x_obj; + t_symbol *x_sym; +} t_recv2; + +static void recv2_bang(t_recv2 *x) +{ + outlet_bang(x->x_obj.ob_outlet); +} + +static void recv2_float(t_recv2 *x, t_float f) +{ + outlet_float(x->x_obj.ob_outlet, f); +} + +static void recv2_symbol(t_recv2 *x, t_symbol *s) +{ + outlet_symbol(x->x_obj.ob_outlet, s); +} + +static void recv2_pointer(t_recv2 *x, t_gpointer *gp) +{ + outlet_pointer(x->x_obj.ob_outlet, gp); +} + +static void recv2_list(t_recv2 *x, t_symbol *s, int argc, t_atom *argv) +{ + outlet_list(x->x_obj.ob_outlet, s, argc, argv); +} + +static void recv2_anything(t_recv2 *x, t_symbol *s, int argc, t_atom *argv) +{ + outlet_anything(x->x_obj.ob_outlet, s, argc, argv); +} + +static void recv2_set(t_recv2 *x, t_symbol *s) +{ + pd_unbind(&x->x_obj.ob_pd, x->x_sym); + x->x_sym = s; + pd_bind(&x->x_obj.ob_pd, s); +} + +static void *recv2_new(t_symbol *s) +{ + t_recv2 *x = (t_recv2 *)pd_new(recv2_class); + x->x_sym = s; + pd_bind(&x->x_obj.ob_pd, s); + outlet_new(&x->x_obj, 0); + return (x); +} + +static void recv2_free(t_recv2 *x) +{ + pd_unbind(&x->x_obj.ob_pd, x->x_sym); +} + +void recv2_setup(void) +{ + recv2_class = class_new(gensym("recv2"), (t_newmethod)recv2_new, + (t_method)recv2_free, sizeof(t_recv2), 0, A_DEFSYM, 0); + class_addbang(recv2_class, recv2_bang); + class_addfloat(recv2_class, (t_method)recv2_float); + class_addsymbol(recv2_class, recv2_symbol); + class_addpointer(recv2_class, recv2_pointer); + class_addlist(recv2_class, recv2_list); + class_addanything(recv2_class, recv2_anything); + class_addmethod(recv2_class, (t_method)recv2_set, gensym("@"),A_DEFSYMBOL, 0); + class_sethelpsymbol(recv2_class, gensym("xgui/help_recv2")); +} -- cgit v1.2.1