[Gridflow-cvs] [svn] commit: r3387 - in /trunk/base: grid.c grid.h number.c source_filter.rb

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Tue Apr 1 13:57:07 EDT 2008


Author: matju
Date: Tue Apr  1 13:57:07 2008
New Revision: 3387

Log:
stop using Ruby-based send_out. add set_atom generic function

Modified:
    trunk/base/grid.c
    trunk/base/grid.h
    trunk/base/number.c
    trunk/base/source_filter.rb

Modified: trunk/base/grid.c
==============================================================================
--- trunk/base/grid.c (original)
+++ trunk/base/grid.c Tue Apr  1 13:57:07 2008
@@ -338,11 +338,9 @@
 void GridOutlet::begin(int woutlet, P<Dim> dim, NumberTypeE nt) {TRACE;
 	this->nt = nt;
 	this->dim = dim;
-	Ruby a[3];
-	a[0] = INT2NUM(woutlet);
-	a[1] = SYM(grid);
-	a[2] = Pointer_s_new(this);
-	parent->send_out(COUNT(a),a);
+	t_atom a[3];
+	SETPOINTER(a,(t_gpointer *)this); // hack
+	outlet_anything(parent->bself->out[woutlet],bsym._grid,1,a);
 	frozen=true;
 	if (!dim->prod()) {finish(); return;}
 	int32 lcm_factor = 1;

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Tue Apr  1 13:57:07 2008
@@ -529,6 +529,7 @@
 
 struct Numop {
 	const char *name;
+	t_symbol *sym;
 	int flags;
 	int size; // numop=1; vecop>1
 #define FOO(T) NumopOn<T> on_##T; \
@@ -550,7 +551,7 @@
 		if (!f) RAISE("operator %s does not support scan",name);
 		f(an,n,(T *)as,(T *)bs);}
 
-	Numop(Ruby sym_, const char *name_,
+	Numop(const char *name_,
 #define FOO(T) NumopOn<T> op_##T, 
 EACH_NUMBER_TYPE(FOO)
 #undef FOO
@@ -558,6 +559,7 @@
 #define FOO(T) on_##T = op_##T;
 EACH_NUMBER_TYPE(FOO)
 #undef FOO
+		sym=gensym((char *)name);
 	}
 };
 #ifdef USE_RUBY
@@ -923,4 +925,13 @@
 static inline string gf_find_file (string x) {return string(rb_str_ptr(rb_funcall(mGridFlow,SI(find_file),1,rb_str_new2(x.data()))));}
 void pd_oprintf (std::ostream &o, const char *s, int argc, t_atom *argv);
 
+inline void set_atom (t_atom *a, uint8     v) {SETFLOAT(a,(float)v);}
+inline void set_atom (t_atom *a, int16     v) {SETFLOAT(a,(float)v);}
+inline void set_atom (t_atom *a, int32     v) {SETFLOAT(a,(float)v);}
+inline void set_atom (t_atom *a, long      v) {SETFLOAT(a,(float)v);}
+inline void set_atom (t_atom *a, float32   v) {SETFLOAT(a,v);}
+inline void set_atom (t_atom *a, float64   v) {SETFLOAT(a,v);}
+inline void set_atom (t_atom *a, t_symbol *v) {SETSYMBOL(a,v);}
+inline void set_atom (t_atom *a, Numop    *v) {SETSYMBOL(a,v->sym);}
+
 #endif // __GF_GRID_H

Modified: trunk/base/number.c
==============================================================================
--- trunk/base/number.c (original)
+++ trunk/base/number.c Tue Apr  1 13:57:07 2008
@@ -155,12 +155,12 @@
 #define DECL_OPON_NOFOLD(L,O,T) NumopOn<T>( \
 	(NumopOn<T>::Map)L(O,T)::_map, (NumopOn<T>::Zip)L(O,T)::_zip, 0,0, \
 	&Y##O<T>::neutral, &Y##O<T>::is_neutral, &Y##O<T>::is_absorbent)
-#define DECLOP(        L,M,O,sym,flags,dim) Numop(0,sym,M(L,O,uint8),M(L,O,int16),M(L,O,int32) \
+#define DECLOP(        L,M,O,sym,flags,dim) Numop(sym,M(L,O,uint8),M(L,O,int16),M(L,O,int32) \
 	NONLITE(,M(L,O,int64)),  M(L,O,float32)   NONLITE(,M(L,O,float64)),flags,dim)
-#define DECLOP_NOFLOAT(L,M,O,sym,flags,dim) Numop(0,sym,M(L,O,uint8),M(L,O,int16),M(L,O,int32) \
+#define DECLOP_NOFLOAT(L,M,O,sym,flags,dim) Numop(sym,M(L,O,uint8),M(L,O,int16),M(L,O,int32) \
 	NONLITE(,M(L,O,int64)),NumopOn<float32>() NONLITE(,NumopOn<float64>()), flags,dim)
 //	NONLITE(,M(L,O,int64),NumopOn<float32>(),NumopOn<float64>()), flags,dim)
-#define DECLOP_FLOAT(  L,M,O,sym,flags,dim) Numop(0,sym,NumopOn<uint8>(),NumopOn<int16>(),NumopOn<int32>() \
+#define DECLOP_FLOAT(  L,M,O,sym,flags,dim) Numop(sym,NumopOn<uint8>(),NumopOn<int16>(),NumopOn<int32>() \
 	NONLITE(,NumopOn<int64>()),M(L,O,float32) NONLITE(,M(L,O,float64)),flags,dim)
 
 #define DECL_OP(                O,sym,flags)     DECLOP(         OL,DECL_OPON       ,O,sym,flags,1)

Modified: trunk/base/source_filter.rb
==============================================================================
--- trunk/base/source_filter.rb (original)
+++ trunk/base/source_filter.rb Tue Apr  1 13:57:07 2008
@@ -242,10 +242,10 @@
 	Out.print "#{cl.inspect}, COUNT(#{cl}_methods), #{cl}_methods };"
 #	STDERR.puts "attributes: "+
 	get="void ___get(t_symbol *s) {"
-	get << "Ruby _r_[3]={INT2NUM(convert(rb_ivar_get(rb_obj_class(rself),SI(@noutlets)),(int*)0)-1),ID2SYM(rb_intern(s->s_name)),Qnil};"
+	get << "t_atom a[1];"
 	frame.attrs.each {|name,attr|
 		virtual = if attr.virtual then "(0,0)" else "" end
-		get << "if (s==gensym(\"#{name})\")) _r_[2]=R(#{name}#{virtual}).r; else "
+		get << "if (s==gensym(\"#{name})\")) set_atom(a,#{name}#{virtual}); else "
 		if frame.methods["_0_"+name].done then
 			STDERR.puts "skipping already defined \\attr #{name}"
 			next
@@ -259,7 +259,7 @@
 	}
 	startup2 += "}"
 	line.gsub!(/\{/,"{"+"IEVAL(rself,\"#{startup2}\");") or raise "\\classinfo line should have a '{' (sorry)"
-	get << "RAISE(\"unknown attr %s\",s->s_name); send_out(3,_r_);}"
+	get << "RAISE(\"unknown attr %s\",s->s_name); outlet_anything(bself->out[bself->nout-1],s,1,a);}"
 	handle_def get if frame.attrs.size>0
 	Out.print "void #{frame.name}_startup (Ruby rself) "+line.chomp
 end



More information about the Gridflow-cvs mailing list