[Gridflow-cvs] [svn] commit: r4767 - in /trunk/src: classes1.cxx classes2.cxx formats.cxx grid.cxx gridflow.cxx gridflow.hxx opencv.cxx quicktimehw.cxx sdl.cxx source_filter.rb videodev.cxx x11.cxx

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Sat Nov 7 21:55:49 EST 2009


Author: matju
Date: Sat Nov  7 21:55:41 2009
New Revision: 4767

Log:
move almost all of BFObject fields to FObject, for convenience.

Modified:
    trunk/src/classes1.cxx
    trunk/src/classes2.cxx
    trunk/src/formats.cxx
    trunk/src/grid.cxx
    trunk/src/gridflow.cxx
    trunk/src/gridflow.hxx
    trunk/src/opencv.cxx
    trunk/src/quicktimehw.cxx
    trunk/src/sdl.cxx
    trunk/src/source_filter.rb
    trunk/src/videodev.cxx
    trunk/src/x11.cxx

Modified: trunk/src/classes1.cxx
==============================================================================
--- trunk/src/classes1.cxx (original)
+++ trunk/src/classes1.cxx Sat Nov  7 21:55:41 2009
@@ -174,7 +174,7 @@
 };
 GRID_INLET(0) {
 } GRID_FLOW {
-	for (int i=0; i<n; i++) outlet_float(bself->outlets[0],data[i]);
+	for (int i=0; i<n; i++) outlet_float(outlets[0],data[i]);
 } GRID_END
 \end class {install("#to_float",1,1); add_creator("#export"); add_creator("@export");}
 
@@ -188,7 +188,7 @@
 	char c[n+1];
 	for (int i=0; i<n; i++) c[i]=(char)data[i];
 	c[n]=0;
-	outlet_symbol(bself->outlets[0],gensym(c));
+	outlet_symbol(outlets[0],gensym(c));
 } GRID_END
 \end class {install("#to_symbol",1,1); add_creator("#export_symbol"); add_creator("@export_symbol");}
 
@@ -971,7 +971,7 @@
 GRID_INLET(0) {
 	//in->set_mode(0);
 } GRID_FINISH {
-	outlet_bang(bself->outlets[0]);
+	outlet_bang(outlets[0]);
 } GRID_END
 \end class {install("#finished",1,1); add_creator("@finished");}
 \class GridDim : FObject {
@@ -989,7 +989,7 @@
 	\grin 0
 };
 GRID_INLET(0) {
-	outlet_symbol(bself->outlets[0],gensym(const_cast<char *>(number_type_table[in->nt].name)));
+	outlet_symbol(outlets[0],gensym(const_cast<char *>(number_type_table[in->nt].name)));
 	/*in->set_mode(0);*/
 } GRID_END
 \end class {install("#type",1,1); add_creator("@type");}
@@ -1273,8 +1273,8 @@
 	blah[0] = sum ? sumy/sum : 0;
 	blah[1] = sum ? sumx/sum : 0;
 	out->send(2,blah);
-	outlet_float(bself->outlets[1],blah[0]);
-	outlet_float(bself->outlets[2],blah[1]);
+	outlet_float(outlets[1],blah[0]);
+	outlet_float(outlets[2],blah[1]);
 } GRID_END
 
 \end class {install("#centroid",1,3);}
@@ -1363,7 +1363,7 @@
 	\attr int form();
 	\attr int form_val;
 	\constructor (int form=0) {form_val=form; initialize3();}
-	void initialize3() {bself->noutlets_set(form_val ? 2 : 4);}
+	void initialize3() {noutlets_set(form_val ? 2 : 4);}
 };
 struct Stats {
 	int64 yy,yx,xx,y,x,area;
@@ -2201,7 +2201,7 @@
 		if (n>32) RAISE("n=%d is too many?",n);
 		a = new Grid(new Dim(n),nt,true);
 		this->n=n;
-		bself->ninlets_set(this->n);
+		ninlets_set(this->n);
 	}
 	\decl void _n_float (int inlet, float f);
 	\decl void _n_list  (int inlet, float f);
@@ -2229,7 +2229,7 @@
 		if (n<1) RAISE("n=%d must be at least 1",n);
 		if (n>32) RAISE("n=%d is too many?",n);
 		this->n=n;
-		bself->noutlets_set(this->n);
+		noutlets_set(this->n);
 	}
 	\grin 0
 };
@@ -2238,7 +2238,7 @@
 	if (in->dim->v[0]!=this->n) RAISE("expecting dim(%ld), got dim(%ld)",this->n,in->dim->v[0]);
 	in->set_chunk(0);
 } GRID_FLOW {
-	for (int i=n-1; i>=0; i--) outlet_float(bself->outlets[i],(t_float)data[i]);
+	for (int i=n-1; i>=0; i--) outlet_float(outlets[i],(t_float)data[i]);
 } GRID_END
 \end class {install("#unpack",1,0);}
 

Modified: trunk/src/classes2.cxx
==============================================================================
--- trunk/src/classes2.cxx (original)
+++ trunk/src/classes2.cxx Sat Nov  7 21:55:41 2009
@@ -79,7 +79,7 @@
 				SETNULL(&sargv[i].defaultv);
 			} else RAISE("expected symbol or nested list");
 		}
-		bself->noutlets_set(sargc);
+		noutlets_set(sargc);
 	}
 	~Args () {delete[] sargv;}
 	\decl 0 bang ();
@@ -91,7 +91,7 @@
     while (!x->gl_env) if (!(x = x->gl_owner)) bug("t_canvasenvironment", x);
     return x;
 } 
-\def 0 bang () {post("%s shouldn't bang [args] anymore.",canvas_getabstop(bself->mom)->gl_name->s_name);}
+\def 0 bang () {post("%s shouldn't bang [args] anymore.",canvas_getabstop(mom)->gl_name->s_name);}
 void outlet_anything2 (t_outlet *o, int argc, t_atom *argv) {
 	if (!argc) outlet_bang(o);
 	else if (argv[0].a_type==A_SYMBOL) outlet_anything(o,argv[0].a_symbol,argc-1,argv+1);
@@ -105,7 +105,7 @@
 	else pd_typedmess(o,&s_list,argc,argv);
 }
 \def 0 loadbang () {
-	t_canvasenvironment *env = canvas_getenv(bself->mom);
+	t_canvasenvironment *env = canvas_getenv(mom);
 	int ac = env->ce_argc;
 	t_atom av[ac];
 	for (int i=0; i<ac; i++) av[i] = env->ce_argv[i];
@@ -119,14 +119,14 @@
 		j++;
 		int k=j;
 		for (; j<ac; j++) if (av[j].a_type==A_SYMBOL && av[j].a_symbol==comma) break;
-		//outlet_anything2(bself->outlets[sargc],j-k,av+k);
-		t_text *t = (t_text *)canvas_getabstop(bself->mom);
+		//outlet_anything2(outlets[sargc],j-k,av+k);
+		t_text *t = (t_text *)canvas_getabstop(mom);
 		if (!t->te_inlet) RAISE("can't send init-messages, because object has no [inlet]");
 		pd_anything2((t_pd *)t->te_inlet,j-k,av+k);
 	}
 }
 void Args::process_args (int argc, t_atom *argv) {
-	t_canvas *canvas = canvas_getrootfor(bself->mom);
+	t_canvas *canvas = canvas_getrootfor(mom);
 	t_symbol *wildcard = gensym("*");
 	for (int i=sargc-1; i>=0; i--) {
 		t_atom *v;
@@ -139,14 +139,14 @@
 			}
 		} else v = &argv[i];
 		if (sargv[i].name==wildcard) {
-			if (argc-i>0) outlet_list(bself->outlets[i],&s_list,argc-i,argv+i);
-			else outlet_bang(bself->outlets[i]);
+			if (argc-i>0) outlet_list(outlets[i],&s_list,argc-i,argv+i);
+			else outlet_bang(outlets[i]);
 		} else {
 			if (v->a_type==A_LIST) {
 				t_binbuf *b = (t_binbuf *)v->a_gpointer;
-				outlet_list(bself->outlets[i],&s_list,binbuf_getnatom(b),binbuf_getvec(b));
-			} else if (v->a_type==A_SYMBOL) outlet_symbol(bself->outlets[i],v->a_symbol);
-			else outlet_anything2(bself->outlets[i],1,v);
+				outlet_list(outlets[i],&s_list,binbuf_getnatom(b),binbuf_getvec(b));
+			} else if (v->a_type==A_SYMBOL) outlet_symbol(outlets[i],v->a_symbol);
+			else outlet_anything2(outlets[i],1,v);
 		}
 	}
 	if (argc>sargc && sargv[sargc-1].name!=wildcard) pd_error(canvas,"warning: too many args (got %d, want %d)", argc, sargc);
@@ -217,15 +217,15 @@
 \def 0 list (...) {
 	if (argc<1) RAISE("empty input");
 	int i=0; for (; i<ac; i++) if (atom_eq(at[i],argv[0])) break;
-	outlet_float(bself->outlets[0],i==ac?-1:i);
+	outlet_float(outlets[0],i==ac?-1:i);
 }
 \def 0 float (float f) {
 	int i=0; for (; i<ac; i++) if (atom_eq(at[i],argv[0])) break;
-	outlet_float(bself->outlets[0],i==ac?-1:i);
+	outlet_float(outlets[0],i==ac?-1:i);
 }
 \def 0 symbol (t_symbol *s) {
 	int i=0; for (; i<ac; i++) if (atom_eq(at[i],argv[0])) break;
-	outlet_float(bself->outlets[0],i==ac?-1:i);
+	outlet_float(outlets[0],i==ac?-1:i);
 }
 //doc:_1_list,"list to search into"
 //doc:_0_float,"float to find in that list"
@@ -250,8 +250,8 @@
 \def 0 float(float f) {
 	int i = int(f);
 	if (i<0) i+=ac;
-	if (i<0 || i>=ac) {outlet_bang(bself->outlets[0]); return;} /* out-of-range */
-	outlet_atom(bself->outlets[0],&at[i]);
+	if (i<0 || i>=ac) {outlet_bang(outlets[0]); return;} /* out-of-range */
+	outlet_atom(outlets[0],&at[i]);
 }
 \def 1 list (...) {
 	if (at) delete[] at;
@@ -269,8 +269,8 @@
 		for (int i=0; i<argc; i++) if (argv[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]=argv[i].a_float;
-		bself-> ninlets_set(1+nmosusses);
-		bself->noutlets_set(1+nmosusses);
+		 ninlets_set(1+nmosusses);
+		noutlets_set(1+nmosusses);
 	}
 	~Range () {delete[] mosusses;}
 	\decl 0 float(float f);
@@ -280,7 +280,7 @@
 \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->outlets[i],f);
+	outlet_float(outlets[i],f);
 }
  // precedence problem in dispatcher... does this problem still exist?
 \def void _n_float(int i, float f) {if (!i) _0_float(argc,argv,f); else mosusses[i-1] = f;}
@@ -535,8 +535,8 @@
 	SETFLOAT(b+0,tv.tv_sec/86400);
 	SETFLOAT(b+1,mod(tv.tv_sec,86400));
 	SETFLOAT(b+2,tv.tv_usec);
-	outlet_anything(bself->outlets[2],&s_list,6,a);
-	outlet_anything(bself->outlets[1],&s_list,3,b);
+	outlet_anything(outlets[2],&s_list,6,a);
+	outlet_anything(outlets[1],&s_list,3,b);
 	send_out(0,strlen(tt),tt);
 }
 
@@ -603,11 +603,11 @@
 void ParallelPort::call() {
 	int flags;
 	if (ioctl(fd,LPGETFLAGS,&flags)<0) post("ioctl: %s",strerror(errno));
-	if (this->flags!=flags) outlet_float(bself->outlets[2],flags);
+	if (this->flags!=flags) outlet_float(outlets[2],flags);
 	this->flags = flags;
 	int status;
 	if (ioctl(fd,LPGETSTATUS,&status)<0) post("ioctl: %s",strerror(errno));
-	if (this->status!=status) outlet_float(bself->outlets[1],status);
+	if (this->status!=status) outlet_float(outlets[1],status);
 	this->status = status;
 	if (clock) clock_delay(clock,2000);
 }
@@ -621,7 +621,7 @@
 	int nsels;
 	t_symbol **sels;
 	~Route2() {if (sels) delete[] sels;}
-	\constructor (...) {nsels=0; sels=0; _1_list(argc,argv); bself->noutlets_set(1+nsels);}
+	\constructor (...) {nsels=0; sels=0; _1_list(argc,argv); noutlets_set(1+nsels);}
 	\decl void anything(...);
 	\decl 1 list(...);
 };
@@ -629,7 +629,7 @@
 	t_symbol *sel = gensym(argv[0].a_symbol->s_name+3);
 	int i=0;
 	for (i=0; i<nsels; i++) if (sel==sels[i]) break;
-	outlet_anything(bself->outlets[i],sel,argc-1,argv+1);
+	outlet_anything(outlets[i],sel,argc-1,argv+1);
 }
 \def 1 list(...) {
 	for (int i=0; i<argc; i++) if (argv[i].a_type!=A_SYMBOL) {delete[] sels; RAISE("$%d: expected symbol",i+1);}
@@ -654,14 +654,14 @@
 		this->lo=0;
 		this->mode=0;
 		this->index=i;
-		bself->noutlets_set(n);
+		noutlets_set(n);
 	}
 	\decl void anything(...);
 	\decl 1 float(int i);
 };
 \def void anything(...) {
 	t_symbol *sel = gensym(argv[0].a_symbol->s_name+3);
-	outlet_anything(bself->outlets[index],sel,argc-1,argv+1);
+	outlet_anything(outlets[index],sel,argc-1,argv+1);
 	if (mode) {
 		index += sgn(mode);
 		if (index<lo || index>hi) {
@@ -721,8 +721,8 @@
 	do_bind(argc,argv);
 }
 void ReceivesProxy_anything (ReceivesProxy *self, t_symbol *s, int argc, t_atom *argv) {
-	outlet_symbol(  self->parent->bself->outlets[1],self->suffix);
-	outlet_anything(self->parent->bself->outlets[0],s,argc,argv);
+	outlet_symbol(  self->parent->outlets[1],self->suffix);
+	outlet_anything(self->parent->outlets[0],s,argc,argv);
 }
 \end class {
 	install("receives",1,2);
@@ -736,7 +736,7 @@
 	\decl void _0_symbol(t_symbol *s);
 };
 \def void _0_symbol(t_symbol *s) {
-	outlet_float(bself->outlets[0],!!zgetfn(&pd_objectmaker,s));
+	outlet_float(outlets[0],!!zgetfn(&pd_objectmaker,s));
 }
 \end class {install("class_exists",1,1);}
 
@@ -751,10 +751,10 @@
 	list = list_new(argc,argv);
 }
 \def 0 list (...) {
-	if (binbuf_getnatom(list) != argc) {outlet_float(bself->outlets[0],0); return;}
+	if (binbuf_getnatom(list) != argc) {outlet_float(outlets[0],0); return;}
 	t_atom2 *at = (t_atom2 *)binbuf_getvec(list);
-	for (int i=0; i<argc; i++) if (!atom_eq(at[i],argv[i])) {outlet_float(bself->outlets[0],0); return;}
-	outlet_float(bself->outlets[0],1);
+	for (int i=0; i<argc; i++) if (!atom_eq(at[i],argv[i])) {outlet_float(outlets[0],0); return;}
+	outlet_float(outlets[0],1);
 }
 \end class {install("list.==",2,1);}
 
@@ -780,7 +780,7 @@
 	\decl 1 bang ();
 };
 \def 0 bang () {struct tms t; times(&t); time = t.tms_utime;}
-\def 1 bang () {struct tms t; times(&t); outlet_float(bself->outlets[0],(t.tms_utime-time)*1000/HZ);}
+\def 1 bang () {struct tms t; times(&t); outlet_float(outlets[0],(t.tms_utime-time)*1000/HZ);}
 \end class {install("usertime",2,1);}
 \class SystemTime : FObject {
 	clock_t time;
@@ -789,7 +789,7 @@
 	\decl 1 bang ();
 };
 \def 0 bang () {struct tms t; times(&t); time = t.tms_stime;}
-\def 1 bang () {struct tms t; times(&t); outlet_float(bself->outlets[0],(t.tms_stime-time)*1000/HZ);}
+\def 1 bang () {struct tms t; times(&t); outlet_float(outlets[0],(t.tms_stime-time)*1000/HZ);}
 \end class {install("systemtime",2,1);}
 \class TSCTime : FObject {
 	uint64 time;
@@ -798,7 +798,7 @@
 	\decl 1 bang ();
 };
 \def 0 bang () {time=rdtsc();}
-\def 1 bang () {outlet_float(bself->outlets[0],(rdtsc()-time)*1000.0/cpu_hertz);}
+\def 1 bang () {outlet_float(outlets[0],(rdtsc()-time)*1000.0/cpu_hertz);}
 \end class {install("tsctime",2,1);
 	struct timeval t0,t1;
 	uint64 u0,u1;
@@ -837,7 +837,7 @@
 \def 0 list (...) {
 	std::ostringstream o;
 	pd_oprintf(o,format.data(),argc,argv);
-	t_canvas *canvas = canvas_getrootfor(bself->mom);
+	t_canvas *canvas = canvas_getrootfor(mom);
 	string s = o.str();
 	pd_error(canvas,"%s",s.data());
 }
@@ -849,7 +849,7 @@
 	\decl 0 list (...);
 };
 \def 0 list (...) {
-	t_outlet *o = bself->outlets[0];
+	t_outlet *o = outlets[0];
 	for (int i=0; i<argc; i++) {
 		if      (argv[i].a_type==A_FLOAT)  outlet_float( o,argv[i]);
 		else if (argv[i].a_type==A_SYMBOL) outlet_symbol(o,argv[i]);
@@ -861,7 +861,7 @@
 //****************************************************************
 
 #define MOM \
-	t_canvas *mom = bself->mom; \
+	t_canvas *mom = this->mom; \
 	for (int i=0; i<n; i++) {mom = mom->gl_owner; if (!mom) RAISE("no such canvas");}
 
 \class GFCanvasFileName : FObject {
@@ -869,14 +869,14 @@
 	\constructor (int n) {this->n=n;}
 	\decl 0 bang ();
 };
-\def 0 bang () {MOM; outlet_symbol(bself->outlets[0],mom->gl_name ? mom->gl_name : gensym("empty"));}
+\def 0 bang () {MOM; outlet_symbol(outlets[0],mom->gl_name ? mom->gl_name : gensym("empty"));}
 \end class {install("gf/canvas_filename",1,1);}
 \class GFCanvasDollarZero : FObject {
 	int n;
 	\constructor (int n) {this->n=n;}
 	\decl 0 bang ();
 };
-\def 0 bang () {MOM; outlet_float(bself->outlets[0],canvas_getenv(mom)->ce_dollarzero);}
+\def 0 bang () {MOM; outlet_float(outlets[0],canvas_getenv(mom)->ce_dollarzero);}
 \end class {install("gf/canvas_dollarzero",1,1);}
 \class GFCanvasGetPos : FObject {
 	int n;
@@ -887,7 +887,7 @@
 	t_atom a[2];
 	SETFLOAT(a+0,mom->gl_obj.te_xpix);
 	SETFLOAT(a+1,mom->gl_obj.te_ypix);
-	outlet_list(bself->outlets[0],&s_list,2,a);
+	outlet_list(outlets[0],&s_list,2,a);
 }
 \end class {install("gf/canvas_getpos",1,1);}
 \class GFCanvasSetPos : FObject {
@@ -918,7 +918,7 @@
 };
 \def 0 bang () {MOM;
 	t_atom a[1]; SETFLOAT(a+0,0);
-	outlet_float(bself->outlets[0],mom->gl_edit);
+	outlet_float(outlets[0],mom->gl_edit);
 }
 \end class {install("gf/canvas_edit_mode",1,1);}
 extern "C" void canvas_setgraph(t_glist *x, int flag, int nogoprect);
@@ -946,13 +946,12 @@
 	\decl 0 xid (t_symbol *t, t_symbol *u);
 };
 \def 0 bang () {
-	t_canvas *mom = bself->mom;
 	for (int i=0; i<n; i++) {mom = mom->gl_owner; if (!mom) RAISE("no such canvas");}
 	sys_vgui("pd %s xid [winfo id .x%lx.c] [winfo id .x%lx]\\;\n",name->s_name,long(mom),long(mom));
 }
 \def 0 xid (t_symbol *t, t_symbol *u) {
-	outlet_symbol(bself->outlets[0],t);
-	outlet_symbol(bself->outlets[1],u);
+	outlet_symbol(outlets[0],t);
+	outlet_symbol(outlets[1],u);
 }
 \end class {install("gf/canvas_xid",1,2);}
 
@@ -995,7 +994,7 @@
 	\constructor (int n) {this->n=n;}
 	\decl 0 bang ();
 };
-\def 0 bang () {MOM; int k=0; canvas_each(y,mom) k++; outlet_float(bself->outlets[0],k);}
+\def 0 bang () {MOM; int k=0; canvas_each(y,mom) k++; outlet_float(outlets[0],k);}
 \end class {install("gf/canvas_count",1,1);}
 
 \class GFCanvasLoadbang : FObject {
@@ -1024,8 +1023,8 @@
 	\decl 0  box_align (t_symbol *s, int x_start, int y_start, int incr);
 };
 #define BEGIN \
-	t_outlet *ouch = ((t_object *)bself->mom)->te_outlet; \
-	t_canvas *can = bself->mom->gl_owner; \
+	t_outlet *ouch = ((t_object *)mom)->te_outlet; \
+	t_canvas *can = mom->gl_owner; \
 	if (!can) RAISE("no such canvas"); \
 	for (int i=0; i<n; i++) {ouch = ouch->next; if (!ouch) {RAISE("no such outlet");}}
 #define wire_each(wire,ouchlet) for (t_outconnect *wire = ouchlet->connections; wire; wire=wire->next)
@@ -1107,8 +1106,8 @@
 		if (horiz) x += x2-x1+incr;
 		else       y += y2-y1+incr;
 	}
-	if (horiz) outlet_float(bself->outlets[0],x-x_start);
-	else       outlet_float(bself->outlets[0],y-y_start);
+	if (horiz) outlet_float(outlets[0],x-x_start);
+	else       outlet_float(outlets[0],y-y_start);
 #else
 	post("doesn't work with DesireData");
 #endif
@@ -1168,7 +1167,7 @@
 	  a = a.replace(i,b.length(),c);
 	  i += c.length();
 	}
-	outlet_symbol(bself->outlets[0],gensym(a.c_str()));
+	outlet_symbol(outlets[0],gensym(a.c_str()));
 }
 \end class {install("gf/string_replace",1,1);}
 
@@ -1178,7 +1177,7 @@
 	\decl 0 symbol (t_symbol *it);
 	\decl 1 symbol (t_symbol *than);
 };
-\def 0 symbol (t_symbol *it) {outlet_float(bself->outlets[0],strcmp(it->s_name,than->s_name)<0);}
+\def 0 symbol (t_symbol *it) {outlet_float(outlets[0],strcmp(it->s_name,than->s_name)<0);}
 \def 1 symbol (t_symbol *than) {this->than=than;}
 \end class {install("gf/string_<",2,1);}
 

Modified: trunk/src/formats.cxx
==============================================================================
--- trunk/src/formats.cxx (original)
+++ trunk/src/formats.cxx Sat Nov  7 21:55:41 2009
@@ -75,13 +75,13 @@
 \def 0 symbol (t_symbol *str) {
 	char *s = strdup(str->s_name);
 	char *t = strrchr(s,'.');
-	if (!t) outlet_symbol(bself->outlets[2],gensym(s));
+	if (!t) outlet_symbol(outlets[2],gensym(s));
 	else {
 		*t = 0;
-		outlet_symbol(bself->outlets[1],gensym(t+1));
+		outlet_symbol(outlets[1],gensym(t+1));
 		std::map<std::string,std::string>::iterator u = suffix_table.find(std::string(t+1));
-		if (u==suffix_table.end()) outlet_bang(bself->outlets[0]);
-		else outlet_symbol(bself->outlets[0],gensym((char *)u->second.data()));
+		if (u==suffix_table.end()) outlet_bang(outlets[0]);
+		else outlet_symbol(outlets[0],gensym((char *)u->second.data()));
 	}
 	free(s);
 }

Modified: trunk/src/grid.cxx
==============================================================================
--- trunk/src/grid.cxx (original)
+++ trunk/src/grid.cxx Sat Nov  7 21:55:41 2009
@@ -198,7 +198,7 @@
 	t_atom a[1];
 	SETGRIDOUT(a,this);
 	if (parent) {
-		outlet_anything(parent->bself->outlets[woutlet],bsym._grid,1,a);
+		outlet_anything(parent->outlets[woutlet],bsym._grid,1,a);
 		if (!dim->prod()) finish();
 	}
 }

Modified: trunk/src/gridflow.cxx
==============================================================================
--- trunk/src/gridflow.cxx (original)
+++ trunk/src/gridflow.cxx Sat Nov  7 21:55:41 2009
@@ -567,6 +567,27 @@
 	BFObject_anything(self->parent,self->id,s,argc,argv);
 }
 
+FObject::FObject (BFObject *bself, MESSAGE) {
+	this->bself = bself;
+	bself->self = this;
+	string name = string(sel->s_name);
+	if (!mom) post("warning: no mom");
+	mom = (t_canvas *)canvas_getcurrent();
+	post("mom=%p",mom);
+	ninlets  = 1;
+	noutlets = 0;
+	inlets  = new  BFProxy*[1];
+	outlets = new t_outlet*[1];
+	FClass *fc = fclasses[name];
+	inlets[0] = 0; // inlet 0 of this table is not in use
+	ninlets_set( fc->ninlets ,false);
+	noutlets_set(fc->noutlets,false);
+}
+FObject::~FObject () {
+	ninlets_set(1,false);
+	delete[] inlets;
+	delete[] outlets;
+}
 static void *BFObject_new (t_symbol *classsym, int ac, t_atom *at) {
     string name = string(classsym->s_name);
     if (fclasses.find(name)==fclasses.end()) {post("GF: class not found: '%s'",classsym->s_name); return 0;}
@@ -580,18 +601,9 @@
 	//pd_post(classsym->s_name,argc,argv);
 	int j;
 	for (j=0; j<argc; j++) if (argv[j].a_type==A_COMMA) break;
-
 	bself->self = 0;
-	bself->mom = (t_canvas *)canvas_getcurrent();
-	bself->ninlets  = 1;
-	bself->noutlets = 0;
-	bself->inlets  = new  BFProxy*[1];
-	bself->outlets = new t_outlet*[1];
-	bself->inlets[0] = 0; // inlet 0 of this table is not in use
-	bself->ninlets_set( fclasses[classsym->s_name]->ninlets ,false);
-	bself->noutlets_set(fclasses[classsym->s_name]->noutlets,false);
 	t_allocator alloc = fclasses[string(classsym->s_name)]->allocator;
-	bself->self = alloc(bself,0,j,(t_atom2 *)argv);
+	bself->self = alloc(bself,classsym,j,(t_atom2 *)argv);
 	while (j<argc) {
 		j++;
 		int k=j;
@@ -604,38 +616,37 @@
 
 static void BFObject_delete (BFObject *bself) {
 	try {delete bself->self;} catch (Barf &oozy) {oozy.error(bself);}
-	bself->ninlets_set(1,false);
-	delete[] bself->inlets;
-	delete[] bself->outlets;
 }
 
 //****************************************************************
 
 static void BFObject_undrawio (BFObject *bself) {
 #ifndef HAVE_DESIREDATA
-	if (!bself->mom || !glist_isvisible(bself->mom)) return;
-	t_rtext *rt = glist_findrtext(bself->mom,bself);
+	t_canvas *mom = bself->self->mom;
+	if (!mom || !glist_isvisible(mom)) return;
+	t_rtext *rt = glist_findrtext(mom,bself);
 	if (!rt) return;
-	glist_eraseiofor(bself->mom,bself,rtext_gettag(rt));
+	glist_eraseiofor(mom,bself,rtext_gettag(rt));
 #endif
 }
 
 static void BFObject_redraw (BFObject *bself) {
 #ifndef HAVE_DESIREDATA
-	if (!bself->mom || !glist_isvisible(bself->mom)) return;
-	t_rtext *rt = glist_findrtext(bself->mom,bself);
+	t_canvas *mom = bself->self->mom;
+	if (!mom || !glist_isvisible(mom)) return;
+	t_rtext *rt = glist_findrtext(mom,bself);
 	if (!rt) return;
-	gobj_vis((t_gobj *)bself,bself->mom,0);
-	gobj_vis((t_gobj *)bself,bself->mom,1);
-	canvas_fixlinesfor(bself->mom,(t_text *)bself);
+	gobj_vis((t_gobj *)bself,mom,0);
+	gobj_vis((t_gobj *)bself,mom,1);
+	canvas_fixlinesfor(mom,(t_text *)bself);
 #endif
 }
 
 /* warning: deleting inlets that are connected will cause pd to crash */
-void BFObject::ninlets_set (int n, bool draw) {
-	if (!te_binbuf) draw=false;
+void FObject::ninlets_set (int n, bool draw) {
+	if (!bself->te_binbuf) draw=false;
 	if (n<1) RAISE("ninlets_set: n=%d must be at least 1",n);
-	if (draw) BFObject_undrawio(this);
+	if (draw) BFObject_undrawio(bself);
 	if (ninlets<n) {
 		BFProxy **noo = new BFProxy*[n];
 		memcpy(noo,inlets,ninlets*sizeof(BFProxy*));
@@ -643,9 +654,9 @@
 		inlets = noo;
 		while (ninlets<n) {
 			BFProxy *p = inlets[ninlets] = (BFProxy *)pd_new(BFProxy_class);
-			p->parent = this;
+			p->parent = bself;
 			p->id = ninlets;
-			p->inlet = inlet_new(this, &p->ob_pd, 0,0);
+			p->inlet = inlet_new(bself,&p->ob_pd,0,0);
 			ninlets++;
 		}
 	} else {
@@ -655,23 +666,23 @@
 			pd_free((t_pd *)inlets[ninlets]);
 		}
 	}
-	if (draw) BFObject_redraw(this);
+	if (draw) BFObject_redraw(bself);
 }
 /* warning: deleting outlets that are connected will cause pd to crash */
-void BFObject::noutlets_set (int n, bool draw) {
-	if (!te_binbuf) draw=false;
+void FObject::noutlets_set (int n, bool draw) {
+	if (!bself->te_binbuf) draw=false;
 	if (n<0) RAISE("noutlets_set: n=%d must be at least 0",n);
-	if (draw) BFObject_undrawio(this);
+	if (draw) BFObject_undrawio(bself);
 	if (noutlets<n) {
 		t_outlet **noo = new t_outlet*[n>0?n:1];
 		memcpy(noo,outlets,noutlets*sizeof(t_outlet*));
 		delete[] outlets;
 		outlets = noo;
-		while (noutlets<n) outlets[noutlets++] = outlet_new(this,&s_anything);
+		while (noutlets<n) outlets[noutlets++] = outlet_new(bself,&s_anything);
 	} else {
 		while (noutlets>n) outlet_free(outlets[--noutlets]);
 	}
-	if (draw) BFObject_redraw(this);
+	if (draw) BFObject_redraw(bself);
 }
 
 string BFObject::binbuf_string () {

Modified: trunk/src/gridflow.hxx
==============================================================================
--- trunk/src/gridflow.hxx (original)
+++ trunk/src/gridflow.hxx Sat Nov  7 21:55:41 2009
@@ -726,7 +726,7 @@
 	static const long MIN_PACKET_SIZE = 1<<8;
 	static const long MAX_PACKET_SIZE = 1<<12;
 // those are set only once
-	FObject *parent; // not a P<> because of circular refs
+	FObject *parent;
 	P<Dim> dim; // dimensions of the grid being sent
 	NumberTypeE nt;
 	std::vector<GridInlet *> inlets; // which inlets are we connected to
@@ -768,26 +768,27 @@
 struct BFProxy;
 struct BFObject : t_object {
 	FObject *self;
+	string binbuf_string ();
+};
+
+// represents objects that have inlets/outlets
+\class FObject {
+	virtual ~FObject ();
+	virtual void changed (t_symbol *s=0) {}
+	BFObject *bself; // point to PD peer
 	int ninlets,noutlets; // per object settings (not class)
 	BFProxy  **inlets;    // direct access to  inlets (not linked lists)
 	t_outlet **outlets;   // direct access to outlets (not linked lists)
 	t_canvas *mom;
 	void  ninlets_set(int n, bool draw=true);
 	void noutlets_set(int n, bool draw=true);
-	string binbuf_string ();
-};
-
-// represents objects that have inlets/outlets
-\class FObject {
-	virtual void changed (t_symbol *s=0) {}
-	BFObject *bself; // point to PD peer
 	std::vector<P<GridInlet> > in;
 	P<GridOutlet> out;
-	FObject(BFObject *bself, MESSAGE) : bself(bself) {bself->self = this;}
+	FObject(BFObject *bself, MESSAGE);
 	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);
+		outlet_list(outlets[outlet],&s_list,argc,foo);
 	}
 	\decl 0 get (t_symbol *s=0);
 	\decl 0 help ();

Modified: trunk/src/opencv.cxx
==============================================================================
--- trunk/src/opencv.cxx (original)
+++ trunk/src/opencv.cxx Sat Nov  7 21:55:41 2009
@@ -409,7 +409,7 @@
 	\constructor (int channels) {
 		if (channels<0 || channels>64) RAISE("channels=%d is not in 1..64",channels);
 		this->channels = channels;
-		bself->noutlets_set(channels);
+		noutlets_set(channels);
 	}
 };
 \end class {}

Modified: trunk/src/quicktimehw.cxx
==============================================================================
--- trunk/src/quicktimehw.cxx (original)
+++ trunk/src/quicktimehw.cxx Sat Nov  7 21:55:41 2009
@@ -87,7 +87,7 @@
 \def 0 bang () {
 	long length = quicktime_video_length(anim,track);
 	long nframe = quicktime_video_position(anim,track);
-	if (nframe >= length) {outlet_bang(bself->te_outlet); return;}
+	if (nframe >= length) {outlet_bang(outlets[0]); return;}
 	/* if it works, only do it once, to avoid silly stderr messages forgotten in LQT */
 	if (!quicktime_reads_cmodel(anim,colorspace,0) && !started) {
 		RAISE("LQT says this video cannot be decoded into the chosen colorspace");
@@ -191,23 +191,13 @@
 }
 
 \def 0 get () {
-/*	t_atom a[1];
-	SETFLOAT(a,(float)length);
-	outlet_anything(bself->te_outlet,gensym("frames"),1,a);
-*/
 	t_atom a[1];
-	SETFLOAT(a,quicktime_video_length(anim,track));
-	outlet_anything(bself->outlets[0],gensym("frames"),1,a);
-	SETFLOAT(a,quicktime_frame_rate(anim,track));
-	outlet_anything(bself->outlets[0],gensym("framerate"),1,a);
-	SETFLOAT(a,quicktime_video_height(anim,track));
-	outlet_anything(bself->outlets[0],gensym("height"),1,a);
-	SETFLOAT(a,quicktime_video_width(anim,track));
-	outlet_anything(bself->outlets[0],gensym("width"),1,a);
-	SETFLOAT(a,quicktime_video_depth(anim,track));
-	outlet_anything(bself->outlets[0],gensym("depth"),1,a);
-	SETSYMBOL(a,gensym(quicktime_video_compressor(anim,track)));
-	outlet_anything(bself->outlets[0],gensym("codec"),1,a);
+	SETFLOAT(a,quicktime_video_length(anim,track));	outlet_anything(outlets[0],gensym("frames"),1,a);
+	SETFLOAT(a,quicktime_frame_rate(anim,track));	outlet_anything(outlets[0],gensym("framerate"),1,a);
+	SETFLOAT(a,quicktime_video_height(anim,track));	outlet_anything(outlets[0],gensym("height"),1,a);
+	SETFLOAT(a,quicktime_video_width(anim,track));	outlet_anything(outlets[0],gensym("width"),1,a);
+	SETFLOAT(a,quicktime_video_depth(anim,track));	outlet_anything(outlets[0],gensym("depth"),1,a);
+	SETSYMBOL(a,gensym(quicktime_video_compressor(anim,track))); outlet_anything(outlets[0],gensym("codec"),1,a);
 	//SUPER;
 }
 

Modified: trunk/src/sdl.cxx
==============================================================================
--- trunk/src/sdl.cxx (original)
+++ trunk/src/sdl.cxx Sat Nov  7 21:55:41 2009
@@ -79,7 +79,7 @@
 	SETFLOAT(a+0,mousey);
 	SETFLOAT(a+1,mousex);
 	SETFLOAT(a+2,mousem);
-	outlet_anything(instance->bself->outlets[0],gensym("position"),COUNT(a),a);
+	outlet_anything(instance->outlets[0],gensym("position"),COUNT(a),a);
 }
 
 static void HandleEvent () {
@@ -102,7 +102,7 @@
 			SETFLOAT(at+1,mousex);
 			SETFLOAT(at+2,mousem);
 			SETSYMBOL(at+3,keyboard[event.key.keysym.sym]);
-			outlet_anything(instance->bself->outlets[0],sel,4,at);
+			outlet_anything(instance->outlets[0],sel,4,at);
 		    } break;
 		    case SDL_MOUSEBUTTONDOWN: SDL_MOUSEBUTTONUP: {
 			if (SDL_MOUSEBUTTONDOWN) mousem |=  (128<<event.button.button);

Modified: trunk/src/source_filter.rb
==============================================================================
--- trunk/src/source_filter.rb (original)
+++ trunk/src/source_filter.rb Sat Nov  7 21:55:41 2009
@@ -229,7 +229,7 @@
 		handle_def "0 #{name} (#{type} #{name}) {this->#{name}=#{name}; changed(gensym(\"#{name}\"));}"
 	}
 	line.gsub!(/^\s*(\w+\s*)?\{/,"")
-	get << "RAISE(\"unknown attr %s\",s->s_name); outlet_anything(bself->outlets[bself->noutlets-1],s,1,a);}"
+	get << "RAISE(\"unknown attr %s\",s->s_name); outlet_anything(outlets[noutlets-1],s,1,a);}"
 	handle_def get if frame.attrs.size>0
 	Out.print "void #{frame.name}_startup (FClass *fclass) {"
 	frame.attrs.each {|name,attr| Out.print "fclass->attrs[\"#{name}\"] = new AttrDecl(\"#{name}\",\"#{attr.type}\");" }

Modified: trunk/src/videodev.cxx
==============================================================================
--- trunk/src/videodev.cxx (original)
+++ trunk/src/videodev.cxx Sat Nov  7 21:55:41 2009
@@ -294,19 +294,19 @@
 		t_atom a[2];
 		SETFLOAT(a+0,vcaps.minheight);
 		SETFLOAT(a+1,vcaps.minwidth);
-		outlet_anything(bself->outlets[0],gensym("minsize"),2,a);
+		outlet_anything(outlets[0],gensym("minsize"),2,a);
 		SETFLOAT(a+0,vcaps.maxheight);
 		SETFLOAT(a+1,vcaps.maxwidth);
-		outlet_anything(bself->outlets[0],gensym("maxsize"),2,a);
+		outlet_anything(outlets[0],gensym("maxsize"),2,a);
 		char *foo = choice_to_s(vp.palette,COUNT(video_palette_choice),video_palette_choice);
 		SETSYMBOL(a,gensym(foo));
 		free(foo);
-		outlet_anything(bself->outlets[0],gensym("palette"),1,a);
+		outlet_anything(outlets[0],gensym("palette"),1,a);
 		SETSYMBOL(a,use_mmap ? gensym("mmap") : gensym("read"));
-		outlet_anything(bself->outlets[0],gensym("transfer"),1,a);
+		outlet_anything(outlets[0],gensym("transfer"),1,a);
 		SETFLOAT(a+0,dim->v[0]);
 		SETFLOAT(a+1,dim->v[1]);
-		outlet_anything(bself->outlets[0],gensym("size"),2,a); // abnormal (does not use nested list)
+		outlet_anything(outlets[0],gensym("size"),2,a); // abnormal (does not use nested list)
 	}
 }
 

Modified: trunk/src/x11.cxx
==============================================================================
--- trunk/src/x11.cxx (original)
+++ trunk/src/x11.cxx Sat Nov  7 21:55:41 2009
@@ -288,7 +288,7 @@
 	SETFLOAT(a+0,y);
 	SETFLOAT(a+1,x);
 	SETFLOAT(a+2,state);
-	outlet_anything(bself->outlets[0],gensym("position"),COUNT(a),a);
+	outlet_anything(outlets[0],gensym("position"),COUNT(a),a);
 }
 
 void FormatX11::call() {
@@ -326,7 +326,7 @@
 			SETFLOAT(at+1,ek->x);
 			SETFLOAT(at+2,ek->state);
 			SETSYMBOL(at+3,gensym(buf));
-			outlet_anything(bself->outlets[0],sel,4,at);
+			outlet_anything(outlets[0],sel,4,at);
 			//XFree(kss);
 		}break;
 		case MotionNotify:{



More information about the Gridflow-cvs mailing list