aboutsummaryrefslogtreecommitdiff
path: root/shared/unstable
diff options
context:
space:
mode:
Diffstat (limited to 'shared/unstable')
-rw-r--r--shared/unstable/forky.c29
-rw-r--r--shared/unstable/forky.h17
2 files changed, 44 insertions, 2 deletions
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);