[Gridflow-cvs] [svn] commit: r3829 - /trunk/base/flow_objects.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Jun 9 16:20:24 EDT 2008


Author: matju
Date: Mon Jun  9 16:20:24 2008
New Revision: 3829

Log:
added class [receives]

Modified:
    trunk/base/flow_objects.c

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Mon Jun  9 16:20:24 2008
@@ -2867,6 +2867,48 @@
 }
 \end class {install("send39",1,0);}
 
+struct Receives;
+struct ReceivesProxy {
+	t_pd x_pd;
+	Receives *parent;
+	t_symbol *suffix;
+};
+t_class *ReceivesProxy_class;
+
+\class Receives : FObject {
+	int ac;
+	ReceivesProxy **av;
+	t_symbol *prefix;
+	t_symbol *local (t_symbol *suffix) {return gensym((string(prefix->s_name) + string(suffix->s_name)).data());}
+	\constructor (t_symbol *prefix, ...) {
+		this->prefix = prefix;
+		ac = argc-1;
+		av = new ReceivesProxy *[argc-1];
+		for (int i=0; i<ac; i++) {
+			av[i] = (ReceivesProxy *)pd_new(ReceivesProxy_class);
+			av[i]->parent = this;
+			av[i]->suffix = argv[i+1];
+			pd_bind(  (t_pd *)av[i],local(av[i]->suffix));
+		}
+	}
+	~Receives () {
+		for (int i=0; i<ac; i++) {
+			pd_unbind((t_pd *)av[i],local(av[i]->suffix));
+			pd_free((t_pd *)av[i]);
+		}
+		delete[] av;
+	}
+};
+void ReceivesProxy_anything (ReceivesProxy *self, t_symbol *s, int argc, t_atom *argv) {
+	outlet_symbol(  self->parent->bself->outlets[1],self->suffix);
+	outlet_anything(self->parent->bself->outlets[0],s,argc,argv);
+}
+\end class {
+	install("receives",1,2);
+	ReceivesProxy_class = class_new(gensym("receives.proxy"),0,0,sizeof(ReceivesProxy),CLASS_PD|CLASS_NOINLET, A_NULL);
+	class_addanything(ReceivesProxy_class,(t_method)ReceivesProxy_anything);
+}
+
 /* this can't report on bang,float,symbol,pointer,list because zgetfn can't either */
 \class ClassExists : FObject {
 	\constructor () {}



More information about the Gridflow-cvs mailing list