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

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 4 02:57:03 EDT 2008


Author: matju
Date: Fri Apr  4 02:57:03 2008
New Revision: 3455

Log:
rewrote [listreverse] 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 Fri Apr  4 02:57:03 2008
@@ -542,7 +542,12 @@
 		d++;
 	}
 } GRID_END
-\def 0 bang () { rb_funcall(rself,SI(_0_list),3,INT2NUM(0),SYM(#),INT2NUM(0)); }
+\def 0 bang () {
+	t_atom a[2];
+	SETFLOAT(a+0,0);
+	SETSYMBOL(a+1,gensym("#"));
+	pd_list((t_pd *)bself,&s_list,2,a);
+}
 \def 1 reassign () { put_at=0; }
 \def 1 put_at (Grid *index) { put_at=index; }
 \def void initialize (Grid *r) {
@@ -2328,6 +2333,8 @@
 
 \end class {install("foreach",1,1);}
 
+//****************************************************************
+
 void ruby2pd (int argc, Ruby *argv, t_atom *at);
 \class GFError : FObject {
 	string format;
@@ -2363,6 +2370,23 @@
 	pd_error(canvas,"%s",o.str().data());
 }
 \end class {install("gf.error",1,0);}
+
+//****************************************************************
+
+template <class T> void swap (T &a, T &b) {T c; c=a; a=b; b=c;}
+
+\class ListReverse : FObject {
+	\decl void initialize();
+	\decl 0 list(...);
+};
+\def void initialize () {SUPER;}
+\def 0 list (...) {
+	for (int i=(argc-1)/2; i>=0; i--) swap(argv[i],argv[argc-i-1]);
+	t_atom at[argc];
+	ruby2pd(argc,argv,at);
+	outlet_list(bself->te_outlet,&s_list,argc,at);
+}
+\end class {install("listreverse",1,1);}
 
 //****************************************************************
 

Modified: trunk/base/flow_objects.rb
==============================================================================
--- trunk/base/flow_objects.rb (original)
+++ trunk/base/flow_objects.rb Fri Apr  4 02:57:03 2008
@@ -294,8 +294,7 @@
 		end
 	end
 	def _1_float i; @index=i.to_i % @n end
-	# hack: this is an alias.
-	class Demux < self; install "demux", 2, 0; end
+	add_creator "demux"
 }
 
 FObject.subclass("listelement",2,1) {
@@ -311,10 +310,6 @@
 	def _1_float(i) @i=i.to_i end
 	def _2_float(n) @n=n.to_i end
 	def _0_list(*a) send_out 0, :list, *a[@i, at n] end
-}
-FObject.subclass("listreverse",1,1) {
-	def initialize() super end
-	def _0_list(*a) send_out 0,:list,*a.reverse end
 }
 
 FObject.subclass("route2",1,1) {



More information about the Gridflow-cvs mailing list