[Gridflow-cvs] [svn] commit: r5598 - in /trunk/src: classes1.cxx grid.cxx gridflow.hxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Wed May 5 19:39:11 EDT 2010


Author: matju
Date: Wed May  5 19:39:09 2010
New Revision: 5598

Log:
Dim, pis aussi GridInlet& dans GRID_INLET(), etc

Modified:
    trunk/src/classes1.cxx
    trunk/src/grid.cxx
    trunk/src/gridflow.hxx

Modified: trunk/src/classes1.cxx
==============================================================================
--- trunk/src/classes1.cxx (original)
+++ trunk/src/classes1.cxx Wed May  5 19:39:09 2010
@@ -255,7 +255,7 @@
 			if (s.tellp()>trunc) return;
 		}
 	}
-	void dump_dims(std::ostream &s, GridInlet *in) {
+	void dump_dims(std::ostream &s, GridInlet &in) {
 		if (name && name!=&s_) s << name->s_name << ": ";
 		s << "Dim[";
 		for (int i=0; i<in->dim->n; i++) {
@@ -480,8 +480,9 @@
 GRID_INLET(1) {
 	NumberTypeE nt = NumberTypeE_type_of(data);
 	if (!put_at) { // reassign
-		if (in[0].sender) r.next = new Grid(in->dim,nt);
-		else              r      = new Grid(in->dim,nt);
+		//!@#$ this was supposed to be inlets[0].sender i suppose... but it's not.
+		if (in.sender) r.next = new Grid(in->dim,nt);
+		else           r      = new Grid(in->dim,nt);
 		return;
 	}
 	// put_at ( ... )

Modified: trunk/src/grid.cxx
==============================================================================
--- trunk/src/grid.cxx (original)
+++ trunk/src/grid.cxx Wed May  5 19:39:09 2010
@@ -119,12 +119,12 @@
 	dex=0;
 	buf=0;
 	try {
-#define FOO(T) gh->flow(this,dex,-1,(T *)0); break;
+#define FOO(T) gh->flow(*this,dex,-1,(T *)0); break;
 		TYPESWITCH(sender->nt,FOO,)
 #undef FOO
 	} catch (Barf &barf) {this->sender=0; throw;}
 	this->dim = dim;
-	sender->callback(this);
+	sender->callback(*this);
 #ifdef TRACEBUFS
 	post("GridInlet:  %20s buf for recving from %p",dim->to_s(),sender);
 #endif
@@ -150,7 +150,7 @@
 		if (bufi==bufn) {
 			long newdex = dex+bufn;
 			CHECK_ALIGN(bufd,sender->nt);
-			try {gh->flow(this,dex,bufn,bufd);} CATCH_IT;
+			try {gh->flow(*this,dex,bufn,bufd);} CATCH_IT;
 			dex = newdex;
 			bufi = 0;
 		}
@@ -158,7 +158,7 @@
 	int m = (n/bufn)*bufn;
 	if (m) {
 		int newdex = dex + m;
-		try {gh->flow(this,dex,m,data);} CATCH_IT;
+		try {gh->flow(*this,dex,m,data);} CATCH_IT;
 		dex = newdex;
 	}
 	data += m;
@@ -170,7 +170,7 @@
 	CHECK_BUSY1(inlet);
 	if (dim.prod() != dex) post("%s: incomplete grid: %ld of %ld from [%s] to [%s]",
 	    ARGS(parent),dex,long(dim.prod()),ARGS(sender->parent),ARGS(parent));
-#define FOO(T) try {gh->flow(this,dex,-2,(T *)0);} CATCH_IT;
+#define FOO(T) try {gh->flow(*this,dex,-2,(T *)0);} CATCH_IT;
 	TYPESWITCH(sender->nt,FOO,)
 #undef FOO
 	dim=0; buf=0; dex=0; sender=0;
@@ -274,9 +274,9 @@
 	}
 }
 
-void GridOutlet::callback(GridInlet *in) {
+void GridOutlet::callback(GridInlet &in) {
 	CHECK_BUSY1(outlet);
-	inlets.push_back(in);
+	inlets.push_back(&in);
 }
 
 void GridOutlet::finish () {

Modified: trunk/src/gridflow.hxx
==============================================================================
--- trunk/src/gridflow.hxx (original)
+++ trunk/src/gridflow.hxx Wed May  5 19:39:09 2010
@@ -652,7 +652,7 @@
 //****************************************************************
 // GridInlet represents a grid-aware inlet
 
-#define GRIDHANDLER_ARGS(T) GridInlet *in, long dex, long n, T *data
+#define GRIDHANDLER_ARGS(T) GridInlet &in, long dex, long n, T *data
 
 // four-part macro for defining the behaviour of a gridinlet in a class
 // C:Class I:Inlet
@@ -696,6 +696,8 @@
 	GridInlet(FObject *parent_, const GridHandler *gh_) :
 		parent(parent_), gh(gh_), sender(0), dim(0), nt(int32_e), dex(0), chunk(-1), bufi(0) {}
 	~GridInlet() {}
+	const GridInlet *operator ->() const {return this;}
+	      GridInlet *operator ->()       {return this;}
 	void set_chunk(long whichdim);
 	int32 factor() {return buf?buf->dim.prod():1;} // which is usually not the same as this->dim->prod(chunk)
 	void begin(GridOutlet *sender);
@@ -760,7 +762,9 @@
 
 	GridOutlet(FObject *parent_, int woutlet, const Dim &dim_, NumberTypeE nt_=int32_e);
 	~GridOutlet() {}
-	void callback(GridInlet *in);
+	void callback(GridInlet &in);
+//	const Dim *operator ->() const {return this;}
+//	      Dim *operator ->()       {return this;}
 
 	// send/send_direct: data belongs to caller, may be stack-allocated,
 	// receiver doesn't modify the data; in send(), there is buffering;
@@ -834,13 +838,13 @@
 	#_a_, number_type_table[(_a_)->nt].name, \
 	#_b_, number_type_table[(_b_)->nt].name);
 static void SAME_DIM(int n, const Dim &a, int ai, const Dim &b, int bi) {
-	if (ai+n > a->n) RAISE("left hand: not enough dimensions");
-	if (bi+n > b->n) RAISE("right hand: not enough dimensions");
+	if (ai+n > a.n) RAISE("left hand: not enough dimensions");
+	if (bi+n > b.n) RAISE("right hand: not enough dimensions");
 	for (int i=0; i<n; i++) {
-		if (a->v[ai+i] != b->v[bi+i]) {
+		if (a[ai+i] != b[bi+i]) {
 			RAISE("mismatch: left dim #%d is %d, right dim #%d is %d",
-				ai+i, a->v[ai+i],
-				bi+i, b->v[bi+i]);}}}
+				ai+i, a[ai+i],
+				bi+i, b[bi+i]);}}}
 
 void suffixes_are (const char *name, const char *suffixes);
 #define install(name,inlets,outlets) install2(fclass,name,inlets,outlets)



More information about the Gridflow-cvs mailing list