From faada59567f8cb252f4a909116595ce309ff5828 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Fri, 23 May 2003 12:29:55 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r647, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/miXed/; revision=648 --- shared/unstable/Makefile | 4 ++ shared/unstable/Makefile.objects | 0 shared/unstable/Makefile.sources | 4 ++ shared/unstable/forky.c | 56 ++++++++++++++++ shared/unstable/forky.h | 11 ++++ shared/unstable/fragile.c | 67 +++++++++++++++++++ shared/unstable/fragile.h | 13 ++++ shared/unstable/loader.c | 139 +++++++++++++++++++++++++++++++++++++++ shared/unstable/loader.h | 12 ++++ shared/unstable/pd_imp.h | 60 +++++++++++++++++ 10 files changed, 366 insertions(+) create mode 100644 shared/unstable/Makefile create mode 100644 shared/unstable/Makefile.objects create mode 100644 shared/unstable/Makefile.sources create mode 100644 shared/unstable/forky.c create mode 100644 shared/unstable/forky.h create mode 100644 shared/unstable/fragile.c create mode 100644 shared/unstable/fragile.h create mode 100644 shared/unstable/loader.c create mode 100644 shared/unstable/loader.h create mode 100644 shared/unstable/pd_imp.h (limited to 'shared/unstable') 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 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 +#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 +#endif +#ifdef UNIX +#include +#include +#endif +#ifdef NT +#include +#include +#endif +#ifdef MACOSX +#include +#endif +#include +#include "m_pd.h" +#include + +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 -- cgit v1.2.1