[Gridflow-cvs] [svn] commit: r3369 - /trunk/base/main.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Mar 31 22:00:43 EDT 2008


Author: matju
Date: Mon Mar 31 22:00:42 2008
New Revision: 3369

Log:
added pd_oprintf, as a starting point for making another better [makefilename].

Modified:
    trunk/base/main.c

Modified: trunk/base/main.c
==============================================================================
--- trunk/base/main.c (original)
+++ trunk/base/main.c Mon Mar 31 22:00:42 2008
@@ -87,6 +87,35 @@
 Ruby rb_ary_fetch(Ruby rself, long i) {
 	Ruby argv[] = { LONG2NUM(i) };
 	return rb_ary_aref(COUNT(argv),argv,rself);
+}
+
+int pd_oprintf (std::ostream &o, const char *s, int argc, t_atom *argv) {
+	int i=0;
+	for (; *s; s++) {
+		if (*s!='%') {o << (char)*s; continue;}
+		s++; // skip the %
+		if (*s=='f') {
+			if (!argc) RAISE("not enough args");
+			if (argv[i].a_type != A_FLOAT) RAISE("expected float");
+			o << argv[i].a_w.w_float;
+		}
+		if (*s=='s') {
+			if (!argc) RAISE("not enough args");
+			if (argv[i].a_type != A_SYMBOL) RAISE("expected float");
+			o << argv[i].a_w.w_symbol->s_name;
+		}
+		if (*s=='_') {
+			if (!argc) RAISE("not enough args");
+			char buf[MAXPDSTRING];
+			atom_string(&argv[i],buf,MAXPDSTRING);
+			o << buf;
+		}
+		if (*s=='%') {
+			o << "%";
+			continue;
+		}
+		RAISE("sorry, this format string is not supported yet");
+	}
 }
 
 //----------------------------------------------------------------



More information about the Gridflow-cvs mailing list