aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--debug-help.pd35
-rw-r--r--debug.c77
-rw-r--r--fatal-help.pd35
-rw-r--r--fatal.c77
-rw-r--r--normal-help.pd35
-rw-r--r--normal.c77
7 files changed, 337 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index cb801f8..a6c28a5 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ LIBRARY_NAME = log
# add your .c source files, one object per file, to the SOURCES
# variable, help files will be included automatically, and for GUI
# objects, the matching .tcl file too
-SOURCES = logpost.c error.c
+SOURCES = logpost.c debug.c normal.c error.c fatal.c
# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
# be included automatically
diff --git a/debug-help.pd b/debug-help.pd
new file mode 100644
index 0000000..1d4efa6
--- /dev/null
+++ b/debug-help.pd
@@ -0,0 +1,35 @@
+#N canvas 545 156 511 332 10;
+#X obj 49 38 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 0 1;
+#X msg 47 120 symbol hello;
+#X msg 61 143 hello;
+#X text 22 7 post at different levels;
+#X obj 224 137 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 3100 1;
+#X obj 46 81 debug;
+#X obj 53 289 debug;
+#X obj 221 157 debug this ia long box of test;
+#X msg 69 168 what is in here;
+#X msg 89 192 list this is a test;
+#X msg 90 226 list 1 2 3;
+#X msg 93 248 1 2 3;
+#X obj 285 55 pointer;
+#X msg 282 23 bang;
+#X obj 286 86 debug;
+#X obj 255 287 debug;
+#X msg 275 264 list;
+#X msg 275 242 list 1;
+#X msg 258 221 list word;
+#X connect 0 0 5 0;
+#X connect 1 0 6 0;
+#X connect 2 0 6 0;
+#X connect 4 0 7 0;
+#X connect 8 0 6 0;
+#X connect 9 0 6 0;
+#X connect 10 0 6 0;
+#X connect 11 0 6 0;
+#X connect 12 0 14 0;
+#X connect 13 0 12 0;
+#X connect 16 0 15 0;
+#X connect 17 0 15 0;
+#X connect 18 0 15 0;
diff --git a/debug.c b/debug.c
new file mode 100644
index 0000000..51d4048
--- /dev/null
+++ b/debug.c
@@ -0,0 +1,77 @@
+
+#include "m_pd.h"
+
+static t_class *debug_class;
+
+typedef struct _debug
+{
+ t_object x_obj;
+ int level;
+ t_symbol* tag;
+} t_debug;
+
+static t_symbol* args2symbol(int argc, t_atom *argv)
+{
+ t_symbol* s;
+ char* buf;
+ int bufsize;
+ t_binbuf *bb = binbuf_new();
+ binbuf_add(bb, argc, argv);
+ binbuf_gettext(bb, &buf, &bufsize);
+ buf = resizebytes(buf, bufsize, bufsize+1);
+ buf[bufsize] = 0;
+ s = gensym(buf);
+ freebytes(buf, bufsize+1);
+ binbuf_free(bb);
+ return s;
+}
+
+static void debug_bang(t_debug *x)
+{
+ logpost(x, x->level, "%s%sbang",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""));
+}
+
+static void debug_pointer(t_debug *x, t_gpointer *gp)
+{
+ logpost(x, x->level, "%s%s(pointer %lx)",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""), gp);
+}
+
+static void debug_float(t_debug *x, t_float f)
+{
+ logpost(x, (const int)x->level, "%s%s%g",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""), f);
+}
+
+static void debug_anything(t_debug *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol* output = args2symbol(argc, argv);
+ logpost(x, (const int)x->level, "%s%s%s %s",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""),
+ s->s_name, output->s_name);
+}
+
+static void *debug_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_debug *x = (t_debug *)pd_new(debug_class);
+ x->tag = &s_;
+ x->level = 3;
+ if (argc > 0)
+ x->tag = args2symbol(argc, argv);
+ return (x);
+}
+
+void debug_setup(void)
+{
+ debug_class = class_new(gensym("debug"),
+ (t_newmethod)debug_new,
+ 0,
+ sizeof(t_debug),
+ CLASS_DEFAULT,
+ A_GIMME, 0);
+ class_addbang(debug_class, debug_bang);
+ class_addfloat(debug_class, debug_float);
+ class_addpointer(debug_class, debug_pointer);
+ class_addanything(debug_class, debug_anything);
+}
diff --git a/fatal-help.pd b/fatal-help.pd
new file mode 100644
index 0000000..1274336
--- /dev/null
+++ b/fatal-help.pd
@@ -0,0 +1,35 @@
+#N canvas 545 156 511 332 10;
+#X obj 49 38 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 0 1;
+#X msg 47 120 symbol hello;
+#X msg 61 143 hello;
+#X text 22 7 post at different levels;
+#X obj 224 137 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 3100 1;
+#X obj 46 81 fatal;
+#X obj 53 289 fatal;
+#X obj 221 157 fatal this ia long box of test;
+#X msg 69 168 what is in here;
+#X msg 89 192 list this is a test;
+#X msg 90 226 list 1 2 3;
+#X msg 93 248 1 2 3;
+#X obj 285 55 pointer;
+#X msg 282 23 bang;
+#X obj 286 86 fatal;
+#X obj 255 287 fatal;
+#X msg 275 264 list;
+#X msg 275 242 list 1;
+#X msg 258 221 list word;
+#X connect 0 0 5 0;
+#X connect 1 0 6 0;
+#X connect 2 0 6 0;
+#X connect 4 0 7 0;
+#X connect 8 0 6 0;
+#X connect 9 0 6 0;
+#X connect 10 0 6 0;
+#X connect 11 0 6 0;
+#X connect 12 0 14 0;
+#X connect 13 0 12 0;
+#X connect 16 0 15 0;
+#X connect 17 0 15 0;
+#X connect 18 0 15 0;
diff --git a/fatal.c b/fatal.c
new file mode 100644
index 0000000..a8b8d0a
--- /dev/null
+++ b/fatal.c
@@ -0,0 +1,77 @@
+
+#include "m_pd.h"
+
+static t_class *fatal_class;
+
+typedef struct _fatal
+{
+ t_object x_obj;
+ int level;
+ t_symbol* tag;
+} t_fatal;
+
+static t_symbol* args2symbol(int argc, t_atom *argv)
+{
+ t_symbol* s;
+ char* buf;
+ int bufsize;
+ t_binbuf *bb = binbuf_new();
+ binbuf_add(bb, argc, argv);
+ binbuf_gettext(bb, &buf, &bufsize);
+ buf = resizebytes(buf, bufsize, bufsize+1);
+ buf[bufsize] = 0;
+ s = gensym(buf);
+ freebytes(buf, bufsize+1);
+ binbuf_free(bb);
+ return s;
+}
+
+static void fatal_bang(t_fatal *x)
+{
+ logpost(x, x->level, "%s%sbang",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""));
+}
+
+static void fatal_pointer(t_fatal *x, t_gpointer *gp)
+{
+ logpost(x, x->level, "%s%s(pointer %lx)",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""), gp);
+}
+
+static void fatal_float(t_fatal *x, t_float f)
+{
+ logpost(x, (const int)x->level, "%s%s%g",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""), f);
+}
+
+static void fatal_anything(t_fatal *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol* output = args2symbol(argc, argv);
+ logpost(x, (const int)x->level, "%s%s%s %s",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""),
+ s->s_name, output->s_name);
+}
+
+static void *fatal_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_fatal *x = (t_fatal *)pd_new(fatal_class);
+ x->tag = &s_;
+ x->level = 0;
+ if (argc > 0)
+ x->tag = args2symbol(argc, argv);
+ return (x);
+}
+
+void fatal_setup(void)
+{
+ fatal_class = class_new(gensym("fatal"),
+ (t_newmethod)fatal_new,
+ 0,
+ sizeof(t_fatal),
+ CLASS_DEFAULT,
+ A_GIMME, 0);
+ class_addbang(fatal_class, fatal_bang);
+ class_addfloat(fatal_class, fatal_float);
+ class_addpointer(fatal_class, fatal_pointer);
+ class_addanything(fatal_class, fatal_anything);
+}
diff --git a/normal-help.pd b/normal-help.pd
new file mode 100644
index 0000000..108c8e1
--- /dev/null
+++ b/normal-help.pd
@@ -0,0 +1,35 @@
+#N canvas 545 156 511 332 10;
+#X obj 49 38 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 0 1;
+#X msg 47 120 symbol hello;
+#X msg 61 143 hello;
+#X text 22 7 post at different levels;
+#X obj 224 137 hsl 128 15 0 127 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 3100 1;
+#X obj 46 81 normal;
+#X obj 53 289 normal;
+#X obj 221 157 normal this ia long box of test;
+#X msg 69 168 what is in here;
+#X msg 89 192 list this is a test;
+#X msg 90 226 list 1 2 3;
+#X msg 93 248 1 2 3;
+#X obj 285 55 pointer;
+#X msg 282 23 bang;
+#X obj 286 86 normal;
+#X obj 255 287 normal;
+#X msg 275 264 list;
+#X msg 275 242 list 1;
+#X msg 258 221 list word;
+#X connect 0 0 5 0;
+#X connect 1 0 6 0;
+#X connect 2 0 6 0;
+#X connect 4 0 7 0;
+#X connect 8 0 6 0;
+#X connect 9 0 6 0;
+#X connect 10 0 6 0;
+#X connect 11 0 6 0;
+#X connect 12 0 14 0;
+#X connect 13 0 12 0;
+#X connect 16 0 15 0;
+#X connect 17 0 15 0;
+#X connect 18 0 15 0;
diff --git a/normal.c b/normal.c
new file mode 100644
index 0000000..74dee18
--- /dev/null
+++ b/normal.c
@@ -0,0 +1,77 @@
+
+#include "m_pd.h"
+
+static t_class *normal_class;
+
+typedef struct _normal
+{
+ t_object x_obj;
+ int level;
+ t_symbol* tag;
+} t_normal;
+
+static t_symbol* args2symbol(int argc, t_atom *argv)
+{
+ t_symbol* s;
+ char* buf;
+ int bufsize;
+ t_binbuf *bb = binbuf_new();
+ binbuf_add(bb, argc, argv);
+ binbuf_gettext(bb, &buf, &bufsize);
+ buf = resizebytes(buf, bufsize, bufsize+1);
+ buf[bufsize] = 0;
+ s = gensym(buf);
+ freebytes(buf, bufsize+1);
+ binbuf_free(bb);
+ return s;
+}
+
+static void normal_bang(t_normal *x)
+{
+ logpost(x, x->level, "%s%sbang",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""));
+}
+
+static void normal_pointer(t_normal *x, t_gpointer *gp)
+{
+ logpost(x, x->level, "%s%s(pointer %lx)",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""), gp);
+}
+
+static void normal_float(t_normal *x, t_float f)
+{
+ logpost(x, (const int)x->level, "%s%s%g",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""), f);
+}
+
+static void normal_anything(t_normal *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol* output = args2symbol(argc, argv);
+ logpost(x, (const int)x->level, "%s%s%s %s",
+ x->tag->s_name, (*x->tag->s_name ? ": " : ""),
+ s->s_name, output->s_name);
+}
+
+static void *normal_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_normal *x = (t_normal *)pd_new(normal_class);
+ x->tag = &s_;
+ x->level = 2;
+ if (argc > 0)
+ x->tag = args2symbol(argc, argv);
+ return (x);
+}
+
+void normal_setup(void)
+{
+ normal_class = class_new(gensym("normal"),
+ (t_newmethod)normal_new,
+ 0,
+ sizeof(t_normal),
+ CLASS_DEFAULT,
+ A_GIMME, 0);
+ class_addbang(normal_class, normal_bang);
+ class_addfloat(normal_class, normal_float);
+ class_addpointer(normal_class, normal_pointer);
+ class_addanything(normal_class, normal_anything);
+}