Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11559
Modified Files: Tag: devel_0_39 desire.c Log Message: t_manager is now a true pd class
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.42 retrieving revision 1.1.2.43 diff -C2 -d -r1.1.2.42 -r1.1.2.43 *** desire.c 29 Oct 2005 11:40:32 -0000 1.1.2.42 --- desire.c 29 Oct 2005 16:01:06 -0000 1.1.2.43 *************** *** 114,121 ****
void queue_put (t_queue *self, void *stuff) { if (self->len==QUEUE_SIZE) {bug("queue full"); return;} self->o[(self->start+self->len)%QUEUE_SIZE] = stuff; self->len++; ! post("queue_get: items in queue: %d",self->len); }
--- 114,122 ----
void queue_put (t_queue *self, void *stuff) { + post("HEY"); if (self->len==QUEUE_SIZE) {bug("queue full"); return;} self->o[(self->start+self->len)%QUEUE_SIZE] = stuff; self->len++; ! post("queue_put: items in queue: %d",self->len); }
*************** *** 128,131 **** --- 129,137 ---- }
+ void queue_free (t_queue *self) { + abort(); + free(self); + } + int queue_empty (t_queue *self) {return self->len==0;} int queue_full (t_queue *self) {return self->len==QUEUE_SIZE;} *************** *** 135,145 ****
typedef struct _manager { t_queue *q; t_clock *clock; } t_manager;
t_manager *manager;
! void manager_call (void *foo) { t_manager *self = (t_manager *)foo; while (!queue_empty(self->q)) { --- 141,153 ----
typedef struct _manager { + t_gobj super; t_queue *q; t_clock *clock; } t_manager;
+ static t_class *manager_class; t_manager *manager;
! void manager_call (void *foo) {L t_manager *self = (t_manager *)foo; while (!queue_empty(self->q)) { *************** *** 152,164 **** }
! void manager_notice (t_manager *self, t_gobj *origin, int argc, t_atom *argv) { t_appendix *a = (t_appendix *)origin->g_adix; ! if (!a->dirtyc) queue_put(self->q,origin); ! a->dirtyc = 1; SETFLOAT(a->dirtyv,-1); /* in the future this may contain real data instead */ }
! t_manager *manager_new (void) { ! t_manager *self = (t_manager *)malloc(sizeof(t_manager)); self->q = queue_new(); self->clock = clock_new(self,(t_method)manager_call); --- 160,176 ---- }
! void manager_notice (t_gobj *self_, t_gobj *origin, int argc, t_atom *argv) {L ! t_manager *self = (t_manager *)self; t_appendix *a = (t_appendix *)origin->g_adix; ! if (!a->dirtyc) { ! queue_put(self->q,origin); ! a->dirtyc = 1; ! } SETFLOAT(a->dirtyv,-1); /* in the future this may contain real data instead */ }
! t_manager *manager_new (t_symbol *s, int argc, t_atom *argv) {L ! t_manager *self = (t_manager *)pd_new(manager_class); ! self->super.g_adix = appendix_new((t_gobj *)self); self->q = queue_new(); self->clock = clock_new(self,(t_method)manager_call); *************** *** 167,170 **** --- 179,188 ---- }
+ void manager_free (t_manager *self) {L + clock_free(self->clock); + queue_free(self->q); + pd_free((t_pd *)self); + } + //-------------------------------------------------------------------------- /* the "glist" class is also known as "canvas" (the two used *************** *** 226,232 **** } } ! glist_each(g,gl) ! //for (g = gl->gl_list; g; g = g->g_next) ! { if (pd_class(&g->g_pd) == canvas_class) glist_doupdatewindowlist((t_glist *)g, sbuf); --- 244,248 ---- } } ! glist_each(g,gl) { if (pd_class(&g->g_pd) == canvas_class) glist_doupdatewindowlist((t_glist *)g, sbuf); *************** *** 253,257 **** x->gl_next = canvas_list; canvas_list = x; ! canvas_redraw(x); }
--- 269,276 ---- x->gl_next = canvas_list; canvas_list = x; ! post("addtolist %lx",(long)x); ! gobj_subscribe((t_gobj *)x,(t_gobj *)manager); ! gobj_changed(x,""); ! // canvas_redraw(x); }
*************** *** 12416,12420 **** } binbuf_gettext(buf,&s,&n); ! sys_vgui("update_object %x {%.*s}\n", (unsigned)self,n,s); sys_mgui(self,"ninlets=","i", obj_ninlets((t_text *)self)); sys_mgui(self,"noutlets=","i",obj_noutlets((t_text *)self)); --- 12435,12439 ---- } binbuf_gettext(buf,&s,&n); ! sys_vgui("update_object %lx {%.*s}\n", (long)self,n,s); sys_mgui(self,"ninlets=","i", obj_ninlets((t_text *)self)); sys_mgui(self,"noutlets=","i",obj_noutlets((t_text *)self)); *************** *** 13388,13396 **** t_canvas *self = (t_canvas *)x; post("canvas_notice(%p,%p,%d,...): havewindow=%d mapped=%d",x,origin,argc,self->gl_havewindow,self->gl_mapped); ! if (self->gl_havewindow /* && self->gl_mapped */) { ! manager_notice(manager,origin,argc,argv); ! } else { gobj_changed3(self,origin,argc,argv); ! } }
--- 13407,13415 ---- t_canvas *self = (t_canvas *)x; post("canvas_notice(%p,%p,%d,...): havewindow=%d mapped=%d",x,origin,argc,self->gl_havewindow,self->gl_mapped); ! // if (self->gl_havewindow /* && self->gl_mapped */) { ! // manager_notice(manager,origin,argc,argv); ! // } else { gobj_changed3(self,origin,argc,argv); ! // } }
*************** *** 13494,13498 ****
void desire_setup(void) { ! manager = manager_new(); #define S(x) x##_setup(); S(vinlet) S(voutlet) --- 13513,13520 ----
void desire_setup(void) { ! manager_class = class_new(gensym("__manager"), (t_newmethod)manager_new, ! (t_method)manager_free, sizeof(t_manager), CLASS_NOINLET, A_GIMME, 0); ! class_setnotice(manager_class,manager_notice); ! manager = manager_new(0,0,0); #define S(x) x##_setup(); S(vinlet) S(voutlet)