[Gridflow-cvs] [svn] commit: r3995 - /trunk/base/flow_objects.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Tue Jul 8 16:49:42 EDT 2008


Author: matju
Date: Tue Jul  8 16:49:40 2008
New Revision: 3995

Log:
make [gf.print] more like [print], and add [#print] support (for grids only, not grid-literals)

Modified:
    trunk/base/flow_objects.c

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Tue Jul  8 16:49:40 2008
@@ -2502,8 +2502,6 @@
 
 //****************************************************************
 
-static void display_update(void *x);
-
 string ssprintf(const char *fmt, ...) {
 	std::ostringstream os;
 	va_list va;
@@ -2516,7 +2514,23 @@
 // write me
 \class GFPrint : FObject {
 	t_symbol *prefix;
-	\constructor (t_symbol *s=0) {prefix=s?s:gensym("print");}
+	t_pd *gp;
+	t_symbol *rsym;
+	\constructor (t_symbol *s=0) {
+		rsym = gensym(const_cast<char *>(ssprintf("gf.print:%08x",this).data())); // not in use atm.
+		prefix=s?s:gensym("print");
+		t_atom a[1];
+		SETSYMBOL(a,prefix);
+		pd_typedmess(&pd_objectmaker,gensym("#print"),1,a);
+		gp = pd_newest();
+		SETPOINTER(a,(t_gpointer *)bself);
+		//pd_typedmess(gp,gensym("dest"),1,a);
+	}
+	~GFPrint () {
+		pd_unbind((t_pd *)bself,rsym);
+		pd_free(gp);
+	}
+	\decl 0 grid(...);
 	\decl void anything (...);
 };
 std::ostream &operator << (std::ostream &self, t_atom &a) {
@@ -2536,17 +2550,28 @@
 	}
 	return self;
 }
+\def 0 grid(...) {pd_typedmess(gp,gensym("grid"),argc,argv);}
 \def void anything(...) {
 	std::ostringstream text;
-	text << prefix << ": ";
-	if (!((argv[0]==gensym("_0_float") || argv[0]==gensym("_0_list")) && argc>1 && argv[1].a_type==A_FLOAT))
-		text << argv[0].a_symbol->s_name+3 << " ";
-	for (int i=1; i<argc; i++) {text << argv[i]; if (i<argc-1) text << ' ';}
+	text << prefix->s_name << ":";
+	if (argv[0]==gensym("_0_list") && argc>=2 && argv[1].a_type==A_FLOAT) {
+		// don't show the selector.
+	} else if (argv[0]==gensym("_0_list") && argc==2 && argv[1].a_type==A_SYMBOL) {
+		text << " symbol";
+	} else if (argv[0]==gensym("_0_list") && argc==2 && argv[1].a_type==A_POINTER) {
+		text << " pointer";
+	} else if (argv[0]==gensym("_0_list") && argc==1) {
+		text << " bang";
+	} else {
+		text << " " << argv[0].a_symbol->s_name+3; // as is
+	}
+	for (int i=1; i<argc; i++) {text << " " << argv[i];}
 	post("%s",text.str().data());
 }
 \end class {install("gf.print",1,0);}
 
 #ifndef HAVE_DESIREDATA
+static void display_update(void *x);
 \class Display : FObject {
 	bool selected;
 	t_glist *canvas;



More information about the Gridflow-cvs mailing list