diff options
author | N.N. <krzyszcz@users.sourceforge.net> | 2005-01-11 10:33:23 +0000 |
---|---|---|
committer | N.N. <krzyszcz@users.sourceforge.net> | 2005-01-11 10:33:23 +0000 |
commit | 6435314717c5fb8fa062eb682c72c8df095b1be3 (patch) | |
tree | 484d02446358890397a755fc144d4ecf25b38f2d /cyclone/shadow/cyclone.c | |
parent | b89456a346e176c4dc536e7de8f14b152cb2b15b (diff) |
svf~: args parsing; prepend/Append: bang handling; seq: pause, continue, goto; many maxmode changes
svn path=/trunk/externals/miXed/; revision=2490
Diffstat (limited to 'cyclone/shadow/cyclone.c')
-rw-r--r-- | cyclone/shadow/cyclone.c | 140 |
1 files changed, 55 insertions, 85 deletions
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 */ - } } |