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

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Nov 9 11:34:21 EST 2009


Author: matju
Date: Mon Nov  9 11:34:21 2009
New Revision: 4837

Log:
move binbuf_string back where it was, and stuff

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

Modified: trunk/src/grid.cxx
==============================================================================
--- trunk/src/grid.cxx (original)
+++ trunk/src/grid.cxx Mon Nov  9 11:34:21 2009
@@ -131,7 +131,7 @@
 #endif
 }
 
-#define CATCH_IT catch (Barf &slimy) {slimy.error(parent);}
+#define CATCH_IT catch (Barf &slimy) {slimy.error(parent->bself);}
 
 template <class T> void GridInlet::flow(long n, T *data) {
 	CHECK_BUSY(inlet); CHECK_TYPE(*data,sender->nt); CHECK_ALIGN(data,sender->nt);

Modified: trunk/src/gridflow.cxx
==============================================================================
--- trunk/src/gridflow.cxx (original)
+++ trunk/src/gridflow.cxx Mon Nov  9 11:34:21 2009
@@ -75,9 +75,14 @@
     text = os.str();
 }
 
-void Barf::error(FObject *self) {
-	if (self) pd_error(self,"%s: %s",self->binbuf_string().data(),text.data());
-	else        ::error(    "%s: %s",self->binbuf_string().data(),text.data());
+void Barf::error(BFObject *bself) {
+	if (!bself) RAISE("wtf?");
+	pd_error(bself,"%s: %s",bself->binbuf_string().data(),text.data());
+}
+void Barf::error(t_symbol *s, int argc, t_atom *argv) {
+	std::ostringstream os;
+	for (int i=0; i<argc; i++) os << (i ? " " : "[") << argv[i];
+        ::error(      "[%s]: %s",os.str().data(),text.data());
 }
 
 void pd_oprint (std::ostream &o, int argc, t_atom *argv) {
@@ -580,7 +585,7 @@
 	m = funcall_lookup(bself,"anything");
 	if (m) {SETSYMBOL(argv+0,gensym(buf)); m(bself->self,argc+1,argv); return;}
 	pd_error((t_pd *)bself, "method '%s' not found for inlet %d in class '%s'",selector->s_name,winlet,pd_classname(bself));
-    } catch (Barf &oozy) {oozy.error(bself->self);}
+    } catch (Barf &oozy) {oozy.error(bself);}
 }
 static void BFObject_anything0 (BFObject *self, t_symbol *s, int argc, t_atom2 *argv) {
 	BFObject_anything(self,0,s,argc,argv);
@@ -618,11 +623,11 @@
 	t_atom argv[argc];
 	for (int i=0; i<argc; i++) argv[i] = at[i];
 	argc = handle_braces(argc,argv);
-	//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;
 	t_allocator alloc = fclasses[string(classsym->s_name)]->allocator;
+	bself->te_binbuf = 0; //HACK: supposed to be 0
 	bself->self = alloc(bself,classsym,j,(t_atom2 *)argv);
 	while (j<argc) {
 		j++;
@@ -631,11 +636,11 @@
 		if (argv[k].a_type==A_SYMBOL) pd_typedmess((t_pd *)bself,argv[k].a_symbol,j-k-1,argv+k+1);
 	}
 	return bself;
-    } catch (Barf &oozy) {oozy.error(bself->self); return 0;}
+    } catch (Barf &oozy) {oozy.error(bself); return 0;}
 }
 
 static void BFObject_delete (BFObject *bself) {
-	try {delete bself->self;} catch (Barf &oozy) {oozy.error(bself->self);}
+	try {delete bself->self;} catch (Barf &oozy) {oozy.error(bself);}
 }
 
 //****************************************************************
@@ -705,8 +710,8 @@
 	if (draw) BFObject_redraw(bself);
 }
 
-string FObject::binbuf_string () {
-	t_binbuf *b = bself->te_binbuf;
+string BFObject::binbuf_string () {
+	t_binbuf *b = te_binbuf;
 	if (!b) return "[???]";
 	std::ostringstream s;
 	int n = binbuf_getnatom(b);
@@ -854,12 +859,9 @@
 			pd_typedmess((t_pd *)bself,gensym("get"),1,a);
 		}
 	} else {
-		//t_atom a[1];
-		//outlet_anything(outlets[noutlets-1],s,1,a);
 		FMethod m = funcall_lookup(bself,"___get");
-		t_atom2 a[1];
-		SETSYMBOL(a,s);
-		if (m) m(this,1,a);
+		if (!m) RAISE("missing ___get");
+		t_atom2 a[1]; SETSYMBOL(a,s); m(this,1,a);
 	}
 }
 \def 0 help () {

Modified: trunk/src/gridflow.hxx
==============================================================================
--- trunk/src/gridflow.hxx (original)
+++ trunk/src/gridflow.hxx Mon Nov  9 11:34:21 2009
@@ -183,7 +183,8 @@
   string text;
   Barf(const char *s, ...);
   Barf(const char *file, int line, const char *func, const char *s, ...);
-  void error(FObject *self);
+  void error(BFObject *self);
+  void error(t_symbol *s, int argc, t_atom *argv);
   ~Barf() {}
 };
 
@@ -767,7 +768,10 @@
 		ARGS(this), __PRETTY_FUNCTION__,#d,(void*)d,bytes,align);}}
 
 struct BFProxy;
-struct BFObject : t_object {FObject *self;};
+struct BFObject : t_object {
+	FObject *self;
+	string binbuf_string ();
+};
 
 // represents objects that have inlets/outlets
 \class FObject {
@@ -778,7 +782,6 @@
 	BFProxy  **inlets;    // direct access to  inlets (not linked lists)
 	t_outlet **outlets;   // direct access to outlets (not linked lists)
 	t_canvas *mom;
-	string binbuf_string ();
 	void  ninlets_set(int n, bool draw=true);
 	void noutlets_set(int n, bool draw=true);
 	std::vector<P<GridInlet> > in;
@@ -799,7 +802,7 @@
 extern Numop *op_add,*op_sub,*op_mul,*op_div,*op_mod,*op_shl,*op_and,*op_put;
 
 #undef ARGS
-#define ARGS(OBJ) ((OBJ) ? (OBJ)->binbuf_string().data() : "[null]")
+#define ARGS(OBJ) ((OBJ) ? (OBJ)->bself->binbuf_string().data() : "[???]")
 #define NOTEMPTY(_a_) if (!(_a_)) RAISE("'%s' is empty",#_a_);
 #define SAME_TYPE(_a_,_b_) if ((_a_)->nt != (_b_)->nt) RAISE("same type please (%s has %s; %s has %s)", \
 	#_a_, number_type_table[(_a_)->nt].name, \
@@ -852,6 +855,7 @@
 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, string    v) {SETSYMBOL(a,gensym(v.data()));}
 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);}
 inline void set_atom (t_atom *a, t_binbuf *v) {SETLIST(a,v);}



More information about the Gridflow-cvs mailing list