diff options
author | N.N. <krzyszcz@users.sourceforge.net> | 2003-09-05 10:03:46 +0000 |
---|---|---|
committer | N.N. <krzyszcz@users.sourceforge.net> | 2003-09-05 10:03:46 +0000 |
commit | 53f05d96ff8e49c87977fa91a06ebade8893606e (patch) | |
tree | 51bd07eb57c532e61515fb85a0fcd83698054854 /shared | |
parent | 672477f94d2d0701f75f2546ad79980dc9ac8543 (diff) |
*** empty log message ***
svn path=/trunk/externals/miXed/; revision=931
Diffstat (limited to 'shared')
-rw-r--r-- | shared/hammer/file.c | 8 | ||||
-rw-r--r-- | shared/unstable/forky.c | 29 | ||||
-rw-r--r-- | shared/unstable/forky.h | 17 |
3 files changed, 46 insertions, 8 deletions
diff --git a/shared/hammer/file.c b/shared/hammer/file.c index 6a94c92..635c9bc 100644 --- a/shared/hammer/file.c +++ b/shared/hammer/file.c @@ -20,8 +20,7 @@ #include <string.h> #include "m_pd.h" #include "g_canvas.h" -/* need this for t_class::c_wb field access, LATER find a better way... */ -#include "unstable/pd_imp.h" +#include "unstable/forky.h" #include "hammer/file.h" static t_class *hammerfile_class = 0; @@ -375,10 +374,7 @@ void hammerfile_setup(t_class *c, int embeddable) { if (embeddable) { - t_widgetbehavior *newwb = getbytes(sizeof(*newwb)); /* never freed */ - *newwb = *c->c_wb; - newwb->w_savefn = hammerembed_save; - class_setwidget(c, newwb); + forky_setsavefn(c, hammerembed_save); class_addmethod(c, (t_method)hammerembed_restore, gensym("restore"), 0); } diff --git a/shared/unstable/forky.c b/shared/unstable/forky.c index 7fb6b08..1feae26 100644 --- a/shared/unstable/forky.c +++ b/shared/unstable/forky.c @@ -7,7 +7,32 @@ #include "shared.h" #include "unstable/forky.h" -//#define FORKY_DEBUG +#if FORKY_VERSION < 37 +/* need this for t_class::c_wb field access */ +#include "unstable/pd_imp.h" +#endif + +#define FORKY_DEBUG + +void forky_setsavefn(t_class *c, t_forkysavefn fn) +{ +#if FORKY_VERSION >= 37 + class_setsavefn(c, fn); +#else + if (c->c_wb->w_savefn) + { + /* cloning is necessary, because class_setwidget has not been called */ + t_widgetbehavior *wb = getbytes(sizeof(*wb)); /* never freed */ +#ifdef FORKY_DEBUG + post("cloning widgetbehavior..."); +#endif + *wb = *c->c_wb; + wb->w_savefn = fn; + class_setwidget(c, wb); + } + else c->c_wb->w_savefn = fn; +#endif +} /* To be called in a 'dsp' method -- e.g. if there are no feeders, the caller might use an optimized version of a 'perform' routine. @@ -18,7 +43,7 @@ int forky_hasfeeders(t_object *x, t_glist *glist, int inno, t_symbol *outsym) linetraverser_start(&t, glist); while (linetraverser_next(&t)) if (t.tr_ob2 == x && t.tr_inno == inno -#ifdef PD_VERSION /* FIXME ask Miller */ +#if FORKY_VERSION >= 36 && (!outsym || outsym == outlet_getsymbol(t.tr_outlet)) #endif ) diff --git a/shared/unstable/forky.h b/shared/unstable/forky.h index 0d27080..df27690 100644 --- a/shared/unstable/forky.h +++ b/shared/unstable/forky.h @@ -5,6 +5,23 @@ #ifndef __FORKY_H__ #define __FORKY_H__ +#ifdef PD_MINOR_VERSION +#define FORKY_VERSION PD_MINOR_VERSION +#elif defined(PD_VERSION) +#define FORKY_VERSION 36 +#else +#define FORKY_VERSION 35 +#endif + +#if FORKY_VERSION >= 37 +#define FORKY_WIDGETPADDING +#else +#define FORKY_WIDGETPADDING 0,0 +#endif + +typedef void (*t_forkysavefn)(t_gobj *x, t_binbuf *b); + +void forky_setsavefn(t_class *c, t_forkysavefn fn); int forky_hasfeeders(t_object *x, t_glist *glist, int inno, t_symbol *outsym); t_int forky_getbitmask(int ac, t_atom *av); |