aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--reference/rawprint-help.pd19
-rw-r--r--src/rawprint.c101
-rw-r--r--src/z_zexy.c1
-rw-r--r--src/z_zexy.h1
4 files changed, 122 insertions, 0 deletions
diff --git a/reference/rawprint-help.pd b/reference/rawprint-help.pd
new file mode 100644
index 0000000..5d50742
--- /dev/null
+++ b/reference/rawprint-help.pd
@@ -0,0 +1,19 @@
+#N canvas 178 555 611 300 10;
+#X text 303 9 part of zexy;
+#X obj 34 32 rawprint;
+#X text 104 34 print a message as raw as possible;
+#X msg 51 61 1;
+#X msg 75 91 symbol bla;
+#X msg 86 128 list 4 2 crash;
+#X text 40 233 this is similar to the built-in [print] but without
+trying to hide things from you;
+#X obj 51 177 t a a;
+#X obj 51 199 rawprint raw;
+#X obj 175 200 print cooked;
+#X msg 116 151 gully;
+#X connect 3 0 7 0;
+#X connect 4 0 7 0;
+#X connect 5 0 7 0;
+#X connect 7 0 8 0;
+#X connect 7 1 9 0;
+#X connect 10 0 7 0;
diff --git a/src/rawprint.c b/src/rawprint.c
new file mode 100644
index 0000000..e523362
--- /dev/null
+++ b/src/rawprint.c
@@ -0,0 +1,101 @@
+/******************************************************
+ *
+ * zexy - implementation file
+ *
+ * copyleft (c) IOhannes m zmölnig
+ *
+ * 1999:forum::für::umläute:2004
+ *
+ * institute of electronic music and acoustics (iem)
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+/* print the incoming message as raw as possible */
+
+#include "zexy.h"
+#include <stdio.h>
+
+static t_class *rawprint_class;
+
+typedef struct _rawprint {
+ t_object x_obj;
+ t_symbol*label;
+} t_rawprint;
+
+static void rawprint_any(t_rawprint *x, t_symbol*s, int argc, t_atom*argv)
+{
+ char buf[MAXPDSTRING];
+ if(x->label) {
+ startpost("%s: ", x->label->s_name);
+ }
+ startpost("\"%s\"", s->s_name);
+ while(argc--) {
+ switch(argv->a_type) {
+ case A_FLOAT:
+ snprintf(buf, MAXPDSTRING-1, "%f", atom_getfloat(argv));
+ break;
+ case A_SYMBOL:
+ snprintf(buf, MAXPDSTRING-1, "'%s'", atom_getsymbol(argv)->s_name);
+ break;
+ case A_POINTER:
+ snprintf(buf, MAXPDSTRING-1, "pointer[0x%X]", argv->a_w.w_gpointer);
+ break;
+ case A_SEMI:
+ snprintf(buf, MAXPDSTRING-1, "SEMI");
+ break;
+ case A_COMMA:
+ snprintf(buf, MAXPDSTRING-1, "COMMA");
+ break;
+ case A_DEFFLOAT:
+ snprintf(buf, MAXPDSTRING-1, "DEFFLOAT[%f]", atom_getfloat(argv));
+ break;
+ case A_DEFSYM:
+ snprintf(buf, MAXPDSTRING-1, "DEFSYM['%s']", atom_getsymbol(argv)->s_name);
+ break;
+ case A_DOLLAR:
+ snprintf(buf, MAXPDSTRING-1, "DOLLAR['%s']", atom_getsymbol(argv)->s_name);
+ break;
+ case A_DOLLSYM:
+ snprintf(buf, MAXPDSTRING-1, "DOLLSYM['%s']", atom_getsymbol(argv)->s_name);
+ break;
+ case A_GIMME:
+ snprintf(buf, MAXPDSTRING-1, "GIMME");
+ break;
+ case A_CANT:
+ snprintf(buf, MAXPDSTRING-1, "CANT");
+ break;
+ default:
+ snprintf(buf, MAXPDSTRING-1, "unknown[%d]", argv->a_type);
+ }
+ buf[MAXPDSTRING-1]=0;
+
+ startpost(" %s", buf);
+ argv++;
+ }
+ endpost();
+
+}
+
+static void *rawprint_new(t_symbol*s)
+{
+ t_rawprint *x = (t_rawprint *)pd_new(rawprint_class);
+ x->label=NULL;
+ if(s&&gensym("")!=s)
+ x->label=s;
+
+ return (x);
+}
+
+void rawprint_setup(void) {
+ rawprint_class = class_new(gensym("rawprint"),
+ (t_newmethod)rawprint_new,
+ 0, sizeof(t_rawprint),
+ CLASS_DEFAULT, A_DEFSYMBOL, 0);
+
+ class_addanything(rawprint_class, rawprint_any);
+ zexy_register("rawprint");
+}
diff --git a/src/z_zexy.c b/src/z_zexy.c
index 340cd61..89f19ca 100644
--- a/src/z_zexy.c
+++ b/src/z_zexy.c
@@ -62,6 +62,7 @@ void z_zexy_setup(void)
pdf_tilde_setup(); /* pdf~ */
prime_setup(); /* prime */
quantize_tilde_setup(); /* quantize~ */
+ rawprint_setup(); /* rawprint */
regex_setup(); /* regex */
relay_setup(); /* relay */
repack_setup(); /* repack */
diff --git a/src/z_zexy.h b/src/z_zexy.h
index 81febdf..b72a122 100644
--- a/src/z_zexy.h
+++ b/src/z_zexy.h
@@ -60,6 +60,7 @@ void packel_setup(void); /* packel */
void pdf_tilde_setup(void); /* pdf~ */
void prime_setup(void); /* prime */
void quantize_tilde_setup(void); /* quantize~ */
+void rawprint_setup(void); /* rawprint */
void regex_setup(void); /* regex */
void relay_setup(void); /* relay */
void repack_setup(void); /* repack */