[Gridflow-cvs] [svn] commit: r3653 - in /trunk: base/flow_objects.c base/grid.c format/main.c gridflow.c gridflow.h optional/fftw.c optional/gem.c optional/opencv.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 25 13:46:32 EDT 2008


Author: matju
Date: Fri Apr 25 13:46:32 2008
New Revision: 3653

Log:
merged GridObject into FObject

Modified:
    trunk/base/flow_objects.c
    trunk/base/grid.c
    trunk/format/main.c
    trunk/gridflow.c
    trunk/gridflow.h
    trunk/optional/fftw.c
    trunk/optional/gem.c
    trunk/optional/opencv.c

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Fri Apr 25 13:46:32 2008
@@ -86,7 +86,7 @@
 //	if (d->n!=1) RAISE("expecting Dim[n], got %s",d->to_s());}
 
 //****************************************************************
-\class GridCast : GridObject {
+\class GridCast : FObject {
 	\attr NumberTypeE nt;
 	\constructor (NumberTypeE nt) {this->nt = nt;}
 	\grin 0
@@ -104,7 +104,7 @@
 
 //{ ?,Dim[B] -> Dim[*Cs] }
 // out0 nt to be specified explicitly
-\class GridImport : GridObject {
+\class GridImport : FObject {
 	\attr NumberTypeE cast;
 	\attr P<Dim> dim; // size of grids to send
 	PtrGrid dim_grid;
@@ -128,7 +128,7 @@
 	\grin 1 int32
 	template <class T> void process (long n, T *data) {
 		if (in.size()<=0) in.resize(1);
-		if (!in[0]) in[0]=new GridInlet((GridObject *)this,stromgol);
+		if (!in[0]) in[0]=new GridInlet((FObject *)this,stromgol);
 		while (n) {
 			if (!out || !out->dim) out = new GridOutlet(this,0,dim?dim:in[0]->dim,cast);
 			long n2 = min((long)n,out->dim->prod()-out->dex);
@@ -161,7 +161,7 @@
 
 \def 0 list(...) {//first two lines are there until grins become strictly initialized.
 	if (in.size()<=0) in.resize(1);
-	if (!in[0]) in[0]=new GridInlet((GridObject *)this,stromgol);
+	if (!in[0]) in[0]=new GridInlet((FObject *)this,stromgol);
 	in[0]->from_list(argc,argv,cast);}
 \def 1 per_message() {dim=0; dim_grid=0;}
 
@@ -171,7 +171,7 @@
 //****************************************************************
 /*{ Dim[*As] -> ? }*/
 /* in0: integer nt */
-\class GridToFloat : GridObject {
+\class GridToFloat : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -181,7 +181,7 @@
 } GRID_END
 \end class {install("#to_float",1,1); add_creator("#export"); add_creator("@export");}
 
-\class GridToSymbol : GridObject {
+\class GridToSymbol : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -197,7 +197,7 @@
 
 /*{ Dim[*As] -> ? }*/
 /* in0: integer nt */
-\class GridExportList : GridObject {
+\class GridExportList : FObject {
 	\constructor () {}
 	int n;
 	\grin 0
@@ -217,7 +217,7 @@
 \end class {install("#to_list",1,1); add_creator("#export_list"); add_creator("@export_list");}
 
 /* **************************************************************** */
-\class GridPrint : GridObject {
+\class GridPrint : FObject {
 	\constructor (t_symbol *name=0) {
 		this->dest = 0;
 		this->name = name;
@@ -370,7 +370,7 @@
 // in0: integer nt
 // in1: whatever nt
 // out0: same nt as in1
-\class GridStore : GridObject {
+\class GridStore : FObject {
 
 	PtrGrid r; // can't be \attr
 	PtrGrid put_at; // can't be //\attr
@@ -558,7 +558,7 @@
 //****************************************************************
 //{ Dim[*As]<T> -> Dim[*As]<T> } or
 //{ Dim[*As]<T>,Dim[*Bs]<T> -> Dim[*As]<T> }
-\class GridOp : GridObject {
+\class GridOp : FObject {
 	\attr Numop *op;
 	PtrGrid r;
 	\constructor (Numop *op, Grid *r=0) {
@@ -616,7 +616,7 @@
 \end class {install("#",2,1); add_creator("@");}
 
 //****************************************************************
-\class GridFold : GridObject {
+\class GridFold : FObject {
 	\attr Numop *op;
 	\attr PtrGrid seed;
 	\constructor (Numop *op) {this->op=op;}
@@ -660,7 +660,7 @@
 
 \end class {install("#fold",1,1);}
 
-\class GridScan : GridObject {
+\class GridScan : FObject {
 	\attr Numop *op;
 	\attr PtrGrid seed;
 	\constructor (Numop *op) {this->op = op;}
@@ -702,7 +702,7 @@
 // Seed   is a Dim[           *ss]<T>
 // result is a Dim[*si,   *sk,*ss]<T>
 // Currently *ss can only be = Dim[]
-\class GridInner : GridObject {
+\class GridInner : FObject {
 	\attr Numop *op;
 	\attr Numop *fold;
 	\attr PtrGrid seed;
@@ -845,7 +845,7 @@
 
 /* **************************************************************** */
 /*{ Dim[*As]<T>,Dim[*Bs]<T> -> Dim[*As,*Bs]<T> }*/
-\class GridOuter : GridObject {
+\class GridOuter : FObject {
 	\attr Numop *op;
 	PtrGrid r;
 	\constructor (Numop *op, Grid *r=0) {
@@ -904,7 +904,7 @@
 //****************************************************************
 //{ Dim[]<T>,Dim[]<T>,Dim[]<T> -> Dim[A]<T> } or
 //{ Dim[B]<T>,Dim[B]<T>,Dim[B]<T> -> Dim[*As,B]<T> }
-\class GridFor : GridObject {
+\class GridFor : FObject {
 	\attr PtrGrid from;
 	\attr PtrGrid to;
 	\attr PtrGrid step;
@@ -983,7 +983,7 @@
 \end class {install("#for",3,1); add_creator("@for");}
 
 //****************************************************************
-\class GridFinished : GridObject {
+\class GridFinished : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -994,7 +994,7 @@
 } GRID_END
 \end class {install("#finished",1,1); add_creator("@finished");}
 
-\class GridDim : GridObject {
+\class GridDim : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -1005,7 +1005,7 @@
 } GRID_END
 \end class {install("#dim",1,1); add_creator("@dim");}
 
-\class GridType : GridObject {
+\class GridType : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -1017,7 +1017,7 @@
 
 //****************************************************************
 //{ Dim[*As]<T>,Dim[B] -> Dim[*Cs]<T> }
-\class GridRedim : GridObject {
+\class GridRedim : FObject {
 	\attr P<Dim> dim;
 	PtrGrid dim_grid;
 	PtrGrid temp; // temp->dim is not of the same shape as dim
@@ -1068,7 +1068,7 @@
 \end class {install("#redim",2,1); add_creator("@redim");}
 
 //****************************************************************
-\class GridJoin : GridObject {
+\class GridJoin : FObject {
 	\attr int which_dim;
 	PtrGrid r;
 	\grin 0
@@ -1140,7 +1140,7 @@
 \end class {install("@join",2,1);}
 
 //****************************************************************
-\class GridGrade : GridObject {
+\class GridGrade : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -1175,10 +1175,10 @@
 \end class {install("#grade",1,1); add_creator("@grade");}
 
 //****************************************************************
-//\class GridMedian : GridObject
-//****************************************************************
-
-\class GridTranspose : GridObject {
+//\class GridMedian : FObject
+//****************************************************************
+
+\class GridTranspose : FObject {
 	\attr int dim1;
 	\attr int dim2;
 	int d1,d2,na,nb,nc,nd; // temporaries
@@ -1234,7 +1234,7 @@
 \end class {install("#transpose",3,1); add_creator("@transpose");}
 
 //****************************************************************
-\class GridReverse : GridObject {
+\class GridReverse : FObject {
 	\attr int dim1; // dimension to act upon
 	int d; // temporaries
 	\constructor (int dim1=0) {this->dim1 = dim1;}
@@ -1266,7 +1266,7 @@
 \end class {install("#reverse",2,1);}
 
 //****************************************************************
-\class GridCentroid : GridObject {
+\class GridCentroid : FObject {
 	\constructor () {}
 	\grin 0 int
 	int sumx,sumy,sum,y; // temporaries
@@ -1304,7 +1304,7 @@
 //****************************************************************
 static void expect_pair (P<Dim> dim) {if (dim->prod()!=2) RAISE("expecting only two numbers. Dim(2)");}
 
-\class GridMoment : GridObject {
+\class GridMoment : FObject {
 	\constructor (int order=1) {
 		offset.constrain(expect_pair);
 		//t_atom2 a[2] = {t_atom2(0),t_atom2(0)};
@@ -1380,7 +1380,7 @@
 \end class {install("#moment",2,1);}
 
 //****************************************************************
-\class GridLabeling : GridObject {
+\class GridLabeling : FObject {
 	\grin 0
 	\attr int form();
 	\attr int form_val;
@@ -1471,7 +1471,7 @@
 \end class {install("#labeling",1,0);}
 
 //****************************************************************
-\class GridPerspective : GridObject {
+\class GridPerspective : FObject {
 	\attr int32 z;
 	\grin 0
 	\constructor (int32 z=256) {this->z=z;}
@@ -1494,7 +1494,7 @@
 \end class {install("#perspective",1,1); add_creator("@perspective");}
 
 //****************************************************************
-\class GridBorder : GridObject {
+\class GridBorder : FObject {
 	\attr P<Dim> diml;
 	\attr P<Dim> dimr;
 	PtrGrid diml_grid;
@@ -1559,7 +1559,7 @@
 // entry in a compiled convolution kernel
 struct PlanEntry { long y,x; bool neutral; };
 
-\class GridConvolve : GridObject {
+\class GridConvolve : FObject {
 	\attr Numop *op;
 	\attr Numop *fold;
 	\attr PtrGrid seed;
@@ -1691,7 +1691,7 @@
 		RAISE("expecting only one or two numbers");
 }
 
-\class GridScaleBy : GridObject {
+\class GridScaleBy : FObject {
 	\attr PtrGrid scale; // integer scale factor
 	int scaley;
 	int scalex;
@@ -1744,7 +1744,7 @@
 
 // ----------------------------------------------------------------
 //{ Dim[A,B,3]<T> -> Dim[C,D,3]<T> }
-\class GridDownscaleBy : GridObject {
+\class GridDownscaleBy : FObject {
 	\attr PtrGrid scale;
 	\attr bool smoothly;
 	int scaley;
@@ -1831,7 +1831,7 @@
 \end class {install("#downscale_by",2,1); add_creator("@downscale_by");}
 
 //****************************************************************
-\class GridLayer : GridObject {
+\class GridLayer : FObject {
 	PtrGrid r;
 	\constructor () {r.constrain(expect_rgb_picture);}
 	\grin 0 int
@@ -1873,7 +1873,7 @@
 	if (d->n!=2 || d->get(1)!=2) RAISE("expecting Dim[n,2] polygon");
 }
 
-\class DrawPolygon : GridObject {
+\class DrawPolygon : FObject {
 	\attr Numop *op;
 	\attr PtrGrid color;
 	\attr PtrGrid polygon;
@@ -1992,7 +1992,7 @@
 	if (d->v[0]!=2) RAISE("position dim 0 should have 2 elements, not %d", d->v[0]);
 }
 
-\class DrawImage : GridObject {
+\class DrawImage : FObject {
 	\attr Numop *op;
 	\attr PtrGrid image;
 	\attr PtrGrid position;
@@ -2102,7 +2102,7 @@
 // Dim[*A],Dim[*B],Dim[C,size(A)-size(B)] -> Dim[*A]
 
 /* NOT FINISHED */
-\class GridDrawPoints : GridObject {
+\class GridDrawPoints : FObject {
 	\attr Numop *op;
 	\attr PtrGrid color;
 	\attr PtrGrid points;
@@ -2144,7 +2144,7 @@
 \end class {install("#draw_points",3,1);}
 
 //****************************************************************
-\class GridPolygonize : GridObject {
+\class GridPolygonize : FObject {
 	\constructor () {}
 	\grin 0
 };
@@ -2159,7 +2159,7 @@
 \end class {install("#polygonize",1,1);}
 
 //****************************************************************
-\class GridNoiseGateYuvs : GridObject {
+\class GridNoiseGateYuvs : FObject {
 	\grin 0
 	int thresh;
 	\decl 1 float(int v);
@@ -2188,7 +2188,7 @@
 
 //****************************************************************
 
-\class GridPack : GridObject {
+\class GridPack : FObject {
 	int n;
 	PtrGrid a;
 	\constructor (int n=2, NumberTypeE nt=int32_e) {
@@ -2219,7 +2219,7 @@
 }
 \end class {install("#pack",1,1); add_creator("@pack");}
 
-\class GridUnpack : GridObject {
+\class GridUnpack : FObject {
 	int n;
 	\constructor (int n=2) {
 		if (n<1) RAISE("n=%d must be at least 1",n);
@@ -2286,7 +2286,7 @@
 
 //****************************************************************
 
-\class GridRotatificator : GridObject {
+\class GridRotatificator : FObject {
 	int angle;
 	int from, to, n;
 	\decl 0 float (int scale);

Modified: trunk/base/grid.c
==============================================================================
--- trunk/base/grid.c (original)
+++ trunk/base/grid.c Fri Apr 25 13:46:32 2008
@@ -387,14 +387,6 @@
 	inlets.push_back(in);
 }
 
-\class GridObject : FObject
-\classinfo {}
-\end class
-
-void startup_grid () {
-	\startall
-}
-
 // never call this. this is a hack to make some things work.
 // i'm trying to circumvent either a bug in the compiler or i don't have a clue. :-(
 void make_gimmick () {

Modified: trunk/format/main.c
==============================================================================
--- trunk/format/main.c (original)
+++ trunk/format/main.c Fri Apr 25 13:46:32 2008
@@ -99,8 +99,8 @@
 }
 \end class FormatLookup {install("gf.format_lookup",1,1);}
 
-\class Format : GridObject
-Format::Format (MESSAGE) : GridObject(MESSAGE2) {
+\class Format : FObject
+Format::Format (MESSAGE) : FObject(MESSAGE2) {
 	mode=0; fd=-1; f=0; cast=int32_e; frame=0;
 	if (argv[0]==gensym("out")) this->mode=2; else
 	if (argv[0]==gensym("in"))  this->mode=4; else RAISE("unknown mode");

Modified: trunk/gridflow.c
==============================================================================
--- trunk/gridflow.c (original)
+++ trunk/gridflow.c Fri Apr 25 13:46:32 2008
@@ -764,7 +764,6 @@
 \end class
 
 void startup_number();
-void startup_grid();
 void startup_flow_objects();
 void startup_format();
 STARTUP_LIST(void)
@@ -804,7 +803,6 @@
 BUILTIN_SYMBOLS(FOO)
 #undef FOO
 	startup_number();
-	startup_grid();
 	startup_flow_objects();
 	startup_format();
 	STARTUP_LIST()

Modified: trunk/gridflow.h
==============================================================================
--- trunk/gridflow.h (original)
+++ trunk/gridflow.h Fri Apr 25 13:46:32 2008
@@ -693,12 +693,12 @@
 #undef FOO
 } GridHandler;
 
-struct GridObject;
+struct FObject;
 struct GridInlet : CObject {
-	GridObject *parent;
+	FObject *parent;
 	const GridHandler *gh;
 private:
-	GridObject *sender;
+	FObject *sender;
 public:
 	P<Dim> dim;
 	NumberTypeE nt;
@@ -711,7 +711,7 @@
 //	long allocfactor,allocmin,allocmax,allocn;
 //	uint8 *alloc;
 
-	GridInlet(GridObject *parent_, const GridHandler *gh_) :
+	GridInlet(FObject *parent_, const GridHandler *gh_) :
 		parent(parent_), gh(gh_), sender(0),
 		dim(0), nt(int32_e), dex(0), bufi(0), mode(4) {}
 	~GridInlet() {}
@@ -770,14 +770,14 @@
 	static const long MIN_PACKET_SIZE = 1<<8;
 	static const long MAX_PACKET_SIZE = 1<<12;
 // those are set only once
-	GridObject *parent; // not a P<> because of circular refs
+	FObject *parent; // not a P<> because of circular refs
 	P<Dim> dim; // dimensions of the grid being sent
 	NumberTypeE nt;
 	std::vector<GridInlet *> inlets; // which inlets are we connected to
 // those are updated during transmission
 	long dex;  // how many numbers were already sent in this connection
 
-	GridOutlet(GridObject *parent_, int woutlet, P<Dim> dim_, NumberTypeE nt_=int32_e) :
+	GridOutlet(FObject *parent_, int woutlet, P<Dim> dim_, NumberTypeE nt_=int32_e) :
 	parent(parent_), dim(dim_), nt(nt_), dex(0), frozen(false), bufi(0) {
 		//int ntsz = number_type_table[nt].size;
 		buf=new Grid(new Dim(MAX_PACKET_SIZE/*/ntsz*/), nt);
@@ -818,7 +818,7 @@
 
 #define CHECK_GRIN(class,i) \
 	if (in.size()<=i) in.resize(i+1); \
-	if (!in[i]) in[i]=new GridInlet((GridObject *)this,&class##_grid_##i##_hand);
+	if (!in[i]) in[i]=new GridInlet((FObject *)this,&class##_grid_##i##_hand);
 
 struct BFProxy;
 struct BFObject : t_object {
@@ -837,19 +837,14 @@
 // represents objects that have inlets/outlets
 struct FObject : CObject {
 	BFObject *bself; // point to PD peer
+	std::vector<P<GridInlet> > in;
+	P<GridOutlet> out;
 	FObject(MESSAGE) : bself(0) {}
 	template <class T> void send_out(int outlet, int argc, T *argv) {
 		t_atom foo[argc];
 		for (int i=0; i<argc; i++) SETFLOAT(&foo[i],argv[i]);
 		outlet_list(bself->outlets[outlet],&s_list,argc,foo);
 	}
-};
-
-struct GridObject : FObject {
-	std::vector<P<GridInlet> > in;
-	P<GridOutlet> out;
-	GridObject(MESSAGE) : FObject(MESSAGE2) {}
-	~GridObject() {}
 	bool is_busy_except(P<GridInlet> gin) {
 		for (uint32 i=0; i<in.size(); i++) if (in[i] && in[i]!=gin && in[i]->dim) return true;
 		return false;
@@ -884,7 +879,7 @@
 void call_super(int argc, t_atom *argv);
 #define SUPER call_super(argc,argv);
 
-\class Format : GridObject {
+\class Format : FObject {
 	int mode;
 	int fd;
 	FILE *f;

Modified: trunk/optional/fftw.c
==============================================================================
--- trunk/optional/fftw.c (original)
+++ trunk/optional/fftw.c Fri Apr 25 13:46:32 2008
@@ -30,7 +30,7 @@
 	if (align) {_L_;post("%s(%s): Alignment Warning: %s=%p is not %d-aligned: %d", \
 		ARGS(this), __PRETTY_FUNCTION__,#d,(void*)d,bytes,align);}}
 
-\class GridFFT : GridObject {
+\class GridFFT : FObject {
 	fftwf_plan plan;
 	P<Dim> lastdim; /* of last input (for plan cache) */
 	long lastchans; /* of last input (for plan cache) */

Modified: trunk/optional/gem.c
==============================================================================
--- trunk/optional/gem.c (original)
+++ trunk/optional/gem.c Fri Apr 25 13:46:32 2008
@@ -38,16 +38,16 @@
 //  in 0: gem
 //  in 1: grid
 // out 0: gem
-\class GridExportPix < GridObject
-struct GridExportPix : GridObject, GemPixObj {
+\class GridExportPix < FObject
+struct GridExportPix : FObject, GemPixObj {
 	CPPEXTERN_HEADER(GridExportPix,GemPixObj)
 public:
 	P<BitPacking> bit_packing;
 	pixBlock m_pixBlock;
 	\attr bool yflip;
 
-	GridExportPix () : GridObject(0,0,0) {RAISE("what?");}
-	GridExportPix (MESSAGE) : GridObject(MESSAGE2) {
+	GridExportPix () : FObject(0,0,0) {RAISE("what?");}
+	GridExportPix (MESSAGE) : FObject(MESSAGE2) {
 		yflip = false;
 		imageStruct &im = m_pixBlock.image = imageStruct();
 		im.ysize = 1;
@@ -117,14 +117,14 @@
 //------------------------------------------------------------------------
 //  in 0: gem (todo: auto 0 = manual mode; bang = send next frame; type = number type attr)
 // out 0: grid
-\class GridImportPix < GridObject
-struct GridImportPix : GridObject, GemPixObj {
+\class GridImportPix < FObject
+struct GridImportPix : FObject, GemPixObj {
 	CPPEXTERN_HEADER(GridImportPix,GemPixObj)
 public:
 	P<BitPacking> bit_packing;
 	\attr bool yflip;
-	GridImportPix () : GridObject(0,0,0) {RAISE("what?");}
-	GridImportPix (MESSAGE) : GridObject(MESSAGE2) {
+	GridImportPix () : FObject(0,0,0) {RAISE("what?");}
+	GridImportPix (MESSAGE) : FObject(MESSAGE2) {
 		uint32 mask[4] = {0x0000ff,0x00ff00,0xff0000,0x000000};
 		bit_packing = new BitPacking(is_le(),4,4,mask);
 		yflip = false;

Modified: trunk/optional/opencv.c
==============================================================================
--- trunk/optional/opencv.c (original)
+++ trunk/optional/opencv.c Fri Apr 25 13:46:32 2008
@@ -122,7 +122,7 @@
 	return a;
 }
 
-\class CvOp1 : GridObject {
+\class CvOp1 : FObject {
 	\attr CvMode mode;
 	\constructor () {mode = cv_mode_auto;}
 	/* has no default \grin 0 handler so far. */
@@ -176,7 +176,7 @@
 };
 \end class {}
 
-\class CvHaarDetectObjects : GridObject {
+\class CvHaarDetectObjects : FObject {
 	\attr double scale_factor; /*=1.1*/
 	\attr int min_neighbors;   /*=3*/
 	\attr int flags;           /*=0*/
@@ -226,7 +226,7 @@
 	\grin 1
 };
 
-void cvMatSend(const CvMat *self, GridObject *obj, int outno) {
+void cvMatSend(const CvMat *self, FObject *obj, int outno) {
 	int m = self->rows;
 	int n = self->cols;
 	int e = CV_MAT_TYPE(cvGetElemType(self));



More information about the Gridflow-cvs mailing list