Beispiel #1
0
/* CHECKED c74's refman and help patch are wrong about int pairs --
   the actual syntax is "[dis]connect indx ondx1 [ondx2 [ondx3..." */
static void matrix_connect(t_matrix *x, t_symbol *s, int ac, t_atom *av)
{
    int onoff = (s == gensym("connect")), indx, celloffset;
    if (ac < 2)
	return;  /* CHECKED */
    /* CHECKED floats silently clipped, symbols converted to 0 */
    indx = (av->a_type == A_FLOAT ? (int)av->a_w.w_float : 0);
    if (indx < 0 || indx >= x->x_ninlets)
    {  /* CHECKED */
	loud_error((t_pd *)x, "invalid inlet number %d", indx);
	return;
    }
    celloffset = indx * x->x_noutlets;
    ac--; av++;
    while (ac)
    {
	/* CHECKED floats silently clipped, symbols converted to 0 */
	int cellndx, ondx = (av->a_type == A_FLOAT ? (int)av->a_w.w_float : 0);
	if (ondx < 0 || ondx >= x->x_noutlets)
	{  /* CHECKED */
	    loud_error((t_pd *)x, "invalid outlet number %d", ondx);
	    return;
	}
	cellndx = celloffset + ondx;
	x->x_cells[cellndx] = onoff;
	if (x->x_gains)
	    matrix_retarget(x, cellndx);
	ac--; av++;
    }
}
Beispiel #2
0
static void funbuff_set(t_funbuff *x, t_symbol *s, int ac, t_atom *av)
{
    /* CHECKED symbols somehow bashed to zeros,
       decreasing x coords corrupt the funbuff -- not emulated here... */
    int i = ac;
    t_atom *ap = av;
    while (i--) if (ap++->a_type != A_FLOAT)
        {
            loud_error((t_pd *)x, "bad input (not a number) -- no data to set");
            return;
        }
    if (!ac || (ac % 2))
    {
        /* CHECKED odd/null ac loudly rejected, current contents preserved */
        loud_error((t_pd *)x, "bad input (%s) -- no data to set",
                   (ac ? "odd arg count" : "no input"));
        return;
    }
    funbuff_clear(x);  /* CHECKED the contents is replaced */
    while (ac--)
    {
        int ndx = (int)av++->a_w.w_float;
        if (!hammertree_insertfloat(&x->x_tree, ndx, av++->a_w.w_float, 1))
            return;
        ac--;
    }
}
Beispiel #3
0
void *plustot_var_new(t_symbol *s, int ac, t_atom *av)
{
    t_plustot_var *x = 0;
    t_glist *glist = canvas_getcurrent();
    t_plustin *tin = 0;
    t_plusvar *var = 0;
    if (ac && av->a_type == A_SYMBOL &&
	(tin = plustin_glistprovide(glist, PLUSTIN_GLIST_ANY, 0)) &&
	(var = plusvar_new(av->a_w.w_symbol->s_name, 0, tin)))
    {
	x = (t_plustot_var *)plusobject_new(plustot_var_class, s, ac, av, 0);
	plusbob_preserve((t_plusbob *)var);
	plusbob_setowner((t_plusbob *)var, (t_pd *)x);
	plusvar_setlist(var, ac - 1, av + 1, 1);
	x->x_glist = glist;
	x->x_var = var;
	x->x_proxy = plusproxy_var_new((t_pd *)x);
	plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0);
	plusoutlet_new(&x->x_plusobject, &s_symbol);
    }
    else
    {
	if (!ac || av->a_type != A_SYMBOL)
	    loud_error(0, "+var: missing name of a variable");
	else
	    loud_error(0, "+var: cannot initialize");
	if (tin)
	{
	    plusbob_preserve((t_plusbob *)tin);
	    plusbob_release((t_plusbob *)tin);
	}
    }
    return (x);
}
Beispiel #4
0
/* LATER rethink the remote case */
void riddle_setsourceblock(t_riddle *rd, int siginno, int newblock)
{
    int slotno = (siginno < 0 ? rd->rd_nsiginlets - siginno - 1 : siginno);
#ifdef RIDDLE_DEBUG
    riddlebug_post(rd, "setsourceblock", "%d (%d) %d",
                   siginno, slotno, newblock);
#endif
    if (siginno >= rd->rd_nsiginlets || -siginno > rd->rd_nremoteslots)
        loudbug_bug("riddle_setsourceblock");
    else if (newblock <= 0)
        loud_error((t_pd *)rd,
                   "invalid source block on inlet %d: %d", siginno, newblock);
    else
    {
        t_rdsource *so = rd->rd_inslots + slotno;
        /* LATER if (so->so_newpattern) complain */
        if (newblock == so->so_newblock)
            so->so_sourcecount++;
        else if (so->so_sourcecount > 0)
            loud_error((t_pd *)rd,
                       "source block mismatch on inlet %d: %d != %d",
                       siginno, newblock, so->so_newblock);
        else
        {
            so->so_newblock = newblock;
            so->so_sourcecount = 1;
        }
    }
}
Beispiel #5
0
static void widgettype_map(t_widgettype *wt, char *cls, char *req)
{
    wt->wt_tkclass = (cls ? gensym(cls) : 0);
    if (wt->wt_requirements)
	freebytes(wt->wt_requirements, strlen(wt->wt_requirements) + 1);
    if (req && *req)
    {
	char *opt = 0;
	wt->wt_requirements = getbytes(strlen(req) + 1);
	strcpy(wt->wt_requirements, req);
	while (req)
	{
	    char *w1 = scriptlet_nextword(req);
	    opt = (*req == '-' ? req : (w1 && *w1 == '-' ? w1 : 0));
	    if (opt)
	    {
		if (strcmp(opt + 1, "exact"))
		{
		    loud_error
			(0, "unknown option \"%s\" in widget type header", opt);
		    opt = 0;
		}
		if (*req == '-')
		{
		    req = w1;
		    continue;
		}
		else w1 = scriptlet_nextword(w1);
	    }
	    if (*req >= '0' && *req <= '9')
	    {
		loud_error
		    (0, "invalid base widget name \"%s\" in widget type header",
		     req);
		req = w1;
	    }
	    else
	    {
		t_widgettype *base;
		char *ver = (w1 && *w1 >= '0' && *w1 <= '9' ? w1 : 0);
		char *w2 = (ver ? scriptlet_nextword(ver) : w1);
#if 1
		loudbug_post("require %s (version %s %s)",
			     req, (opt ? opt : ">="), (ver ? ver : "any"));
#endif
		base = widgettype_get(gensym(req), ver, opt, wt->wt_glist);
		if (!base->wt_tkclass)
		    loud_error(0, "missing base widget file \"%s.wid\"", req);
		req = w2;
	    }
	}
    }
    else wt->wt_requirements = 0;
}
Beispiel #6
0
void loud_syserror(t_pd *x, char *fmt, ...)
{
    if (fmt)
    {
	char buf[MAXPDSTRING];
	va_list ap;
	va_start(ap, fmt);
	vsprintf(buf, fmt, ap);
	loud_error(x, "%s (%s)", buf, strerror(errno));
	va_end(ap);
    }
    else loud_error(x, strerror(errno));
}
/* returns tagged +bob if valid, null otherwise (silent if caller is empty) */
t_plusbob *plustag_isvalid(t_symbol *tag, t_pd *caller)
{
    if (tag->s_name == plustag_name)
	return (((t_plusstub *)tag)->sb_bob);
    else if (caller)
    {
	if (strcmp(tag->s_name, plustag_name))
	    loud_error((caller == PLUSBOB_OWNER ? 0 : caller),
 "does not understand '%s' (check object connections)", tag->s_name);
	else
	    loud_error((caller == PLUSBOB_OWNER ? 0 : caller), "confused...");
    }
    return (0);
}
Beispiel #8
0
void tow_setup(void)
{
    int result = LOADER_OK;
    if (zgetfn(&pd_objectmaker, gensym("widget")))
	loud_warning(0, "tow", "widget is already loaded");
    else
	result = unstable_load_lib("", "widget");
    if (result == LOADER_NOFILE)
	loud_error(0, "widget library is missing");
    else if (!zgetfn(&pd_objectmaker, gensym("widget")))
    {
	loud_error(0, "version mismatch");
	loud_errand(0, "use a more recent Pd release (or recompile toxy).");
    }
}
Beispiel #9
0
static t_pd *grab_next(t_grab *x)
{
nextremote:
    if (x->x_tograbbed)
    {
	int inno;
	x->x_tograbbed =
	    fragile_outlet_nextconnection(x->x_tograbbed, &x->x_grabbed, &inno);
	if (x->x_grabbed)
	{
	    if (inno)
	    {
		if (x->x_target)
		    loud_error((t_pd *)x,
			       "right outlet must feed leftmost inlet");
		else
		    loud_error((t_pd *)x,
			       "remote proxy must feed leftmost inlet");
	    }
	    else
	    {
		t_outlet *op;
		t_outlet *goutp;
		int goutno = x->x_noutlets;
		x->x_ngrabout = obj_noutlets(x->x_grabbed);
		if (goutno > x->x_ngrabout) goutno = x->x_ngrabout;
		while (goutno--)
		{
		    x->x_grabcons[goutno] =
			obj_starttraverseoutlet(x->x_grabbed, &goutp, goutno);
		    goutp->o_connections =
			obj_starttraverseoutlet((t_object *)x, &op, goutno);
		}
		return ((t_pd *)x->x_grabbed);
	    }
	}
    }
    if (x->x_bindelem) while (x->x_bindelem = x->x_bindelem->e_next)
    {
	t_object *ob;
	if (ob = pd_checkobject(x->x_bindelem->e_who))
	{
	    x->x_tograbbed = fragile_outlet_connections(ob->ob_outlet);
	    goto nextremote;
	}
    }
    return (0);
}
Beispiel #10
0
static void plustot_env_evalfile(t_plustot_env *x, t_symbol *fname)
{
    char buf1[MAXPDSTRING], buf2[MAXPDSTRING], *nameptr, *dir;
    int fd;
    dir = canvas_getdir(x->x_glist)->s_name;
    if ((fd = open_via_path(dir, fname->s_name, "",
			    buf1, &nameptr, MAXPDSTRING, 0)) < 0)
    {
	loud_error((t_pd *)x, "file '%s' not found", fname->s_name);
    }
    else
    {
	Tcl_Interp *interp = plustin_getinterp(x->x_tin);
	FILE *fp;
    	close(fd);
	strcpy(buf2, buf1);
	strcat(buf2, "/");
	strcat(buf2, nameptr);
	sys_bashfilename(buf2, buf2);
	Tcl_Preserve(interp);
	if (Tcl_EvalFile(interp, buf2) != TCL_OK)
	{
	    strcpy(buf1, "evaluation failed (");
	    strncat(buf1, buf2, MAXPDSTRING - strlen(buf1) - 2);
	    strcat(buf1, ")");
	    plusloud_tclerror((t_pd *)x, interp, buf1);
	}
	Tcl_Release(interp);
    }
}
Beispiel #11
0
/* CHECKED empty sequence stored as an empty file */
static void mtr_dowrite(t_mtr *x, t_mtrack *source, t_symbol *fname)
{
    int failed = 0;
    char path[MAXPDSTRING];
    FILE *fp;
    if (x->x_glist)
	canvas_makefilename(x->x_glist, fname->s_name, path, MAXPDSTRING);
    else
    {
    	strncpy(path, fname->s_name, MAXPDSTRING);
    	path[MAXPDSTRING-1] = 0;
    }
    /* CHECKED no global message */
    if (fp = sys_fopen(path, "w"))
    {
	/* CHECKED single-track writing does not seem to work (a bug?) */
	if (source) failed = mtr_writetrack(x, source, fp);
	else
	{
	    int id;
	    t_mtrack **tpp;
	    for (id = 0, tpp = x->x_tracks; id < x->x_ntracks; id++, tpp++)
		if (failed = mtr_writetrack(x, *tpp, fp))
		    break;
	}
	if (failed) sys_unixerror(path);  /* LATER rethink */
	fclose(fp);
    }
    else
    {
	sys_unixerror(path);  /* LATER rethink */
	failed = 1;
    }
    if (failed) loud_error((t_pd *)x, "writing text file \"%s\" failed", path);
}
Beispiel #12
0
t_canvas *riddle_nextgraph(t_riddle *rd)
{
    while (rd->rd_private->pr_oc)
    {
        t_object *dst;
        t_inlet *ip;
        int inno;
        rd->rd_private->pr_oc =
            obj_nexttraverseoutlet(rd->rd_private->pr_oc, &dst, &ip, &inno);
        if (dst)
        {
            int siginno = obj_siginletindex(dst, inno);
            if (siginno < 0)
            {
                /* should not happen, LATER rethink */
                break;
            }
            else if (pd_class((t_pd *)dst) != canvas_class)
            {
                loud_error((t_pd *)rd, "invalid connection (not to a canvas)");
                break;
            }
            else return ((t_canvas *)dst);
        }
    }
    return (0);
}
void *plustot_qlist_new(t_symbol *s, int ac, t_atom *av)
{
    t_plustot_qlist *x = 0;
    t_glist *glist = canvas_getcurrent();
    t_plustin *tin = 0;
    t_plustob *tob = 0;
    if ((tin = plustin_glistprovide(glist, PLUSTIN_GLIST_ANY, 0)) &&
	(tob = plustob_new(tin, 0)))
    {
	x = (t_plustot_qlist *)
	    plusobject_new(plustot_qlist_class, s, ac, av, 0);
	plusbob_preserve((t_plusbob *)tob);
	plusbob_setowner((t_plusbob *)tob, (t_pd *)x);
	plustob_setlist(tob, ac, av);
	x->x_glist = glist;
	x->x_tob = tob;
	x->x_proxy = plusproxy_qlist_new(x);
	plusinlet_new(&x->x_plusobject, (t_pd *)x->x_proxy, 0, 0);
	plusoutlet_new(&x->x_plusobject, &s_anything);
	x->x_rightout = outlet_new((t_object *)x, &s_symbol);
    }
    else
    {
	loud_error(0, "+qlist: cannot initialize");
	if (tin)
	{
	    plusbob_preserve((t_plusbob *)tin);
	    plusbob_release((t_plusbob *)tin);
	}
    }
    return (x);
}
Beispiel #14
0
int loud_floatarg(t_class *c, int which, int ac, t_atom *av,
		  t_float *vp, t_float minval, t_float maxval,
		  int underaction, int overaction, char *what)
{
    int result = LOUD_ARGOK;
    if (which < ac)
    {
	av += which;
	if (av->a_type == A_FLOAT)
	{
	    t_float f = av->a_w.w_float;
	    if (f < minval)
	    {
		*vp = (underaction & LOUD_CLIP ? minval : f);
		if (underaction)
		    result = LOUD_ARGUNDER;
	    }
	    else if (f > maxval)
	    {
		*vp = (overaction & LOUD_CLIP ? maxval : f);
		if (overaction)
		    result = LOUD_ARGOVER;
	    }
	    else *vp = f;
	}
	else result = LOUD_ARGTYPE;
    }
    else result = LOUD_ARGMISSING;
    if (what)
    {
	switch (result)
	{
	case LOUD_ARGUNDER:
	    if (underaction & LOUD_WARN)
	    {
		if (underaction & LOUD_CLIP)
		    loud_warning(&c, 0, "%s rounded up to %g", what, minval);
		else
		    loud_warning(&c, 0, "less than %g %s requested",
				 minval, what);
	    }
	    break;
	case LOUD_ARGOVER:
	    if (overaction & LOUD_WARN)
	    {
		if (overaction & LOUD_CLIP)
		    loud_warning(&c, 0, "%s truncated to %g", what, maxval);
		else
		    loud_warning(&c, 0, "more than %g %s requested",
				 maxval, what);
	    }
	    break;
	case LOUD_ARGTYPE:
	    loud_error(0, "bad argument %d (%s)", which, class_getname(c));
	    break;
	default:;
	}
    }
    return (result);
}
Beispiel #15
0
static t_probtrans *prob_findstate(t_prob *x, int value, int complain)
{
    t_probtrans *state;
    for (state = x->x_translist; state; state = state->tr_nextstate)
	if (state->tr_value == value)
	    break;
    if (!state && complain && !x->x_silent)
	loud_error((t_pd *)x, "no state %d", value);  /* CHECKED */
    return (state);
}
Beispiel #16
0
static void riddle__reblock(t_riddle *rd, t_symbol *pattern,
                            t_floatarg f1, t_floatarg f2, t_floatarg f3)
{
    riddle_setsourceflags(rd, (int)f1, (int)f3);
    if (pattern == rdps__)
        riddle_setsourceblock(rd, (int)f1, (int)f2);
    else if (pattern)
        riddle_setsourcelayout(rd, (int)f1, pattern, (int)f2);
    else
        loud_error((t_pd *)rd, "bad arguments to '_reblock'");
}
Beispiel #17
0
static void matrix_list(t_matrix *x, t_symbol *s, int ac, t_atom *av)
{
    int indx, ondx, cellndx, onoff;
    float gain;
    if (ac < 3)
	return;  /* CHECKED list silently ignored if ac < 3 */
    /* CHECKED floats silently clipped, symbols converted to 0 */
    indx = (av->a_type == A_FLOAT ? (int)av->a_w.w_float : 0);
    if (indx < 0 || indx >= x->x_ninlets)
    {  /* CHECKED */
	loud_error((t_pd *)x, "invalid inlet number %d", indx);
	return;
    }
    ac--; av++;
    /* CHECKED floats silently clipped, symbols converted to 0 */
    ondx = (av->a_type == A_FLOAT ? (int)av->a_w.w_float : 0);
    if (ondx < 0 || ondx >= x->x_noutlets)
    {  /* CHECKED */
	loud_error((t_pd *)x, "invalid outlet number %d", ondx);
	return;
    }
    cellndx = indx * x->x_noutlets + ondx;
    ac--; av++;
    /* CHECKED negative gain used in nonbinary mode, accepted as 1 in binary */
    gain = (av->a_type == A_FLOAT ? av->a_w.w_float : 0.);
    onoff = (gain < -MATRIX_GAINEPSILON || gain > MATRIX_GAINEPSILON);
    x->x_cells[cellndx] = onoff;
    if (x->x_gains)
    {
	if (onoff)  /* CHECKME */
	    x->x_gains[cellndx] = gain;
	ac--; av++;
	if (ac)
	{
	    float ramp = (av->a_type == A_FLOAT ? av->a_w.w_float : 0.);
	    x->x_ramps[cellndx] = (ramp < MATRIX_MINRAMP ? 0. : ramp);
	}
	matrix_retarget(x, cellndx);
    }
}
Beispiel #18
0
void riddle_setsourcelayout(t_riddle *rd, int siginno,
                            t_symbol *newpattern, int maxblock)
{
    int slotno = (siginno < 0 ? rd->rd_nsiginlets - siginno - 1 : siginno);
#ifdef RIDDLE_DEBUG
    riddlebug_post(rd, "setsourcelayout", "%d (%d) %s %d",
                   siginno, slotno, newpattern->s_name, maxblock);
#endif
    if (siginno >= rd->rd_nsiginlets || -siginno > rd->rd_nremoteslots)
        loudbug_bug("riddle_setsourcelayout");
    else
    {
        t_rdsource *so = rd->rd_inslots + slotno;
        if (newpattern == so->so_newpattern)
            so->so_sourcecount++;
        else if (so->so_sourcecount > 0)
        {
            if (so->so_newpattern)
                loud_error((t_pd *)rd,
                           "source layout mismatch on inlet %d: %s != %s",
                           siginno, newpattern->s_name,
                           so->so_newpattern->s_name);
            else
                loud_error((t_pd *)rd,
                           "source layout/block mismatch on inlet %d");
        }
        else if (newpattern = riddle_validatepattern(newpattern))
        {
            so->so_newpattern = newpattern;
            if (maxblock)
            {
                if (maxblock > so->so_newblock)
                    so->so_newblock = maxblock;
            }
            else so->so_newblock = rd->rd_graphblock;
            so->so_sourcecount = 1;
        }
    }
}
Beispiel #19
0
void hammer_setup(void)
{
    if (canvas_getcurrent())
    {
	/* Loading the library by object creation is banned, because of a danger
	   of having some of the classes already loaded. LATER rethink. */
	loud_error(0, "apparently an attempt to create a 'hammer' object");
	loud_errand(0, "without having hammer library preloaded");
	return;
    }
    if (zgetfn(&pd_objectmaker, gensym("hammer")))
    {
	loud_error(0, "hammer is already loaded");
	return;
    }
    if (!zgetfn(&pd_objectmaker, gensym("cyclone")))
	post("this is hammer %s, %s %s build",
	     CYCLONE_VERSION, loud_ordinal(CYCLONE_BUILD), CYCLONE_RELEASE);
    hammer_class = class_new(gensym("hammer"),
			     (t_newmethod)hammer_new,
			     (t_method)hammer_free,
			     sizeof(t_hammer), 0, 0);
    class_addbang(hammer_class, hammer_bang);
    class_addmethod(hammer_class, (t_method)hammer_cd,
		    gensym("cd"), A_DEFSYM, 0);
    class_addmethod(hammer_class, (t_method)hammer_pwd,
		    gensym("pwd"), A_SYMBOL, 0);
    class_addmethod(hammer_class, (t_method)hammer_import,
		    gensym("import"), A_DEFSYM, 0);
    class_addmethod(hammer_class, (t_method)hammer_click,
		    gensym("click"),
		    A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
    hammerfile_setup(hammer_class, 0);
    hammer_firstndx = fragile_class_count();
    allhammers_setup();
    hammer_lastndx = fragile_class_count() - 1;
}
Beispiel #20
0
int riddle_checksourceblock(t_riddle *rd, int siginno, int reqblock)
{
    int block = riddle_getsourceblock(rd, siginno);
    if (block == reqblock)
        return (1);
    else
    {
        if (!rd->rd_wasdisabled && rd->rd_inslots[siginno].so_sourcecount)
            loud_error((t_pd *)rd,
                       "invalid source block on inlet %d: %d (%d expected)",
                       siginno, block, reqblock);
        rd->rd_disabled = 1;
        return (0);
    }
}
Beispiel #21
0
int riddle_checksourcelayout(t_riddle *rd, int siginno,
                             t_symbol *reqpattern, int *maxblockp)
{
    t_symbol *pattern = riddle_getsourcelayout(rd, siginno, maxblockp);
    if (reqpattern == pattern ||
            riddle_validatepattern(reqpattern) == pattern)
        return (1);
    else
    {
        if (!rd->rd_wasdisabled && rd->rd_inslots[siginno].so_sourcecount)
        {
            if (pattern)
                loud_error((t_pd *)rd,
                           "wrong source layout on inlet %d: %s (%s expected)",
                           siginno, pattern->s_name, reqpattern->s_name);
            else
                loud_error((t_pd *)rd,
                           "invalid source on inlet %d: layout %s expected",
                           siginno, reqpattern->s_name);
        }
        rd->rd_disabled = 1;
        return (0);
    }
}
Beispiel #22
0
static void funbuff_find(t_funbuff *x, t_floatarg f)
{
    t_hammernode *np;
    if (np = x->x_tree.t_first)
    {
        do
        {
            /* CHECKED lastdelta preserved */
            if (HAMMERNODE_GETFLOAT(np) == f)
                funbuff_dooutput(x, np->n_key, x->x_lastdelta);
        }
        while (np = np->n_next);
        /* CHECKED no bangout, no complaint if nothing found */
    }
    else loud_error((t_pd *)x, "nothing to find");  /* CHECKED */
}
Beispiel #23
0
static void funbuff_dump(t_funbuff *x)
{
    t_hammernode *np;
    if (np = x->x_tree.t_first)
    {
        do
        {
            x->x_lastdelta = HAMMERNODE_GETFLOAT(np);  /* CHECKED */
            /* float value preserved (this is incompatible) */
            funbuff_dooutput(x, np->n_key, x->x_lastdelta);
        }
        while (np = np->n_next);
        /* CHECKED no bangout */
    }
    else loud_error((t_pd *)x, "nothing to dump");  /* CHECKED */
}
Beispiel #24
0
int loud_checkint(t_pd *x, t_float f, int *valuep, t_symbol *mess)
{
    if ((*valuep = (int)f) == f)
	return (1);
    else
    {
	static t_symbol *floatsym = 0;
	if (!floatsym)
	    floatsym = gensym("noninteger float");
	if (mess == &s_float)
	    loud_nomethod(x, floatsym);
	else if (mess)
	    loud_error(x, "\"%s\" argument invalid for message \"%s\"",
		       floatsym->s_name, mess->s_name);
	return (0);
    }
}
/* returns tagged +bob if valid, null otherwise (silent if caller is empty) */
t_plusbob *plustag_validroot(t_symbol *tag, t_symbol *rname, t_pd *caller)
{
    if (tag->s_name == plustag_name)
    {
	t_plusbob *bob = ((t_plusstub *)tag)->sb_bob;
	if (bob->bob_root->tp_name == rname)
	    return (bob);
	else if (caller)
	{
	    t_symbol *s = bob->bob_root->tp_name;
	    loud_error((caller == PLUSBOB_OWNER ? bob->bob_owner : caller),
		       "invalid base type '%s' ('%s' expected)",
		       (s ? s->s_name : "<unknown>"),
		       (rname ? rname->s_name : "<unknown>"));
	}
    }
    else if (plustag_isvalid(tag, caller))  /* print the error there */
	loudbug_bug("plustag_validroot");
    return (0);
}
Beispiel #26
0
static void funbuff_doread(t_funbuff *x, t_symbol *fn)
{
    t_binbuf *bb = binbuf_new();
    int ac;
    t_atom *av;
    char buf[MAXPDSTRING];
    /* FIXME use open_via_path() */
    canvas_makefilename(x->x_canvas, fn->s_name, buf, MAXPDSTRING);
    binbuf_read(bb, buf, "", 0);
    if ((ac = binbuf_getnatom(bb)) &&
            (av = binbuf_getvec(bb)) &&
            av->a_type == A_SYMBOL &&
            av->a_w.w_symbol == gensym("funbuff"))
    {
        post("funbuff_read: %s read successful", fn->s_name);  /* CHECKED */
        funbuff_set(x, 0, ac-1, av+1);
    }
    else  /* CHECKED no complaints... */
        loud_error((t_pd *)x, "invalid file %s", fn->s_name);
    binbuf_free(bb);
}
Beispiel #27
0
void *plustot_env_new(t_symbol *s, int ac, t_atom *av)
{
    t_plustot_env *x = 0;
    t_glist *gl = canvas_getcurrent();
    t_plustin *oldtin = plustin_glistfind(gl, PLUSTIN_GLIST_THIS);
    t_plustin *deftin = (oldtin ? 0 : plustin_glistfind(gl, PLUSTIN_GLIST_ANY));
    t_plustin *tin = 0;
    if ((tin = oldtin)
	|| (tin = plustin_glistprovide(gl, PLUSTIN_GLIST_THIS, 1)))
    {
	int warned = 0;
	x = (t_plustot_env *)plusobject_new(plustot_env_class, s, ac, av, 0);
	x->x_tin = tin;
	plusbob_preserve((t_plusbob *)tin);
	x->x_glist = gl;
	plusoutlet_new(&x->x_plusobject, &s_symbol);
	if (deftin)
	    /* true if both oldtin == 0 (we are first in this glist)
	       and plustin_default != 0 (bobs exist already) */
	    plustot_env_takeover(x->x_glist,
				 (t_plusbob *)deftin, (t_plusbob *)tin);
	x->x_filehandle = hammerfile_new((t_pd *)x, 0,
					 plustot_env_evalfilehook, 0, 0);
	while (ac--)
	{
	    if (av->a_type == A_SYMBOL)
		plustot_env_evalfile(x, av->a_w.w_symbol);
	    else if (!warned)
	    {
		loud_warning((t_pd *)x, 0, "bad atom");
		warned = 1;
	    }
	    av++;
	}
    }
    else loud_error(0, "+env: cannot initialize");
    return (x);
}
Beispiel #28
0
void loud_classarg(t_class *c)
{
    loud_error(0, "missing or bad arguments in \"%s\"", class_getname(c));
}
Beispiel #29
0
void loud_messarg(t_pd *x, t_symbol *s)
{
    loud_error(x, "bad arguments for message \"%s\"", s->s_name);
}
Beispiel #30
0
void loud_nomethod(t_pd *x, t_symbol *s)
{
    loud_error(x, "doesn't understand \"%s\"", s->s_name);
}