Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18881
Modified Files: Tag: desiredata desire.c m_pd.h Log Message: removed gs_which
Index: m_pd.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v retrieving revision 1.4.4.11.2.33.2.23 retrieving revision 1.4.4.11.2.33.2.24 diff -C2 -d -r1.4.4.11.2.33.2.23 -r1.4.4.11.2.33.2.24 *** m_pd.h 3 Jan 2007 02:36:26 -0000 1.4.4.11.2.33.2.23 --- m_pd.h 3 Jan 2007 03:13:43 -0000 1.4.4.11.2.33.2.24 *************** *** 102,109 **** typedef struct _gstub { union { ! struct _glist *gs_glist; struct _array *gs_array; } gs_un; ! int gs_which; /* GP_GLIST/GP_ARRAY */ int gs_refcount; /* number of gpointers pointing here */ } t_gstub; --- 102,109 ---- typedef struct _gstub { union { ! struct _glist *gs_glist; /* should be renamed to gs_canvas */ struct _array *gs_array; } gs_un; ! int gs_pointless; int gs_refcount; /* number of gpointers pointing here */ } t_gstub; *************** *** 120,128 **** typedef union word { t_float w_float; /* A_FLOAT */ ! t_symbol *w_symbol; /* A_SYMBOL */ t_gpointer *w_gpointer; /* A_POINTER */ ! t_array *w_array; /* DS nested array? */ ! struct _glist *w_list; /* DS nested list? */ ! int w_index; /* what's this? */ } t_word;
--- 120,128 ---- typedef union word { t_float w_float; /* A_FLOAT */ ! t_symbol *w_symbol; /* A_SYMBOL or A_DOLLSYM */ t_gpointer *w_gpointer; /* A_POINTER */ ! t_array *w_array; /* DT_ARRAY */ ! struct _glist *w_list; /* DT_LIST */ ! t_int w_index; /* A_SEMI or A_COMMA or A_DOLLAR */ } t_word;
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.102 retrieving revision 1.1.2.217.2.103 diff -C2 -d -r1.1.2.217.2.102 -r1.1.2.217.2.103 *** desire.c 3 Jan 2007 02:36:24 -0000 1.1.2.217.2.102 --- desire.c 3 Jan 2007 03:13:41 -0000 1.1.2.217.2.103 *************** *** 1374,1379 **** scalars (g_scalar.c); their graphical behavior is defined accordingly. */
t_array *array_new(t_symbol *templatesym, t_gpointer *parent) { ! t_array *x = (t_array *)getbytes(sizeof (*x)); t_template *t = template_findbyname(templatesym); x->templatesym = templatesym; --- 1374,1381 ---- scalars (g_scalar.c); their graphical behavior is defined accordingly. */
+ t_class *array_class; + t_array *array_new(t_symbol *templatesym, t_gpointer *parent) { ! t_array *x = (t_array *)pd_new(array_class); t_template *t = template_findbyname(templatesym); x->templatesym = templatesym; *************** *** 1411,1417 **** #define STUB(x) x->gp.gp_stub
static void array_resize_and_redraw(t_array *array, int n) { t_array *a2 = array; ! while (STUB(a2)->gs_which == GP_ARRAY) a2 = STUB(a2)->gs_un.gs_array; array_resize(array,n); gobj_changed(array,0); --- 1413,1421 ---- #define STUB(x) x->gp.gp_stub
+ static int gstub_which(t_gstub *); + static void array_resize_and_redraw(t_array *array, int n) { t_array *a2 = array; ! while (gstub_which(STUB(a2)) == GP_ARRAY) a2 = STUB(a2)->gs_un.gs_array; array_resize(array,n); gobj_changed(array,0); *************** *** 1423,1433 **** t_template *scalartemplate = template_findbyname(x->templatesym); gstub_cutoff(x->stub); ! for (int i=0; i < x->n; i++) { ! t_word *wp = (t_word *)(x->vec + x->elemsize*i); ! word_free(wp, scalartemplate); ! } ! /* aligned free */ freealignedbytes(x->vec, x->elemsize * x->n); - freebytes(x, sizeof *x); }
--- 1427,1432 ---- t_template *scalartemplate = template_findbyname(x->templatesym); gstub_cutoff(x->stub); ! for (int i=0; i < x->n; i++) word_free((t_word *)(x->vec + x->elemsize*i), scalartemplate); freealignedbytes(x->vec, x->elemsize * x->n); }
*************** *** 1576,1580 **** saveit = (flags & 1) != 0; t_garray *x = graph_scalar(gl, s, templatesym, saveit); ! x->hidename = ((flags & 8) >> 3); if (n <= 0) n = 100; array_resize(x->scalar->v[zonset].w_array, n); --- 1575,1579 ---- saveit = (flags & 1) != 0; t_garray *x = graph_scalar(gl, s, templatesym, saveit); ! x->hidename = (flags>>3)&1; if (n <= 0) n = 100; array_resize(x->scalar->v[zonset].w_array, n); *************** *** 1697,1701 ****
static void array_redraw(t_array *a, t_canvas *canvas) { ! while (STUB(a)->gs_which == GP_ARRAY) a = STUB(a)->gs_un.gs_array; scalar_redraw(a->gp.gp_un.gp_scalar, canvas); } --- 1696,1700 ----
static void array_redraw(t_array *a, t_canvas *canvas) { ! while (gstub_which(STUB(a)) == GP_ARRAY) a = STUB(a)->gs_un.gs_array; scalar_redraw(a->gp.gp_un.gp_scalar, canvas); } *************** *** 2168,2171 **** --- 2167,2172 ---- t_class *c = garray_class = class_new(gensym("array"), 0, (t_method)garray_free, sizeof(t_garray), CLASS_GOBJ, 0); + array_class = class_new(gensym("array_really"), 0, (t_method)array_free, + sizeof(t_array), CLASS_GOBJ, 0); class_addmethod3(c, garray_const, "const", "F"); class_addlist(garray_class, garray_list); *************** *** 3615,3619 **** t_dataslot *dt = t->vec; for (int i=0; i<t->n; i++, dt++) { ! if (dt->type == DT_ARRAY) array_free(wp[i].w_array); else if (dt->type == DT_LIST) canvas_free(wp[i].w_list); } --- 3616,3620 ---- t_dataslot *dt = t->vec; for (int i=0; i<t->n; i++, dt++) { ! if (dt->type == DT_ARRAY) pd_free(wp[i].w_array); else if (dt->type == DT_LIST) canvas_free(wp[i].w_list); } *************** *** 5067,5072 **** t_gstub *gstub_new(t_canvas *gl, t_array *a) { t_gstub *gs = (t_gstub *)getbytes(sizeof(*gs)); ! if (gl) {gs->gs_which = GP_CANVAS; gs->gs_un.gs_glist = gl;} ! else {gs->gs_which = GP_ARRAY; gs->gs_un.gs_array = a;} gs->gs_refcount = 0; return gs; --- 5068,5073 ---- t_gstub *gstub_new(t_canvas *gl, t_array *a) { t_gstub *gs = (t_gstub *)getbytes(sizeof(*gs)); ! if (gl) gs->gs_un.gs_glist = gl; ! else gs->gs_un.gs_array = a; gs->gs_refcount = 0; return gs; *************** *** 5079,5083 **** static void gstub_dis(t_gstub *gs) { int refcount = --gs->gs_refcount; ! if ((!refcount) && gs->gs_which == GP_NONE) t_freebytes(gs, sizeof (*gs)); else if (refcount < 0) bug("gstub_dis"); } --- 5080,5084 ---- static void gstub_dis(t_gstub *gs) { int refcount = --gs->gs_refcount; ! if (!refcount && gstub_which(gs) == GP_NONE) t_freebytes(gs, sizeof (*gs)); else if (refcount < 0) bug("gstub_dis"); } *************** *** 5087,5095 **** otherwise we wait for the last gstub_dis() to free it. */ void gstub_cutoff(t_gstub *gs) { ! gs->gs_which = GP_NONE; if (gs->gs_refcount < 0) bug("gstub_cutoff"); if (!gs->gs_refcount) t_freebytes(gs, sizeof (*gs)); }
/* call this to verify that a pointer is fresh, i.e., that it either points to real data or to the head of a list, and that in either case --- 5088,5101 ---- otherwise we wait for the last gstub_dis() to free it. */ void gstub_cutoff(t_gstub *gs) { ! gs->gs_un.gs_array = 0; if (gs->gs_refcount < 0) bug("gstub_cutoff"); if (!gs->gs_refcount) t_freebytes(gs, sizeof (*gs)); }
+ static int gstub_which(t_gstub *gs) { + if (gs->gs_un.gs_array) return 0; + if (gs->gs_un.gs_array->_class == array_class) return GP_ARRAY; else return GP_CANVAS; + } + /* call this to verify that a pointer is fresh, i.e., that it either points to real data or to the head of a list, and that in either case *************** *** 5099,5104 **** t_gstub *gs = gp->gp_stub; if (!gs) return 0; ! if (gs->gs_which == GP_ARRAY) return 1; ! if (gs->gs_which == GP_CANVAS) return headok || gp->gp_un.gp_scalar; return 0; } --- 5105,5110 ---- t_gstub *gs = gp->gp_stub; if (!gs) return 0; ! if (gstub_which(gs) == GP_ARRAY) return 1; ! if (gstub_which(gs) == GP_CANVAS) return headok || gp->gp_un.gp_scalar; return 0; } *************** *** 5108,5113 **** static t_symbol *gpointer_gettemplatesym(const t_gpointer *gp) { t_gstub *gs = gp->gp_stub; ! if (gs->gs_which == GP_CANVAS) {t_scalar *sc = gp->gp_un.gp_scalar; return sc ? sc->t : 0;} ! else {t_array *a = gs->gs_un.gs_array; return a->templatesym;} }
--- 5114,5119 ---- static t_symbol *gpointer_gettemplatesym(const t_gpointer *gp) { t_gstub *gs = gp->gp_stub; ! if (gstub_which(gs) == GP_CANVAS) {t_scalar *sc = gp->gp_un.gp_scalar; return sc ? sc->t : 0;} ! else {t_array *a = gs->gs_un.gs_array; return a->templatesym;} }
*************** *** 5191,5195 **** int wantselected = f!=0; if (!gs) {pd_error(x, "next: no current pointer"); return;} ! if (gs->gs_which != GP_CANVAS) {pd_error(x, "next: lists only, not arrays"); return;} canvas = gs->gs_un.gs_glist; if (isstale(gp)) {pd_error(x, "next: stale pointer"); return;} --- 5197,5201 ---- int wantselected = f!=0; if (!gs) {pd_error(x, "next: no current pointer"); return;} ! if (gstub_which(gs) != GP_CANVAS) {pd_error(x, "next: lists only, not arrays"); return;} canvas = gs->gs_un.gs_glist; if (isstale(gp)) {pd_error(x, "next: stale pointer"); return;} *************** *** 5221,5229 **** if (!gpointer_check(&x->gp, 1)) {pd_error(x, "bang: empty pointer"); return;} gs = x->gp.gp_stub; ! if (gs->gs_which == GP_CANVAS) canvas = gs->gs_un.gs_glist; else { t_array *owner_array = gs->gs_un.gs_array; ! while (STUB(owner_array)->gs_which == GP_ARRAY) ! owner_array = STUB(owner_array)->gs_un.gs_array; canvas = STUB(owner_array)->gs_un.gs_glist; } --- 5227,5234 ---- if (!gpointer_check(&x->gp, 1)) {pd_error(x, "bang: empty pointer"); return;} gs = x->gp.gp_stub; ! if (gstub_which(gs) == GP_CANVAS) canvas = gs->gs_un.gs_glist; else { t_array *owner_array = gs->gs_un.gs_array; ! while (gstub_which(STUB(owner_array)) == GP_ARRAY) owner_array = STUB(owner_array)->gs_un.gs_array; canvas = STUB(owner_array)->gs_un.gs_glist; } *************** *** 5253,5257 **** if (!gpointer_check(&x->gp, 1)) {pd_error(x, "rewind: empty pointer"); return;} gs = x->gp.gp_stub; ! if (gs->gs_which != GP_CANVAS) {pd_error(x, "rewind: sorry, unavailable for arrays"); return;} canvas = gs->gs_un.gs_glist; gpointer_setcanvas(&x->gp, canvas, 0); --- 5258,5262 ---- if (!gpointer_check(&x->gp, 1)) {pd_error(x, "rewind: empty pointer"); return;} gs = x->gp.gp_stub; ! if (gstub_which(gs) != GP_CANVAS) {pd_error(x, "rewind: sorry, unavailable for arrays"); return;} canvas = gs->gs_un.gs_glist; gpointer_setcanvas(&x->gp, canvas, 0); *************** *** 5302,5306 **** TEMPLATE_CHECK(x,x->templatesym,) if (!gpointer_check(gp, 0)) {pd_error(x, "stale or empty pointer"); return;} ! t_word *vec = gs->gs_which==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; vp = x->variables + nitems-1; for (int i=nitems-1; i>=0; i--, vp--) { --- 5307,5311 ---- TEMPLATE_CHECK(x,x->templatesym,) if (!gpointer_check(gp, 0)) {pd_error(x, "stale or empty pointer"); return;} ! t_word *vec = gstub_which(gs)==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; vp = x->variables + nitems-1; for (int i=nitems-1; i>=0; i--, vp--) { *************** *** 5376,5388 **** } if (!nitems) return; ! t_word *vec = gs->gs_which == GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; t_setvariable *vp=x->variables; if (x->issymbol) for (int i=0; i<nitems; i++,vp++) template_setsymbol(t, vp->sym, vec, vp->w.w_symbol, 1); else for (int i=0; i<nitems; i++,vp++) template_setfloat(t, vp->sym, vec, vp->w.w_float, 1); ! if (gs->gs_which == GP_CANVAS) scalar_redraw(gp->gp_un.gp_scalar, gs->gs_un.gs_glist); else { t_array *owner_array = gs->gs_un.gs_array; ! while (STUB(owner_array)->gs_which == GP_ARRAY) owner_array = STUB(owner_array)->gs_un.gs_array; scalar_redraw(owner_array->gp.gp_un.gp_scalar, STUB(owner_array)->gs_un.gs_glist); } --- 5381,5393 ---- } if (!nitems) return; ! t_word *vec = gstub_which(gs) == GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; t_setvariable *vp=x->variables; if (x->issymbol) for (int i=0; i<nitems; i++,vp++) template_setsymbol(t, vp->sym, vec, vp->w.w_symbol, 1); else for (int i=0; i<nitems; i++,vp++) template_setfloat(t, vp->sym, vec, vp->w.w_float, 1); ! if (gstub_which(gs) == GP_CANVAS) scalar_redraw(gp->gp_un.gp_scalar, gs->gs_un.gs_glist); else { t_array *owner_array = gs->gs_un.gs_array; ! while (gstub_which(STUB(owner_array)) == GP_ARRAY) owner_array = STUB(owner_array)->gs_un.gs_array; scalar_redraw(owner_array->gp.gp_un.gp_scalar, STUB(owner_array)->gs_un.gs_glist); } *************** *** 5440,5444 **** return; } ! t_word *w = gparent->gp_stub->gs_which==GP_ARRAY ? gparent->gp_un.gp_w : gparent->gp_un.gp_scalar->v; TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(t, fieldsym, &onset, &type, &elemtemplatesym)) { --- 5445,5449 ---- return; } ! t_word *w = gstub_which(gparent->gp_stub)==GP_ARRAY ? gparent->gp_un.gp_w : gparent->gp_un.gp_scalar->v; TEMPLATE_CHECK(x,x->templatesym,) if (!template_find_field(t, fieldsym, &onset, &type, &elemtemplatesym)) { *************** *** 5499,5503 **** return; } ! t_word *w = gs->gs_which==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; t_array *array = *(t_array **)(((char *)w) + onset); outlet_float(x->ob_outlet, (float)(array->n)); --- 5504,5508 ---- return; } ! t_word *w = gstub_which(gs)==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; t_array *array = *(t_array **)(((char *)w) + onset); outlet_float(x->ob_outlet, (float)(array->n)); *************** *** 5534,5538 **** return; } ! t_word *w = gs->gs_which==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; TEMPLATE_CHECK(x,x->templatesym,) t_symbol *elemtemplatesym; --- 5539,5543 ---- return; } ! t_word *w = gstub_which(gs)==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; TEMPLATE_CHECK(x,x->templatesym,) t_symbol *elemtemplatesym; *************** *** 5557,5565 **** but if we belong to an element of another array we have to search back until we get to a scalar to erase. When graphics updates become queueable this may fall apart... */ ! if (gs->gs_which == GP_CANVAS) { if (canvas_isvisible(gs->gs_un.gs_glist)) sys_mgui(gp->gp_un.gp_scalar,"delete",""); } else { t_array *o = gs->gs_un.gs_array; ! while (STUB(o)->gs_which == GP_ARRAY) o = STUB(o)->gs_un.gs_array; if (canvas_isvisible(STUB(o)->gs_un.gs_glist)) sys_mgui(o->gp.gp_un.gp_scalar, "delete",""); } --- 5562,5570 ---- but if we belong to an element of another array we have to search back until we get to a scalar to erase. When graphics updates become queueable this may fall apart... */ ! if (gstub_which(gs) == GP_CANVAS) { if (canvas_isvisible(gs->gs_un.gs_glist)) sys_mgui(gp->gp_un.gp_scalar,"delete",""); } else { t_array *o = gs->gs_un.gs_array; ! while (gstub_which(STUB(o)) == GP_ARRAY) o = STUB(o)->gs_un.gs_array; if (canvas_isvisible(STUB(o)->gs_un.gs_glist)) sys_mgui(o->gp.gp_un.gp_scalar, "delete",""); } *************** *** 5576,5584 **** } } ! if (gs->gs_which == GP_CANVAS) { gobj_changed(gp->gp_un.gp_scalar,0); } else {/*is there something missing here?*/ t_array *o = gs->gs_un.gs_array; ! while (STUB(o)->gs_which == GP_ARRAY) o = STUB(o)->gs_un.gs_array; gobj_changed(o->gp.gp_un.gp_scalar,0); } --- 5581,5589 ---- } } ! if (gstub_which(gs) == GP_CANVAS) { gobj_changed(gp->gp_un.gp_scalar,0); } else {/*is there something missing here?*/ t_array *o = gs->gs_un.gs_array; ! while (gstub_which(STUB(o)) == GP_ARRAY) o = STUB(o)->gs_un.gs_array; gobj_changed(o->gp.gp_un.gp_scalar,0); } *************** *** 5630,5634 **** TEMPLATE_CHECK(x,x->templatesym,) if (!gs) {pd_error(x, "no current pointer"); return;} ! if (gs->gs_which != GP_CANVAS) {pd_error(x, "lists only, not arrays"); return;} t_canvas *canvas = gs->gs_un.gs_glist; if (isstale(gp)) {pd_error(x, "stale pointer"); return;} --- 5635,5639 ---- TEMPLATE_CHECK(x,x->templatesym,) if (!gs) {pd_error(x, "no current pointer"); return;} ! if (gstub_which(gs) != GP_CANVAS) {pd_error(x, "lists only, not arrays"); return;} t_canvas *canvas = gs->gs_un.gs_glist; if (isstale(gp)) {pd_error(x, "stale pointer"); return;} *************** *** 5685,5689 **** } if (type != DT_LIST) {pd_error(x, "field %s not of type list", x->fieldsym->s_name); return;} ! t_word *w = gs->gs_which==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; gpointer_setcanvas(&x->gp, *(t_canvas **)(((char *)w) + onset), 0); outlet_pointer(x->ob_outlet, &x->gp); --- 5690,5694 ---- } if (type != DT_LIST) {pd_error(x, "field %s not of type list", x->fieldsym->s_name); return;} ! t_word *w = gstub_which(gs)==GP_ARRAY ? gp->gp_un.gp_w : gp->gp_un.gp_scalar->v; gpointer_setcanvas(&x->gp, *(t_canvas **)(((char *)w) + onset), 0); outlet_pointer(x->ob_outlet, &x->gp);