diff options
Diffstat (limited to 'cyclone/shadow')
-rw-r--r-- | cyclone/shadow/Makefile.objects | 1 | ||||
-rw-r--r-- | cyclone/shadow/cyclone.c | 140 | ||||
-rw-r--r-- | cyclone/shadow/dummies.c | 20 | ||||
-rw-r--r-- | cyclone/shadow/maxmode.c | 175 |
4 files changed, 228 insertions, 108 deletions
diff --git a/cyclone/shadow/Makefile.objects b/cyclone/shadow/Makefile.objects index dd8fb57..66aea0d 100644 --- a/cyclone/shadow/Makefile.objects +++ b/cyclone/shadow/Makefile.objects @@ -1,6 +1,7 @@ SHARED_OBJECTS = \ common/loud.o \ common/grow.o \ +common/fitter.o \ common/lex.o \ common/binport.o \ common/port.o \ diff --git a/cyclone/shadow/cyclone.c b/cyclone/shadow/cyclone.c index a702074..30f1c84 100644 --- a/cyclone/shadow/cyclone.c +++ b/cyclone/shadow/cyclone.c @@ -1,14 +1,12 @@ -/* Copyright (c) 2003-2004 krzYszcz and others. +/* Copyright (c) 2003-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ /* Never use forked calls in shadow code... */ -/* LATER support multi-atom dir (creation args), and fn ('import' message) - (same in hammer and sickle) */ +/* LATER support multi-atom dir ('cd' message), and fn ('import' message) + (same in maxmode, hammer and sickle) */ -#include <stdio.h> -#include <string.h> #include "m_pd.h" #include "common/loud.h" #include "common/port.h" @@ -22,6 +20,7 @@ typedef struct _cyclone { t_object x_ob; t_symbol *x_dir; + t_symbol *x_canvasdir; t_hammerfile *x_filehandle; } t_cyclone; @@ -29,11 +28,8 @@ static t_class *cyclone_class; static int cyclone_hammerndx; static int cyclone_sicklendx; static int cyclone_nettlesndx; -static int cyclone_dummiesndx; static int cyclone_lastndx; -static t_pd *cyclone_dproxy = 0; - static void cyclone_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) { import_max(fn->s_name, ""); @@ -41,7 +37,8 @@ static void cyclone_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) static void cyclone_doimport(t_cyclone *x, t_symbol *fn, t_symbol *dir) { - if (!dir || dir == &s_) dir = x->x_dir; + if (!dir || dir == &s_) + dir = x->x_dir; if (fn && fn != &s_) import_max(fn->s_name, (dir && dir != &s_) ? dir->s_name : ""); else @@ -59,42 +56,28 @@ static void cyclone_import(t_cyclone *x, t_symbol *fn) cyclone_doimport(x, fn, 0); } -static void cyclone_bang(t_cyclone *x) +static void cyclone_cd(t_cyclone *x, t_symbol *dir) { - int i; - fragile_class_printnames("hammer classes are: ", - cyclone_hammerndx, cyclone_sicklendx - 1); - fragile_class_printnames("sickle classes are: ", - cyclone_sicklendx, cyclone_nettlesndx - 1); - fragile_class_printnames("nettles are: ", - cyclone_nettlesndx, cyclone_dummiesndx - 1); - if (cyclone_dproxy) - pd_bang(cyclone_dproxy); - else - post("no replacement abstractions"); - if (cyclone_lastndx > cyclone_dummiesndx) - post("send 'dummies' message to see the list of %d dummy classes", - /* cyclone_lastndx points to the "_dummy" sentinel class */ - cyclone_lastndx - cyclone_dummiesndx); - else - post("no dummies"); + /* LATER hammerfile interface for relative jumps, etc. */ + x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir); } -static void cyclone_reps(t_cyclone *x) +static void cyclone_pwd(t_cyclone *x) { - if (cyclone_dproxy) - typedmess(cyclone_dproxy, gensym("reps"), 0, 0); - else - post("no replacement abstractions"); + outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir); } -static void cyclone_dummies(t_cyclone *x) +static void cyclone_bang(t_cyclone *x) { - if (cyclone_lastndx > cyclone_dummiesndx) - fragile_class_printnames("dummies are: ", - cyclone_dummiesndx, cyclone_lastndx); - else - post("no dummies"); + if (cyclone_hammerndx && cyclone_sicklendx) + { + fragile_class_printnames("hammer classes are: ", + cyclone_hammerndx, cyclone_sicklendx - 1); + fragile_class_printnames("sickle classes are: ", + cyclone_sicklendx, cyclone_nettlesndx - 1); + } + fragile_class_printnames("nettles are: ", + cyclone_nettlesndx, cyclone_lastndx - 1); } static void cyclone_free(t_cyclone *x) @@ -102,26 +85,20 @@ static void cyclone_free(t_cyclone *x) hammerfile_free(x->x_filehandle); } -static void *cyclone_new(t_symbol *s) +static void *cyclone_new(void) { t_cyclone *x = (t_cyclone *)pd_new(cyclone_class); x->x_filehandle = hammerfile_new((t_pd *)x, 0, cyclone_readhook, 0, 0); - x->x_dir = (s && s != &s_ ? s : canvas_getdir(x->x_filehandle->f_canvas)); + x->x_canvasdir = canvas_getdir(x->x_filehandle->f_canvas); + x->x_dir = x->x_canvasdir; + outlet_new((t_object *)x, &s_symbol); return (x); } void cyclone_setup(void) { - int hresult, sresult, dresult; - hresult = sresult = dresult = LOADER_OK; - if (canvas_getcurrent()) - { - /* Loading the library by object creation is banned, because of a danger - of having some of the classes already loaded. LATER rethink. */ - loud_error(0, "apparently an attempt to create a 'cyclone' object"); - loud_errand(0, "without having cyclone library preloaded"); - return; - } + int hresult, sresult; + hresult = sresult = LOADER_OK; if (zgetfn(&pd_objectmaker, gensym("cyclone"))) { loud_error(0, "cyclone is already loaded"); @@ -132,12 +109,12 @@ void cyclone_setup(void) cyclone_class = class_new(gensym("cyclone"), (t_newmethod)cyclone_new, (t_method)cyclone_free, - sizeof(t_cyclone), 0, A_DEFSYM, 0); + sizeof(t_cyclone), 0, 0); class_addbang(cyclone_class, cyclone_bang); - class_addmethod(cyclone_class, (t_method)cyclone_reps, - gensym("reps"), 0); - class_addmethod(cyclone_class, (t_method)cyclone_dummies, - gensym("dummies"), 0); + class_addmethod(cyclone_class, (t_method)cyclone_cd, + gensym("cd"), A_DEFSYM, 0); + class_addmethod(cyclone_class, (t_method)cyclone_pwd, + gensym("pwd"), 0); class_addmethod(cyclone_class, (t_method)cyclone_import, gensym("import"), A_DEFSYM, 0); class_addmethod(cyclone_class, (t_method)cyclone_click, @@ -145,49 +122,42 @@ void cyclone_setup(void) A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); hammerfile_setup(cyclone_class, 0); - cyclone_hammerndx = fragile_class_count(); - if (zgetfn(&pd_objectmaker, gensym("hammer"))) - loud_warning(0, "cyclone", "hammer is already loaded"); - else - hresult = unstable_load_lib("", "hammer"); - - cyclone_sicklendx = fragile_class_count(); - if (zgetfn(&pd_objectmaker, gensym("sickle"))) - loud_warning(0, "cyclone", "sickle is already loaded"); + if (canvas_getcurrent()) + { + /* Loading hammer and sickle by cyclone object creation is banned, + because of a danger of having some of the classes already loaded. */ + loud_warning(0, "cyclone", + "creating cyclone object without loading cyclone components"); + cyclone_hammerndx = cyclone_sicklendx = 0; + } else - sresult = unstable_load_lib("", "sickle"); + { + cyclone_hammerndx = fragile_class_count(); + if (zgetfn(&pd_objectmaker, gensym("hammer"))) + loud_warning(0, "cyclone", "hammer is already loaded"); + else + hresult = unstable_load_lib("", "hammer"); + cyclone_sicklendx = fragile_class_count(); + if (zgetfn(&pd_objectmaker, gensym("sickle"))) + loud_warning(0, "cyclone", "sickle is already loaded"); + else + sresult = unstable_load_lib("", "sickle"); + } cyclone_nettlesndx = fragile_class_count(); allnettles_setup(); - - cyclone_dummiesndx = fragile_class_count(); - if (zgetfn(&pd_objectmaker, gensym("dummies"))) - loud_warning(0, "cyclone", "dummies are already loaded"); - else - dresult = unstable_load_lib("", "dummies"); - cyclone_lastndx = fragile_class_count() - 1; if (hresult == LOADER_NOFILE) loud_error(0, "hammer library is missing"); else if (sresult == LOADER_NOFILE) loud_error(0, "sickle library is missing"); - else if (!zgetfn(&pd_objectmaker, gensym("hammer")) || - !zgetfn(&pd_objectmaker, gensym("sickle"))) + else if (cyclone_hammerndx && + (!zgetfn(&pd_objectmaker, gensym("hammer")) || + !zgetfn(&pd_objectmaker, gensym("sickle")))) { loud_error(0, "version mismatch"); loud_errand(0, "use a more recent Pd release (or recompile the cyclone)."); } - else if (dresult == LOADER_NOFILE) - loud_warning(0, "cyclone", "dummies not found"); - else - { - t_symbol *s = gensym("_cc.dummies"); - if (s->s_thing && !s->s_next - && !strcmp(class_getname(*s->s_thing), "_cc.dummies")) - cyclone_dproxy = s->s_thing; - else - bug("cyclone_setup"); /* FIXME */ - } } diff --git a/cyclone/shadow/dummies.c b/cyclone/shadow/dummies.c index 0a3c218..5ad7cc1 100644 --- a/cyclone/shadow/dummies.c +++ b/cyclone/shadow/dummies.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2004 krzYszcz and others. +/* Copyright (c) 2003-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ @@ -554,7 +554,7 @@ static t_object *dummy_newobject(t_symbol *s, t_dummy_slot **slotp) x = (t_object *)pd_new(dummy_classes[fnd]); sl = &dummy_slots[fnd]; if (fnd == dummy_nclasses) - bug("dummy_newobject"); /* create a "_dummy" in this case */ + loudbug_bug("dummy_newobject"); /* create a "_dummy" in this case */ else if (!sl->s_warned) { loud_warning((t_pd *)x, 0, "dummy substitution"); @@ -567,15 +567,6 @@ static t_object *dummy_newobject(t_symbol *s, t_dummy_slot **slotp) static void ccdummies_bang(t_pd *x) { if (dummy_nreps) - post("send 'reps' message to see the list of %d \ -replacement abstractions", dummy_nreps); - else - post("no replacement abstractions"); -} - -static void ccdummies_reps(t_pd *x) -{ - if (dummy_nreps) { char *msg = "replacement abstractions are: "; int i, len = strlen(msg); @@ -619,8 +610,9 @@ void dummies_setup(void) ndoomed++; else if (ndoomed && i < dummy_nclasses - 1) { - bug("dummies_setup"); - post("(\"%s\": clashing or doomed dummy not registered for import)", + loudbug_bug("dummies_setup"); + loudbug_post + ("(\"%s\": clashing or doomed dummy not registered for import)", sl->s_name); } if ((fd = open_via_path("", sl->s_name, ".pd", @@ -643,7 +635,5 @@ void dummies_setup(void) ccdummies_class = class_new(gensym("_cc.dummies"), 0, 0, sizeof(t_pd), CLASS_PD | CLASS_NOINLET, 0); class_addbang(ccdummies_class, ccdummies_bang); - class_addmethod(ccdummies_class, (t_method)ccdummies_reps, - gensym("reps"), 0); pd_bind(pd_new(ccdummies_class), gensym("_cc.dummies")); /* never freed */ } diff --git a/cyclone/shadow/maxmode.c b/cyclone/shadow/maxmode.c index f90d990..9cd1055 100644 --- a/cyclone/shadow/maxmode.c +++ b/cyclone/shadow/maxmode.c @@ -1,21 +1,180 @@ -/* Copyright (c) 2004 krzYszcz and others. +/* Copyright (c) 2004-2005 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 <stdio.h> +#include <string.h> #include "m_pd.h" #include "common/loud.h" +#include "common/fitter.h" +#include "common/port.h" +#include "hammer/file.h" +#include "unstable/fragile.h" #include "unstable/loader.h" +#include "../build_counter" + +typedef struct _maxmode +{ + t_object x_ob; + t_symbol *x_dir; + t_symbol *x_canvasdir; + t_hammerfile *x_filehandle; +} t_maxmode; + +static t_class *maxmode_class; +static int maxmode_dummiesndx; +static int maxmode_lastndx; +static t_pd *maxmode_dproxy = 0; +static int maxmode_withbanner = 0; + +static void maxmode_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) +{ + import_max(fn->s_name, ""); +} + +static void maxmode_doimport(t_maxmode *x, t_symbol *fn, t_symbol *dir) +{ + if (!dir || dir == &s_) + dir = x->x_dir; + if (fn && fn != &s_) + import_max(fn->s_name, (dir && dir != &s_) ? dir->s_name : ""); + else + hammerpanel_open(x->x_filehandle, dir); +} + +static void maxmode_click(t_maxmode *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +{ + maxmode_doimport(x, 0, 0); +} + +static void maxmode_import(t_maxmode *x, t_symbol *fn) +{ + maxmode_doimport(x, fn, 0); +} + +static void maxmode_cd(t_maxmode *x, t_symbol *dir) +{ + /* LATER hammerfile interface for relative jumps, etc. */ + x->x_dir = (dir && dir != &s_ ? dir : x->x_canvasdir); +} + +static void maxmode_pwd(t_maxmode *x) +{ + outlet_symbol(((t_object *)x)->ob_outlet, x->x_dir); +} + +static void maxmode_bang(t_maxmode *x) +{ + if (maxmode_dproxy) + pd_bang(maxmode_dproxy); + else + post("no replacement abstractions"); + if (maxmode_lastndx > maxmode_dummiesndx) + fragile_class_printnames("dummies are: ", + maxmode_dummiesndx, maxmode_lastndx); + else + post("no dummies"); +} + +static void maxmode_free(t_maxmode *x) +{ + hammerfile_free(x->x_filehandle); +} + +static void *maxmode_new(t_symbol *s, int ac, t_atom *av) +{ + t_maxmode *x = (t_maxmode *)pd_new(maxmode_class); + if (maxmode_withbanner && !ac) + { + post("this is maxmode %s, %s %s build", + CYCLONE_VERSION, loud_ordinal(CYCLONE_BUILD), CYCLONE_RELEASE); + loud_warning(0, "maxmode", + "creating maxmode object without loading cyclone components"); + maxmode_withbanner = 0; + } + if (!fittermax_get()) + { + int selective = 0; + if (ac) + { + while (ac--) if (av->a_type == A_SYMBOL) + { + /* FIXME register into fitter for per-patch, selective + compatibility control */ + av++; + } + } + if (!selective) + fittermax_set(); + } + x->x_filehandle = hammerfile_new((t_pd *)x, 0, maxmode_readhook, 0, 0); + x->x_canvasdir = canvas_getdir(x->x_filehandle->f_canvas); + x->x_dir = x->x_canvasdir; + outlet_new((t_object *)x, &s_symbol); + return (x); +} void maxmode_setup(void) { - shared_setmaxcompatibility(); - if (zgetfn(&pd_objectmaker, gensym("cyclone"))) - loud_warning(0, "maxmode", "cyclone is already loaded"); + int dresult = LOADER_OK; + if (zgetfn(&pd_objectmaker, gensym("maxmode"))) + { + loud_error(0, "maxmode is already loaded"); + return; + } + maxmode_class = class_new(gensym("maxmode"), + (t_newmethod)maxmode_new, + (t_method)maxmode_free, + sizeof(t_maxmode), 0, A_GIMME, 0); + class_addbang(maxmode_class, maxmode_bang); + class_addmethod(maxmode_class, (t_method)maxmode_cd, + gensym("cd"), A_DEFSYM, 0); + class_addmethod(maxmode_class, (t_method)maxmode_pwd, + gensym("pwd"), 0); + class_addmethod(maxmode_class, (t_method)maxmode_import, + gensym("import"), A_DEFSYM, 0); + class_addmethod(maxmode_class, (t_method)maxmode_click, + gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + hammerfile_setup(maxmode_class, 0); + + if (canvas_getcurrent()) + { + fitter_setup(0, 0, 0); + if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) + /* cycloneless maxmode -- banner is posted by the oldest + maxmode object with no creation arguments */ + maxmode_withbanner = 1; + } + else + { + fittermax_set(); + if (zgetfn(&pd_objectmaker, gensym("cyclone"))) + loud_warning(0, "maxmode", "cyclone is already loaded"); + else + { + if (unstable_load_lib("", "cyclone") == LOADER_NOFILE) + loud_error(0, "cyclone library is missing"); + else if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) + loud_error(0, "miXed/Pd version mismatch"); + } + } + maxmode_dummiesndx = fragile_class_count(); + if (zgetfn(&pd_objectmaker, gensym("dummies"))) + loud_warning(0, "maxmode", "dummies are already loaded"); + else + dresult = unstable_load_lib("", "dummies"); + maxmode_lastndx = fragile_class_count() - 1; + if (dresult == LOADER_NOFILE) + loud_warning(0, "maxmode", "dummies not found"); else { - if (unstable_load_lib("", "cyclone") == LOADER_NOFILE) - loud_error(0, "cyclone library is missing"); - else if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) - loud_error(0, "miXed/Pd version mismatch"); + t_symbol *s = gensym("_cc.dummies"); + if (s->s_thing && !s->s_next + && !strcmp(class_getname(*s->s_thing), "_cc.dummies")) + maxmode_dproxy = s->s_thing; + else + loudbug_bug("maxmode_setup"); /* FIXME */ } } |