[Gridflow-cvs] [svn] commit: r3657 - in /trunk: base/flow_objects.c format/videodev.c gridflow.c gridflow.h

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 25 15:31:13 EDT 2008


Author: matju
Date: Fri Apr 25 15:31:13 2008
New Revision: 3657

Log:
merge initialize2 into \constructor

Modified:
    trunk/base/flow_objects.c
    trunk/format/videodev.c
    trunk/gridflow.c
    trunk/gridflow.h

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Fri Apr 25 15:31:13 2008
@@ -1384,9 +1384,8 @@
 	\grin 0
 	\attr int form();
 	\attr int form_val;
-	\constructor (int form=0) {form_val=form;}
-	\decl void initialize2();
-	\decl void initialize3();
+	\constructor (int form=0) {form_val=form; initialize3();}
+	void initialize3();
 };
 
 struct Stats {
@@ -1457,14 +1456,13 @@
 	delete[] dat;
 } GRID_END
 
-\def void initialize2() {initialize3(0,0);}
 \def int form() {return form_val;}
 \def 0 form(int form) {
 	if (form<0 || form>1) RAISE("form must be 0 or 1, not %d",form);
 	form_val=form;
-	initialize3(0,0);
-}
-\def void initialize3() {
+	initialize3();
+}
+void GridLabeling::initialize3() {
 	bself->ninlets_set(form_val ? 2 : 4);
 }
 
@@ -2196,14 +2194,13 @@
 		if (n>32) RAISE("n=%d is too many?",n);
 		a = new Grid(new Dim(n),nt,true);
 		this->n=n;
-	}
-	\decl void initialize2 ();
+		bself->ninlets_set(this->n);
+	}
 	\decl void _n_float (int inlet, float f);
 	\decl void _n_list  (int inlet, float f);
 	\decl 0 bang ();
 	//\grin 0
 };
-\def void initialize2 () {bself->ninlets_set(this->n);}
 \def void _n_float (int inlet, float f) {
 #define FOO(T) ((T *)*a)[inlet] = (T)f;
 TYPESWITCH(a->nt,FOO,);
@@ -2225,8 +2222,8 @@
 		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;
-	}
-	\decl void initialize2 ();
+		bself->noutlets_set(this->n);
+	}
 	\grin 0
 };
 GRID_INLET(GridUnpack,0) {
@@ -2234,7 +2231,6 @@
 } GRID_FLOW {
 	for (int i=n-1; i>=0; i--) outlet_float(bself->outlets[i],(t_float)data[i]);
 } GRID_END
-\def void initialize2 () {bself->noutlets_set(this->n);}
 \end class {install("#unpack",1,0);}
 
 //****************************************************************
@@ -2390,16 +2386,13 @@
 		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;
-	}
-	\decl void initialize2();
+		bself-> ninlets_set(1+nmosusses);
+		bself->noutlets_set(1+nmosusses);
+	}
 	\decl 0 float(float f);
 	\decl 0 list(float f);
 	\decl void _n_float(int i, float f);
 };
-\def void initialize2() {
-	bself-> ninlets_set(1+nmosusses);
-	bself->noutlets_set(1+nmosusses);
-}
 \def 0 list(float f) {_0_float(argc,argv,f);}
 \def 0 float(float f) {
 	int i;
@@ -2445,12 +2438,15 @@
 		SETFLOAT(a,20);
 		pd_typedmess(gp,gensym("maxrows"),1,a);
 		text << "...";
+		pd_bind((t_pd *)bself,rsym);
+		SETPOINTER(a,(t_gpointer *)bself);
+		pd_typedmess(gp,gensym("dest"),1,a);
+		clock = clock_new((void *)this,(void(*)())display_update);
 	}
 	~Display () {
 		pd_unbind((t_pd *)bself,rsym);
 		if (clock) clock_free(clock);
 	}
-	\decl void initialize2();
 	\decl void anything (...);
 	\decl 0 set_size(int sy, int sx);
 	\decl 0 grid(...);
@@ -2508,13 +2504,6 @@
 static void display_update(void *x) {
 	Display *self = (Display *)x;
 	if (self->vis) self->show();
-}
-\def void initialize2 () {
-	pd_bind((t_pd *)bself,rsym);
-	t_atom a[1];
-	SETPOINTER(a,(t_gpointer *)bself);
-	pd_typedmess(gp,gensym("dest"),1,a);
-	clock = clock_new((void *)this,(void(*)())display_update);
 }
 \def 0 set_size(int sy, int sx) {this->sy=sy; this->sx=sx;}
 \def void anything (...) {
@@ -2609,12 +2598,11 @@
 				SETNULL(&sargv[i].defaultv);
 			} else RAISE("expected symbol or nested list");
 		}
-	}
-	\decl void initialize2 ();
+		bself->noutlets_set(sargc+1);
+	}
 	\decl 0 bang ();
 	void process_args (int argc, t_atom *argv);
 };
-\def void initialize2 () {bself->noutlets_set(sargc+1);}
 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);
@@ -2778,12 +2766,10 @@
 	int nsels;
 	t_symbol **sels;
 	~Route2() {if (sels) delete[] sels;}
-	\constructor (...) {nsels=0; sels=0; _1_list(argc,argv);}
-	\decl void initialize2();
+	\constructor (...) {nsels=0; sels=0; _1_list(argc,argv); bself->noutlets_set(1+nsels);}
 	\decl void anything(...);
 	\decl 1 list(...);
 };
-\def void initialize2() {bself->noutlets_set(1+nsels);}
 \def void anything(...) {
 	t_symbol *sel = gensym(argv[0].a_symbol->s_name+3);
 	int i=0;
@@ -2813,12 +2799,11 @@
 		this->lo=0;
 		this->mode=0;
 		this->index=i;
-	}
-	\decl void initialize2();
+		bself->noutlets_set(n);
+	}
 	\decl void anything(...);
 	\decl 1 float(int i);
 };
-\def void initialize2() {bself->noutlets_set(n);}
 \def void anything(...) {
 	t_symbol *sel = gensym(argv[0].a_symbol->s_name+3);
 	outlet_anything(bself->outlets[index],sel,argc-1,argv+1);

Modified: trunk/format/videodev.c
==============================================================================
--- trunk/format/videodev.c (original)
+++ trunk/format/videodev.c Fri Apr 25 15:31:13 2008
@@ -243,7 +243,7 @@
 		f = fopen(filename.data(),"r+");
 		if (!f) RAISE("can't open device '%s': %s",filename.data(),strerror(errno));
 		fd = fileno(f);
-		initialize2(); // name conflict...
+		initialize2();
 	}
 	void frame_finished (uint8 * buf);
 

Modified: trunk/gridflow.c
==============================================================================
--- trunk/gridflow.c (original)
+++ trunk/gridflow.c Fri Apr 25 15:31:13 2008
@@ -507,12 +507,6 @@
 
 void call_super(int argc, t_atom *argv) {/* unimplemented */}
 
-static void funcall (BFObject *bself, const char *sel, int argc, t_atom *argv, bool silent=false) {
-	Method method = funcall_lookup(bself,sel);
-	if (method) {method(bself->self,argc,(t_atom2 *)argv); return;}
-	if (!silent) pd_error((t_pd *)bself, "method '%s' not found in class '%s'",sel,pd_classname(bself));
-}
-
 //****************************************************************
 // BFObject
 
@@ -569,25 +563,25 @@
 #endif
 	int j;
 	for (j=0; j<argc; j++) if (argv[j].a_type==A_COMMA) break;
-	t_allocator alloc = fclasses[string(classsym->s_name)]->allocator;
-	FObject *self = (FObject *)alloc(bself,0,j,(t_atom2 *)argv);
-	bself->self = self;
-	bself->mom = 0;
-#ifdef HAVE_GEM
-	bself->gemself = (CPPExtern *)((void **)self+11); /* not 64-bit-safe */
-	CPPExtern::m_holder = 0;
-#ifdef HAVE_HOLDNAME
-	CPPExtern::m_holdname=0;
-#endif
-#endif
+
+	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->ninlets_set( fclasses[classsym->s_name]->ninlets);
 	bself->noutlets_set(fclasses[classsym->s_name]->noutlets);
-	funcall(bself,"initialize2",0,0,true);
-	bself->mom = (t_canvas *)canvas_getcurrent();
+#ifdef HAVE_GEM
+	bself->gemself = (CPPExtern *)((void **)bself->self+11); /* not 64-bit-safe */
+	CPPExtern::m_holder = 0;
+#ifdef HAVE_HOLDNAME
+	CPPExtern::m_holdname=0;
+#endif
+#endif
+	t_allocator alloc = fclasses[string(classsym->s_name)]->allocator;
+	bself->self = (FObject *)alloc(bself,0,j,(t_atom2 *)argv);
+
 	while (j<argc) {
 		j++;
 		int k=j;
@@ -636,7 +630,6 @@
 
 /* warning: deleting inlets that are connected will cause pd to crash */
 void BFObject::ninlets_set (int n) {
-	if (!this) RAISE("there is no bself");
 	if (n<1) RAISE("ninlets_set: n=%d must be at least 1",n);
 	BFObject_undrawio(this);
 	if (ninlets<n) {
@@ -662,7 +655,6 @@
 }
 /* warning: deleting outlets that are connected will cause pd to crash */
 void BFObject::noutlets_set (int n) {
-	if (!this) RAISE("there is no bself");
 	if (n<0) RAISE("noutlets_set: n=%d must be at least 0",n);
 	BFObject_undrawio(this);
 	if (noutlets<n) {

Modified: trunk/gridflow.h
==============================================================================
--- trunk/gridflow.h (original)
+++ trunk/gridflow.h Fri Apr 25 15:31:13 2008
@@ -842,7 +842,7 @@
 	BFObject *bself; // point to PD peer
 	std::vector<P<GridInlet> > in;
 	P<GridOutlet> out;
-	FObject(BFObject *bself, MESSAGE) : bself(bself) {}
+	FObject(BFObject *bself, MESSAGE) : bself(bself) {bself->self = this;}
 	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]);



More information about the Gridflow-cvs mailing list