/* Copyright (c) 1997-1999 Miller Puckette. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ #if 0 //#ifdef ROCKBOX #include "plugin.h" #include "../../pdbox.h" #endif #define PD_CLASS_DEF #include "m_pd.h" #include "m_imp.h" #include "s_stuff.h" #ifdef ROCKBOX #include "plugin.h" #include "../../pdbox.h" #else /* ROCKBOX */ #include #ifdef UNIX #include #endif #ifdef MSW #include #endif #include #include #endif /* ROCKBOX */ static t_symbol *class_loadsym; /* name under which an extern is invoked */ static void pd_defaultfloat(t_pd *x, t_float f); static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv); t_pd pd_objectmaker; /* factory for creating "object" boxes */ t_pd pd_canvasmaker; /* factory for creating canvases */ static t_symbol *class_extern_dir = &s_; static void pd_defaultanything(t_pd *x, t_symbol *s, int argc, t_atom *argv) { #ifdef ROCKBOX (void) argc; (void) argv; #endif pd_error(x, "%s: no method for '%s'", (*x)->c_name->s_name, s->s_name); } static void pd_defaultbang(t_pd *x) { if (*(*x)->c_listmethod != pd_defaultlist) (*(*x)->c_listmethod)(x, 0, 0, 0); else (*(*x)->c_anymethod)(x, &s_bang, 0, 0); } static void pd_defaultpointer(t_pd *x, t_gpointer *gp) { if (*(*x)->c_listmethod != pd_defaultlist) { t_atom at; SETPOINTER(&at, gp); (*(*x)->c_listmethod)(x, 0, 1, &at); } else { t_atom at; SETPOINTER(&at, gp); (*(*x)->c_anymethod)(x, &s_pointer, 1, &at); } } static void pd_defaultfloat(t_pd *x, t_float f) { if (*(*x)->c_listmethod != pd_defaultlist) { t_atom at; SETFLOAT(&at, f); (*(*x)->c_listmethod)(x, 0, 1, &at); } else { t_atom at; SETFLOAT(&at, f); (*(*x)->c_anymethod)(x, &s_float, 1, &at); } } static void pd_defaultsymbol(t_pd *x, t_symbol *s) { if (*(*x)->c_listmethod != pd_defaultlist) { t_atom at; SETSYMBOL(&at, s); (*(*x)->c_listmethod)(x, 0, 1, &at); } else { t_atom at; SETSYMBOL(&at, s); (*(*x)->c_anymethod)(x, &s_symbol, 1, &at); } } void obj_list(t_object *x, t_symbol *s, int argc, t_atom *argv); static void class_nosavefn(t_gobj *z, t_binbuf *b); /* handle "list" messages to Pds without explicit list methods defined. */ static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv) { /* a list with one element which is a number can be handled by a "float" method if any is defined; same for "symbol", "pointer". */ if (argc == 1) { if (argv->a_type == A_FLOAT && *(*x)->c_floatmethod != pd_defaultfloat) { (*(*x)->c_floatmethod)(x, argv->a_w.w_float); return; } else if (argv->a_type == A_SYMBOL && *(*x)->c_symbolmethod != pd_defaultsymbol) { (*(*x)->c_symbolmethod)(x, argv->a_w.w_symbol); return; } else if (argv->a_type == A_POINTER && *(*x)->c_pointermethod != pd_defaultpointer) { (*(*x)->c_pointermethod)(x, argv->a_w.w_gpointer); return; } } /* Next try for an "anything" method */ if ((*x)->c_anymethod != pd_defaultanything) (*(*x)->c_anymethod)(x, &s_list, argc, argv); /* if the object is patchable (i.e., can have proper inlets) send it on to obj_list which will unpack the list into the inlets */ else if ((*x)->c_patchable) obj_list((t_object *)x, s, argc, argv); /* otherwise gove up and complain. */ else pd_defaultanything(x, &s_list, argc, argv); } /* for now we assume that all "gobjs" are text unless explicitly overridden later by calling class_setbehavior(). I'm not sure how to deal with Pds that aren't gobjs; shouldn't there be a way to check that at run time? Perhaps the presence of a "newmethod" should be our cue, or perhaps the "tiny" flag. */ /* another matter. This routine does two unrelated things: it creates a Pd class, but also adds a "new" method to create an instance of it. These are combined for historical reasons and for brevity in writing objects. To avoid adding a "new" method send a null function pointer. To add additional ones, use class_addcreator below. Some "classes", like "select", are actually two classes of the same name, one for the single- argument form, one for the multiple one; see select_setup() to find out how this is handled. */ extern t_widgetbehavior text_widgetbehavior; extern void text_save(t_gobj *z, t_binbuf *b); t_class *class_new(t_symbol *s, t_newmethod newmethod, t_method freemethod, size_t size, int flags, t_atomtype type1, ...) { va_list ap; t_atomtype vec[MAXPDARG+1], *vp = vec; int count = 0; t_class *c; int typeflag = flags & CLASS_TYPEMASK; if (!typeflag) typeflag = CLASS_PATCHABLE; *vp = type1; va_start(ap, type1); while (*vp) { if (count == MAXPDARG) { error("class %s: sorry: only %d creation args allowed", s->s_name, MAXPDARG); break; } vp++; count++; *vp = va_arg(ap, t_atomtype); } va_end(ap); if (pd_objectmaker && newmethod) { /* add a "new" method by the name specified by the object */ class_addmethod(pd_objectmaker, (t_method)newmethod, s, vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); if (class_loadsym) { /* if we're loading an extern it might have been invoked by a longer file name; in this case, make this an admissible name too. */ char *loadstring = class_loadsym->s_name, l1 = strlen(s->s_name), l2 = strlen(loadstring); if (l2 > l1 && !strcmp(s->s_name, loadstring + (l2 - l1))) class_addmethod(pd_objectmaker, (t_method)newmethod, class_loadsym, vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); } } c = (t_class *)t_getbytes(sizeof(*c)); c->c_name = c->c_helpname = s; c->c_size = size; c->c_methods = t_getbytes(0); c->c_nmethod = 0; c->c_freemethod = (t_method)freemethod; c->c_bangmethod = pd_defaultbang; c->c_pointermethod = pd_defaultpointer; c->c_floatmethod = pd_defaultfloat; c->c_symbolmethod = pd_defaultsymbol; c->c_listmethod = pd_defaultlist; c->c_anymethod = pd_defaultanything; c->c_wb = (typeflag == CLASS_PATCHABLE ? &text_widgetbehavior : 0); c->c_pwb = 0; c->c_firstin = ((flags & CLASS_NOINLET) == 0); c->c_patchable = (typeflag == CLASS_PATCHABLE); c->c_gobj = (typeflag >= CLASS_GOBJ); c->c_drawcommand = 0; c->c_floatsignalin = 0; c->c_externdir = class_extern_dir; c->c_savefn = (typeflag == CLASS_PATCHABLE ? text_save : class_nosavefn); #if 0 post("class: %s", c->c_name->s_name); #endif return (c); } /* add a creation method, which is a function that returns a Pd object suitable for putting in an object box. We presume you've got a class it can belong to, but this won't be used until the newmethod is actually called back (and the new method explicitly takes care of this.) */ void class_addcreator(t_newmethod newmethod, t_symbol *s, t_atomtype type1, ...) { va_list ap; t_atomtype vec[MAXPDARG+1], *vp = vec; int count = 0; *vp = type1; va_start(ap, type1); while (*vp) { if (count == MAXPDARG) { error("class %s: sorry: only %d creation args allowed", s->s_name, MAXPDARG); break; } vp++; count++; *vp = va_arg(ap, t_atomtype); } va_end(ap); class_addmethod(pd_objectmaker, (t_method)newmethod, s, vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); } void class_addmethod(t_class *c, t_method fn, t_symbol *sel, t_atomtype arg1, ...) { va_list ap; t_methodentry *m; t_atomtype argtype = arg1; int nargs; va_start(ap, arg1); /* "signal" method specifies that we take audio signals but that we don't want automatic float to signal conversion. This is obsolete; you should now use the CLASS_MAINSIGNALIN macro. */ if (sel == &s_signal) { if (c->c_floatsignalin) post("warning: signal method overrides class_mainsignalin"); c->c_floatsignalin = -1; } /* check for special cases. "Pointer" is missing here so that pd_objectmaker's pointer method can be typechecked differently. */ if (sel == &s_bang) { if (argtype) goto phooey; class_addbang(c, fn); } else if (sel == &s_float) { if (argtype != A_FLOAT || va_arg(ap, t_atomtype)) goto phooey; class_doaddfloat(c, fn); } else if (sel == &s_symbol) { if (argtype != A_SYMBOL || va_arg(ap, t_atomtype)) goto phooey; class_addsymbol(c, fn); } else if (sel == &s_list) { if (argtype != A_GIMME) goto phooey; class_addlist(c, fn); } else if (sel == &s_anything) { if (argtype != A_GIMME) goto phooey; class_addanything(c, fn); } else { c->c_methods = t_resizebytes(c->c_methods, c->c_nmethod * sizeof(*c->c_methods), (c->c_nmethod + 1) * sizeof(*c->c_methods)); m = c->c_methods + c->c_nmethod; c->c_nmethod++; m->me_name = sel; m->me_fun = (t_gotfn)fn; nargs = 0; while (argtype != A_NULL && nargs < MAXPDARG) { m->me_arg[nargs++] = argtype; argtype = va_arg(ap, t_atomtype); } if (argtype != A_NULL) error("%s_%s: only 5 arguments are typecheckable; use A_GIMME", c->c_name->s_name, sel->s_name); va_end(ap); m->me_arg[nargs] = A_NULL; } return; phooey: bug("class_addmethod: %s_%s: bad argument types\n", c->c_name->s_name, sel->s_name); } /* Instead of these, see the "class_addfloat", etc., macros in m_pd.h */ void class_addbang(t_class *c, t_method fn) { c->c_bangmethod = (t_bangmethod)fn; } void class_addpointer(t_class *c, t_method fn) { c->c_pointermethod = (t_pointermethod)fn; } void class_doaddfloat(t_class *c, t_method fn) { c->c_floatmethod = (t_floatmethod)fn; } void class_addsymbol(t_class *c, t_method fn) { c->c_symbolmethod = (t_symbolmethod)fn; } void class_addlist(t_class *c, t_method fn) { c->c_listmethod = (t_listmethod)fn; } void class_addanything(t_class *c, t_method fn) { c->c_anymethod = (t_anymethod)fn; } void class_setwidget(t_class *c, t_widgetbehavior *w) { c->c_wb = w; } void class_setparentwidget(t_class *c, t_parentwidgetbehavior *pw) { c->c_pwb = pw; } char *class_getname(t_class *c) { return (c->c_name->s_name); } char *class_gethelpname(t_class *c) { return (c->c_helpname->s_name); } void class_sethelpsymbol(t_class *c, t_symbol *s) { c->c_helpname = s; } t_parentwidgetbehavior *pd_getparentwidget(t_pd *x) { return ((*x)->c_pwb); } void class_setdrawcommand(t_class *c) { c->c_drawcommand = 1; } int class_isdrawcommand(t_class *c) { return (c->c_drawcommand); } static void pd_floatforsignal(t_pd *x, t_float f) { int offset = (*x)->c_floatsignalin; if (offset > 0) *(t_sample *)(((char *)x) + offset) = ftofix(f); else pd_error(x, "%s: float unexpected for signal input", (*x)->c_name->s_name); } void class_domainsignalin(t_class *c, int onset) { if (onset <= 0) onset = -1; else { if (c->c_floatmethod != pd_defaultfloat) post("warning: %s: float method overwritten", c->c_name->s_name); c->c_floatmethod = (t_floatmethod)pd_floatforsignal; } c->c_floatsignalin = onset; } void class_set_extern_dir(t_symbol *s) { class_extern_dir = s; } char *class_gethelpdir(t_class *c) { return (c->c_externdir->s_name); } static void class_nosavefn(t_gobj *z, t_binbuf *b) { #ifdef ROCKBOX (void) z; (void) b; #endif bug("save function called but not defined"); } void class_setsavefn(t_class *c, t_savefn f) { c->c_savefn = f; } t_savefn class_getsavefn(t_class *c) { return (c->c_savefn); } void class_setpropertiesfn(t_class *c, t_propertiesfn f) { c->c_propertiesfn = f; } t_propertiesfn class_getpropertiesfn(t_class *c) { return (c->c_propertiesfn); } /* ---------------- the symbol table ------------------------ */ #define HASHSIZE 1024 static t_symbol *symhash[HASHSIZE]; t_symbol *dogensym(char *s, t_symbol *oldsym) { t_symbol **sym1, *sym2; unsigned int hash1 = 0, hash2 = 0; int length = 0; char *s2 = s; while (*s2) { hash1 += *s2; hash2 += hash1; length++; s2++; } sym1 = symhash + (hash2 & (HASHSIZE-1)); while ((sym2 = *sym1)) { if (!strcmp(sym2->s_name, s)) return(sym2); sym1 = &sym2->s_next; } if (oldsym) sym2 = oldsym; else { sym2 = (t_symbol *)t_getbytes(sizeof(*sym2)); sym2->s_name = t_getbytes(length+1); sym2->s_next = 0; sym2->s_thing = 0; strcpy(sym2->s_name, s); } *sym1 = sym2; return (sym2); } t_symbol *gensym(char *s) { // printf("gensym: %s\n", s); #ifdef ROCKBOX if(s == NULL) return dogensym("/", 0); else #endif return(dogensym(s, 0)); } #ifndef ROCKBOX static #endif t_symbol *addfileextent(t_symbol *s) { char namebuf[MAXPDSTRING], *str = s->s_name; int ln = strlen(str); if (!strcmp(str + ln - 3, ".pd")) return (s); strcpy(namebuf, str); strcpy(namebuf+ln, ".pd"); return (gensym(namebuf)); } static int tryingalready; void canvas_popabstraction(t_canvas *x); extern t_pd *newest; t_symbol* pathsearch(t_symbol *s,char* ext); int pd_setloadingabstraction(t_symbol *sym); /* this routine is called when a new "object" is requested whose class Pd doesn't know. Pd tries to load it as an extern, then as an abstraction. */ void new_anything(void *dummy, t_symbol *s, int argc, t_atom *argv) { t_pd *current; t_symbol *dir = canvas_getcurrentdir(); int fd; char dirbuf[MAXPDSTRING], *nameptr; if (tryingalready) return; newest = 0; class_loadsym = s; if (sys_load_lib(dir->s_name, s->s_name)) { tryingalready = 1; typedmess(dummy, s, argc, argv); tryingalready = 0; return; } class_loadsym = 0; current = s__X.s_thing; if ((fd = open_via_path(dir->s_name, s->s_name, ".pd", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 || (fd = open_via_path(dir->s_name, s->s_name, ".pat", dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0) { close (fd); if (!pd_setloadingabstraction(s)) { canvas_setargs(argc, argv); /* bug fix by Krzysztof Czaja */ binbuf_evalfile(gensym(nameptr), gensym(dirbuf)); if (s__X.s_thing != current) canvas_popabstraction((t_canvas *)(s__X.s_thing)); canvas_setargs(0, 0); } else error("%s: can't load abstraction within itself\n", s->s_name); } else newest = 0; } t_symbol s_pointer = {"pointer", 0, 0}; t_symbol s_float = {"float", 0, 0}; t_symbol s_symbol = {"symbol", 0, 0}; t_symbol s_bang = {"bang", 0, 0}; t_symbol s_list = {"list", 0, 0}; t_symbol s_anything = {"anything", 0, 0}; t_symbol s_signal = {"signal", 0, 0}; t_symbol s__N = {"#N", 0, 0}; t_symbol s__X = {"#X", 0, 0}; t_symbol s_x = {"x", 0, 0}; t_symbol s_y = {"y", 0, 0}; t_symbol s_ = {"", 0, 0}; static t_symbol *symlist[] = { &s_pointer, &s_float, &s_symbol, &s_bang, &s_list, &s_anything, &s_signal, &s__N, &s__X, &s_x, &s_y, &s_}; void mess_init(void) { t_symbol **sp; int i; if (pd_objectmaker) return; for (i = sizeof(symlist)/sizeof(*symlist), sp = symlist; i--; sp++) (void) dogensym((*sp)->s_name, *sp); pd_objectmaker = class_new(gensym("objectmaker"), 0, 0, sizeof(t_pd), CLASS_DEFAULT, A_NULL); pd_canvasmaker = class_new(gensym("classmaker"), 0, 0, sizeof(t_pd), CLASS_DEFAULT, A_NULL); pd_bind(&pd_canvasmaker, &s__N); class_addanything(pd_objectmaker, (t_method)new_anything); } t_pd *newest; /* This is externally available, but note that it might later disappear; the whole "newest" thing is a hack which needs to be redesigned. */ t_pd *pd_newest(void) { return (newest); } /* horribly, we need prototypes for each of the artificial function calls in typedmess(), to keep the compiler quiet. */ typedef t_pd *(*t_newgimme)(t_symbol *s, int argc, t_atom *argv); typedef void(*t_messgimme)(t_pd *x, t_symbol *s, int argc, t_atom *argv); typedef t_pd *(*t_fun0)( t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); typedef t_pd *(*t_fun1)(t_int i1, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); typedef t_pd *(*t_fun2)(t_int i1, t_int i2, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); typedef t_pd *(*t_fun3)(t_int i1, t_int i2, t_int i3, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); typedef t_pd *(*t_fun4)(t_int i1, t_int i2, t_int i3, t_int i4, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); typedef t_pd *(*t_fun5)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); typedef t_pd *(*t_fun6)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_int i6, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv) { #ifndef ROCKBOX t_method *f; #endif t_class *c = *x; t_methodentry *m; t_atomtype *wp, wanttype; int i; t_int ai[MAXPDARG+1], *ap = ai; t_floatarg ad[MAXPDARG+1], *dp = ad; int narg = 0; t_pd *bonzo; /* check for messages that are handled by fixed slots in the class structure. We don't catch "pointer" though so that sending "pointer" to pd_objectmaker doesn't require that we supply a pointer value. */ if (s == &s_float) { if (!argc) (*c->c_floatmethod)(x, 0.); else if (argv->a_type == A_FLOAT) (*c->c_floatmethod)(x, argv->a_w.w_float); else goto badarg; return; } if (s == &s_bang) { (*c->c_bangmethod)(x); return; } if (s == &s_list) { (*c->c_listmethod)(x, s, argc, argv); return; } if (s == &s_symbol) { if (argc && argv->a_type == A_SYMBOL) (*c->c_symbolmethod)(x, argv->a_w.w_symbol); else (*c->c_symbolmethod)(x, &s_); return; } for (i = c->c_nmethod, m = c->c_methods; i--; m++) if (m->me_name == s) { wp = m->me_arg; if (*wp == A_GIMME) { if (x == &pd_objectmaker) newest = (*((t_newgimme)(m->me_fun)))(s, argc, argv); else (*((t_messgimme)(m->me_fun)))(x, s, argc, argv); return; } if (argc > MAXPDARG) argc = MAXPDARG; if (x != &pd_objectmaker) *(ap++) = (t_int)x, narg++; while((wanttype = *wp++)) { switch (wanttype) { case A_POINTER: if (!argc) goto badarg; else { if (argv->a_type == A_POINTER) *ap = (t_int)(argv->a_w.w_gpointer); else goto badarg; argc--; argv++; } narg++; ap++; break; case A_FLOAT: if (!argc) goto badarg; case A_DEFFLOAT: if (!argc) *dp = 0; else { if (argv->a_type == A_FLOAT) *dp = argv->a_w.w_float; else goto badarg; argc--; argv++; } dp++; break; case A_SYMBOL: if (!argc) goto badarg; case A_DEFSYM: if (!argc) *ap = (t_int)(&s_); else { if (argv->a_type == A_SYMBOL) *ap = (t_int)(argv->a_w.w_symbol); /* if it's an unfilled "dollar" argument it appears as zero here; cheat and bash it to the null symbol. Unfortunately, this lets real zeros pass as symbols too, which seems wrong... */ else if (x == &pd_objectmaker && argv->a_type == A_FLOAT && argv->a_w.w_float == 0) *ap = (t_int)(&s_); else goto badarg; argc--; argv++; } narg++; ap++; #ifdef ROCKBOX break; default: break; #endif } } switch (narg) { case 0 : bonzo = (*(t_fun0)(m->me_fun)) (ad[0], ad[1], ad[2], ad[3], ad[4]); break; case 1 : bonzo = (*(t_fun1)(m->me_fun)) (ai[0], ad[0], ad[1], ad[2], ad[3], ad[4]); break; case 2 : bonzo = (*(t_fun2)(m->me_fun)) (ai[0], ai[1], ad[0], ad[1], ad[2], ad[3], ad[4]); break; case 3 : bonzo = (*(t_fun3)(m->me_fun)) (ai[0], ai[1], ai[2], ad[0], ad[1], ad[2], ad[3], ad[4]); break; case 4 : bonzo = (*(t_fun4)(m->me_fun)) (ai[0], ai[1], ai[2], ai[3], ad[0], ad[1], ad[2], ad[3], ad[4]); break; case 5 : bonzo = (*(t_fun5)(m->me_fun)) (ai[0], ai[1], ai[2], ai[3], ai[4], ad[0], ad[1], ad[2], ad[3], ad[4]); break; case 6 : bonzo = (*(t_fun6)(m->me_fun)) (ai[0], ai[1], ai[2], ai[3], ai[4], ai[5], ad[0], ad[1], ad[2], ad[3], ad[4]); break; default: bonzo = 0; } if (x == &pd_objectmaker) newest = bonzo; return; } (*c->c_anymethod)(x, s, argc, argv); return; badarg: pd_error(x, "Bad arguments for message '%s' to object '%s'", s->s_name, c->c_name->s_name); } void pd_vmess(t_pd *x, t_symbol *sel, char *fmt, ...) { va_list ap; t_atom arg[MAXPDARG], *at =arg; int nargs = 0; char *fp = fmt; va_start(ap, fmt); while (1) { if (nargs > MAXPDARG) { pd_error(x, "pd_vmess: only %d allowed", MAXPDARG); break; } switch(*fp++) { case 'f': SETFLOAT(at, va_arg(ap, double)); break; case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break; case 'i': SETFLOAT(at, va_arg(ap, t_int)); break; case 'p': SETPOINTER(at, va_arg(ap, t_gpointer *)); break; default: goto done; } at++; nargs++; } done: va_end(ap); typedmess(x, sel, nargs, arg); } void pd_forwardmess(t_pd *x, int argc, t_atom *argv) { if (argc) { t_atomtype t = argv->a_type; if (t == A_SYMBOL) pd_typedmess(x, argv->a_w.w_symbol, argc-1, argv+1); else if (t == A_POINTER) { if (argc == 1) pd_pointer(x, argv->a_w.w_gpointer); else pd_list(x, &s_list, argc, argv); } else if (t == A_FLOAT) { if (argc == 1) pd_float(x, argv->a_w.w_float); else pd_list(x, &s_list, argc, argv); } else bug("pd_forwardmess"); } } void nullfn(void) {} t_gotfn getfn(t_pd *x, t_symbol *s) { t_class *c = *x; t_methodentry *m; int i; for (i = c->c_nmethod, m = c->c_methods; i--; m++) if (m->me_name == s) return(m->me_fun); pd_error(x, "%s: no method for message '%s'", c->c_name->s_name, s->s_name); return((t_gotfn)nullfn); } t_gotfn zgetfn(t_pd *x, t_symbol *s) { t_class *c = *x; t_methodentry *m; int i; for (i = c->c_nmethod, m = c->c_methods; i--; m++) if (m->me_name == s) return(m->me_fun); return(0); } '>588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685