compile fixes for pd 0.52

This commit is contained in:
Miller Puckette 2021-12-11 09:14:17 -08:00
parent e4ef77337a
commit 3da06d1024
2 changed files with 1 additions and 174 deletions

View file

@ -55,6 +55,6 @@ set(COMPONENT_SRCS "espd.c pdmain.c \
set(COMPONENT_ADD_INCLUDEDIRS ".")
set(COMPONENT_ADD_CFLAGS "-DPD -DHAVE_UNISTD_H -DHAVE_ALLOCA_H -DPD_HEADLESS\
-DSYMTABHASHSIZE=512 -DSTUPID_SORT -Wno-unused-variable")
-DSYMTABHASHSIZE=512 -DSTUPID_SORT -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format")
register_component()

View file

@ -302,8 +302,6 @@ int sys_defaultfont = 1;
int sys_nearestfontsize(int fontsize) {return (1);}
int sys_noautopatch = 1;
int gobj_shouldvis(t_gobj *x, struct _glist *glist) {return (0);}
void canvas_undo_cleardirty(t_canvas *x) {}
t_undo_action *canvas_undo_init(t_canvas *x) {return (0);}
@ -645,58 +643,6 @@ bad:
(sink? class_getname(pd_class(&sink->g_pd)) : "???"));
}
/* ---------------- generic widget behavior ------------------------- */
void gobj_getrect(t_gobj *x, t_glist *glist, int *x1, int *y1,
int *x2, int *y2)
{
if (x->g_pd->c_wb && x->g_pd->c_wb->w_getrectfn)
(*x->g_pd->c_wb->w_getrectfn)(x, glist, x1, y1, x2, y2);
else *x1 = *y1 = 0, *x2 = *y2 = 10;
}
void gobj_displace(t_gobj *x, t_glist *glist, int dx, int dy)
{
if (x->g_pd->c_wb && x->g_pd->c_wb->w_displacefn)
(*x->g_pd->c_wb->w_displacefn)(x, glist, dx, dy);
}
/* here we add an extra check whether we're mapped, because some
editing moves are carried out on invisible windows (notably, re-creating
abstractions when one is saved). Should any other widget finctions also
be doing this? */
void gobj_select(t_gobj *x, t_glist *glist, int state)
{
if (glist->gl_mapped && x->g_pd->c_wb && x->g_pd->c_wb->w_selectfn)
(*x->g_pd->c_wb->w_selectfn)(x, glist, state);
}
void gobj_activate(t_gobj *x, t_glist *glist, int state)
{
if (x->g_pd->c_wb && x->g_pd->c_wb->w_activatefn)
(*x->g_pd->c_wb->w_activatefn)(x, glist, state);
}
void gobj_delete(t_gobj *x, t_glist *glist)
{
if (x->g_pd->c_wb && x->g_pd->c_wb->w_deletefn)
(*x->g_pd->c_wb->w_deletefn)(x, glist);
}
void gobj_vis(t_gobj *x, struct _glist *glist, int flag)
{
if (x->g_pd->c_wb && x->g_pd->c_wb->w_visfn && gobj_shouldvis(x, glist))
(*x->g_pd->c_wb->w_visfn)(x, glist, flag);
}
int gobj_click(t_gobj *x, struct _glist *glist,
int xpix, int ypix, int shift, int alt, int dbl, int doit)
{
if (x->g_pd->c_wb && x->g_pd->c_wb->w_clickfn)
return ((*x->g_pd->c_wb->w_clickfn)(x,
glist, xpix, ypix, shift, alt, dbl, doit));
else return (0);
}
void canvas_vis(t_canvas *x, t_floatarg f) {}
@ -1012,122 +958,3 @@ double sys_getrealtime(void)
(1./1000000.) * (now.tv_usec - then.tv_usec));
}
/* ------------------ g_traversal.c --------------- */
/* ------------- gstubs and gpointers - safe pointing --------------- */
/* create a gstub which is "owned" by a glist (gl) or an array ("a"). */
t_gstub *gstub_new(t_glist *gl, t_array *a)
{
t_gstub *gs = t_getbytes(sizeof(*gs));
if (gl)
{
gs->gs_which = GP_GLIST;
gs->gs_un.gs_glist = gl;
}
else
{
gs->gs_which = GP_ARRAY;
gs->gs_un.gs_array = a;
}
gs->gs_refcount = 0;
return (gs);
}
/* when a "gpointer" is set to point to this stub (so we can later chase
down the owner) we increase a reference count. The following routine is called
whenever a gpointer is unset from pointing here. If the owner is
gone and the refcount goes to zero, we can free the gstub safely. */
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");
}
/* this routing is called by the owner to inform the gstub that it is
being deleted. If no gpointers are pointing here, we can free the gstub;
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
the object hasn't disappeared since this pointer was generated.
Unless "headok" is set, the routine also fails for the head of a list. */
int gpointer_check(const t_gpointer *gp, int headok)
{
t_gstub *gs = gp->gp_stub;
if (!gs) return (0);
if (gs->gs_which == GP_ARRAY)
{
if (gs->gs_un.gs_array->a_valid != gp->gp_valid) return (0);
else return (1);
}
else if (gs->gs_which == GP_GLIST)
{
if (!headok && !gp->gp_un.gp_scalar) return (0);
else if (gs->gs_un.gs_glist->gl_valid != gp->gp_valid) return (0);
else return (1);
}
else return (0);
}
/* copy a pointer to another, assuming the second one hasn't yet been
initialized. New gpointers should be initialized either by this
routine or by gpointer_init below. */
void gpointer_copy(const t_gpointer *gpfrom, t_gpointer *gpto)
{
*gpto = *gpfrom;
if (gpto->gp_stub)
gpto->gp_stub->gs_refcount++;
else bug("gpointer_copy");
}
/* clear a gpointer that was previously set, releasing the associated
gstub if this was the last reference to it. */
void gpointer_unset(t_gpointer *gp)
{
t_gstub *gs;
if ((gs = gp->gp_stub))
{
gstub_dis(gs);
gp->gp_stub = 0;
}
}
void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x)
{
t_gstub *gs;
if ((gs = gp->gp_stub)) gstub_dis(gs);
gp->gp_stub = gs = glist->gl_stub;
gp->gp_valid = glist->gl_valid;
gp->gp_un.gp_scalar = x;
gs->gs_refcount++;
}
void gpointer_setarray(t_gpointer *gp, t_array *array, t_word *w)
{
t_gstub *gs;
if ((gs = gp->gp_stub)) gstub_dis(gs);
gp->gp_stub = gs = array->a_stub;
gp->gp_valid = array->a_valid;
gp->gp_un.gp_w = w;
gs->gs_refcount++;
}
void gpointer_init(t_gpointer *gp)
{
gp->gp_stub = 0;
gp->gp_valid = 0;
gp->gp_un.gp_scalar = 0;
}