From 4f51fe6574a7d46ddb95bb85e1053e86c2fb805a Mon Sep 17 00:00:00 2001 From: Miller Puckette Date: Sat, 20 Sep 2008 00:30:48 +0000 Subject: pd 0.42-0 test 05 svn path=/trunk/; revision=10301 --- pd/src/x_interface.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'pd/src/x_interface.c') diff --git a/pd/src/x_interface.c b/pd/src/x_interface.c index 4effa0d9..044961b1 100644 --- a/pd/src/x_interface.c +++ b/pd/src/x_interface.c @@ -5,6 +5,7 @@ /* interface objects */ #include "m_pd.h" +#include /* -------------------------- print ------------------------------ */ static t_class *print_class; @@ -15,34 +16,39 @@ typedef struct _print t_symbol *x_sym; } t_print; -static void *print_new(t_symbol *s) +static void *print_new(t_symbol *sel, int argc, t_atom *argv) { t_print *x = (t_print *)pd_new(print_class); - if (*s->s_name) x->x_sym = s; - else x->x_sym = gensym("print"); + t_symbol *s = atom_getsymbolarg(0, argc, argv); + if (!*s->s_name) + x->x_sym = gensym("print"); + else if (!strcmp(s->s_name, "-n")) + x->x_sym = &s_; + else x->x_sym = s; return (x); } static void print_bang(t_print *x) { - post("%s: bang", x->x_sym->s_name); + post("%s%sbang", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : "")); } static void print_pointer(t_print *x, t_gpointer *gp) { - post("%s: (gpointer)", x->x_sym->s_name); + post("%s%s(gpointer)", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : "")); } static void print_float(t_print *x, t_float f) { - post("%s: %g", x->x_sym->s_name, f); + post("%s%s%g", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : ""), f); } static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv) { int i; if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name); - else startpost("%s: %s", x->x_sym->s_name, + else startpost("%s%s%s", x->x_sym->s_name, + (*x->x_sym->s_name ? ": " : ""), (argc > 1 ? s_list.s_name : (argc == 1 ? s_symbol.s_name : s_bang.s_name))); postatom(argc, argv); @@ -52,7 +58,8 @@ static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv) static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv) { int i; - startpost("%s: %s", x->x_sym->s_name, s->s_name); + startpost("%s%s%s", x->x_sym->s_name, (*x->x_sym->s_name ? ": " : ""), + s->s_name); postatom(argc, argv); endpost(); } @@ -60,7 +67,7 @@ static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv) static void print_setup(void) { print_class = class_new(gensym("print"), (t_newmethod)print_new, 0, - sizeof(t_print), 0, A_DEFSYM, 0); + sizeof(t_print), 0, A_GIMME, 0); class_addbang(print_class, print_bang); class_addfloat(print_class, print_float); class_addpointer(print_class, print_pointer); @@ -68,8 +75,6 @@ static void print_setup(void) class_addanything(print_class, print_anything); } - - void x_interface_setup(void) { print_setup(); -- cgit v1.2.1