# HG changeset patch # User mas01cr # Date 1246892994 0 # Node ID 7293a11b0fecbd78695b1b211621814bb121188f # Parent a082d2babb3d8f628b23876f1e349cddb36b6e08 Marginally more idiomatic adbpd_setquerytype() That whole bit of logic is going to go away soon, because those query type names are a relic -- but it's good to getting it looking reasonable first. diff -r a082d2babb3d -r 7293a11b0fec bindings/pd/adbpd.c --- a/bindings/pd/adbpd.c Mon Jul 06 15:09:53 2009 +0000 +++ b/bindings/pd/adbpd.c Mon Jul 06 15:09:54 2009 +0000 @@ -357,22 +357,22 @@ /* This sets the query type */ static void adbpd_setquerytype(t_adbpd *x,t_symbol *s,int argc, t_atom *argv){ if (argc == 1 && argv->a_type == A_SYMBOL) { - - // Determine which constant to use based on the string passed. - if(strncmp(argv->a_w.w_symbol->s_name, "track", MAXSTR)==0) + t_symbol *type = atom_getsymbol(argv); + if(type == gensym("track")) { x->x_dbquerytype=O2_TRACK_QUERY; - else if(strncmp(argv->a_w.w_symbol->s_name, "point", MAXSTR)==0) + } else if(type == gensym("point")) { x->x_dbquerytype=O2_POINT_QUERY; - else if(strncmp(argv->a_w.w_symbol->s_name, "sequence", MAXSTR)==0) + } else if(type == gensym("sequence")) { x->x_dbquerytype=O2_SEQUENCE_QUERY; - else if(strncmp(argv->a_w.w_symbol->s_name, "nsequence", MAXSTR)==0) + } else if(type == gensym("nsequence")) { x->x_dbquerytype=O2_N_SEQUENCE_QUERY; - else if(strncmp(argv->a_w.w_symbol->s_name, "onetoonensequence", MAXSTR)==0) + } else if(type == gensym("onetoonensequence")) { x->x_dbquerytype=O2_ONE_TO_ONE_N_SEQUENCE_QUERY; - else - error("unsupported query type"); - - post("Query type has been set to '%s'",argv->a_w.w_symbol->s_name); + } else { + error("unsupported query type: '%s'", type->s_name); + return; + } + post("Query type has been set to '%s'", type->s_name); } } @@ -396,7 +396,7 @@ /* the arguments in this line refer to INPUT ARGUMENTS and not OUTPUTS */ adbpd_class = class_new(gensym("adbpd"),(t_newmethod)adbpd_new,0,sizeof(t_adbpd),0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - + /* all methods that respond to input must be defined here */ class_addbang(adbpd_class, adbpd_bang); class_addfloat(adbpd_class, adbpd_setqpoint);