aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorN.N. <krzyszcz@users.sourceforge.net>2004-05-12 15:01:35 +0000
committerN.N. <krzyszcz@users.sourceforge.net>2004-05-12 15:01:35 +0000
commit7d42c7df89091db055ad77ef4bbfb64059858e52 (patch)
tree5390a17317f473e89aeecc0554069c9f90df6b41 /shared
parent075b865652ce146fe8419494b149ceadcac48071 (diff)
mapping feature for ported names
svn path=/trunk/externals/miXed/; revision=1725
Diffstat (limited to 'shared')
-rw-r--r--shared/common/binport.c12
-rw-r--r--shared/common/port.c119
-rw-r--r--shared/common/port.h5
3 files changed, 118 insertions, 18 deletions
diff --git a/shared/common/binport.c b/shared/common/binport.c
index 90eb4a1..e2c9d34 100644
--- a/shared/common/binport.c
+++ b/shared/common/binport.c
@@ -245,12 +245,12 @@ static int binport_readfloat(FILE *fp, float *fptr)
}
else if (ex || hi || lo)
{
- double d;
+ double dhi, dlo, dabs;
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);
+ 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.;
#ifdef BINPORT_DEBUG
@@ -679,7 +679,7 @@ static int maxtext_nextatom(FILE *fp, t_atom *ap)
else if (floatstate == 2)
binport_setint(ap, atoi(buf));
else if (floatstate == 4 || floatstate == 5 || floatstate == 8)
- binport_setfloat(ap, atof(buf));
+ binport_setfloat(ap, (float)atof(buf));
else
binport_setsymbol(ap, gensym(buf));
}
diff --git a/shared/common/port.c b/shared/common/port.c
index 87f770e..5ea4dcd 100644
--- a/shared/common/port.c
+++ b/shared/common/port.c
@@ -92,6 +92,83 @@ static t_symbol *portps_funbuff;
static t_symbol *portps_prob;
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)
{
if (ndx < x->x_inatoms)
@@ -392,10 +469,30 @@ static void import_addclassname(t_port *x, char *outname, t_atom *inatom)
SETSYMBOL(&at, gensym(outname));
else
{
+ t_symbol *insym = 0;
if (inatom->a_type == A_SYMBOL)
{
/* LATER bash inatom to lowercase (CHECKME first) */
- t_symbol *insym = inatom->a_w.w_symbol;
+ 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 &&
(insym == portps_inlet || insym == portps_outlet ||
@@ -406,7 +503,15 @@ static void import_addclassname(t_port *x, char *outname, t_atom *inatom)
binbuf_add(x->x_outbb, 1, &at);
}
}
- import_copyatoms(&at, inatom, 1);
+ 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);
}
@@ -921,17 +1026,8 @@ static t_portnode imnode_newobj = { imslots_newobj,
/* LATER consider merging newobj and newex */
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 },
{ "unpack", imaction_P6_pack, 0, 0, 0 },
@@ -1124,6 +1220,7 @@ static void port_dochecksetup(t_portnode *node)
if (subtree)
port_dochecksetup(subtree);
}
+ import_setdefmapping();
}
#define BOGUS_NINLETS 23
diff --git a/shared/common/port.h b/shared/common/port.h
index 5d2c118..2053c20 100644
--- a/shared/common/port.h
+++ b/shared/common/port.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2003 krzYszcz and others.
+/* 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. */
@@ -6,5 +6,8 @@
#define __PORT_H__
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