[Gridflow-cvs] [svn] commit: r3607 - in /trunk/base: flow_objects.c grid.c grid.h

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 18 18:18:12 EDT 2008


Author: matju
Date: Fri Apr 18 18:18:11 2008
New Revision: 3607

Log:
remove type Ruby

Modified:
    trunk/base/flow_objects.c
    trunk/base/grid.c
    trunk/base/grid.h

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Fri Apr 18 18:18:11 2008
@@ -1315,7 +1315,9 @@
 \class GridMoment : GridObject {
 	\constructor (int order=1) {
 		offset.constrain(expect_pair);
-		offset=new Grid(EVAL("[0,0]"));
+		//t_atom2 a[2] = {t_atom2(0),t_atom2(0)};
+		t_atom a[2]; SETFLOAT(a,0); SETFLOAT(a+1,0);
+		offset=new Grid(2,a,int32_e);
 		if (order!=1 && order!=2) RAISE("supports only orders 1 and 2 for now");
 		this->order=order;
 	}
@@ -1703,7 +1705,8 @@
 	int scalex;
 	\constructor (Grid *factor=0) {
 		scale.constrain(expect_scale_factor);
-		scale=new Grid(INT2NUM(2));
+		t_atom a[1]; SETFLOAT(a,2);
+		scale=new Grid(1,a,int32_e);
 		if (factor) scale=factor;
 		prepare_scale_factor();
 	}
@@ -1757,7 +1760,8 @@
 	PtrGrid temp;
 	\constructor (Grid *factor=0, t_symbol *option=0) {
 		scale.constrain(expect_scale_factor);
-		scale=new Grid(INT2NUM(2));
+		t_atom a[1]; SETFLOAT(a,2);
+		scale=new Grid(1,a,int32_e);
 		if (factor) scale=factor;
 		prepare_scale_factor();
 		smoothly = option==gensym("smoothly");

Modified: trunk/base/grid.c
==============================================================================
--- trunk/base/grid.c (original)
+++ trunk/base/grid.c Fri Apr 18 18:18:11 2008
@@ -108,32 +108,6 @@
 #undef FOO
 }
 
-void Grid::init_from_ruby_list(int n, Ruby *a, NumberTypeE nt) {
-	Ruby delim = SYM(#);
-	for (int i=0; i<n; i++) {
-		if (a[i] == delim) {
-			int32 v[i];
-			if (i!=0 && TYPE(a[i-1])==T_SYMBOL) nt=NumberTypeE_find(a[--i]);
-			for (int j=0; j<i; j++) RAISE("MEUH");
-			init(new Dim(i,v),nt);
-			CHECK_ALIGN2(this->data,nt);
-			if (a[i] != delim) i++;
-			i++; a+=i; n-=i;
-			goto fill;
-		}
-	}
-	if (n!=0 && TYPE(a[0])==T_SYMBOL) {
-		nt = NumberTypeE_find(a[0]);
-		a++, n--;
-	}
-	init(new Dim(n),nt);
-	CHECK_ALIGN2(this->data,nt);
-	fill:
-	int nn = dim->prod();
-	n = min(n,nn);
-	RAISE("meuh");
-}
-
 void Grid::init_from_atom(const t_atom &x) {
 	if (x.a_type==A_LIST) {
 		t_binbuf *b = (t_binbuf *)x.a_gpointer;
@@ -142,20 +116,6 @@
 		init(new Dim(),int32_e);
 		CHECK_ALIGN2(this->data,nt);
 		((int32 *)*this)[0] = (int32)x.a_float;
-	} else {
-		rb_funcall(
-		EVAL("proc{|x| raise \"can't convert to grid: #{x.inspect}\"}"),
-		SI(call),1,x);
-	}
-}
-
-void Grid::init_from_ruby(Ruby x) {
-	if (TYPE(x)==T_ARRAY) {
-		init_from_ruby_list(rb_ary_len(x),rb_ary_ptr(x));
-	} else if (INTEGER_P(x) || FLOAT_P(x)) {
-		init(new Dim(),int32_e);
-		CHECK_ALIGN2(this->data,nt);
-		RAISE("meuh");
 	} else {
 		rb_funcall(
 		EVAL("proc{|x| raise \"can't convert to grid: #{x.inspect}\"}"),

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Fri Apr 18 18:18:11 2008
@@ -495,23 +495,10 @@
 extern std::map<string,Numop *> op_dict;
 extern std::map<string,Numop *> vop_dict;
 
-#ifdef USE_RUBY
-static inline NumberTypeE convert(Ruby x, NumberTypeE *bogus) {return NumberTypeE_find(x);}
-#endif
 static inline NumberTypeE convert(const t_atom &x, NumberTypeE *bogus) {
 	if (x.a_type!=A_SYMBOL) RAISE("expected number-type"); return NumberTypeE_find(string(x.a_w.w_symbol->s_name));}
 
 
-#ifdef USE_RUBY
-static Numop *convert(Ruby x, Numop **bogus) {
-	if (TYPE(x)!=T_STRING) x=rb_funcall(x,SI(to_s),0);
-	string k = string(rb_str_ptr(x));
-	if (op_dict.find(k)==op_dict.end()) {
-		if (vop_dict.find(k)==vop_dict.end()) RAISE("expected two-input-operator, not %s", rb_str_ptr(rb_funcall(x,SI(inspect),0)));
-		return vop_dict[k];
-	} else return op_dict[k];
-}
-#endif
 static Numop *convert(const t_atom &x, Numop **bogus) {
 	if (x.a_type!=A_SYMBOL) RAISE("expected numop (as symbol)");
 	string k = string(x.a_symbol->s_name);
@@ -533,9 +520,7 @@
 		init(dim,nt);
 		if (clear) {long size = bytes(); CLEAR((char *)data,size);}
 	}
-	Grid(Ruby          x) {state=1; init_from_ruby(x);}
 	Grid(const t_atom &x) {state=1; init_from_atom(x);}
-	Grid(int n, Ruby   *a, NumberTypeE nt_=int32_e) {state=1; init_from_ruby_list(n,a,nt_);}
 	Grid(int n, t_atom *a, NumberTypeE nt_=int32_e) {state=1; init_from_list(n,a,nt_);}
 	template <class T> Grid(P<Dim> dim, T *data) {
 		state=0; this->dim=dim;
@@ -565,13 +550,9 @@
 		}
 		//fprintf(stderr,"rdata=%p data=%p align=%d\n",rdata,data,align);
 	}
-	void init_from_ruby(Ruby x);
 	void init_from_atom(const t_atom &x);
-	void init_from_ruby_list(int n, Ruby   *a, NumberTypeE nt=int32_e);
 	void init_from_list(     int n, t_atom *a, NumberTypeE nt=int32_e);
 };
-
-static inline Grid *convert (Ruby          r, Grid **bogus) {return r?new Grid(r):0;}
 static inline Grid *convert (const t_atom &r, Grid **bogus) {return new Grid(r);}
 
 // DimConstraint interface:
@@ -598,20 +579,12 @@
 #undef INCR
 #undef DECR
 
-static inline P<Dim> convert(Ruby x, P<Dim> *foo) {
-	Grid *d = convert(x,(Grid **)0);
-	if (!d) RAISE("urgh");
-	if (d->dim->n!=1) RAISE("dimension list must have only one dimension itself");
-	return new Dim(d->dim->v[0],(int32 *)(d->data));
-}
 static inline P<Dim> convert(const t_atom &x, P<Dim> *foo) {
 	Grid *d = convert(x,(Grid **)0);
 	if (!d) RAISE("urgh");
 	if (d->dim->n!=1) RAISE("dimension list must have only one dimension itself");
 	return new Dim(d->dim->v[0],(int32 *)(d->data));
 }
-
-static inline PtrGrid convert(Ruby          x, PtrGrid *foo) {return PtrGrid(convert(x,(Grid **)0));}
 static inline PtrGrid convert(const t_atom &x, PtrGrid *foo) {return PtrGrid(convert(x,(Grid **)0));}
 
 //****************************************************************
@@ -837,7 +810,6 @@
 	void *p;
 	Pointer(MESSAGE) {RAISE("calling Pointer constructor the wrong way"); }
 	Pointer(void *_p) : p(_p) {}
-	\decl Ruby ptr ();
 };
 \end class Pointer
 



More information about the Gridflow-cvs mailing list