Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4167
Modified Files:
Tag: desiredata
kernel.c
Log Message:
shrunk code for loading and saving .pat files
Index: kernel.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -C2 -d -r1.1.2.15 -r1.1.2.16
*** kernel.c 31 Dec 2006 07:27:21 -0000 1.1.2.15
--- kernel.c 31 Dec 2006 07:54:20 -0000 1.1.2.16
***************
*** 1646,1652 ****
t_gotfn getfn(t_pd *x, t_symbol *s) {
t_class *c = *x;
! t_methodentry *m;
! int i;
! for (i = c->nmethod, m = c->methods; i--; m++) if (m->me_name == s) return m->me_fun;
pd_error(x, "%s: no method for message '%s'", c->name->s_name, s->s_name);
return (t_gotfn)nullfn;
--- 1646,1651 ----
t_gotfn getfn(t_pd *x, t_symbol *s) {
t_class *c = *x;
! t_methodentry *m = c->methods;
! for (int i=c->nmethod; i--; m++) if (m->me_name == s) return m->me_fun;
pd_error(x, "%s: no method for message '%s'", c->name->s_name, s->s_name);
return (t_gotfn)nullfn;
***************
*** 1655,1661 ****
t_gotfn zgetfn(t_pd *x, t_symbol *s) {
t_class *c = *x;
! t_methodentry *m;
! int i;
! for (i = c->nmethod, m = c->methods; i--; m++) if (m->me_name == s) return m->me_fun;
return 0;
}
--- 1654,1659 ----
t_gotfn zgetfn(t_pd *x, t_symbol *s) {
t_class *c = *x;
! t_methodentry *m = c->methods;
! for (int i=c->nmethod; i--; m++) if (m->me_name == s) return m->me_fun;
return 0;
}
***************
*** 1679,1684 ****
int class_getfieldindex(t_class *x, const char *s) {
t_symbol *sy = gensym((char *)s);
! int i;
! for (i=0; i<x->nfields; i++) if (x->fields[i]==sy) return i;
return -1;
}
--- 1677,1681 ----
int class_getfieldindex(t_class *x, const char *s) {
t_symbol *sy = gensym((char *)s);
! for (int i=0; i<x->nfields; i++) if (x->fields[i]==sy) return i;
return -1;
}
***************
*** 1709,1713 ****
if (c-> listmethod != pd_defaultlist) sys_vgui("<list> ");
if (c-> anymethod != pd_defaultanything) sys_vgui("<any> ");
! {int i; for (i=0; i<c->nmethod; i++) sys_vgui("%s ",c->methods[i].me_name->s_name);}
sys_vgui("}]; %s %s %s\n",cb_recv->s_name, cb_sel->s_name, s->s_name);
}
--- 1706,1710 ----
if (c-> listmethod != pd_defaultlist) sys_vgui("<list> ");
if (c-> anymethod != pd_defaultanything) sys_vgui("<any> ");
! for (int i=0; i<c->nmethod; i++) sys_vgui("%s ",c->methods[i].me_name->s_name);
sys_vgui("}]; %s %s %s\n",cb_recv->s_name, cb_sel->s_name, s->s_name);
}
***************
*** 1939,1946 ****
void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y) {
t_binbuf *z = binbuf_new();
! int i;
! t_atom *ap;
binbuf_add(z, y->n, y->vec);
! for (i = 0, ap = z->vec; i < z->n; i++, ap++) {
char tbuf[MAXPDSTRING];
switch (ap->a_type) {
--- 1936,1942 ----
void binbuf_addbinbuf(t_binbuf *x, t_binbuf *y) {
t_binbuf *z = binbuf_new();
! t_atom *ap = z->vec;
binbuf_add(z, y->n, y->vec);
! for (int i=0; i < z->n; i++, ap++) {
char tbuf[MAXPDSTRING];
switch (ap->a_type) {
***************
*** 2135,2144 ****
} else s = argv[at->a_w.w_index-1].a_w.w_symbol;
} else if (at->a_type == A_DOLLSYM) {
! if (!(s = binbuf_realizedollsym(at->a_w.w_symbol, argc, argv, 0))) {
error("$%s: not enough arguments supplied", at->a_w.w_symbol->s_name);
goto cleanup;
}
! }
! else s = atom_getsymbol(at);
target = s->s_thing;
/* IMPD: allows messages to unbound objects, via pointers */
--- 2131,2140 ----
} else s = argv[at->a_w.w_index-1].a_w.w_symbol;
} else if (at->a_type == A_DOLLSYM) {
! s = binbuf_realizedollsym(at->a_w.w_symbol, argc, argv, 0);
! if (!s) {
error("$%s: not enough arguments supplied", at->a_w.w_symbol->s_name);
goto cleanup;
}
! } else s = atom_getsymbol(at);
target = s->s_thing;
/* IMPD: allows messages to unbound objects, via pointers */
***************
*** 2387,2390 ****
--- 2383,2387 ----
!strcmp((a)->a_w.w_symbol->s_name, (b)))
+ #define GETF(i) atom_getfloatarg(i,natom,nextmess)
static t_binbuf *binbuf_convert(t_binbuf *oldb, int maxtopd) {
t_binbuf *newb = binbuf_new();
***************
*** 2430,2439 ****
stackdepth++;
nobj = 0;
! binbuf_addv(newb, "ssfffff;",
! gensym("#N"), gensym("canvas"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! atom_getfloatarg(4, natom, nextmess) - atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(5, natom, nextmess) - atom_getfloatarg(3, natom, nextmess), 10.);
}
}
--- 2427,2432 ----
stackdepth++;
nobj = 0;
! binbuf_addv(newb, "ssfffff;", gensym("#N"), gensym("canvas"), GETF(2), GETF(3),
! GETF(4)-GETF(2), GETF(5)-GETF(3), 10.);
}
}
***************
*** 2447,2453 ****
if (natom >= 7 && !strcmp(second, "newobj")
&& (ISSYMBOL(&nextmess[6], "patcher") || ISSYMBOL(&nextmess[6], "p"))) {
! binbuf_addv(newb, "ssffss;", gensym("#X"), gensym("restore"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
gensym("pd"), atom_getsymbolarg(7, natom, nextmess));
if (stackdepth) stackdepth--;
--- 2440,2444 ----
if (natom >= 7 && !strcmp(second, "newobj")
&& (ISSYMBOL(&nextmess[6], "patcher") || ISSYMBOL(&nextmess[6], "p"))) {
! binbuf_addv(newb, "ssffss;", gensym("#X"), gensym("restore"), GETF(2), GETF(3),
gensym("pd"), atom_getsymbolarg(7, natom, nextmess));
if (stackdepth) stackdepth--;
***************
*** 2482,2539 ****
nobj++;
} else if (!strcmp(second, "button")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! gensym("bng"));
nobj++;
} else if (!strcmp(second, "number") || !strcmp(second, "flonum")) {
! binbuf_addv(newb, "ssff;", gensym("#X"), gensym("floatatom"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess));
nobj++;
} else if (!strcmp(second, "slider")) {
! float inc = atom_getfloatarg(7, natom, nextmess);
if (inc <= 0) inc = 1;
binbuf_addv(newb, "ssffsffffffsssfffffffff;", gensym("#X"), gensym("obj"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), gensym("vsl"),
! atom_getfloatarg(4, natom, nextmess),
! atom_getfloatarg(5, natom, nextmess),
! atom_getfloatarg(6, natom, nextmess),
! atom_getfloatarg(6, natom, nextmess)
! + (atom_getfloatarg(5, natom, nextmess) - 1) * inc,
! 0., 0.,
! gensym("empty"), gensym("empty"), gensym("empty"),
0., -8., 0., 8., -262144., -1., -1., 0., 1.);
nobj++;
} else if (!strcmp(second, "toggle")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), gensym("tgl"));
nobj++;
} else if (!strcmp(second, "inlet")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! gensym((char *)(natom > 5 ? "inlet~" : "inlet")));
nobj++;
} else if (!strcmp(second, "outlet")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
gensym((char *)(natom > 5 ? "outlet~" : "outlet")));
nobj++;
} else if (!strcmp(second, "user")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"),
! atom_getfloatarg(3, natom, nextmess),
! atom_getfloatarg(4, natom, nextmess),
atom_getsymbolarg(2, natom, nextmess));
nobj++;
} else if (!strcmp(second, "connect") || !strcmp(second, "fasten")) {
binbuf_addv(newb, "ssffff;", gensym("#X"), gensym("connect"),
! nobj - atom_getfloatarg(2, natom, nextmess) - 1,
! atom_getfloatarg(3, natom, nextmess),
! nobj - atom_getfloatarg(4, natom, nextmess) - 1,
! atom_getfloatarg(5, natom, nextmess));
}
}
--- 2473,2507 ----
nobj++;
} else if (!strcmp(second, "button")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"), GETF(2), GETF(3), gensym("bng"));
nobj++;
} else if (!strcmp(second, "number") || !strcmp(second, "flonum")) {
! binbuf_addv(newb, "ssff;", gensym("#X"), gensym("floatatom"), GETF(2), GETF(3));
nobj++;
} else if (!strcmp(second, "slider")) {
! float inc = GETF(7);
if (inc <= 0) inc = 1;
binbuf_addv(newb, "ssffsffffffsssfffffffff;", gensym("#X"), gensym("obj"),
! GETF(2), GETF(3), gensym("vsl"), GETF(4), GETF(5), GETF(6), GETF(6)+(GETF(5)-1)*inc,
! 0., 0., gensym("empty"), gensym("empty"), gensym("empty"),
0., -8., 0., 8., -262144., -1., -1., 0., 1.);
nobj++;
} else if (!strcmp(second, "toggle")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"), GETF(2), GETF(3), gensym("tgl"));
nobj++;
} else if (!strcmp(second, "inlet")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"), GETF(2), GETF(3),
! gensym((char *)(natom > 5 ? "inlet~" : "inlet")));
nobj++;
} else if (!strcmp(second, "outlet")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"), GETF(2), GETF(3),
gensym((char *)(natom > 5 ? "outlet~" : "outlet")));
nobj++;
} else if (!strcmp(second, "user")) {
! binbuf_addv(newb, "ssffs;", gensym("#X"), gensym("obj"), GETF(3), GETF(4),
atom_getsymbolarg(2, natom, nextmess));
nobj++;
} else if (!strcmp(second, "connect") || !strcmp(second, "fasten")) {
binbuf_addv(newb, "ssffff;", gensym("#X"), gensym("connect"),
! nobj-GETF(2)-1, GETF(3), nobj-GETF(4)-1, GETF(5));
}
}
***************
*** 2549,2556 ****
nobj = 0;
binbuf_addv(newb, "ssffff;", gensym("#N"), gensym("vpatcher"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! atom_getfloatarg(4, natom, nextmess),
! atom_getfloatarg(5, natom, nextmess));
}
}
--- 2517,2521 ----
nobj = 0;
binbuf_addv(newb, "ssffff;", gensym("#N"), gensym("vpatcher"),
! GETF(2), GETF(3), GETF(4), GETF(5));
}
}
***************
*** 2558,2564 ****
if (natom >= 5 && !strcmp(second, "restore") && (ISSYMBOL (&nextmess[4], "pd"))) {
binbuf_addv(newb, "ss;", gensym("#P"), gensym("pop"));
! binbuf_addv(newb, "ssffffss;", gensym("#P"), gensym("newobj"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), 50., 1.,
gensym("patcher"), atom_getsymbolarg(5, natom, nextmess));
if (stackdepth) stackdepth--;
--- 2523,2527 ----
if (natom >= 5 && !strcmp(second, "restore") && (ISSYMBOL (&nextmess[4], "pd"))) {
binbuf_addv(newb, "ss;", gensym("#P"), gensym("pop"));
! binbuf_addv(newb, "ssffffss;", gensym("#P"), gensym("newobj"), GETF(2), GETF(3), 50., 1.,
gensym("patcher"), atom_getsymbolarg(5, natom, nextmess));
if (stackdepth) stackdepth--;
***************
*** 2568,2607 ****
t_symbol *classname = atom_getsymbolarg(4, natom, nextmess);
if (classname == gensym("inlet"))
! binbuf_addv(newb, "ssfff;", gensym("#P"), gensym("inlet"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), 15.);
else if (classname == gensym("inlet~"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("inlet"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), 15., 1.);
else if (classname == gensym("outlet"))
! binbuf_addv(newb, "ssfff;", gensym("#P"), gensym("outlet"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), 15.);
else if (classname == gensym("outlet~"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("outlet"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), 15., 1.);
else if (classname == gensym("bng"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("button"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! atom_getfloatarg(5, natom, nextmess), 0.);
else if (classname == gensym("tgl"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("toggle"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! atom_getfloatarg(5, natom, nextmess), 0.);
else if (classname == gensym("vsl"))
binbuf_addv(newb, "ssffffff;", gensym("#P"), gensym("slider"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess),
! atom_getfloatarg(5, natom, nextmess),
! atom_getfloatarg(6, natom, nextmess),
! (atom_getfloatarg(8, natom, nextmess) -
! atom_getfloatarg(7, natom, nextmess)) /
! (atom_getfloatarg(6, natom, nextmess) == 1? 1 :
! atom_getfloatarg(6, natom, nextmess) - 1),
! atom_getfloatarg(7, natom, nextmess));
else {
SETSYMBOL(outmess, gensym("#P"));
--- 2531,2550 ----
t_symbol *classname = atom_getsymbolarg(4, natom, nextmess);
if (classname == gensym("inlet"))
! binbuf_addv(newb, "ssfff;", gensym("#P"), gensym("inlet"), GETF(2), GETF(3), 15.);
else if (classname == gensym("inlet~"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("inlet"), GETF(2), GETF(3), 15., 1.);
else if (classname == gensym("outlet"))
! binbuf_addv(newb, "ssfff;", gensym("#P"), gensym("outlet"), GETF(2), GETF(3), 15.);
else if (classname == gensym("outlet~"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("outlet"), GETF(2), GETF(3), 15., 1.);
else if (classname == gensym("bng"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("button"), GETF(2), GETF(3), GETF(5), 0.);
else if (classname == gensym("tgl"))
! binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("toggle"), GETF(2), GETF(3), GETF(5), 0.);
else if (classname == gensym("vsl"))
binbuf_addv(newb, "ssffffff;", gensym("#P"), gensym("slider"),
! GETF(2), GETF(3), GETF(5), GETF(6),
! (GETF(8)-GETF(7)) / (GETF(6)==1?1:GETF(6)-1),
! GETF(7));
else {
SETSYMBOL(outmess, gensym("#P"));
***************
*** 2629,2640 ****
nobj++;
} else if (!strcmp(second, "floatatom")) {
! binbuf_addv(newb, "ssfff;", gensym("#P"), gensym("flonum"),
! atom_getfloatarg(2, natom, nextmess),
! atom_getfloatarg(3, natom, nextmess), 35);
nobj++;
} else if (!strcmp(second, "connect")) {
binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("connect"),
! nobj - atom_getfloatarg(2, natom, nextmess) - 1, atom_getfloatarg(3, natom, nextmess),
! nobj - atom_getfloatarg(4, natom, nextmess) - 1, atom_getfloatarg(5, natom, nextmess));
}
}
--- 2572,2580 ----
nobj++;
} else if (!strcmp(second, "floatatom")) {
! binbuf_addv(newb, "ssfff;", gensym("#P"), gensym("flonum"), GETF(2), GETF(3), 35);
nobj++;
} else if (!strcmp(second, "connect")) {
binbuf_addv(newb, "ssffff;", gensym("#P"), gensym("connect"),
! nobj-GETF(2)-1, GETF(3), nobj-GETF(4)-1, GETF(5));
}
}