aboutsummaryrefslogtreecommitdiff
path: root/src/nroute.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2004-03-09 03:51:28 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2004-03-09 03:51:28 +0000
commit50a389bea35a91ddae1394c5d35a6f1c703f5bdd (patch)
tree345af9da1a2432cdde199637af884d0cb744cf40 /src/nroute.c
parent6f58df1602bc981858c874a55c73dab0e76258cc (diff)
Checked in Olaf's 1.5.2 sources. Here are the changes:
v 1.5.2 (17. december 2003): - modified netclient for not to drop received data: use of syspollfn instead of clock to poll for incoming data, circular recv buffer v 1.5 (18. october 2003): - added some usefull features to arraycopy (i.e. copying just parts of an array and copying to specified position in destination array) - new object: nchange - IRIX 6.5 port (for GCC 3.3) - OS X binary (Jaguar 10.2.6) v 1.4 (22. may 2003): - updated sources to compile with Pd0.37-test4 - new object: arraycopy v 1.3 (12. april 2003): - new objects: sync listfifo - all setup routines renamed to maxlib_<object>_setup() to avoid name clashes, old names still work via class_addcreator() - some improvements for the help files svn path=/trunk/externals/maxlib/; revision=1394
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
+}