Ejemplo n.º 1
0
    /* 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;
    int fd;
    char dirbuf[MAXPDSTRING], classslashclass[MAXPDSTRING], *nameptr;
    if (tryingalready>MAXOBJDEPTH){
      error("maximum object loading depth %d reached", MAXOBJDEPTH);
      return;
    }
    newest = 0;
    class_loadsym = s;
    if (sys_load_lib(canvas_getcurrent(), s->s_name))
    {
        tryingalready++;
        typedmess(dummy, s, argc, argv);
        tryingalready--;
        return;
    }
    class_loadsym = 0;
    current = s__X.s_thing;
    /* for class/class.pd support, to match class/class.pd_linux  */
    snprintf(classslashclass, MAXPDSTRING, "%s/%s", s->s_name, s->s_name);
    if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd",
        dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
            (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat",
                dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
               (fd = canvas_open(canvas_getcurrent(), classslashclass, ".pd",
                    dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0)
    {
        close (fd);
        if (!pd_setloadingabstraction(s))
        {
            canvas_setargs(argc, argv);
            binbuf_evalfile(gensym(nameptr), gensym(dirbuf));
            canvas_initbang((t_canvas *)(s__X.s_thing));/* JMZ*/
            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;
}
Ejemplo n.º 2
0
    /* 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;
    int fd;
    char dirbuf[FILENAME_MAX], *nameptr;
    if (tryingalready) return;
    newest = 0;
    class_loadsym = s;
    if (sys_load_lib(canvas_getcurrent(), s->s_name))
    {
        tryingalready = 1;
        typedmess(dummy, s, argc, argv);
        tryingalready = 0;
        return;
    }
    class_loadsym = 0;
    current = s__X.s_thing;
    if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd",
        dirbuf, &nameptr, FILENAME_MAX, 0)) >= 0 ||
            (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat",
                dirbuf, &nameptr, FILENAME_MAX, 0)) >= 0)
    {
        close (fd);
        if (!pd_setloadingabstraction(s))
        {
            canvas_setargs(argc, argv);
            binbuf_evalfile(gensym(nameptr), gensym(dirbuf));
            canvas_initbang((t_canvas *)(s__X.s_thing));/* JMZ*/
            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;
}