aboutsummaryrefslogtreecommitdiff
path: root/src/nroute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nroute.c')
-rw-r--r--src/nroute.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/nroute.c b/src/nroute.c
index c8c94c5..e0f6ea4 100644
--- a/src/nroute.c
+++ b/src/nroute.c
@@ -35,12 +35,12 @@
static char *version = "nroute v0.1, written by Olaf Matthes <olaf.matthes@gmx.de>";
-typedef struct nroute
-{
- t_object x_obj;
- t_outlet *out1;
+typedef struct nroute
+{
+ t_object x_obj;
+ t_outlet *out1;
t_outlet *out2;
- t_int pos;
+ t_int pos;
t_atom match;
} t_nroute;
@@ -54,36 +54,36 @@ typedef struct proxy
/* this is the routine that actually does the routing / matching */
/* it get's called by all other routines that get any input and */
- /* even handles the second (proxy) inlet ! */
-static void nroute_any(t_nroute *x, t_symbol *s, int argc, t_atom *argv)
+ /* even handles the second (proxy) inlet ! */
+static void nroute_any(t_nroute *x, t_symbol *s, int argc, t_atom *argv)
{
if(s)
{
- if (x->pos == 1 && x->match.a_type == A_SYMBOL && x->match.a_w.w_symbol == s)
- outlet_anything (x->out1,s,argc,argv);
- else if (x->pos > 1 && x->pos <= argc + 1 &&
- argv[x->pos-2].a_type == x->match.a_type &&
- argv[x->pos-2].a_w.w_float == x->match.a_w.w_float)
- outlet_anything (x->out1,s,argc,argv);
- else outlet_anything (x->out2,s,argc,argv);
- }
+ if (x->pos == 1 && x->match.a_type == A_SYMBOL && x->match.a_w.w_symbol == s)
+ outlet_anything (x->out1,s,argc,argv);
+ else if (x->pos > 1 && x->pos <= argc + 1 &&
+ argv[x->pos-2].a_type == x->match.a_type &&
+ argv[x->pos-2].a_w.w_float == x->match.a_w.w_float)
+ outlet_anything (x->out1,s,argc,argv);
+ else outlet_anything (x->out2,s,argc,argv);
+ }
else
- {
- if (x->pos > 0 && x->pos <= argc &&
- argv[x->pos-1].a_type == x->match.a_type &&
- argv[x->pos-1].a_w.w_float == x->match.a_w.w_float)
- outlet_list (x->out1,0,argc,argv);
- else outlet_list (x->out2,0,argc,argv);
- }
-}
-
-static void nroute_float(t_nroute *x, float f)
-{
- t_atom a;
+ {
+ if (x->pos > 0 && x->pos <= argc &&
+ argv[x->pos-1].a_type == x->match.a_type &&
+ argv[x->pos-1].a_w.w_float == x->match.a_w.w_float)
+ outlet_list (x->out1,0,argc,argv);
+ else outlet_list (x->out2,0,argc,argv);
+ }
+}
+
+static void nroute_float(t_nroute *x, float f)
+{
+ t_atom a;
- SETFLOAT (&a,f);
- nroute_any(x,0,1,&a);
-}
+ SETFLOAT (&a,f);
+ nroute_any(x,0,1,&a);
+}
static void nroute_list(t_nroute *x, t_symbol *s, int argc, t_atom *argv)
{
@@ -120,34 +120,34 @@ static t_class *nroute_class;
static t_class *proxy_class;
static void *nroute_new(t_symbol *s, int argc, t_atom *argv)
-{
+{
t_nroute *x = (t_nroute *)pd_new(nroute_class);
t_proxy *inlet = (t_proxy *)pd_new(proxy_class); /* for the proxy inlet */
inlet->x = x; /* make x visible to the proxy inlets */
- x->pos = 1;
- x->match.a_type = A_NULL;
- if (argc > 2) { error ("nroute: extra arguments"); return 0; }
- if (argc > 1) {
- if (argv[1].a_type == A_FLOAT) x->pos = argv[1].a_w.w_float;
- else { post ("nroute: second argument must be (int) position"); return 0; }
- }
- if (argc > 0) {
- x->match.a_type = argv[0].a_type;
- x->match.a_w.w_float = argv[0].a_w.w_float;
- }
+ x->pos = 1;
+ x->match.a_type = A_NULL;
+ if (argc > 2) { error ("nroute: extra arguments"); return 0; }
+ if (argc > 1) {
+ if (argv[1].a_type == A_FLOAT) x->pos = argv[1].a_w.w_float;
+ else { post ("nroute: second argument must be (int) position"); return 0; }
+ }
+ if (argc > 0) {
+ x->match.a_type = argv[0].a_type;
+ x->match.a_w.w_float = argv[0].a_w.w_float;
+ }
inlet->index = 0; /* we are going to create a proxy inlet no. 0 */
/* it belongs to the object t_nroute but the destination is t_proxy */
inlet_new(&x->x_obj, &inlet->obj.ob_pd, 0,0);
/* and now a 'normal' third inlet */
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("right"));
- x->out1 = outlet_new(&x->x_obj, gensym("list"));
+ x->out1 = outlet_new(&x->x_obj, gensym("list"));
x->out2 = outlet_new(&x->x_obj, gensym("list"));
- return (x);
+ return (x);
}
-#ifndef MAXLIB
+#ifndef MAXLIB
void nroute_setup(void)
{
/* the object's class: */
@@ -176,4 +176,4 @@ void maxlib_nroute_setup(void)
#else
class_sethelpsymbol(nroute_class, gensym("maxlib/help-nroute.pd"));
#endif
-} \ No newline at end of file
+}