Update of /cvsroot/pure-data/externals/miXed/shared/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20056/miXed/shared/common
Modified Files: binport.c port.c port.h Log Message: mapping feature for ported names
Index: port.h =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** port.h 23 May 2003 12:29:52 -0000 1.1.1.1 --- port.h 12 May 2004 15:01:35 -0000 1.2 *************** *** 1,3 **** ! /* Copyright (c) 2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2003-2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 7,10 **** --- 7,13 ----
void import_max(char *fn, char *dir); + void import_setmapping(int size, char **mapping); + char **import_getmapping(int *sizep); + char *port_usemapping(char *from, int mapsize, char **mapping);
#endif
Index: port.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/shared/common/port.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** port.c 23 Apr 2004 11:25:53 -0000 1.12 --- port.c 12 May 2004 15:01:35 -0000 1.13 *************** *** 93,96 **** --- 93,173 ---- static t_symbol *portps_picture;
+ static char *import_defmapping[] = + { + /* clashing clones */ + "append", "Append", + "b", "bangbang", + "clip", "Clip", + "clip~", "Clip~", + "line~", "Line~", + "scope~", "Scope~", + "snapshot~", "Snapshot~", + + /* clashing dummies */ + "biquad~", "Biquad~", + "change", "Change", + "key", "Key", + "keyup", "Keyup", + "line", "Line", + "poly", "Poly", + + /* doomed dummies */ + "appledvd", "c74.appledvd", + "plugconfig", "c74.plugconfig", + "plugin~", "c74.plugin~", + "plugmidiin", "c74.plugmidiin", + "plugmidiout", "c74.plugmidiout", + "plugmod", "c74.plugmod", + "plugmorph", "c74.plugmorph", + "plugmultiparam", "c74.plugmultiparam", + "plugout~", "c74.plugout~", + "plugphasor~", "c74.plugphasor~", + "plugreceive~", "c74.plugreceive~", + "plugsend~", "c74.plugsend~", + "plugstore", "c74.plugstore", + "plugsync~", "c74.plugsync~", + "pp", "c74.pp", + "pptempo", "c74.pptempo", + "pptime", "c74.pptime", + "rewire~", "c74.rewire~", + "sndmgrin~", "c74.sndmgrin~", + "vdp", "c74.vdp", + "vst~", "c74.vst~" + }; + + static int import_mapsize = 0; + static char **import_mapping = 0; + + static void import_setdefmapping(void) + { + import_mapsize = sizeof(import_defmapping)/(2 * sizeof(*import_defmapping)); + import_mapping = import_defmapping; + } + + void import_setmapping(int size, char **mapping) + { + import_mapsize = size; + import_mapping = mapping; + } + + char **import_getmapping(int *sizep) + { + if (!import_mapping) import_setdefmapping(); + *sizep = import_mapsize; + return (import_mapping); + } + + char *port_usemapping(char *from, int mapsize, char **mapping) + { + while (mapsize--) + { + if (strcmp(*mapping, from)) + mapping += 2; + else + return (mapping[1]); + } + return (0); + } + static t_int port_getint(t_port *x, int ndx) { *************** *** 393,400 **** else { if (inatom->a_type == A_SYMBOL) { /* LATER bash inatom to lowercase (CHECKME first) */ ! t_symbol *insym = inatom->a_w.w_symbol; if (insym != &s_bang && insym != &s_float && insym != &s_symbol && insym != &s_list && --- 470,497 ---- else { + t_symbol *insym = 0; if (inatom->a_type == A_SYMBOL) { /* LATER bash inatom to lowercase (CHECKME first) */ ! insym = inatom->a_w.w_symbol; ! if (import_mapping && import_mapsize) ! { ! char **fromp = import_mapping, **top = import_mapping + 1; ! int cnt = import_mapsize; ! while (cnt--) ! { ! if (strcmp(*fromp, insym->s_name)) ! { ! fromp += 2; ! top += 2; ! } ! else ! { ! insym = gensym(*top); ! inatom = 0; ! break; ! } ! } ! } if (insym != &s_bang && insym != &s_float && insym != &s_symbol && insym != &s_list && *************** *** 407,411 **** } } ! import_copyatoms(&at, inatom, 1); } binbuf_add(x->x_outbb, 1, &at); --- 504,516 ---- } } ! if (inatom) ! import_copyatoms(&at, inatom, 1); ! else if (insym) ! SETSYMBOL(&at, insym); ! else ! { ! bug("import_addclassname"); ! SETSYMBOL(&at, gensym("???")); ! } } binbuf_add(x->x_outbb, 1, &at); *************** *** 922,936 **** static t_portslot imslots_newex[] = { - { "append", import_objarg, "Append", 0, 0 }, - { "biquad~", import_objarg, "Biquad~", 0, 0 }, - { "change", import_objarg, "Change", 0, 0 }, - { "clip", import_objarg, "Clip", 0, 0 }, - { "clip~", import_objarg, "Clip~", 0, 0 }, { "key", import_obj, "Key", 0, 0 }, { "keyup", import_obj, "Keyup", 0, 0 }, - { "line", import_objarg, "Line", 0, 0 }, - { "line~", import_objarg, "Line~", 0, 0 }, - { "poly", import_objarg, "Poly", 0, 0 }, - { "snapshot~", import_objarg, "Snapshot~", 0, 0 },
{ "pack", imaction_P6_pack, 0, 0, 0 }, --- 1027,1032 ---- *************** *** 1125,1128 **** --- 1221,1225 ---- port_dochecksetup(subtree); } + import_setdefmapping(); }
Index: binport.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/shared/common/binport.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** binport.c 17 Apr 2004 17:45:28 -0000 1.4 --- binport.c 12 May 2004 15:01:35 -0000 1.5 *************** *** 246,255 **** else if (ex || hi || lo) { ! double d; ex -= 0x401e; ! hi = ((hi - 0x7fffffff) - 1) + ((float)0x7fffffff + 1.); ! lo = ((lo - 0x7fffffff) - 1) + ((float)0x7fffffff + 1.); ! d = ldexp(hi, ex) + ldexp(lo, ex - 32); ! *fptr = ((word[0] & 0x80) ? -(float)d : (float)d); } else *fptr = 0.; --- 246,255 ---- else if (ex || hi || lo) { ! double dhi, dlo, dabs; ex -= 0x401e; ! dhi = (double)((hi - 0x7fffffff) - 1) + ((float)0x7fffffff + 1.); ! dlo = (double)((lo - 0x7fffffff) - 1) + ((float)0x7fffffff + 1.); ! dabs = ldexp(dhi, ex) + ldexp(dlo, ex - 32); ! *fptr = ((word[0] & 0x80) ? -(float)dabs : (float)dabs); } else *fptr = 0.; *************** *** 680,684 **** binport_setint(ap, atoi(buf)); else if (floatstate == 4 || floatstate == 5 || floatstate == 8) ! binport_setfloat(ap, atof(buf)); else binport_setsymbol(ap, gensym(buf)); --- 680,684 ---- binport_setint(ap, atoi(buf)); else if (floatstate == 4 || floatstate == 5 || floatstate == 8) ! binport_setfloat(ap, (float)atof(buf)); else binport_setsymbol(ap, gensym(buf));