aboutsummaryrefslogtreecommitdiff
path: root/toxy/plustot.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxy/plustot.c')
-rw-r--r--toxy/plustot.c103
1 files changed, 51 insertions, 52 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);
}