Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5751
Modified Files: Tag: desiredata builtins.c Log Message: cleanup of [list]
Index: builtins.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v retrieving revision 1.1.2.20 retrieving revision 1.1.2.21 diff -C2 -d -r1.1.2.20 -r1.1.2.21 *** builtins.c 28 Jun 2007 16:46:24 -0000 1.1.2.20 --- builtins.c 28 Jun 2007 22:56:53 -0000 1.1.2.21 *************** *** 674,689 **** static void alist_toatoms(t_binbuf *x, t_atom *to) {for (size_t i=0; i<x->n; i++) to[i] = x->v[i];}
t_class *list_append_class; ! struct t_list_append : t_object { ! t_binbuf *alist; ! }; static t_pd *list_append_new(t_symbol *s, int argc, t_atom *argv) { t_list_append *x = (t_list_append *)pd_new(list_append_class); ! x->alist = binbuf_new(); ! alist_list(x->alist, 0, argc, argv); ! outlet_new(x, &s_list); ! inlet_new(x,x->alist, 0, 0); return x; } static void list_append_list(t_list_append *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; --- 674,705 ---- static void alist_toatoms(t_binbuf *x, t_atom *to) {for (size_t i=0; i<x->n; i++) to[i] = x->v[i];}
+ + struct t_list_append : t_object {t_binbuf *alist;}; + struct t_list_prepend : t_object {t_binbuf *alist;}; + struct t_list_split : t_object {t_float f;}; + struct t_list_trim : t_object {}; + struct t_list_length : t_object {}; + t_class *list_append_class; ! t_class *list_prepend_class; ! t_class *list_split_class; ! t_class *list_trim_class; ! t_class *list_length_class; ! static t_pd *list_append_new(t_symbol *s, int argc, t_atom *argv) { t_list_append *x = (t_list_append *)pd_new(list_append_class); ! x->alist = binbuf_new(); alist_list(x->alist, 0, argc, argv); ! outlet_new(x, &s_list); inlet_new(x,x->alist, 0, 0); return x; } + static t_pd *list_prepend_new(t_symbol *s, int argc, t_atom *argv) { + t_list_prepend *x = (t_list_prepend *)pd_new(list_prepend_class); + x->alist = binbuf_new(); alist_list(x->alist, 0, argc, argv); + outlet_new(x, &s_list); inlet_new(x,x->alist,0,0); + return x; + } + static void list_append_free (t_list_append *x) {binbuf_free(x->alist);} + static void list_prepend_free(t_list_prepend *x) {binbuf_free(x->alist);} + static void list_append_list(t_list_append *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; *************** *** 705,728 **** ATOMS_FREEA(outv, outc); } - static void list_append_free(t_list_append *x) {binbuf_free(x->alist);} - static void list_append_setup() { - list_append_class = class_new2("list append",list_append_new,list_append_free,sizeof(t_list_append),0,"*"); - class_addlist(list_append_class, list_append_list); - class_addanything(list_append_class, list_append_anything); - class_sethelpsymbol(list_append_class, &s_list); - } - - t_class *list_prepend_class; - struct t_list_prepend : t_object { - t_binbuf *alist; - }; - static t_pd *list_prepend_new(t_symbol *s, int argc, t_atom *argv) { - t_list_prepend *x = (t_list_prepend *)pd_new(list_prepend_class); - x->alist = binbuf_new(); - alist_list(x->alist, 0, argc, argv); - outlet_new(x, &s_list); - inlet_new(x,x->alist,0,0); - return x; - } static void list_prepend_list(t_list_prepend *x, t_symbol *s, int argc, t_atom *argv) { t_atom *outv; --- 721,724 ---- *************** *** 744,759 **** ATOMS_FREEA(outv, outc); } - static void list_prepend_free(t_list_prepend *x) {binbuf_free(x->alist);} - static void list_prepend_setup() { - list_prepend_class = class_new2("list prepend",list_prepend_new,list_prepend_free,sizeof(t_list_prepend),0,"*"); - class_addlist(list_prepend_class, list_prepend_list); - class_addanything(list_prepend_class, list_prepend_anything); - class_sethelpsymbol(list_prepend_class, &s_list); - } - - t_class *list_split_class; - struct t_list_split : t_object { - t_float f; - }; static t_pd *list_split_new(t_floatarg f) { t_list_split *x = (t_list_split *)pd_new(list_split_class); --- 740,743 ---- *************** *** 781,793 **** ATOMS_FREEA(outv, argc+1); } - static void list_split_setup() { - list_split_class = class_new2("list split",list_split_new,0,sizeof(t_list_split),0,"F"); - class_addlist(list_split_class, list_split_list); - class_addanything(list_split_class, list_split_anything); - class_sethelpsymbol(list_split_class, &s_list); - }
- t_class *list_trim_class; - struct t_list_trim : t_object {}; static t_pd *list_trim_new() { t_list_trim *x = (t_list_trim *)pd_new(list_trim_class); --- 765,769 ---- *************** *** 802,814 **** outlet_anything(x->outlet, s, argc, argv); } - static void list_trim_setup() { - list_trim_class = class_new2("list trim",list_trim_new,0,sizeof(t_list_trim),0,""); - class_addlist(list_trim_class, list_trim_list); - class_addanything(list_trim_class, list_trim_anything); - class_sethelpsymbol(list_trim_class, &s_list); - }
- t_class *list_length_class; - struct t_list_length : t_object {}; static t_pd *list_length_new() { t_list_length *x = (t_list_length *)pd_new(list_length_class); --- 778,782 ---- *************** *** 822,831 **** outlet_float(x->outlet, (float)argc+1); } - static void list_length_setup() { - list_length_class = class_new2("list length",list_length_new,0,sizeof(t_list_length),0,""); - class_addlist(list_length_class, list_length_list); - class_addanything(list_length_class, list_length_anything); - class_sethelpsymbol(list_length_class, &s_list); - }
static void *list_new(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) { --- 790,793 ---- *************** *** 849,852 **** --- 811,829 ---- }
+ #define LISTOP(name,argspec,freer) \ + list_##name##_class = class_new2("list " #name,list_##name##_new,freer,sizeof(t_list_##name),0,argspec); \ + class_addlist(list_##name##_class, list_##name##_list); \ + class_addanything(list_##name##_class, list_##name##_anything); \ + class_sethelpsymbol(list_##name##_class, &s_list); + + static void list_setup () { + LISTOP(append,"*",list_append_free) + LISTOP(prepend,"*",list_prepend_free) + LISTOP(split,"F",0) + LISTOP(trim,"",0) + LISTOP(length,"",0) + class_addcreator2("list",list_new,"*"); + } + /* miller's "homebrew" linear-congruential algorithm */ static t_class *random_class; *************** *** 986,992 ****
static t_class *realtime_class; ! struct t_realtime : t_object { ! double setrealtime; ! }; static void realtime_bang(t_realtime *x) { x->setrealtime = sys_getrealtime(); --- 963,967 ----
static t_class *realtime_class; ! struct t_realtime : t_object {double setrealtime;}; static void realtime_bang(t_realtime *x) { x->setrealtime = sys_getrealtime(); *************** *** 1218,1224 ****
static t_class *pdint_class; ! struct t_pdint : t_object { ! t_float f; ! }; static void *pdint_new(t_floatarg f) { t_pdint *x = (t_pdint *)pd_new(pdint_class); --- 1193,1197 ----
static t_class *pdint_class; ! struct t_pdint : t_object {t_float f;}; static void *pdint_new(t_floatarg f) { t_pdint *x = (t_pdint *)pd_new(pdint_class); *************** *** 1238,1244 ****
static t_class *pdfloat_class; ! struct t_pdfloat : t_object { ! t_float f; ! }; static void *pdfloat_new(t_pd *dummy, t_float f) { t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class); --- 1211,1215 ----
static t_class *pdfloat_class; ! struct t_pdfloat : t_object {t_float f;}; static void *pdfloat_new(t_pd *dummy, t_float f) { t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class); *************** *** 1260,1266 ****
static t_class *pdsymbol_class; ! struct t_pdsymbol : t_object { ! t_symbol *s; ! }; static void *pdsymbol_new(t_pd *dummy, t_symbol *s) { t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class); --- 1231,1235 ----
static t_class *pdsymbol_class; ! struct t_pdsymbol : t_object {t_symbol *s;}; static void *pdsymbol_new(t_pd *dummy, t_symbol *s) { t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class); *************** *** 3107,3110 **** --- 3076,3080 ---- }
+ void builtins_setup() { t_symbol *s = gensym("acoustics.pd"); *************** *** 3179,3188 **** class_addlist(binbuf_class, alist_list); class_addanything(binbuf_class, alist_anything); ! list_append_setup(); ! list_prepend_setup(); ! list_split_setup(); ! list_trim_setup(); ! list_length_setup(); ! class_addcreator2("list",list_new,"*"); arithmetic_setup(); midi_setup(); --- 3149,3153 ---- class_addlist(binbuf_class, alist_list); class_addanything(binbuf_class, alist_anything); ! list_setup(); arithmetic_setup(); midi_setup();