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

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Apr 14 14:46:33 EDT 2008


Author: matju
Date: Mon Apr 14 14:46:32 2008
New Revision: 3488

Log:
[range] now in c++ not ruby

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 14:46:32 2008
@@ -2441,6 +2441,39 @@
 }
 \end class {install("listflatten",1,1);}
 
+\class Range : FObject {
+	t_float *mosusses;
+	int nmosusses;
+	\decl void initialize(...);
+	\decl void initialize2();
+	\decl 0 float(float f);
+	\decl 0 list(float f);
+	\decl void _n_float(int i, float f);
+};
+\def void initialize(...) {
+	nmosusses = argc;
+	t_atom at[argc];
+	ruby2pd(argc,argv,at);
+	for (int i=0; i<argc; i++) if (at[i].a_type!=A_FLOAT) RAISE("$%d: expected float",i+1);
+	mosusses = new t_float[argc];
+	for (int i=0; i<argc; i++) mosusses[i]=at[i].a_w.w_float;
+}
+\def void initialize2() {
+	bself-> ninlets_set(1+nmosusses);
+	bself->noutlets_set(1+nmosusses);
+}
+\def 0 list(float f) {_0_float(argc,argv,f);}
+\def 0 float(float f) {
+	int i;
+	for (i=0; i<nmosusses; i++) if (f<mosusses[i]) break;
+	outlet_float(bself->out[i],f);
+}
+\def void _n_float(int i, float f) {
+	if (!i) _0_float(argc,argv,f); // precedence problem in rubyext...
+	else mosusses[i-1] = f;
+}
+\end class {install("range",1,1);}
+
 //****************************************************************
 
 static void display_update(void *x);

Modified: trunk/base/flow_objects.rb
==============================================================================
--- trunk/base/flow_objects.rb (original)
+++ trunk/base/flow_objects.rb Mon Apr 14 14:46:32 2008
@@ -234,21 +234,6 @@
 	end
 }
 
-FObject.subclass("range",1,1) {
-  def initialize(*a) @a=a end
-  def initialize2
-    self.ninlets=  1+ at a.length
-    self.noutlets= 1+ at a.length
-  end
-  def _0_list(x) _0_float(x) end
-  def _0_float(x) i=0; i+=1 until @a[i]==nil or x<@a[i]; send_out i,x end
-  def method_missing(sel,*a)
-    m = /^(_\d+_)(.*)/.match(sel.to_s) or return super
-    m[2]=="float" or return super
-    @a[m[1].to_i-1] = a[0]
-    post "setting a[#{m[1].to_i-1}] = #{a[0]}"
-  end
-}
 FObject.subclass("listfind",2,1) {
   def initialize(*a) _1_list(*a) end
   def _1_list(*a) @a = a end



More information about the Gridflow-cvs mailing list