[PD-dev] Prefixed target with [remote] (maxlib)
Maurizio Umberto Puxeddu
umbpux at tin.it
Fri Jan 24 12:50:52 CET 2003
Hello.
The attached patch is meant to enable [remote] to automatically prepend
a string to all the incoming message targets.
[remote pippo]
will forward messages to "pippoA", "pippopluto" instead of "A" and
"pluto".
The typical use would be sending messages to local target. So
|A 10 20 30, B 100 200 300< -> [remote $0-]
would forward the message "10 20 30" to "%0-A" and "100 200 300" to
"$0-B".
Can this be included in the original version?
Should I make another class?
There was an easier way?
Thanks for everything.
Maurizio Umberto Puxeddu.
-------------- next part --------------
--- remote.c.~1.1.1.1.~ 2002-11-20 18:46:03.000000000 +0100
+++ remote.c 2003-01-24 12:34:42.000000000 +0100
@@ -37,12 +37,15 @@
typedef struct _remote
{
t_object x_obj;
+ t_symbol *prefix;
} t_remote;
/* send 'anything' to receiver */
static void remote_anything(t_remote *x, t_symbol *s, int argc, t_atom *argv)
{
int i;
+ char mysym[MAXPDSTRING];
+ t_symbol *target;
t_atom av[MAX_ARG]; /* the 'new' t_atom without first element */
t_int ac = argc - 1; /* the 'new' number of arguments */
@@ -62,13 +65,16 @@
av[i - 1] = argv[i]; /* just copy, don't care about types */
}
/* send only argument-part to receivers */
- if (s->s_thing) pd_forwardmess(s->s_thing, argc, argv);
+ sprintf(mysym,"%s%s", x->prefix->s_name, s->s_name);
+ target = gensym(mysym);
+ if (target->s_thing) pd_forwardmess(target->s_thing, argc, argv);
}
-static void *remote_new(void)
+static void *remote_new(t_symbol *s)
{
t_remote *x = (t_remote *)pd_new(remote_class);
-
+
+ x->prefix = s;
#ifndef MAXLIB
post(version);
#endif
@@ -78,7 +84,7 @@
void remote_setup(void)
{
remote_class = class_new(gensym("remote"), (t_newmethod)remote_new, 0,
- sizeof(t_remote), 0, 0);
+ sizeof(t_remote), 0, A_DEFSYM, 0);
class_addanything(remote_class, remote_anything);
class_sethelpsymbol(remote_class, gensym("maxlib/help-remote.pd"));
}
More information about the Pd-dev
mailing list