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); }
static void grab_restore(t_grab *x) { t_outlet *goutp; int goutno = x->x_noutlets; if (goutno > x->x_ngrabout) goutno = x->x_ngrabout; while (goutno--) { obj_starttraverseoutlet(x->x_grabbed, &goutp, goutno); goutp->o_connections = x->x_grabcons[goutno]; } }
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)); } } } }
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); }
t_canvas *riddle_firstgraph(t_riddle *rd, int outno) { t_outlet *op; rd->rd_private->pr_oc = obj_starttraverseoutlet((t_object *)rd, &op, outno); return (rd->rd_private->pr_oc ? riddle_nextgraph(rd) : 0); }