From 00aecaac183d203d80e099803461083feb73533f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 5 Nov 2007 06:30:48 +0000 Subject: working version with storage and a bang to output stored value; should add right inlet for storing svn path=/trunk/externals/hcs/; revision=8936 --- sys_gui.c | 70 ++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'sys_gui.c') diff --git a/sys_gui.c b/sys_gui.c index cb3fd9a..1b6cd9b 100644 --- a/sys_gui.c +++ b/sys_gui.c @@ -8,50 +8,62 @@ static t_class *sys_gui_class; typedef struct _sys_gui { t_object x_obj; + char *send_buffer; } t_sys_gui; +static void sys_gui_bang(t_sys_gui *x) +{ + sys_gui(x->send_buffer); +} -static void *sys_gui_anything(t_sys_gui *x, t_symbol *s, int argc, t_atom *argv) +static void sys_gui_anything(t_sys_gui *x, t_symbol *s, int argc, t_atom *argv) { + post("sys_gui_anything"); int i = 0; - int firsttime = 1; - t_symbol *tmp_symbol = s; - char tmp_string[MAXPDSTRING]; - char send_buffer[MAXPDSTRING] = "\0"; - - do { - tmp_symbol = atom_getsymbolarg(i, argc, argv); - if(tmp_symbol == &s_) - { - snprintf(tmp_string, MAXPDSTRING, "%g", atom_getfloatarg(i, argc , argv)); - strncat(send_buffer, tmp_string, MAXPDSTRING); - } - else - { - strncat(send_buffer, tmp_symbol->s_name, MAXPDSTRING); - } - i++; - if(firsttime) firsttime = 0; - } while(isend_buffer, MAXPDSTRING, "%s ", s->s_name); + for(i=0;isend_buffer, buf, MAXPDSTRING - strlen(x->send_buffer)); + strncat(x->send_buffer, " ", MAXPDSTRING - strlen(x->send_buffer)); + } + strncat(x->send_buffer, " ;\n", 3); + sys_gui(x->send_buffer); } +static void sys_gui_list(t_sys_gui *x, t_symbol *s, int argc, t_atom *argv) +{ + post("sys_gui_list"); + int i = 0; + char buf[MAXPDSTRING]; + + for(i=0;isend_buffer, buf, MAXPDSTRING - strlen(x->send_buffer)); + strncat(x->send_buffer, " ", MAXPDSTRING - strlen(x->send_buffer)); + } + strncat(x->send_buffer, " ;\n", 3); + sys_gui(x->send_buffer); +} -static void *sys_gui_new(t_symbol *s, int argc, t_atom *argv) +static void sys_gui_free(t_sys_gui *x) +{ + freebytes(x->send_buffer,MAXPDSTRING); +} + +static void *sys_gui_new(t_symbol *s) { t_sys_gui *x = (t_sys_gui *)pd_new(sys_gui_class); outlet_new(&x->x_obj, &s_anything); + x->send_buffer = (char *)getbytes(MAXPDSTRING); return(x); } -static void sys_gui_free(t_sys_gui *x) -{ -} - void sys_gui_setup(void) { sys_gui_class = class_new(gensym("sys_gui"), @@ -59,4 +71,6 @@ void sys_gui_setup(void) sizeof(t_sys_gui), 0, 0); class_addanything(sys_gui_class, (t_method)sys_gui_anything); + class_addbang(sys_gui_class, (t_method)sys_gui_bang); + class_addlist(sys_gui_class, (t_method)sys_gui_list); } -- cgit v1.2.1