Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9990
Modified Files: Tag: desiredata desire.c Log Message: temporary [reply] objects for handling client-server sync
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.81 retrieving revision 1.1.2.217.2.82 diff -C2 -d -r1.1.2.217.2.81 -r1.1.2.217.2.82 *** desire.c 19 Dec 2006 18:32:36 -0000 1.1.2.217.2.81 --- desire.c 19 Dec 2006 19:22:36 -0000 1.1.2.217.2.82 *************** *** 203,207 **** struct t_queue { int start,len; ! void *o[QUEUE_SIZE]; };
--- 203,207 ---- struct t_queue { int start,len; ! t_pd *o[QUEUE_SIZE]; };
*************** *** 212,218 **** }
void queue_put (t_queue *self, t_pd *stuff) { #ifdef DEBUG_QUEUE - char *buf; int bufn; t_binbuf *b = ((t_text *)stuff)->binbuf; if (b) {char *buf; int bufn; binbuf_gettext(b,&buf,&bufn); printf("queue_put [%.*s]\n",bufn,buf);} --- 212,219 ---- }
+ #define DEBUG_QUEUE + void queue_put (t_queue *self, t_pd *stuff) { #ifdef DEBUG_QUEUE t_binbuf *b = ((t_text *)stuff)->binbuf; if (b) {char *buf; int bufn; binbuf_gettext(b,&buf,&bufn); printf("queue_put [%.*s]\n",bufn,buf);} *************** *** 228,232 ****
void *queue_get (t_queue *self) { ! void *stuff = self->o[self->start]; self->start = (self->start+1)%QUEUE_SIZE; self->len--; --- 229,233 ----
void *queue_get (t_queue *self) { ! t_pd *stuff = self->o[self->start]; self->start = (self->start+1)%QUEUE_SIZE; self->len--; *************** *** 239,243 **** binbuf_gettext(b,&buf,&bufn); printf("queue_get [%.*s] %p\n",bufn,buf,stuff); ! } else printf("queue_get (%s)\n",(*(t_pd*)stuff)->c_name->s_name); } #endif --- 240,244 ---- binbuf_gettext(b,&buf,&bufn); printf("queue_get [%.*s] %p\n",bufn,buf,stuff); ! } else printf("queue_get (%s)\n",stuff->_class->c_name->s_name); } #endif *************** *** 267,270 **** --- 268,296 ----
//-------------------------------------------------------------------------- + // reply system: + + struct t_reply : t_gobj { + short serial; + void *answer; + }; + + t_class *reply_class; + + static t_reply *reply_new (short serial, void *answer) { + t_reply *self = (t_reply *)pd_new(reply_class); + self->dix = appendix_new(self); + self->serial = serial; + self->answer = answer; + fprintf(stderr,"reply_new %ld x%lx\n",(long)self->serial,(long)self->answer); + return self; + } + + static void reply_send (t_reply *self) { + sys_vgui("serial %ld x%lx\n",(long)self->serial,(long)self->answer); + } + + static void reply_free (t_reply *self) {} + + //-------------------------------------------------------------------------- // update manager:
*************** *** 283,289 **** t_gobj *o = (t_gobj *)queue_get(self->q); if (!o) continue; /* cancelled notice */ ! if (!o->g_adix->dirtyc) continue; ! pd_upload(o); ! o->g_adix->dirtyc = 0; } clock_delay(self->clock,50); --- 309,322 ---- t_gobj *o = (t_gobj *)queue_get(self->q); if (!o) continue; /* cancelled notice */ ! //fprintf(stderr,"manager_call, o->_class=%s\n",o->_class->c_name->s_name); ! if (o->_class == reply_class) { ! reply_send((t_reply *)o); ! pd_free(o); ! } else { ! if (o->g_adix->dirtyc) { ! pd_upload(o); ! o->g_adix->dirtyc = 0; ! } ! } } clock_delay(self->clock,50); *************** *** 3754,3758 **** buf[bufsize] = 0; sprintf(buf2, "pdtk_data_dialog %%s {"); - gfxstub_new((t_pd *)owner, x, buf2); sys_gui(buf); sys_gui("}\n"); --- 3787,3790 ---- *************** *** 7384,7395 **** /* end miller 0.40 */
- /* desiredata pre5 */ static void canvas_with_reply (t_canvas *x, t_symbol *s, int argc, t_atom *argv) { if (!( argc>=2 && IS_A_FLOAT(argv,0) && IS_A_SYMBOL(argv,1) )) return; pd_typedmess(x,atom_getsymbol(&argv[1]),argc-2,argv+2); ! sys_vgui("serial %ld x%lx\n",(long)atom_getfloat(&argv[0]),(long)newest); }
static void g_canvas_setup(void) { declare_class = class_new(gensym("declare"), (t_newmethod)declare_new, (t_method)declare_free, sizeof(t_declare), CLASS_NOINLET, A_GIMME, 0); --- 7416,7430 ---- /* end miller 0.40 */
static void canvas_with_reply (t_canvas *x, t_symbol *s, int argc, t_atom *argv) { if (!( argc>=2 && IS_A_FLOAT(argv,0) && IS_A_SYMBOL(argv,1) )) return; pd_typedmess(x,atom_getsymbol(&argv[1]),argc-2,argv+2); ! queue_put(manager->q,reply_new((short)atom_getfloat(&argv[0]),newest)); }
static void g_canvas_setup(void) { + reply_class = class_new(gensym("reply"), 0, + (t_method)reply_free, sizeof(t_reply), CLASS_GOBJ, A_CANT, 0); + // class_setsavefn(reply_class, (t_savefn)reply_savefn); + declare_class = class_new(gensym("declare"), (t_newmethod)declare_new, (t_method)declare_free, sizeof(t_declare), CLASS_NOINLET, A_GIMME, 0);