Exemplo n.º 1
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);
}
Exemplo n.º 2
0
/* ensures that sinks match signal outlets -- this is needed in the constructor,
   but is called before each push, perhaps too defensively... LATER rethink */
static int riddle_validatesinks(t_riddle *rd)
{
    t_object *x = (t_object *)rd;
    int sigoutno, outno, nouts = obj_noutlets(x);
    for (sigoutno = 0, outno = 0; outno < nouts; outno++)
    {
        if (obj_issignaloutlet(x, outno))
        {
            if (sigoutno < rd->rd_nsigoutlets)
            {
                if (rd->rd_outslots[sigoutno].si_outno != outno)
                {
                    if (rd->rd_outslots[sigoutno].si_outno < 0)
                        rd->rd_outslots[sigoutno].si_outno = outno;
                    else
                    {
                        loudbug_bug("riddle_validatesinks 1");
                        return (0);
                    }
                }
            }
            else
            {
                loudbug_bug("riddle_validatesinks 2");
                /* LATER grow */
                return (0);
            }
            sigoutno++;
        }
    }
    if (sigoutno < rd->rd_nsigoutlets)
    {
        loudbug_bug("riddle_validatesinks 3");
        /* LATER shrink */
        return (0);
    }
    return (1);
}
Exemplo n.º 3
0
static void dereconnect(t_glist*cnv, t_object*org, t_object*replace)
{
    t_gobj*gobj;
    int replace_i = canvas_getindex(cnv, o2g(replace));
    for(gobj=cnv->gl_list; gobj; gobj=gobj->g_next)
    {
        t_object*obj=g2o(gobj);
        int obj_i = canvas_getindex(cnv, gobj);
        int obj_nout=0;
        int nout;
        if(!obj)continue;
        obj_nout=obj_noutlets(obj);
        for(nout=0; nout<obj_nout; nout++)
        {
            t_outlet*out=0;
            t_outconnect*conn=obj_starttraverseoutlet(obj, &out, nout);
            while(conn)
            {
                int which;
                t_object*dest=0;
                t_inlet *in =0;
                int dest_i;
                conn=obj_nexttraverseoutlet(conn, &dest, &in, &which);
                if(dest!=org)
                    continue;
                dest_i = canvas_getindex(cnv, o2g(dest));
                obj_disconnect(obj, nout, dest, which);
                canvas_undo_add(cnv, UNDO_DISCONNECT, "disconnect",
                    canvas_undo_set_disconnect(cnv, obj_i, nout, dest_i, which));
                obj_connect(obj, nout, replace, which);
                canvas_undo_add(cnv, UNDO_CONNECT, "connect",
                    canvas_undo_set_connect(cnv, obj_i, nout, replace_i, which));
            }
        }
    }
}