diff options
author | Thomas O Fredericks <mrtof@users.sourceforge.net> | 2009-10-09 15:08:30 +0000 |
---|---|---|
committer | Thomas O Fredericks <mrtof@users.sourceforge.net> | 2009-10-09 15:08:30 +0000 |
commit | 3fcf217797b7c91f1371968d7de4124c9999f646 (patch) | |
tree | 33a82f33c07e85ae8d4823056da95e4e1281e2c7 /src | |
parent | d88938d7edb7387badf3a5500767dcf78c56fb7d (diff) |
Added new no_save and wait_for_bang to param
svn path=/trunk/externals/tof/; revision=12569
Diffstat (limited to 'src')
-rw-r--r-- | src/param.c | 60 | ||||
-rw-r--r-- | src/tof.h | 43 |
2 files changed, 70 insertions, 33 deletions
diff --git a/src/param.c b/src/param.c index 2aab6aa..0d29ac3 100644 --- a/src/param.c +++ b/src/param.c @@ -44,6 +44,7 @@ typedef struct _paramClass { t_symbol* receive; t_symbol* send; t_symbol* set_s; + int nowaitforbang; } t_paramClass; typedef struct _paramClass_inlet2 @@ -87,7 +88,7 @@ static void paramClass_anything(t_paramClass *x, t_symbol *s, int ac, t_atom *av tof_copy_atoms(av, x->av, ac); } - paramClass_bang(x); + if (x->nowaitforbang) paramClass_bang(x); } @@ -165,11 +166,40 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av) t_symbol* path = param_get_path(canvas,name); t_symbol* root = tof_get_dollarzero(tof_get_root_canvas(canvas)); - x->param = param_register(x,root,path,\ - (t_paramGetMethod) paramClass_get,\ - (t_paramSaveMethod) paramClass_save,\ - (t_paramGUIMethod) paramClass_GUI); + //FIND THE GUI OPTIONS: /g + int ac_temp = 0; + t_atom* av_temp = NULL; + + tof_find_tagged_argument('/',gensym("/g"), ac-1, av+1,&ac_temp,&av_temp); + x->gac = ac_temp; + x->gav = getbytes(x->gac * sizeof(*(x->gav))); + tof_copy_atoms(av_temp,x->gav,x->gac); + + // FIND THE NO LOADBANG TAG: /nlb + x->noloadbang = tof_find_tag('/',gensym("/nlb"), ac-1, av+1); + //post("nlb: %i",x->noloadbang); + + // FIND THE NO SAVE TAG: /ns + int nosave = tof_find_tag('/',gensym("/ns"), ac-1, av+1); + //post("ns: %i",nosave); + + // FIND THE WAIT FOR BANG TAG: /wfb + x->nowaitforbang = !(tof_find_tag('/',gensym("/wfb"), ac-1, av+1)); + + + // REGISTER PARAM + t_paramSaveMethod paramSaveMethod = NULL; + t_paramGUIMethod paramGUIMethod = NULL; + + if ( x->gac > 0 ) paramGUIMethod = (t_paramGUIMethod) paramClass_GUI; + if ( nosave = 0 ) paramSaveMethod = (t_paramSaveMethod) paramClass_save; + + x->param = param_register(x,root,path, \ + (t_paramGetMethod) paramClass_get, \ + paramSaveMethod, \ + paramGUIMethod); + if (!x->param) return NULL; // FIND PARAM VALUE @@ -203,27 +233,11 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av) - // FIND THE NO LOADBANG TAG: /nlb - int i; - x->noloadbang = 0; - - for ( i =0; i < ac; i++) { - if ( IS_A_SYMBOL(av,i) && (strcmp("/nlb",atom_getsymbol(av+i)->s_name) == 0)) { - x->noloadbang = 1; - break; - } - } + - //FIND THE GUI OPTIONS: /g - int ac_g = 0; - t_atom* av_g = NULL; - // There could be a problem if the the name is also /g - tof_find_tagged_argument('/',gensym("/g"), ac, av,&ac_g,&av_g); - x->gac = ac_g; - x->gav = getbytes(x->gac * sizeof(*(x->gav))); - tof_copy_atoms(av_g,x->gav,x->gac); + @@ -197,22 +197,42 @@ static int tof_next_tagged_argument(char tag, int ac, t_atom *av, int* ac_a, t_a return (*ac_a); } -static void tof_find_tagged_argument(char tag,t_symbol *name, int ac, t_atom *av, int *ac_r,t_atom** av_r) { + + +static int tof_find_tag(char tag, t_symbol* name, int ac, t_atom* av) { + int i; + for (i=0; i<ac;i++) { + if ( IS_A_SYMBOL(av,i) && name == atom_getsymbol(av+i) ) { + return 1; + } + } + return 0; +} + + + + +// Returns 1 if the tag was found +// Fills the given int* and t_atom** with the arguments of the tag +static int tof_find_tagged_argument(char tag,t_symbol *name, int ac, t_atom *av, int *ac_r,t_atom** av_r) { int i; + int match = 0; int j = 0; for (i=0;i<ac;i++) { - //if ( IS_A_SYMBOL(av,i)) post("analyzing %s",atom_getsymbol(av+i)->s_name); - if ( IS_A_SYMBOL(av,i) && name == atom_getsymbol(av+i) && (i+1)<ac ) { - //post("matches"); - i=i+1; - for (j=i;j<ac;j++) { - if ( IS_A_SYMBOL(av,j) && (atom_getsymbol(av+j))->s_name[0] == tag ) { - //j = j-1; - break; + if ( IS_A_SYMBOL(av,i) && name == atom_getsymbol(av+i) ) { + // FOUND MATCH + match = 1; + if ( (i+1)<ac ) { // IS THERE SPACE FOR AT LEAST ONE ARGUMENT? + i=i+1; + for (j=i;j<ac;j++) { //FIND ITS END + if ( IS_A_SYMBOL(av,j) && (atom_getsymbol(av+j))->s_name[0] == tag ) { + //j = j-1; + break; + } } + break; } - break; } } j = j-i; @@ -226,6 +246,9 @@ static void tof_find_tagged_argument(char tag,t_symbol *name, int ac, t_atom *av *ac_r = 0; *av_r = NULL; } + + return match; + } |