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_blob) /* MP 20070106 blob type */ { post("class_addmethod: %p", fn); if (argtype != A_BLOB || va_arg(ap, t_atomtype)) goto phooey; class_addblob(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 { /* Pd-extended doesn't use the aliasing automagic int i; for (i = 0; i < c->c_nmethod; i++) if (c->c_methods[i].me_name == sel) { char nbuf[80]; snprintf(nbuf, 80, "%s_aliased", sel->s_name); c->c_methods[i].me_name = gensym(nbuf); if (c == pd_objectmaker) post("warning: class '%s' overwritten; old one renamed '%s'", sel->s_name, nbuf); else post("warning: old method '%s' for class '%s' renamed '%s'", sel->s_name, c->c_name->s_name, nbuf); } */ 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); }
void GEMglReportError :: obj_setupCallback(t_class *classPtr) { class_addanything(classPtr, GEMglReportError::bangMessCallback); };
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, i; 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 { t_atomtype argvec[MAXPDARG+1]; nargs = 0; while (argtype != A_NULL && nargs < MAXPDARG) { argvec[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); argvec[nargs] = 0; #ifdef PDINSTANCE for (i = 0; i < pd_ninstances; i++) { class_addmethodtolist(c, &c->c_methods[i], c->c_nmethod, (t_gotfn)fn, dogensym(sel->s_name, 0, pd_instances[i]), argvec, pd_instances[i]); } #else class_addmethodtolist(c, &c->c_methods, c->c_nmethod, (t_gotfn)fn, sel, argvec, &pd_maininstance); #endif c->c_nmethod++; } goto done; phooey: bug("class_addmethod: %s_%s: bad argument types\n", c->c_name->s_name, sel->s_name); done: va_end(ap); return; }
void h_deque_setup(void) { // the object class h_deque_class = class_new(gensym("h_deque"), (t_newmethod)h_deque_new, (t_method)h_deque_free, sizeof(t_h_deque), CLASS_DEFAULT, A_GIMME, 0); // a class for the proxy-inlet proxy_class = class_new(gensym("h_deque_proxy"), NULL, NULL, sizeof(t_proxy), CLASS_PD|CLASS_NOINLET, A_NULL); class_addmethod(h_deque_class, (t_method)h_deque_set, gensym("set"), A_GIMME, 0); class_addmethod(h_deque_class, (t_method)h_deque_insert, gensym("insert"), A_GIMME, 0); class_addanything(proxy_class, (t_method)h_deque_value); // the right inlet class_addmethod(h_deque_class, (t_method)h_deque_get, gensym("get"), A_GIMME, 0); class_addmethod(h_deque_class, (t_method)h_deque_push_back, gensym("pushback"), A_GIMME, 0); class_addmethod(h_deque_class, (t_method)h_deque_pop_back, gensym("popback"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_back, gensym("back"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_push_front, gensym("pushfront"), A_GIMME, 0); class_addmethod(h_deque_class, (t_method)h_deque_pop_front, gensym("popfront"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_front, gensym("front"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_remove, gensym("remove"), A_GIMME, 0); class_addmethod(h_deque_class, (t_method)h_deque_resize, gensym("resize"), A_GIMME , 0); class_addmethod(h_deque_class, (t_method)h_deque_getsize, gensym("getsize"), A_DEFFLOAT , 0); class_addmethod(h_deque_class, (t_method)h_deque_set_namespace, gensym("namespace"), A_DEFSYMBOL , 0); class_addmethod(h_deque_class, (t_method)h_deque_get_namespace, gensym("getnamespace"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_getall, gensym("getall"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_print, gensym("print"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_clear, gensym("clear"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_clear_all, gensym("clearall"), A_DEFFLOAT, 0); class_addmethod(h_deque_class, (t_method)h_deque_save, gensym("save"), A_DEFSYMBOL, 0); class_addmethod(h_deque_class, (t_method)h_deque_read, gensym("read"), A_DEFSYMBOL, 0); class_addmethod(h_deque_class, (t_method)h_deque_read_at, gensym("readat"), A_GIMME, 0); class_addmethod(h_deque_class, (t_method)h_deque_save_xml, gensym("saveXML"), A_DEFSYMBOL , 0); class_addmethod(h_deque_class, (t_method)h_deque_read_xml, gensym("readXML"), A_DEFSYMBOL , 0); class_addmethod(h_deque_class, (t_method)h_deque_read_at_xml, gensym("readatXML"), A_GIMME, 0); // without an argument the following two methods wont work ??? why?? because of c++? class_addmethod(h_deque_class, (t_method)h_deque_help, gensym("help"),A_DEFFLOAT, 0); }
void sendcanvas_setup(void) { sendcanvas_class = class_new(gensym("sendcanvas"), (t_newmethod)sendcanvas_new, (t_method)sendcanvas_free, sizeof(t_sendcanvas), 0, A_DEFFLOAT, 0); class_addanything(sendcanvas_class, (t_method)sendcanvas_anything); }
///////////////////////////////////////////////////////// // static member function // ///////////////////////////////////////////////////////// void polygon :: obj_setupCallback(t_class *classPtr) { class_addlist(classPtr, reinterpret_cast<t_method>(&polygon::listCallback)); class_addmethod(classPtr, reinterpret_cast<t_method>(&polygon::vertexCallback), gensym("vertex"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); class_addanything(classPtr, reinterpret_cast<t_method>(&polygon::vertCallback)); }
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); }
/* adapted m_pd_setup() from m_pd.c */ static void dict_bindlist_setup(t_dict *x) { x->d_bindlist_class = class_new(dict_key(x, "bindlist"), 0, 0, sizeof(t_dict_bindlist), CLASS_PD, 0); class_addanything(x->d_bindlist_class, dict_bindlist_anything); }
void glob_init(void) { maxclass = class_new(gensym("max"), 0, 0, sizeof(t_pd), CLASS_DEFAULT, A_NULL); class_addanything(maxclass, max_default); pd_bind(&maxclass, gensym("max")); glob_pdobject = class_new(gensym("pd"), 0, 0, sizeof(t_pd), CLASS_DEFAULT, A_NULL); class_addmethod(glob_pdobject, (t_method)glob_initfromgui, gensym("init"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_setfilename, gensym("filename"), A_SYMBOL, A_SYMBOL, 0); class_addmethod(glob_pdobject, (t_method)glob_evalfile, gensym("open"), A_SYMBOL, A_SYMBOL, 0); class_addmethod(glob_pdobject, (t_method)glob_quit, gensym("quit"), 0); class_addmethod(glob_pdobject, (t_method)glob_verifyquit, gensym("verifyquit"), A_DEFFLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_foo, gensym("foo"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_dsp, gensym("dsp"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_meters, gensym("meters"), A_FLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_key, gensym("key"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_audiostatus, gensym("audiostatus"), 0); class_addmethod(glob_pdobject, (t_method)glob_finderror, gensym("finderror"), 0); class_addmethod(glob_pdobject, (t_method)glob_audio_properties, gensym("audio-properties"), A_DEFFLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_audio_dialog, gensym("audio-dialog"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_audio_setapi, gensym("audio-setapi"), A_FLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_midi_setapi, gensym("midi-setapi"), A_FLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_midi_properties, gensym("midi-properties"), A_DEFFLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_midi_dialog, gensym("midi-dialog"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_start_path_dialog, gensym("start-path-dialog"), 0); class_addmethod(glob_pdobject, (t_method)glob_path_dialog, gensym("path-dialog"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_start_startup_dialog, gensym("start-startup-dialog"), 0); class_addmethod(glob_pdobject, (t_method)glob_startup_dialog, gensym("startup-dialog"), A_GIMME, 0); class_addmethod(glob_pdobject, (t_method)glob_ping, gensym("ping"), 0); class_addmethod(glob_pdobject, (t_method)glob_savepreferences, gensym("save-preferences"), 0); class_addmethod(glob_pdobject, (t_method)glob_version, gensym("version"), A_FLOAT, 0); class_addmethod(glob_pdobject, (t_method)glob_perf, gensym("perf"), A_FLOAT, 0); #ifdef UNIX class_addmethod(glob_pdobject, (t_method)glob_watchdog, gensym("watchdog"), 0); #endif class_addanything(glob_pdobject, max_default); pd_bind(&glob_pdobject, gensym("pd")); }