summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/x_interface.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
commit513389b4c1bc8afe4b2dc9947c534bfeb105e3da (patch)
tree10e673b35651ac567fed2eda0c679c7ade64cbc6 /apps/plugins/pdbox/PDa/src/x_interface.c
parent95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (diff)
downloadrockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.tar.gz
rockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.zip
Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin project of Wincent Balin. Stripped some non-sourcefiles and added a rockbox readme that needs a bit more info from Wincent. Is added to CATEGORIES and viewers, but not yet to SUBDIRS (ie doesn't build yet)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21044 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/x_interface.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/x_interface.c156
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 ------------------------------ */
10static t_class *print_class;
11
12typedef struct _print
13{
14 t_object x_obj;
15 t_symbol *x_sym;
16} t_print;
17
18static 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
26static void print_bang(t_print *x)
27{
28 post("%sbang", x->x_sym->s_name);
29}
30
31static void print_pointer(t_print *x, t_gpointer *gp)
32{
33 post("%s(gpointer)", x->x_sym->s_name);
34}
35
36static void print_float(t_print *x, t_float f)
37{
38 post("%s%g", x->x_sym->s_name, f);
39}
40
41static 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
53static 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
62static 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
75void 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 ------------------------------ */
88static t_class *print_class;
89
90typedef struct _print
91{
92 t_object x_obj;
93 t_symbol *x_sym;
94} t_print;
95
96static 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
104static void print_bang(t_print *x)
105{
106 post("%sbang", x->x_sym->s_name);
107}
108
109static void print_pointer(t_print *x, t_gpointer *gp)
110{
111 post("%s(gpointer)", x->x_sym->s_name);
112}
113
114static void print_float(t_print *x, t_float f)
115{
116 post("%s%g", x->x_sym->s_name, f);
117}
118
119static 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
131static 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
140static 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
153void x_interface_setup(void)
154{
155 print_setup();
156}