aboutsummaryrefslogtreecommitdiff
path: root/shared/unstable
diff options
context:
space:
mode:
Diffstat (limited to 'shared/unstable')
-rw-r--r--shared/unstable/Makefile4
-rw-r--r--shared/unstable/Makefile.objects0
-rw-r--r--shared/unstable/Makefile.sources4
-rw-r--r--shared/unstable/forky.c56
-rw-r--r--shared/unstable/forky.h11
-rw-r--r--shared/unstable/fragile.c67
-rw-r--r--shared/unstable/fragile.h13
-rw-r--r--shared/unstable/loader.c139
-rw-r--r--shared/unstable/loader.h12
-rw-r--r--shared/unstable/pd_imp.h60
10 files changed, 366 insertions, 0 deletions
diff --git a/shared/unstable/Makefile b/shared/unstable/Makefile
new file mode 100644
index 0000000..5dcb2c8
--- /dev/null
+++ b/shared/unstable/Makefile
@@ -0,0 +1,4 @@
+ROOT_DIR = ../..
+include $(ROOT_DIR)/Makefile.common
+
+all: $(OBJECTS)
diff --git a/shared/unstable/Makefile.objects b/shared/unstable/Makefile.objects
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/shared/unstable/Makefile.objects
diff --git a/shared/unstable/Makefile.sources b/shared/unstable/Makefile.sources
new file mode 100644
index 0000000..4636701
--- /dev/null
+++ b/shared/unstable/Makefile.sources
@@ -0,0 +1,4 @@
+OTHER_SOURCES = \
+fragile.c \
+forky.c \
+loader.c
diff --git a/shared/unstable/forky.c b/shared/unstable/forky.c
new file mode 100644
index 0000000..7fb6b08
--- /dev/null
+++ b/shared/unstable/forky.c
@@ -0,0 +1,56 @@
+/* Copyright (c) 2003 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#include "m_pd.h"
+#include "g_canvas.h"
+#include "shared.h"
+#include "unstable/forky.h"
+
+//#define FORKY_DEBUG
+
+/* 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.
+ LATER think about replacing 'linetraverser' calls with something faster. */
+int forky_hasfeeders(t_object *x, t_glist *glist, int inno, t_symbol *outsym)
+{
+ t_linetraverser t;
+ linetraverser_start(&t, glist);
+ while (linetraverser_next(&t))
+ if (t.tr_ob2 == x && t.tr_inno == inno
+#ifdef PD_VERSION /* FIXME ask Miller */
+ && (!outsym || outsym == outlet_getsymbol(t.tr_outlet))
+#endif
+ )
+ return (1);
+ return (0);
+}
+
+/* Not really a forky, just found no better place to put it in.
+ Used in bitwise signal binops (sickle). Checked against msp2. */
+t_int forky_getbitmask(int ac, t_atom *av)
+{
+ t_int result = 0;
+ if (sizeof(shared_t_bitmask) >= sizeof(t_int))
+ {
+ int nbits = sizeof(t_int) * 8;
+ shared_t_bitmask bitmask = 1 << (nbits - 1);
+ if (ac > nbits)
+ ac = nbits;
+ while (ac--)
+ {
+ if (av->a_type == A_FLOAT &&
+ (int)av->a_w.w_float) /* CHECKED */
+ result |= bitmask;
+ /* CHECKED symbols are zero */
+ bitmask >>= 1;
+ av++;
+ }
+ /* CHECKED missing are zero */
+#ifdef FORKY_DEBUG
+ post("mask set to %.8x", result);
+#endif
+ }
+ else bug("sizeof(shared_t_bitmask)");
+ return (result);
+}
diff --git a/shared/unstable/forky.h b/shared/unstable/forky.h
new file mode 100644
index 0000000..0d27080
--- /dev/null
+++ b/shared/unstable/forky.h
@@ -0,0 +1,11 @@
+/* Copyright (c) 2003 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#ifndef __FORKY_H__
+#define __FORKY_H__
+
+int forky_hasfeeders(t_object *x, t_glist *glist, int inno, t_symbol *outsym);
+t_int forky_getbitmask(int ac, t_atom *av);
+
+#endif
diff --git a/shared/unstable/fragile.c b/shared/unstable/fragile.c
new file mode 100644
index 0000000..3267721
--- /dev/null
+++ b/shared/unstable/fragile.c
@@ -0,0 +1,67 @@
+/* Copyright (c) 1997-2003 Miller Puckette, krzYszcz, and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#include <string.h>
+#include "m_pd.h"
+#include "unstable/pd_imp.h"
+#include "unstable/fragile.h"
+
+int fragile_class_count(void)
+{
+ return (pd_objectmaker->c_nmethod);
+}
+
+void fragile_class_printnames(char *msg, int firstndx, int lastndx)
+{
+ t_methodentry *mp = pd_objectmaker->c_methods;
+ int ndx, len = strlen(msg);
+ startpost(msg);
+ for (ndx = firstndx, mp += ndx; ndx <= lastndx; ndx++, mp++)
+ {
+ t_symbol *s = mp->me_name;
+ if (s && s->s_name[0] != '_')
+ {
+ int l = 1 + strlen(s->s_name);
+ if ((len += l) > 66)
+ {
+ endpost();
+ startpost(" ");
+ len = 3 + l;
+ }
+ poststring(s->s_name);
+ }
+ }
+ endpost();
+}
+
+/* This structure is local to g_array.c. We need it,
+ because there is no other way to get into array's graph. */
+struct _garray
+{
+ t_gobj x_gobj;
+ t_glist *x_glist;
+ /* ... */
+};
+
+t_glist *fragile_garray_glist(void *arr)
+{
+ return (((struct _garray *)arr)->x_glist);
+}
+
+/* This is local to m_obj.c.
+ LATER export write access to o_connections field ('grab' class).
+ LATER encapsulate 'traverseoutlet' routines (not in the stable API yet). */
+struct _outlet
+{
+ t_object *o_owner;
+ struct _outlet *o_next;
+ t_outconnect *o_connections;
+ t_symbol *o_sym;
+};
+
+/* obj_starttraverseoutlet() replacement */
+t_outconnect *fragile_outlet_connections(t_outlet *o)
+{
+ return (o ? o->o_connections : 0);
+}
diff --git a/shared/unstable/fragile.h b/shared/unstable/fragile.h
new file mode 100644
index 0000000..c1ba8e3
--- /dev/null
+++ b/shared/unstable/fragile.h
@@ -0,0 +1,13 @@
+/* Copyright (c) 2003 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#ifndef __FRAGILE_H__
+#define __FRAGILE_H__
+
+int fragile_class_count(void);
+void fragile_class_printnames(char *msg, int firstndx, int lastndx);
+t_glist *fragile_garray_glist(void *arr);
+t_outconnect *fragile_outlet_connections(t_outlet *o);
+
+#endif
diff --git a/shared/unstable/loader.c b/shared/unstable/loader.c
new file mode 100644
index 0000000..91b7ff3
--- /dev/null
+++ b/shared/unstable/loader.c
@@ -0,0 +1,139 @@
+/* Copyright (c) 1997-2003 Miller Puckette, krzYszcz, and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* This is just a not-yet-in-the-API-sys_load_lib() duplication
+ (modulo differentiating the error return codes). LATER use the original. */
+
+#include "loader.h"
+
+#ifdef __linux__
+#include <dlfcn.h>
+#endif
+#ifdef UNIX
+#include <stdlib.h>
+#include <unistd.h>
+#endif
+#ifdef NT
+#include <io.h>
+#include <windows.h>
+#endif
+#ifdef MACOSX
+#include <mach-o/dyld.h>
+#endif
+#include <string.h>
+#include "m_pd.h"
+#include <stdio.h>
+
+typedef void (*t_xxx)(void);
+
+static char sys_dllextent[] =
+#ifdef __FreeBSD__
+ ".pd_freebsd";
+#endif
+#ifdef IRIX
+#ifdef N32
+ ".pd_irix6";
+#else
+ ".pd_irix5";
+#endif
+#endif
+#ifdef __linux__
+ ".pd_linux";
+#endif
+#ifdef MACOSX
+ ".pd_darwin";
+#endif
+#ifdef NT
+ ".dll";
+#endif
+
+int unstable_load_lib(char *dirname, char *classname)
+{
+ char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING],
+ *nameptr, *lastdot;
+ void *dlobj;
+ t_xxx makeout;
+ int fd;
+#ifdef NT
+ HINSTANCE ntdll;
+#endif
+#if 0
+ fprintf(stderr, "lib %s %s\n", dirname, classname);
+#endif
+ if ((fd = open_via_path(dirname, classname, sys_dllextent,
+ dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
+ {
+ return (LOADER_NOFILE);
+ }
+ else
+ {
+ close(fd);
+ /* refabricate the pathname */
+ strcpy(filename, dirbuf);
+ strcat(filename, "/");
+ strcat(filename, nameptr);
+ /* extract the setup function name */
+ if (lastdot = strrchr(nameptr, '.'))
+ *lastdot = 0;
+
+#ifdef MACOSX
+ strcpy(symname, "_");
+ strcat(symname, nameptr);
+#else
+ strcpy(symname, nameptr);
+#endif
+ /* if the last character is a tilde, replace with "_tilde" */
+ if (symname[strlen(symname) - 1] == '~')
+ strcpy(symname + (strlen(symname) - 1), "_tilde");
+ /* and append _setup to form the C setup function name */
+ strcat(symname, "_setup");
+#ifdef __linux__
+ dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
+ if (!dlobj)
+ {
+ post("%s: %s", filename, dlerror());
+ return (LOADER_BADFILE);
+ }
+ makeout = (t_xxx)dlsym(dlobj, symname);
+#endif
+#ifdef NT
+ sys_bashfilename(filename, filename);
+ ntdll = LoadLibrary(filename);
+ if (!ntdll)
+ {
+ post("%s: couldn't load", filename);
+ return (LOADER_BADFILE);
+ }
+ makeout = (t_xxx)GetProcAddress(ntdll, symname);
+#endif
+#ifdef MACOSX
+ {
+ NSObjectFileImage image;
+ void *ret;
+ NSSymbol s;
+ if ( NSCreateObjectFileImageFromFile( filename, &image) != NSObjectFileImageSuccess )
+ {
+ post("%s: couldn't load", filename);
+ return (LOADER_BADFILE);
+ }
+ ret = NSLinkModule( image, filename,
+ NSLINKMODULE_OPTION_BINDNOW
+ + NSLINKMODULE_OPTION_PRIVATE);
+
+ s = NSLookupSymbolInModule(ret, symname);
+
+ if (s)
+ makeout = (t_xxx)NSAddressOfSymbol( s);
+ else makeout = 0;
+ }
+#endif
+ }
+ if (!makeout)
+ {
+ post("load_object: Symbol \"%s\" not found", symname);
+ return (LOADER_NOENTRY);
+ }
+ (*makeout)();
+ return (LOADER_OK);
+}
diff --git a/shared/unstable/loader.h b/shared/unstable/loader.h
new file mode 100644
index 0000000..e9766ac
--- /dev/null
+++ b/shared/unstable/loader.h
@@ -0,0 +1,12 @@
+/* Copyright (c) 2003 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#ifndef __LOADER_H__
+#define __LOADER_H__
+
+enum { LOADER_OK, LOADER_NOFILE, LOADER_BADFILE, LOADER_NOENTRY };
+
+int unstable_load_lib(char *dirname, char *classname);
+
+#endif
diff --git a/shared/unstable/pd_imp.h b/shared/unstable/pd_imp.h
new file mode 100644
index 0000000..bf659ed
--- /dev/null
+++ b/shared/unstable/pd_imp.h
@@ -0,0 +1,60 @@
+/* Copyright (c) 1997-2003 Miller Puckette and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#ifndef __PD_IMP_H__
+#define __PD_IMP_H__
+
+#ifdef PD_MINOR_VERSION
+#include "m_imp.h"
+#else
+
+typedef struct _methodentry
+{
+ t_symbol *me_name;
+ t_gotfn me_fun;
+ t_atomtype me_arg[MAXPDARG+1];
+} t_methodentry;
+
+EXTERN_STRUCT _widgetbehavior;
+
+typedef void (*t_bangmethod)(t_pd *x);
+typedef void (*t_pointermethod)(t_pd *x, t_gpointer *gp);
+typedef void (*t_floatmethod)(t_pd *x, t_float f);
+typedef void (*t_symbolmethod)(t_pd *x, t_symbol *s);
+typedef void (*t_listmethod)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+typedef void (*t_anymethod)(t_pd *x, t_symbol *s, int argc, t_atom *argv);
+
+struct _class
+{
+ t_symbol *c_name; /* name (mostly for error reporting) */
+ t_symbol *c_helpname; /* name of help file */
+ size_t c_size; /* size of an instance */
+ t_methodentry *c_methods; /* methods other than bang, etc below */
+ int c_nmethod; /* number of methods */
+ t_method c_freemethod; /* function to call before freeing */
+ t_bangmethod c_bangmethod; /* common methods */
+ t_pointermethod c_pointermethod;
+ t_floatmethod c_floatmethod;
+ t_symbolmethod c_symbolmethod;
+ t_listmethod c_listmethod;
+ t_anymethod c_anymethod;
+ struct _widgetbehavior *c_wb; /* "gobjs" only */
+ struct _parentwidgetbehavior *c_pwb;/* widget behavior in parent */
+ int c_floatsignalin; /* onset to float for signal input */
+ char c_gobj; /* true if is a gobj */
+ char c_patchable; /* true if we have a t_object header */
+ char c_firstin; /* if patchable, true if draw first inlet */
+ char c_drawcommand; /* a drawing command for a template */
+};
+
+EXTERN int obj_noutlets(t_object *x);
+EXTERN int obj_ninlets(t_object *x);
+EXTERN t_outconnect *obj_starttraverseoutlet(t_object *x, t_outlet **op,
+ int nout);
+EXTERN t_outconnect *obj_nexttraverseoutlet(t_outconnect *lastconnect,
+ t_object **destp, t_inlet **inletp, int *whichp);
+
+#endif
+
+#endif