コード例 #1
0
ファイル: riddle.c プロジェクト: andynicholson/libpd
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);
}
コード例 #2
0
ファイル: g_editor_extras.c プロジェクト: porres/pure-data
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));
            }
        }
    }
}
コード例 #3
0
ファイル: riddle.c プロジェクト: andynicholson/libpd
static int rdsink_push(t_rdsink *si, t_object *x, int outno)
{
    int result = 1;
    t_outlet *op;
    t_outconnect *oc = obj_starttraverseoutlet(x, &op, outno);
    while (oc)
    {
        t_object *dst;
        t_inlet *ip;
        int inno;
        oc = obj_nexttraverseoutlet(oc, &dst, &ip, &inno);
        if (dst)
        {
            int siginno = obj_siginletindex(dst, inno);
            if (siginno < 0)
            {
                /* should not happen, LATER rethink */
            }
            else if (zgetfn((t_pd *)dst, rdps__reblock))
            {
                si->si_outbuf->a_w.w_float = (t_float)siginno;
                typedmess((t_pd *)dst, rdps__reblock, 4, si->si_outbuf);
            }
            else if (pd_class((t_pd *)dst) == canvas_class)
            {
                t_gobj *ob;
                int i;
                for (i = 0, ob = ((t_canvas *)dst)->gl_list;
                        ob; ob = ob->g_next)
                {
                    if (pd_class((t_pd *)ob) == vinlet_class)
                    {
                        if (i == inno)
                            break;
                        else
                            i++;
                    }
                }
                if (ob)
                {
#ifdef RIDDLE_DEBUG
                    riddlebug_post(si->si_riddle, "PUSH-SUBCANVAS",
                                   "vinlet %d (\"%s\")",
                                   inno, class_getname(*(t_pd *)ob));
#endif
                    rdsink_push(si, (t_object *)ob, 0);
                }
                else loudbug_bug("rdsink_push 1");
            }
            else if (pd_class((t_pd *)dst) == voutlet_class)
            {
                t_rdvoutlet *vout = (t_rdvoutlet *)dst;
                if (vout->x_canvas)
                {
                    int n;
                    t_outlet *o;
                    for (o = ((t_object *)vout->x_canvas)->ob_outlet, n = 0;
                            o; o = (t_outlet *)(((t_rdoutlet *)o)->o_next), n++)
                        if (o == vout->x_parentoutlet)
                            break;
                    if (o)
                    {
#ifdef RIDDLE_DEBUG
                        riddlebug_post(si->si_riddle, "PUSH-OUTLET",
                                       "outno %d, graph %x",
                                       n, (int)vout->x_canvas);
#endif
                        rdsink_push(si, (t_object *)vout->x_canvas, n);
                    }
                    else loudbug_bug("rdsink_push 2");
                }
#ifdef RIDDLE_DEBUG
                else riddlebug_post(si->si_riddle, "PUSH-OUTLET",
                                        "void canvas...");
#endif
            }
            else
            {
                char *dstname = class_getname(*(t_pd *)dst);
#ifdef RIDDLE_DEBUG
                riddlebug_post(si->si_riddle, "PUSH-RIDDLESS",
                               "inlet %d (\"%s\")", inno, dstname);
#endif
                if (si->si_flags & RIDDLE_STRICTNESSMASK)
                {
                    if (strcmp(dstname, "print~"))
                    {
                        loud_error((t_pd *)x, "not a riddle: \"%s\"", dstname);
                        result = 0;
                    }
                }
                else if (!strcmp(dstname, "send~") ||
                         !strcmp(dstname, "throw~"))
                {
                    loud_error((t_pd *)x, "bad destination: \"%s\"", dstname);
                    result = 0;
                }
            }
        }
    }
    return (result);
}