[Gridflow-cvs] [svn] commit: r3499 - in /trunk/base: flow_objects.c flow_objects.rb

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Apr 14 20:22:05 EDT 2008


Author: matju
Date: Mon Apr 14 20:22:04 2008
New Revision: 3499

Log:
rewrote [route2] in c++

Modified:
    trunk/base/flow_objects.c
    trunk/base/flow_objects.rb

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Mon Apr 14 20:22:04 2008
@@ -2901,6 +2901,42 @@
 
 //****************************************************************
 
+\class Route2 : FObject {
+	int nsels;
+	t_symbol **sels;
+	Route2() : nsels(0), sels(0) {}
+	~Route2() {if (sels) delete[] sels;}
+	\decl void initialize(...);
+	\decl void initialize2();
+	\decl void method_missing(...);
+	\decl 1 list(...);
+};
+\def void initialize(...) {
+	SUPER;
+	_1_list(argc,argv);
+}
+\def void initialize2() {bself->noutlets_set(1+nsels);}
+\def void method_missing(...) {
+	t_atom at[argc];
+	ruby2pd(argc,argv,at);
+	t_symbol *sel = gensym(at[0].a_w.w_symbol->s_name+3);
+	int i=0;
+	for (i=0; i<nsels; i++) if (sel==sels[i]) break;
+	outlet_anything(bself->out[i],sel,argc-1,at+1);
+}
+\def 1 list(...) {
+	t_atom at[argc];
+	ruby2pd(argc,argv,at);
+	for (int i=0; i<argc; i++) if (at[i].a_type!=A_SYMBOL) {delete[] sels; RAISE("$%d: expected symbol",i+1);}
+	if (sels) delete[] sels;
+	nsels = argc;
+	sels = new t_symbol*[argc];
+	for (int i=0; i<argc; i++) sels[i] = at[i].a_w.w_symbol;
+}
+\end class {install("route2",1,1);}
+
+//****************************************************************
+
 #define OP(x) op_dict[string(#x)]
 void startup_flow_objects () {
 	op_add = OP(+);

Modified: trunk/base/flow_objects.rb
==============================================================================
--- trunk/base/flow_objects.rb (original)
+++ trunk/base/flow_objects.rb Mon Apr 14 20:22:04 2008
@@ -202,20 +202,6 @@
 	add_creator "demux"
 }
 
-FObject.subclass("route2",1,1) {
-	def initialize(*b)
-		super; @b=b; @bh={}
-		b.each_with_index {|x,i| @bh[x]=i }
-	end
-	def initialize2(*b) self.noutlets= 1+ at b.length end
-	def _0_(*a) i=@bh[a[0]]||@b.length; send_out i,*a end
-	def _1_list(*b) @b=b end
-	def method_missing(sym,*a)
-		(m = /(_\d_)(.*)/.match sym.to_s) or return super
-		_0_ m[2].intern, *a
-	end
-}
-
 FObject.subclass("printargs",1,0) {
   def initialize(*args)
     super



More information about the Gridflow-cvs mailing list