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

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Tue Sep 14 17:07:00 EDT 2010


Author: matju
Date: Tue Sep 14 17:06:59 2010
New Revision: 6264

Log:
move atomtype_to_s there, and use it in a few places

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

Modified: trunk/src/gridflow.cxx
==============================================================================
--- trunk/src/gridflow.cxx (original)
+++ trunk/src/gridflow.cxx Tue Sep 14 17:06:59 2010
@@ -83,6 +83,12 @@
         ::error("[%s]: %s",os.str().data(),text.data());
 }
 
+#define Z(T) case T: return #T; break;
+const char *atomtype_to_s (t_atomtype t) {
+  switch (t) {Z(A_FLOAT)Z(A_SYMBOL)Z(A_POINTER)Z(A_DOLLAR)Z(A_DOLLSYM)Z(A_COMMA)Z(A_SEMI)Z(A_LIST)Z(A_GRID)Z(A_GRIDOUT)
+  default: return "unknown type";}}
+#undef Z
+
 void pd_oprint (ostream &o, int argc, t_atom *argv) {
 	for (int i=0; i<argc; i++) {
 		t_atomtype t = argv[i].a_type;
@@ -96,7 +102,7 @@
 			o << "[";
 			pd_oprint(o,binbuf_getnatom(b),binbuf_getvec(b));
 			o << "]";
-		} else o << "(atom of type " << t << ")";
+		} else o << "(atom of type " << atomtype_to_s(t) << ")";
 		if (i!=argc-1) o << " ";
 	}
 }
@@ -185,7 +191,7 @@
     else if (a.a_type==A_POINTER) (*this)(a.a_gpointer);
     else if (a.a_type==A_LIST   ) (*this)((t_list *)a.a_gpointer);
     else if (a.a_type==A_BLOB   ) (*this)((t_blob *)a.a_gpointer);
-    else error("can't send atom whose type is %d",a.a_type);
+    else error("can't send atom whose type is %s",atomtype_to_s(a.a_type));
     //self(1,av);
 }
 
@@ -197,7 +203,7 @@
 	if (a.a_type==A_POINTER) return a.a_gpointer==b.a_gpointer; // not deep
 	if (a.a_type==A_LIST)    return a.a_gpointer==b.a_gpointer; // not deep
 	if (a.a_type==A_BLOB)    return a.a_gpointer==b.a_gpointer; // not deep
-	RAISE("don't know how to compare elements of type %d",a.a_type);
+	RAISE("don't know how to compare elements of type %s",atomtype_to_s(a.a_type));
 }
 //----------------------------------------------------------------
 // Dim

Modified: trunk/src/gridflow.hxx
==============================================================================
--- trunk/src/gridflow.hxx (original)
+++ trunk/src/gridflow.hxx Tue Sep 14 17:06:59 2010
@@ -64,6 +64,8 @@
 #define A_LIST    t_atomtype(13) /* (t_binbuf *) */
 #define A_GRID    t_atomtype(14) /* (Grid *)    */
 #define A_GRIDOUT t_atomtype(15) /* (GridOut *) */
+
+const char *atomtype_to_s (t_atomtype t);
 
 #define gensym(s) gensym(const_cast<char *>(s))
 #define sys_vgui(FMT,ARGS...) sys_vgui(const_cast<char *>(FMT),ARGS)
@@ -678,7 +680,6 @@
 struct GridInlet : CObject {
 	// set once ever
 	FObject *parent; const GridHandler *gh;
-	
 	// set once per transmission
 	GridOut *sender; Dim dim; NumberTypeE nt; /* nt shouldn't need to exist */
 	// modified continually



More information about the Gridflow-cvs mailing list