aboutsummaryrefslogtreecommitdiff
path: root/toxy
diff options
context:
space:
mode:
Diffstat (limited to 'toxy')
-rw-r--r--toxy/plustot.c103
-rw-r--r--toxy/plustot.qlist.c5
-rw-r--r--toxy/tot.c21
-rw-r--r--toxy/widget.c188
-rw-r--r--toxy/widgettype.c16
5 files changed, 152 insertions, 181 deletions
diff --git a/toxy/plustot.c b/toxy/plustot.c
index 3e6ec7c..1a738ef 100644
--- a/toxy/plustot.c
+++ b/toxy/plustot.c
@@ -99,8 +99,8 @@ t_plustin *plustin_create(t_plustype *tp, t_plusbob *parent, t_symbol *id)
if (interp && (tin = (t_plustin *)plusenv_create(tp, parent, id)))
{
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "plustin_create '%s' over %x\n",
- (id ? id->s_name : "default"), (int)interp);
+ loudbug_post("plustin_create '%s' over %x",
+ (id ? id->s_name : "default"), (int)interp);
#endif
tin->tin_interp = interp;
Tcl_Preserve(interp);
@@ -118,8 +118,8 @@ static void plustin_delete(t_plustin *tin)
{
#ifdef PLUSTOT_DEBUG
t_symbol *id = plusenv_getid((t_plusenv *)tin);
- fprintf(stderr, "plustin_delete '%s' over %x\n",
- (id ? id->s_name : "default"), (int)tin->tin_interp);
+ loudbug_post("plustin_delete '%s' over %x",
+ (id ? id->s_name : "default"), (int)tin->tin_interp);
#endif
Tcl_Preserve(tin->tin_interp);
if (!Tcl_InterpDeleted(tin->tin_interp))
@@ -290,7 +290,7 @@ static void plustob_attach(t_plustob *tob)
tob->tob_tin = tin;
plusbob_preserve((t_plusbob *)tin);
}
- else bug("plustob_attach");
+ else loudbug_bug("plustob_attach");
}
/* To be called from client code.
@@ -459,8 +459,7 @@ Tcl_Obj *plustob_setlist(t_plustob *tob, int ac, t_atom *av)
if (count > tob->tob_elbufsize)
{
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "growing +To %d -> %d\n",
- tob->tob_elbufsize, count);
+ loudbug_post("growing +To %d -> %d", tob->tob_elbufsize, count);
#endif
tob->tob_elbuf =
grow_nodata(&count, &tob->tob_elbufsize, tob->tob_elbuf,
@@ -576,8 +575,7 @@ Tcl_Obj *plustob_setbinbuf(t_plustob *tob, t_binbuf *bb)
{
int n = count;
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "growing +To %d -> %d\n",
- tob->tob_elbufsize, count);
+ loudbug_post("growing +To %d -> %d", tob->tob_elbufsize, count);
#endif
tob->tob_elbuf =
grow_nodata(&n, &tob->tob_elbufsize, tob->tob_elbuf,
@@ -694,7 +692,7 @@ t_plusvar *plusvar_create(t_plustype *tp, t_plustin *tin, Tcl_Obj *ob,
}
else
{
- bug("plusvar_create");
+ loudbug_bug("plusvar_create");
goto varfailed2;
}
if (index)
@@ -779,11 +777,12 @@ static Tcl_Obj *plusvar_postset(t_plusvar *var)
{
#ifdef PLUSTOT_DEBUGREFCOUNTS
if (var->var_index)
- fprintf(stderr, "vv %x plusvar_postset [%s(%s)]\n",
- (int)tob->tob_value, var->var_name, var->var_index);
+ loudbug_post("vv %x plusvar_postset [%s(%s)]",
+ (int)tob->tob_value, var->var_name,
+ var->var_index);
else
- fprintf(stderr, "vv %x plusvar_postset [%s]\n",
- (int)tob->tob_value, var->var_name);
+ loudbug_post("vv %x plusvar_postset [%s]",
+ (int)tob->tob_value, var->var_name);
#endif
}
else plusloud_tclerror(0, interp, "cannot set variable");
@@ -932,7 +931,7 @@ void plusstring_release(t_plusstring *ps)
if (ps->ps_buf) freebytes(ps->ps_buf, ps->ps_len);
freebytes(ps, sizeof(*ps));
}
- else bug("plusstring_release");
+ else loudbug_bug("plusstring_release");
}
}
@@ -1012,8 +1011,8 @@ static t_plusproxy *plusproxy_new(t_pd *master, int ndx, t_plustin *tin)
static void plusproxy_free(t_plusproxy *pp)
{
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "plusproxy_free (%s %d)\n",
- (pp->pp_var ? pp->pp_var->var_name : "empty"), pp->pp_ndx);
+ loudbug_post("plusproxy_free (%s %d)",
+ (pp->pp_var ? pp->pp_var->var_name : "empty"), pp->pp_ndx);
#endif
if (pp->pp_var)
plusbob_release((t_plusbob *)pp->pp_var);
@@ -1066,11 +1065,11 @@ static void plusproxy_debug(t_plusproxy *pp)
t_plustin *tin = ((t_plustob *)pp->pp_var)->tob_tin;
t_symbol *id = plusenv_getid((t_plusenv *)tin);
t_symbol *glname = plustin_getglistname(tin);
- fprintf(stderr, "+proxy %d, glist %x\n",
- pp->pp_ndx, (int)((t_plustot *)pp->pp_master)->x_glist);
- fprintf(stderr, " plustin '%s' (%s) over %x\n",
- (id ? id->s_name : "default"),
- (glname ? glname->s_name : "<anonymous>"), (int)tin->tin_interp);
+ loudbug_post("+proxy %d, glist %x",
+ pp->pp_ndx, (int)((t_plustot *)pp->pp_master)->x_glist);
+ loudbug_post(" plustin '%s' (%s) over %x", (id ? id->s_name : "default"),
+ (glname ? glname->s_name : "<anonymous>"),
+ (int)tin->tin_interp);
}
#endif
@@ -1094,7 +1093,7 @@ static int plustot_usevariable(t_plustot *x, Tcl_Token *tp, int doit)
}
else buf[size] = 0;
strncpy(buf, tp->start, size);
- fprintf(stderr, "%s ", buf);
+ loudbug_startpost("%s ", buf);
}
#endif
tp++;
@@ -1160,7 +1159,7 @@ static int plustot_usevariable(t_plustot *x, Tcl_Token *tp, int doit)
if (!doit)
{
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "(inlet %d) ", inno);
+ loudbug_startpost("(inlet %d) ", inno);
#endif
if (inno >= x->x_nproxies)
x->x_nproxies = inno + 1;
@@ -1181,7 +1180,7 @@ static int plustot_usevariable(t_plustot *x, Tcl_Token *tp, int doit)
else
{
PLUSDEBUG_ENDPOST("plustot_usevariable");
- bug("plustot_usevariable");
+ loudbug_bug("plustot_usevariable");
goto badvariable;
}
}
@@ -1257,7 +1256,7 @@ static int plustot_doparsevariables(t_plustot *x, Tcl_Interp *interp,
int sz = (tp->size < MAXPDSTRING ? tp->size : MAXPDSTRING);
strncpy(buf, tp->start, sz);
buf[sz] = 0;
- fprintf(stderr, "simple word's text: %s\n", buf);
+ loudbug_post("simple word's text: %s", buf);
}
#endif
if (ntok-- && tp->type == TCL_TOKEN_TEXT && tp->size > 0)
@@ -1289,7 +1288,7 @@ static int plustot_doparsevariables(t_plustot *x, Tcl_Interp *interp,
int sz = (tp->size < MAXPDSTRING ? tp->size : MAXPDSTRING);
strncpy(buf, tp->start, sz);
buf[sz] = 0;
- fprintf(stderr, "other type (%d): %s\n", tp->type, buf);
+ loudbug_post("other type (%d): %s", tp->type, buf);
}
#endif
tp++;
@@ -1307,7 +1306,7 @@ static int plustot_parsevariables(t_plustot *x, Tcl_Interp *interp,
{
int nvars;
#ifdef PLUSTOT_DEBUG
- if (!doit) fprintf(stderr, "variables: ");
+ if (!doit) loudbug_startpost("variables: ");
#endif
nvars = plustot_doparsevariables(x, interp, buf, len, parsep, doit);
#ifdef PLUSTOT_DEBUG
@@ -1315,10 +1314,10 @@ static int plustot_parsevariables(t_plustot *x, Tcl_Interp *interp,
{
if (nvars > 0)
{
- fprintf(stderr, "\n%d variable substitutions\n", nvars);
- fprintf(stderr, "%d inlets requested\n", x->x_nproxies);
+ loudbug_post("\n%d variable substitutions", nvars);
+ loudbug_post("%d inlets requested", x->x_nproxies);
}
- else if (nvars == 0) fprintf(stderr, "none\n");
+ else if (nvars == 0) loudbug_post("none");
}
#endif
return (nvars);
@@ -1355,7 +1354,7 @@ static int plustot_makeproxies(t_plustot *x)
}
else
{
- bug("plustot_makeproxies");
+ loudbug_bug("plustot_makeproxies");
goto proxiesfailed;
}
return (1);
@@ -1396,7 +1395,7 @@ static int plustot_resetwords(t_plustot *x)
{
int n = nwords;
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "growing words %d -> %d\n", x->x_maxwords, nwords);
+ loudbug_post("growing words %d -> %d", x->x_maxwords, nwords);
#endif
x->x_words = grow_nodata(&n, &x->x_maxwords, x->x_words,
PLUSTOT_INIMAXWORDS, x->x_wordsini,
@@ -1423,7 +1422,7 @@ static int plustot_resetargs(t_plustot *x)
{
int n = nargs;
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "growing argv %d -> %d\n", x->x_maxargs, nargs);
+ loudbug_post("growing argv %d -> %d", x->x_maxargs, nargs);
#endif
x->x_argv = grow_nodata(&n, &x->x_maxargs, x->x_argv,
PLUSTOT_INIMAXWORDS, x->x_argvini,
@@ -1438,7 +1437,7 @@ static int plustot_resetargs(t_plustot *x)
}
else if (nargs < x->x_maxargs)
{
- bug("plustot_resetargs"); /* LATER rethink */
+ loudbug_bug("plustot_resetargs"); /* LATER rethink */
plustot_initwords(x);
plustot_initargs(x);
return (0);
@@ -1457,17 +1456,16 @@ static int plustot_makewords(t_plustot *x)
int len;
char buf[TCL_UTF_MAX];
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "arguments:\n");
+ loudbug_post("arguments:");
#endif
for (i = 1, tp = x->x_tailparse.tokenPtr;
i < nwords; i++, tp += ncomponents)
{
#ifdef PLUSTOT_DEBUG
- fprintf(stderr,
- " %s token: type %d[%d], having %d[%d] component%s\n",
- loud_ordinal(i), tp->type, tp[1].type,
- tp->numComponents, tp[1].numComponents,
- (tp->numComponents > 1 ? "s" : ""));
+ loudbug_post(" %s token: type %d[%d], having %d[%d] component%s",
+ loud_ordinal(i), tp->type, tp[1].type,
+ tp->numComponents, tp[1].numComponents,
+ (tp->numComponents > 1 ? "s" : ""));
#endif
ncomponents = tp->numComponents;
tp++;
@@ -1605,16 +1603,17 @@ static int plustot_argsfromtokens(t_plustot *x, Tcl_Interp *interp)
int i, nwords = x->x_tailparse.numWords + 1;
Tcl_Token *tp;
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, "arguments:\n");
+ loudbug_post("arguments:");
#endif
for (i = 1, tp = x->x_tailparse.tokenPtr;
i < nwords; i++, tp += (tp->numComponents + 1))
{
int result;
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, " %s token: type %d[%d], having %d component%s",
- loud_ordinal(i), tp->type, tp[1].type,
- tp->numComponents, (tp->numComponents > 1 ? "s" : ""));
+ loudbug_startpost(" %s token: type %d[%d], having %d component%s",
+ loud_ordinal(i), tp->type, tp[1].type,
+ tp->numComponents,
+ (tp->numComponents > 1 ? "s" : ""));
#endif
result = Tcl_EvalTokensStandard(interp, tp + 1, tp->numComponents);
if (result == TCL_OK)
@@ -1625,9 +1624,9 @@ static int plustot_argsfromtokens(t_plustot *x, Tcl_Interp *interp)
"plustot_argsfromwords");
Tcl_ResetResult(interp);
#ifdef PLUSTOT_DEBUG
- fprintf(stderr, ", %sshared: '%s'\n",
- (Tcl_IsShared(x->x_argv[i]) ? "" : "not "),
- Tcl_GetString(x->x_argv[i]));
+ loudbug_post(", %sshared: '%s'",
+ (Tcl_IsShared(x->x_argv[i]) ? "" : "not "),
+ Tcl_GetString(x->x_argv[i]));
#endif
}
else
@@ -1787,10 +1786,10 @@ static void plustot_debug(t_plustot *x)
t_plustin *tin = x->x_tob->tob_tin;
t_symbol *id = plusenv_getid((t_plusenv *)tin);
t_symbol *glname = plustin_getglistname(tin);
- fprintf(stderr, "+tot, glist %x\n", (int)x->x_glist);
- fprintf(stderr, " plustin '%s' (%s) over %x\n",
- (id ? id->s_name : "default"),
- (glname ? glname->s_name : "<anonymous>"), (int)tin->tin_interp);
+ loudbug_post("+tot, glist %x", (int)x->x_glist);
+ loudbug_post(" plustin '%s' (%s) over %x", (id ? id->s_name : "default"),
+ (glname ? glname->s_name : "<anonymous>"),
+ (int)tin->tin_interp);
if (x->x_mainproxy)
plusproxy_debug(x->x_mainproxy);
}
diff --git a/toxy/plustot.qlist.c b/toxy/plustot.qlist.c
index e077177..e4787fd 100644
--- a/toxy/plustot.qlist.c
+++ b/toxy/plustot.qlist.c
@@ -56,8 +56,9 @@ static t_binbuf *plustot_qlist_usurp(t_plustot_qlist *x)
{
t_binbuf *bb = ((t_qlist *)booty)->x_binbuf;
#ifdef PLUSTOT_QLIST_DEBUG
- post("booty '%s' at %x:", class_getname(*(t_pd *)booty), (int)booty);
- binbuf_print(bb);
+ loudbug_post("booty '%s' at %x:",
+ class_getname(*(t_pd *)booty), (int)booty);
+ loudbug_postbinbuf(bb);
#endif
return (bb);
}
diff --git a/toxy/tot.c b/toxy/tot.c
index 9e1c07d..65bfe9a 100644
--- a/toxy/tot.c
+++ b/toxy/tot.c
@@ -108,7 +108,7 @@ static t_symbol *tot_getcvname(t_tot *x)
return (x->x_dotname);
else
{
- bug("tot_getcvname");
+ loudbug_bug("tot_getcvname");
return (gensym("???"));
}
}
@@ -289,8 +289,8 @@ static void tot__vised(t_tot *x, t_symbol *s, t_floatarg f)
int flag = f != 0.;
#ifdef TOT_DEBUG
t_symbol *pn = tot_getpathname(x, 0);
- post("tot__vised %s %g (pathname %s) ", s->s_name, f,
- (pn ? pn->s_name : "unknown"));
+ loudbug_post("tot__vised %s %g (pathname %s) ", s->s_name, f,
+ (pn ? pn->s_name : "unknown"));
#endif
if (!x->x_visedpathname)
{
@@ -310,13 +310,14 @@ static void tot_debug(t_tot *x)
t_symbol *pn = tot_getpathname(x, 0);
int sz;
char *bp;
- post("containing glist: %x", x->x_glist);
- post("destination: %s", tot_getcvname(x)->s_name);
- post("pathname%s %s", (pn ? ":" : ""), (pn ? pn->s_name : "unknown"));
+ loudbug_post("containing glist: %x", x->x_glist);
+ loudbug_post("destination: %s", tot_getcvname(x)->s_name);
+ loudbug_post("pathname%s %s", (pn ? ":" : ""),
+ (pn ? pn->s_name : "unknown"));
bp = scriptlet_getbuffer(x->x_transient, &sz);
- post("transient buffer (size %d):\n\"%s\"", sz, bp);
+ loudbug_post("transient buffer (size %d):\n\"%s\"", sz, bp);
bp = scriptlet_getbuffer(x->x_persistent, &sz);
- post("persistent buffer (size %d):\n\"%s\"", sz, bp);
+ loudbug_post("persistent buffer (size %d):\n\"%s\"", sz, bp);
}
#endif
@@ -394,7 +395,7 @@ static void tot_attach(t_tot *x)
x->x_guidetached = 0;
}
}
- else bug("tot_attach");
+ else loudbug_bug("tot_attach");
}
}
@@ -461,7 +462,7 @@ static void totspy_anything(t_totspy *ts, t_symbol *s, int ac, t_atom *av)
ts->ts_lastmotion[2] = av[2];
ts->ts_gotmotion = 1;
}
- else bug("totspy_anything");
+ else loudbug_bug("totspy_anything");
}
if (ts->ts_on)
{
diff --git a/toxy/widget.c b/toxy/widget.c
index b0b83ac..6700812 100644
--- a/toxy/widget.c
+++ b/toxy/widget.c
@@ -21,7 +21,7 @@
static t_class *makeshift_class;
#ifdef KRZYSZCZ
-//#define WIDGET_DEBUG
+#define WIDGET_DEBUG
//#define TOW_DEBUG
//#define WIDGET_PROFILE
#endif
@@ -159,10 +159,10 @@ static void widgetprofile_handler_quit(void)
static void widget_profile(t_widget *x)
{
- fputs("total time in ms:\n", stderr);
- fprintf(stderr, "handler get %g\n", widgetprofile_handlerslice[0] * 1000.);
- fprintf(stderr, "handler eval %g\n", widgetprofile_handlerslice[1] * 1000.);
- fprintf(stderr, "handler push %g\n", widgetprofile_handlerslice[2] * 1000.);
+ loudbug_post("total time in ms:");
+ loudbug_post("\thandler get %g", widgetprofile_handlerslice[0] * 1000.);
+ loudbug_post("\thandler eval %g", widgetprofile_handlerslice[1] * 1000.);
+ loudbug_post("\thandler push %g", widgetprofile_handlerslice[2] * 1000.);
}
#define WIDGETPROFILE_HANDLER_ENTER widgetprofile_handler_enter()
@@ -198,7 +198,7 @@ static t_symbol *widget_getcvpathname(t_widget *x, t_glist *glist)
t_canvas *cv;
if (glist && glist != x->x_glist)
{
- bug("widget_getcvpathname");
+ loudbug_bug("widget_getcvpathname");
x->x_glist = glist;
}
cv = glist_getcanvas(x->x_glist);
@@ -221,37 +221,6 @@ static t_symbol *widget_getmypathname(t_widget *x, t_glist *glist)
return (gensym(buf));
}
-/* pity cannot set sys_printtostderr... */
-static void widget_postatoms(FILE *fp, char *msg, int ac, t_atom *av)
-{
- if (fp)
- {
- fputs(msg, fp);
- while (ac--)
- {
- char buf[80];
- atom_string(av, buf, 80);
- fputc(' ', fp);
- fputs(buf, fp);
- av++;
- }
- fputc('\n', fp);
- }
- else
- {
- startpost(msg);
- while (ac--)
- {
- if (av->a_type == A_FLOAT)
- postfloat(av->a_w.w_float);
- else if (av->a_type == A_SYMBOL)
- poststring(av->a_w.w_symbol->s_name);
- av++;
- }
- endpost();
- }
-}
-
/* If Tk widget creation fails, gui will send the '_failure' message
to the Pd widget object, asking the receiving object to transform
itself into a regular text object. Due to the 'bindlist' corruption
@@ -273,7 +242,7 @@ static void widget_transtick(t_widget *x)
t_atom *hnd = props_getall(x->x_handlers, &nhnd);
t_atom *arg = props_getall(x->x_arguments, &narg);
if (widget_transforming++)
- bug("widget_transtick");
+ loudbug_bug("widget_transtick");
binbuf_addv(bb, "sss", gensym("widget"), x->x_type, x->x_name);
if (narg) binbuf_add(bb, narg, arg);
if (nopt) binbuf_add(bb, nopt, opt);
@@ -383,7 +352,7 @@ static void widget_pushoptions(t_widget *x, int doit)
else scriptlet_vpush(x->x_transient, "itemoptions");
}
else if (!scriptlet_isempty(x->x_optscript))
- bug("widget_pushoptions");
+ loudbug_bug("widget_pushoptions");
}
static void widget_pushinits(t_widget *x)
@@ -395,13 +364,13 @@ static void widget_pushinits(t_widget *x)
0, 0, x->x_arguments))
scriptlet_vpush(x->x_transient, "typeinit");
else if (*widgettype_getinitializer(x->x_typedef, &sz) && sz > 0)
- bug("widget_pushinits (type)");
+ loudbug_bug("widget_pushinits (type)");
}
if (scriptlet_evaluate(x->x_iniscript, x->x_transient, 0,
0, 0, x->x_arguments))
scriptlet_vpush(x->x_transient, "iteminit");
else if (!scriptlet_isempty(x->x_iniscript))
- bug("widget_pushinits (instance)");
+ loudbug_bug("widget_pushinits (instance)");
}
static void widget_pushconstructors(t_widget *x)
@@ -414,7 +383,7 @@ static void widget_pushconstructors(t_widget *x)
0, 0, x->x_arguments))
scriptlet_push(x->x_transient);
else if (*widgettype_getconstructor(x->x_typedef, &sz) && sz > 0)
- bug("widget_pushconstructors (type)");
+ loudbug_bug("widget_pushconstructors (type)");
}
}
@@ -428,7 +397,7 @@ static void widget_pushdestructors(t_widget *x)
0, 0, x->x_arguments))
scriptlet_push(x->x_transient);
else if (*widgettype_getdestructor(x->x_typedef, &sz) && sz > 0)
- bug("widget_pushdestructors (type)");
+ loudbug_bug("widget_pushdestructors (type)");
}
}
@@ -606,7 +575,7 @@ static t_symbol *widget_addprops(t_widget *x, t_props *op, int single,
}
else
{
- bug("widget_addprops");
+ loudbug_bug("widget_addprops");
return (0);
}
}
@@ -852,7 +821,7 @@ static int widget_resettype(t_widget *x, t_widgettype *wt)
}
else
{
- bug("widget_resettype");
+ loudbug_bug("widget_resettype");
return (0);
}
}
@@ -862,15 +831,12 @@ static void widget_redefine(t_widget *x)
widget_resettype(x, widgettype_reload(x->x_type));
}
-static void widget__failure(t_widget *x, t_symbol *s, int ac, t_atom *av)
+static void widget__failure(t_widget *x)
{
-#if 0
- /* moved to the gui side -- supporting special chars in error message */
- startpost("tcl error:");
- postatom(ac, av);
- endpost();
-#endif
loud_error((t_pd *)x, "creation failure");
+ /* details printed at the gui side, in order to support special chars
+ in error message */
+ loud_errand((t_pd *)x, "see standard error for details");
x->x_vised = 0;
clock_delay(x->x_transclock, 0);
}
@@ -880,8 +846,8 @@ static void widget__config(t_widget *x, t_symbol *target, t_symbol *bg,
t_floatarg fw, t_floatarg fh, t_floatarg fst)
{
#ifdef WIDGET_DEBUG
- post("config %x %s \"%s\" %g %g",
- (int)x, target->s_name, bg->s_name, fw, fh);
+ loudbug_post("config %x %s \"%s\" %g %g",
+ (int)x, target->s_name, bg->s_name, fw, fh);
#endif
x->x_width = (int)fw;
x->x_height = (int)fh;
@@ -893,9 +859,9 @@ static void widget__config(t_widget *x, t_symbol *target, t_symbol *bg,
static void widget__value(t_widget *x, t_symbol *s, int ac, t_atom *av)
{
#ifdef WIDGET_DEBUG
- startpost("value:");
- postatom(ac, av);
- endpost();
+ loudbug_startpost("value:");
+ loudbug_postatom(ac, av);
+ loudbug_endpost();
#endif
/* FIXME */
}
@@ -979,7 +945,7 @@ static void widget__motion(t_widget *x, t_symbol *s, int ac, t_atom *av)
if (x->x_glist->gl_havewindow) /* LATER calculate on-parent coords */
{
#if 0
- post("motion %g %g", av[0].a_w.w_float, av[1].a_w.w_float);
+ loudbug_post("motion %g %g", av[0].a_w.w_float, av[1].a_w.w_float);
#endif
if (x->x_cvtarget->s_thing)
/* LATER rethink */
@@ -1001,6 +967,18 @@ int widget_iswidget(t_gobj *g, t_symbol *type, t_symbol *name)
}
#ifdef WIDGET_DEBUG
+static void widgetbug_postprops(char *msg, t_props *pp)
+{
+ int ac;
+ t_atom *av = props_getall(pp, &ac);
+ if (av)
+ {
+ loudbug_startpost(msg);
+ loudbug_postatom(ac, av);
+ loudbug_endpost();
+ }
+}
+
static void widget_debug(t_widget *x)
{
t_symbol *pn = widget_getcvpathname(x, 0);
@@ -1009,51 +987,43 @@ static void widget_debug(t_widget *x)
t_atom *ap;
static char bempty[] = "<empty>";
char *bp, *key;
- fprintf(stderr, "containing glist: %x\n", (int)x->x_glist);
- fprintf(stderr, "cv pathname%s %s\n",
- (pn ? ":" : ""), (pn ? pn->s_name : "unknown"));
- fprintf(stderr, "my pathname%s %s\n",
- (mn ? ":" : ""), (mn ? mn->s_name : "unknown"));
- if (ap = props_getall(widgettype_getoptions(x->x_typedef), &nopt))
- widget_postatoms(stderr, "default options:", nopt, ap);
- if (ap = props_getall(x->x_options, &nopt))
- widget_postatoms(stderr, "instance options:", nopt, ap);
- if (ap = props_getall(widgettype_gethandlers(x->x_typedef), &nopt))
- widget_postatoms(stderr, "default handlers:", nopt, ap);
- if (ap = props_getall(x->x_handlers, &nopt))
- widget_postatoms(stderr, "instance handlers:", nopt, ap);
- if (ap = props_getall(widgettype_getarguments(x->x_typedef), &nopt))
- widget_postatoms(stderr, "default arguments:", nopt, ap);
- if (ap = props_getall(x->x_arguments, &nopt))
- widget_postatoms(stderr, "instance arguments:", nopt, ap);
- fprintf(stderr, "dictionary:\n");
+ loudbug_post("containing glist: %x", (int)x->x_glist);
+ loudbug_post("cv pathname%s %s",
+ (pn ? ":" : ""), (pn ? pn->s_name : "unknown"));
+ loudbug_post("my pathname%s %s",
+ (mn ? ":" : ""), (mn ? mn->s_name : "unknown"));
+ widgetbug_postprops("default options:",
+ widgettype_getoptions(x->x_typedef));
+ widgetbug_postprops("instance options:", x->x_options);
+ widgetbug_postprops("default handlers:",
+ widgettype_gethandlers(x->x_typedef));
+ widgetbug_postprops("instance handlers:", x->x_handlers);
+ widgetbug_postprops("default arguments:",
+ widgettype_getarguments(x->x_typedef));
+ widgetbug_postprops("instance arguments:", x->x_arguments);
+ loudbug_post("dictionary:");
bp = props_firstvalue(x->x_arguments, &key);
while (bp)
{
- fprintf(stderr, "\t%s: \"%s\"\n", key, bp);
+ loudbug_post("\t%s: \"%s\"", key, bp);
bp = props_nextvalue(x->x_arguments, &key);
}
bp = scriptlet_getcontents(x->x_transient, &sz);
- fprintf(stderr, "transient buffer (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("transient buffer (size %d):\n\"%s\"", sz, (bp ? bp : bempty));
bp = scriptlet_getcontents(x->x_optscript, &sz);
- fprintf(stderr, "option buffer (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("option buffer (size %d):\n\"%s\"", sz, (bp ? bp : bempty));
bp = widgettype_getconstructor(x->x_typedef, &sz);
- fprintf(stderr, "type constructor (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("type constructor (size %d):\n\"%s\"", sz, (bp ? bp : bempty));
bp = widgettype_getdestructor(x->x_typedef, &sz);
- fprintf(stderr, "type destructor (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("type destructor (size %d):\n\"%s\"", sz, (bp ? bp : bempty));
bp = widgettype_getinitializer(x->x_typedef, &sz);
- fprintf(stderr, "type initializer (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("type initializer (size %d):\n\"%s\"", sz, (bp ? bp : bempty));
bp = scriptlet_getcontents(x->x_iniscript, &sz);
- fprintf(stderr, "instance initializer (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("instance initializer (size %d):\n\"%s\"",
+ sz, (bp ? bp : bempty));
bp = masterwidget_getcontents(&sz);
- fprintf(stderr, "setup definitions (size %d):\n\"%s\"\n",
- sz, (bp ? bp : bempty));
+ loudbug_post("setup definitions (size %d):\n\"%s\"",
+ sz, (bp ? bp : bempty));
}
#endif
@@ -1245,7 +1215,8 @@ static void tow_widgetattach(t_tow *x, t_widget *w)
x->x_widgetlist = we;
pd_bind((t_pd *)x, w->x_cbtarget);
#ifdef TOW_DEBUG
- post("%s widget '%s' attached", w->x_type->s_name, w->x_cbtarget->s_name);
+ loudbug_post("%s widget '%s' attached",
+ w->x_type->s_name, w->x_cbtarget->s_name);
#endif
}
@@ -1257,8 +1228,8 @@ static void tow_widgetdetach(t_tow *x, t_widget *w)
if (we2->we_widget == w)
{
#ifdef TOW_DEBUG
- post("%s widget '%s' detached by widget's destructor",
- w->x_type->s_name, w->x_cbtarget->s_name);
+ loudbug_post("%s widget '%s' detached by widget's destructor",
+ w->x_type->s_name, w->x_cbtarget->s_name);
#endif
pd_unbind((t_pd *)x, w->x_cbtarget);
if (we1)
@@ -1270,7 +1241,7 @@ static void tow_widgetdetach(t_tow *x, t_widget *w)
}
we1 = we2;
}
- bug("tow_widgetdetach");
+ loudbug_bug("tow_widgetdetach");
}
static void widget_attach(t_widget *x)
@@ -1310,12 +1281,12 @@ static void tow_attach(t_tow *x)
}
#ifdef TOW_DEBUG
if (!x->x_widgetlist)
- post("%s widget '%s' not found",
- x->x_type->s_name, x->x_name->s_name);
+ loudbug_post("%s widget '%s' not found",
+ x->x_type->s_name, x->x_name->s_name);
#endif
}
#ifdef TOW_DEBUG
- else post("glist '%s' not found", x->x_cvname->s_name);
+ else loudbug_post("glist '%s' not found", x->x_cvname->s_name);
#endif
}
@@ -1334,8 +1305,8 @@ static void tow_detach(t_tow *x)
if (te2->te_tow == x)
{
#ifdef TOW_DEBUG
- post("%s widget '%s' detached by tow's destructor",
- w->x_type->s_name, w->x_cbtarget->s_name);
+ loudbug_post("%s widget '%s' detached by tow's destructor",
+ w->x_type->s_name, w->x_cbtarget->s_name);
#endif
if (te1)
te1->te_next = te2->te_next;
@@ -1346,7 +1317,7 @@ static void tow_detach(t_tow *x)
}
te1 = te2;
}
- if (!te2) bug("tow_detach");
+ if (!te2) loudbug_bug("tow_detach");
}
}
@@ -1354,22 +1325,21 @@ static void tow_detach(t_tow *x)
static void tow_debug(t_tow *x)
{
t_widgetentry *we;
- fprintf(stderr, "attached widgets:\n");
+ loudbug_post("attached widgets:");
for (we = x->x_widgetlist; we; we = we->we_next)
{
t_widget *w = we->we_widget;
t_towentry *te;
int other = 0, found = 0;
- fprintf(stderr, "\t%s %s", w->x_type->s_name, w->x_cbtarget->s_name);
+ loudbug_startpost("\t%s %s", w->x_type->s_name, w->x_cbtarget->s_name);
for (te = w->x_towlist; te; te = te->te_next)
if (te->te_tow == x)
found++;
else
other++;
- fprintf(stderr, " (%d other tow%s)\n", other, (other == 1 ? "" : "s"));
+ loudbug_post(" (%d other tow%s)", other, (other == 1 ? "" : "s"));
if (found != 1)
- fprintf(stderr, "BUG: listed %d times in widget's towlist\n",
- found);
+ loudbug_bug("listed %d times in widget's towlist", found);
}
}
#endif
@@ -1378,7 +1348,7 @@ static void tow_free(t_tow *x)
{
t_tow *t1, *t2;
#ifdef TOW_DEBUG
- startpost("updating towlist...");
+ loudbug_startpost("updating towlist...");
#endif
for (t1 = 0, t2 = towlist; t2; t2 = t2->x_next)
{
@@ -1389,7 +1359,7 @@ static void tow_free(t_tow *x)
else
towlist = t2->x_next;
#ifdef TOW_DEBUG
- post("ok");
+ loudbug_post("ok");
#endif
break;
}
@@ -1480,7 +1450,7 @@ void widget_setup(void)
class_addmethod(widget_class, (t_method)widget_redefine,
gensym("redefine"), 0);
class_addmethod(widget_class, (t_method)widget__failure,
- gensym("_failure"), A_GIMME, 0);
+ gensym("_failure"), 0);
class_addmethod(widget_class, (t_method)widget__config,
gensym("_config"),
A_SYMBOL, A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, 0);
diff --git a/toxy/widgettype.c b/toxy/widgettype.c
index 20ff933..0b993c1 100644
--- a/toxy/widgettype.c
+++ b/toxy/widgettype.c
@@ -61,14 +61,14 @@ static void widgettype_map(t_widgettype *wt, char *cls, char *pkg)
/* only for debugging (never call, unless certain that nobody references wt) */
static void widgettype_free(t_masterwidget *mw, t_widgettype *wt)
{
- fprintf(stderr, "widgettype free... ");
+ loudbug_startpost("widgettype free... ");
dict_unbind(mw->mw_typemap, (t_pd *)wt, wt->wt_typekey);
props_freeall(wt->wt_options);
scriptlet_free(wt->wt_iniscript);
scriptlet_free(wt->wt_newscript);
scriptlet_free(wt->wt_freescript);
pd_free((t_pd *)wt);
- fprintf(stderr, "done\n");
+ loudbug_post("done");
}
#endif
@@ -141,7 +141,7 @@ static t_scriptlet *masterwidget_cmnthook(t_pd *caller, char *rc,
typeval = widgettype_new(mw, buf, cls, pkg);
mw->mw_parsedtype = typeval;
#ifdef WIDGETTYPE_DEBUG
- post("adding widget type '%s'", typeval->wt_typekey->s_name);
+ loudbug_post("adding widget type '%s'", typeval->wt_typekey->s_name);
#endif
scriptlet_reset(typeval->wt_iniscript);
return (typeval->wt_iniscript);
@@ -217,7 +217,7 @@ static int widgettype_doload(t_widgettype *wt, t_symbol *s)
== SCRIPTLET_OK)
{
#ifdef WIDGETTYPE_VERBOSE
- post("using a separate %s's definition file", s->s_name);
+ loudbug_post("using a separate %s's definition file", s->s_name);
#endif
if (!scriptlet_isempty(mwsp))
{
@@ -229,7 +229,7 @@ static int widgettype_doload(t_widgettype *wt, t_symbol *s)
scriptlet_push(sp);
scriptlet_append(masterwidget->mw_setupscript, mwsp);
}
- else bug("widgettype_doload");
+ else loudbug_bug("widgettype_doload");
scriptlet_free(sp);
}
result = 1;
@@ -376,7 +376,7 @@ void masterwidget_validate(void)
if (rcresult == SCRIPTLET_OK)
{
#ifdef WIDGETTYPE_VERBOSE
- post("using file 'setup.wid'");
+ loudbug_post("using file 'setup.wid'");
#endif
}
else
@@ -410,7 +410,7 @@ void masterwidget_validate(void)
}
else
{
- bug("masterwidget_validate 1");
+ loudbug_bug("masterwidget_validate 1");
rcresult = SCRIPTLET_BADFILE;
}
if (rcresult == SCRIPTLET_OK)
@@ -421,7 +421,7 @@ void masterwidget_validate(void)
if (scriptlet_evaluate(masterwidget->mw_setupscript, sp, 0, 0, 0, 0))
scriptlet_push(sp);
else
- bug("masterwidget_validate 2");
+ loudbug_bug("masterwidget_validate 2");
scriptlet_free(sp);
}
}