File: ixprint.c

package info (click to toggle)
pd-cxc 0.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 500 kB
  • sloc: ansic: 3,528; makefile: 347
file content (88 lines) | stat: -rw-r--r-- 2,000 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "m_pd.h"

/* -------------------------- ixprint ------------------------------ 
 * print without "print: " ...
 */
static t_class *ixprint_class;

typedef struct _ixprint
{
    t_object x_obj;
    t_symbol *x_sym;
} t_ixprint;

static void *ixprint_new(t_symbol *s)
{
    t_ixprint *x = (t_ixprint *)pd_new(ixprint_class);
    if (*s->s_name) x->x_sym = s;
    // change, plain print ..
    else x->x_sym = gensym("");
    return (x);
}

static void ixprint_bang(t_ixprint *x)
{
    post("bang", x->x_sym->s_name);
}

static void ixprint_pointer(t_ixprint *x, t_gpointer *gp)
{
    post("(gpointer)", x->x_sym->s_name);
}

static void ixprint_float(t_ixprint *x, t_float f)
{
    post("%g",f);
}

static void ixprint_list(t_ixprint *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    char buf[80];
    if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name);
    else startpost("%s",
    	(argc > 1 ? s_list.s_name : s_symbol.s_name));
    postatom(argc, argv);
    endpost();
}

static void ixprint_anything(t_ixprint *x, t_symbol *s, int argc, t_atom *argv)
{
    int i;
    char buf[80];
    startpost("%s", s->s_name);
    postatom(argc, argv);
    endpost();
}

/* -------------------------- logger ------------------------------
 * log text input into file , output linecount ..
 */

/* static t_class *logger_class;

typedef struct _logger
{
  t_object x_obj;
  t_symbol x_fname;
  t_float x_lc;
} t_logger;

static void *logger_new(t_symbol *s)
{
    t_logger *x = (t_logger *)pd_new(logger_class);
    x->x_fname = gensym("pd.log");
    return (x);
}
*/

void ixprint_setup(void)
{
    ixprint_class = class_new(gensym("ixprint"), (t_newmethod)ixprint_new, 0,
    	sizeof(t_ixprint), 0, A_DEFSYM, 0);
    class_addbang(ixprint_class, ixprint_bang);
    class_addfloat(ixprint_class, ixprint_float);
    class_addpointer(ixprint_class, ixprint_pointer);
    class_addlist(ixprint_class, ixprint_list);
    class_addanything(ixprint_class, ixprint_anything);
}