diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/x_interface.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/x_interface.c | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/x_interface.c b/apps/plugins/pdbox/PDa/src/x_interface.c new file mode 100644 index 0000000000..f6ab350a91 --- /dev/null +++ b/apps/plugins/pdbox/PDa/src/x_interface.c | |||
@@ -0,0 +1,156 @@ | |||
1 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
2 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
3 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
4 | |||
5 | /* interface objects */ | ||
6 | |||
7 | #include "m_pd.h" | ||
8 | |||
9 | /* -------------------------- print ------------------------------ */ | ||
10 | static t_class *print_class; | ||
11 | |||
12 | typedef struct _print | ||
13 | { | ||
14 | t_object x_obj; | ||
15 | t_symbol *x_sym; | ||
16 | } t_print; | ||
17 | |||
18 | static void *print_new(t_symbol *s) | ||
19 | { | ||
20 | t_print *x = (t_print *)pd_new(print_class); | ||
21 | if (*s->s_name) x->x_sym = s; | ||
22 | else x->x_sym = gensym(""); | ||
23 | return (x); | ||
24 | } | ||
25 | |||
26 | static void print_bang(t_print *x) | ||
27 | { | ||
28 | post("%sbang", x->x_sym->s_name); | ||
29 | } | ||
30 | |||
31 | static void print_pointer(t_print *x, t_gpointer *gp) | ||
32 | { | ||
33 | post("%s(gpointer)", x->x_sym->s_name); | ||
34 | } | ||
35 | |||
36 | static void print_float(t_print *x, t_float f) | ||
37 | { | ||
38 | post("%s%g", x->x_sym->s_name, f); | ||
39 | } | ||
40 | |||
41 | static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv) | ||
42 | { | ||
43 | int i; | ||
44 | char buf[80]; | ||
45 | if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name); | ||
46 | else startpost("%s%s", x->x_sym->s_name, | ||
47 | (argc > 1 ? s_list.s_name : (argc == 1 ? s_symbol.s_name : | ||
48 | s_bang.s_name))); | ||
49 | postatom(argc, argv); | ||
50 | endpost(); | ||
51 | } | ||
52 | |||
53 | static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv) | ||
54 | { | ||
55 | int i; | ||
56 | char buf[80]; | ||
57 | startpost("%s%s", x->x_sym->s_name, s->s_name); | ||
58 | postatom(argc, argv); | ||
59 | endpost(); | ||
60 | } | ||
61 | |||
62 | static void print_setup(void) | ||
63 | { | ||
64 | print_class = class_new(gensym("print"), (t_newmethod)print_new, 0, | ||
65 | sizeof(t_print), 0, A_DEFSYM, 0); | ||
66 | class_addbang(print_class, print_bang); | ||
67 | class_addfloat(print_class, print_float); | ||
68 | class_addpointer(print_class, print_pointer); | ||
69 | class_addlist(print_class, print_list); | ||
70 | class_addanything(print_class, print_anything); | ||
71 | } | ||
72 | |||
73 | |||
74 | |||
75 | void x_interface_setup(void) | ||
76 | { | ||
77 | print_setup(); | ||
78 | } | ||
79 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
80 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
81 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
82 | |||
83 | /* interface objects */ | ||
84 | |||
85 | #include "m_pd.h" | ||
86 | |||
87 | /* -------------------------- print ------------------------------ */ | ||
88 | static t_class *print_class; | ||
89 | |||
90 | typedef struct _print | ||
91 | { | ||
92 | t_object x_obj; | ||
93 | t_symbol *x_sym; | ||
94 | } t_print; | ||
95 | |||
96 | static void *print_new(t_symbol *s) | ||
97 | { | ||
98 | t_print *x = (t_print *)pd_new(print_class); | ||
99 | if (*s->s_name) x->x_sym = s; | ||
100 | else x->x_sym = gensym(""); | ||
101 | return (x); | ||
102 | } | ||
103 | |||
104 | static void print_bang(t_print *x) | ||
105 | { | ||
106 | post("%sbang", x->x_sym->s_name); | ||
107 | } | ||
108 | |||
109 | static void print_pointer(t_print *x, t_gpointer *gp) | ||
110 | { | ||
111 | post("%s(gpointer)", x->x_sym->s_name); | ||
112 | } | ||
113 | |||
114 | static void print_float(t_print *x, t_float f) | ||
115 | { | ||
116 | post("%s%g", x->x_sym->s_name, f); | ||
117 | } | ||
118 | |||
119 | static void print_list(t_print *x, t_symbol *s, int argc, t_atom *argv) | ||
120 | { | ||
121 | int i; | ||
122 | char buf[80]; | ||
123 | if (argc && argv->a_type != A_SYMBOL) startpost("%s:", x->x_sym->s_name); | ||
124 | else startpost("%s%s", x->x_sym->s_name, | ||
125 | (argc > 1 ? s_list.s_name : (argc == 1 ? s_symbol.s_name : | ||
126 | s_bang.s_name))); | ||
127 | postatom(argc, argv); | ||
128 | endpost(); | ||
129 | } | ||
130 | |||
131 | static void print_anything(t_print *x, t_symbol *s, int argc, t_atom *argv) | ||
132 | { | ||
133 | int i; | ||
134 | char buf[80]; | ||
135 | startpost("%s%s", x->x_sym->s_name, s->s_name); | ||
136 | postatom(argc, argv); | ||
137 | endpost(); | ||
138 | } | ||
139 | |||
140 | static void print_setup(void) | ||
141 | { | ||
142 | print_class = class_new(gensym("print"), (t_newmethod)print_new, 0, | ||
143 | sizeof(t_print), 0, A_DEFSYM, 0); | ||
144 | class_addbang(print_class, print_bang); | ||
145 | class_addfloat(print_class, print_float); | ||
146 | class_addpointer(print_class, print_pointer); | ||
147 | class_addlist(print_class, print_list); | ||
148 | class_addanything(print_class, print_anything); | ||
149 | } | ||
150 | |||
151 | |||
152 | |||
153 | void x_interface_setup(void) | ||
154 | { | ||
155 | print_setup(); | ||
156 | } | ||