Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28764
Modified Files: Tag: desiredata desire.h desire.c kernel.c m_pd.h Log Message: gradual evaluation
Index: m_pd.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v retrieving revision 1.4.4.11.2.33.2.20 retrieving revision 1.4.4.11.2.33.2.21 diff -C2 -d -r1.4.4.11.2.33.2.20 -r1.4.4.11.2.33.2.21 *** m_pd.h 31 Dec 2006 05:37:54 -0000 1.4.4.11.2.33.2.20 --- m_pd.h 31 Dec 2006 19:21:40 -0000 1.4.4.11.2.33.2.21 *************** *** 344,351 **** EXTERN t_atom *binbuf_getvec(t_binbuf *x); EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv); ! EXTERN int binbuf_read( t_binbuf *b, char *filename, char *dirname, int crflag); ! EXTERN int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int crflag); ! EXTERN int binbuf_read_via_path( t_binbuf *b, char *filename, char *dirname, int crflag); ! EXTERN int binbuf_write( t_binbuf *x, char *filename, char *dir, int crflag); EXTERN void binbuf_evalfile(t_symbol *name, t_symbol *dir); EXTERN t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av, int tonew); --- 344,351 ---- EXTERN t_atom *binbuf_getvec(t_binbuf *x); EXTERN void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv); ! EXTERN int binbuf_read( t_binbuf *b, char *filename, char *dirname, int flags); ! EXTERN int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int flags); ! EXTERN int binbuf_read_via_path( t_binbuf *b, char *filename, char *dirname, int flags); ! EXTERN int binbuf_write( t_binbuf *x, char *filename, char *dir, int flags); EXTERN void binbuf_evalfile(t_symbol *name, t_symbol *dir); EXTERN t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av, int tonew);
Index: kernel.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v retrieving revision 1.1.2.19 retrieving revision 1.1.2.20 diff -C2 -d -r1.1.2.19 -r1.1.2.20 *** kernel.c 31 Dec 2006 16:39:17 -0000 1.1.2.19 --- kernel.c 31 Dec 2006 19:21:40 -0000 1.1.2.20 *************** *** 1860,1870 **** }
! void pd_eval_text(char *t) { t_binbuf *x = binbuf_new(); ! char *end = t + strlen(t); while (t!=end) { t = sys_syntax ? binbuf_text_matju(x,t,end) : binbuf_text_miller(x,t,end); if (x->n && x->vec[x->n-1].a_type == A_SEMI) { - fprintf(stderr,"pd_eval_text semi n=%d\n",x->n); binbuf_eval(x,0,0,0); binbuf_clear(x); --- 1860,1869 ---- }
! void pd_eval_text(char *t, size_t size) { t_binbuf *x = binbuf_new(); ! char *end = t+size; while (t!=end) { t = sys_syntax ? binbuf_text_matju(x,t,end) : binbuf_text_miller(x,t,end); if (x->n && x->vec[x->n-1].a_type == A_SEMI) { binbuf_eval(x,0,0,0); binbuf_clear(x); *************** *** 2266,2270 **** }
! int binbuf_read(t_binbuf *b, char *filename, char *dirname, int crflag) { long length; char *buf; --- 2265,2269 ---- }
! int binbuf_read(t_binbuf *b, char *filename, char *dirname, int flags) { long length; char *buf; *************** *** 2287,2292 **** return 1; } ! if (crflag) for (int i=0; i<length; i++) if (buf[i]=='\n') buf[i] = ';'; ! binbuf_text(b, buf, length); t_freebytes(buf, length); close(fd); --- 2286,2291 ---- return 1; } ! if (flags&1) for (int i=0; i<length; i++) if (buf[i]=='\n') buf[i] = ';'; ! if (flags&2) pd_eval_text(buf,length); else binbuf_text(b, buf, length); t_freebytes(buf, length); close(fd); *************** *** 2295,2313 ****
/* read a binbuf from a file, via the search patch of a canvas */ ! int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int crflag) { char buf[MAXPDSTRING], *bufptr; int filedesc = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0) {error("%s: can't open", filename); return 1;} close(filedesc); ! return !!binbuf_read(b, bufptr, buf, crflag); }
/* old version */ ! int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, int crflag) { char buf[MAXPDSTRING], *bufptr; int filedesc = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0) {error("%s: can't open", filename); return 1;} close(filedesc); ! return !!binbuf_read(b, bufptr, buf, crflag); }
--- 2294,2312 ----
/* read a binbuf from a file, via the search patch of a canvas */ ! int binbuf_read_via_canvas(t_binbuf *b, char *filename, t_canvas *canvas, int flags) { char buf[MAXPDSTRING], *bufptr; int filedesc = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0) {error("%s: can't open", filename); return 1;} close(filedesc); ! return !!binbuf_read(b, bufptr, buf, flags); }
/* old version */ ! int binbuf_read_via_path(t_binbuf *b, char *filename, char *dirname, int flags) { char buf[MAXPDSTRING], *bufptr; int filedesc = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0); if (filedesc<0) {error("%s: can't open", filename); return 1;} close(filedesc); ! return !!binbuf_read(b, bufptr, buf, flags); }
*************** *** 2608,2615 **** void pd_doloadbang(void);
- /* LATER make this evaluate the file on-the-fly. */ /* LATER figure out how to log errors */ ! void binbuf_evalfile(t_symbol *name, t_symbol *dir) ! { t_binbuf *b = binbuf_new(); int import = !strcmp(name->s_name + strlen(name->s_name) - 4, ".pat"); --- 2607,2612 ---- void pd_doloadbang(void);
/* LATER figure out how to log errors */ ! void binbuf_evalfile(t_symbol *name, t_symbol *dir) { t_binbuf *b = binbuf_new(); int import = !strcmp(name->s_name + strlen(name->s_name) - 4, ".pat"); *************** *** 2617,2630 **** int dspstate = canvas_suspend_dsp(); glob_setfilename(0, name, dir); ! if (binbuf_read(b, name->s_name, dir->s_name, 0)) { ! perror(name->s_name); } else { ! if (import) { ! t_binbuf *newb = binbuf_convert(b, 1); ! binbuf_free(b); ! b = newb; ! } ! binbuf_eval(b, 0, 0, 0); } glob_setfilename(0, &s_, &s_); /* bug fix by Krzysztof Czaja */ binbuf_free(b); --- 2614,2626 ---- int dspstate = canvas_suspend_dsp(); glob_setfilename(0, name, dir); ! if (import) { ! if (binbuf_read(b, name->s_name, dir->s_name, 0)) {perror(name->s_name); goto bye;} ! t_binbuf *newb = binbuf_convert(b, 1); ! binbuf_free(b); ! b = newb; } else { ! if (binbuf_read(b, name->s_name, dir->s_name, 2)) perror(name->s_name); } + bye: glob_setfilename(0, &s_, &s_); /* bug fix by Krzysztof Czaja */ binbuf_free(b); *************** *** 2634,2646 **** void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir) { t_pd *x = 0; ! /* even though binbuf_evalfile appears to take care of dspstate, ! we have to do it again here, because canvas_startdsp() assumes ! that all toplevel canvases are visible. LATER check if this ! is still necessary -- probably not. */ ! int dspstate = canvas_suspend_dsp(); binbuf_evalfile(name, dir); while ((x != s__X.s_thing) && (x = s__X.s_thing)) ! vmess(x, gensym("pop"), "i", 1); pd_doloadbang(); canvas_resume_dsp(dspstate); --- 2630,2641 ---- void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir) { t_pd *x = 0; ! /* even though binbuf_evalfile appears to take care of dspstate, ! we have to do it again here, because canvas_startdsp() assumes ! that all toplevel canvases are visible. ! LATER: check if this is still necessary -- probably not. */ int dspstate = canvas_suspend_dsp(); binbuf_evalfile(name, dir); while ((x != s__X.s_thing) && (x = s__X.s_thing)) ! vmess(x, gensym("pop"), "i", 1); pd_doloadbang(); canvas_resume_dsp(dspstate);
Index: desire.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.h,v retrieving revision 1.1.2.49.2.20 retrieving revision 1.1.2.49.2.21 diff -C2 -d -r1.1.2.49.2.20 -r1.1.2.49.2.21 *** desire.h 31 Dec 2006 16:39:15 -0000 1.1.2.49.2.20 --- desire.h 31 Dec 2006 19:21:38 -0000 1.1.2.49.2.21 *************** *** 268,272 **** /* from kernel.c */ EXTERN void gobj_save(t_gobj *x, t_binbuf *b); ! EXTERN void pd_eval_text(char *t); EXTERN int sys_syntax;
--- 268,272 ---- /* from kernel.c */ EXTERN void gobj_save(t_gobj *x, t_binbuf *b); ! EXTERN void pd_eval_text(char *t, size_t size); EXTERN int sys_syntax;
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.217.2.99 retrieving revision 1.1.2.217.2.100 diff -C2 -d -r1.1.2.217.2.99 -r1.1.2.217.2.100 *** desire.c 31 Dec 2006 16:39:15 -0000 1.1.2.217.2.99 --- desire.c 31 Dec 2006 19:21:38 -0000 1.1.2.217.2.100 *************** *** 1441,1444 **** --- 1441,1446 ---- and float-arrays. */
+ void pd_eval_text2(char *s) {pd_eval_text(s,strlen(s));} + extern "C" void garray_init(void) { hack = 0; /* invisible canvases must be, uh, invisible */ *************** *** 1446,1450 **** t_binbuf *b = binbuf_new(); glob_setfilename(0, gensym("_float"), gensym(".")); ! pd_eval_text( "#N canvas 0 0 458 153 10;\n" "#X obj 43 31 struct _float_array array z float float style float linewidth float color;\n" --- 1448,1452 ---- t_binbuf *b = binbuf_new(); glob_setfilename(0, gensym("_float"), gensym(".")); ! pd_eval_text2( "#N canvas 0 0 458 153 10;\n" "#X obj 43 31 struct _float_array array z float float style float linewidth float color;\n" *************** *** 1452,1456 **** vmess(s__X.s_thing, gensym("pop"), "i", 0); glob_setfilename(0, gensym("_float_array"), gensym(".")); ! pd_eval_text( "#N canvas 0 0 458 153 10;\n" "#X obj 39 26 struct float float y;\n"); --- 1454,1458 ---- vmess(s__X.s_thing, gensym("pop"), "i", 0); glob_setfilename(0, gensym("_float_array"), gensym(".")); ! pd_eval_text2( "#N canvas 0 0 458 153 10;\n" "#X obj 39 26 struct float float y;\n"); *************** *** 2766,2770 **** else if (*format->s_name) pd_error(x,"canvas_read: unknown flag: %s", format->s_name);
! if (binbuf_read_via_path(b, filename->s_name, canvas_getdir(canvas)->s_name, cr)) { pd_error(x, "read failed"); binbuf_free(b); --- 2768,2773 ---- else if (*format->s_name) pd_error(x,"canvas_read: unknown flag: %s", format->s_name);
! /* flag 2 means eval continuously. this is required to autodetect the syntax */ ! if (binbuf_read_via_path(b, filename->s_name, canvas_getdir(canvas)->s_name, cr|2)) { pd_error(x, "read failed"); binbuf_free(b); *************** *** 2773,2782 **** if (wasvis) canvas_vis(canvas, 0); if (clearme) canvas_clear(x); ! canvas_readfrombinbuf(x, b, filename->s_name, 0); if (wasvis) canvas_vis(canvas, 1); binbuf_free(b); }
! static void canvas_read(t_canvas *x, t_symbol *filename, t_symbol *format) {canvas_doread(x,filename,format,1);} static void canvas_mergefile(t_canvas *x, t_symbol *filename, t_symbol *format) {canvas_doread(x,filename,format,0);}
--- 2776,2785 ---- if (wasvis) canvas_vis(canvas, 0); if (clearme) canvas_clear(x); ! /* canvas_readfrombinbuf(x, b, filename->s_name, 0); */ /* what's this for? */ if (wasvis) canvas_vis(canvas, 1); binbuf_free(b); }
! static void canvas_read( t_canvas *x, t_symbol *filename, t_symbol *format) {canvas_doread(x,filename,format,1);} static void canvas_mergefile(t_canvas *x, t_symbol *filename, t_symbol *format) {canvas_doread(x,filename,format,0);}
*************** *** 7352,7357 **** char *dirresult, char **nameresult, unsigned int size, int bin) { int fd = -1; - t_canvas *y; - /* first check if "name" is absolute (and if so, try to open) */ if (sys_open_absolute(name, ext, dirresult, nameresult, size, bin, &fd)) return fd; --- 7355,7358 ---- *************** *** 7359,7369 **** /* otherwise "name" is relative; start trying in directories named in this and parent environments */ ! for (y = x; y; y = y->owner) if (y->env) { t_namelist *nl; t_canvas *x2 = x; while (x2 && x2->owner) x2 = x2->owner; const char *dir = x2 ? canvas_getdir(x2)->s_name : "."; ! for (nl = y->env->path; nl; nl = nl->nl_next) ! { char realname[MAXPDSTRING]; strncpy(realname, dir, MAXPDSTRING); --- 7360,7369 ---- /* otherwise "name" is relative; start trying in directories named in this and parent environments */ ! for (t_canvas *y=x; y; y = y->owner) if (y->env) { t_namelist *nl; t_canvas *x2 = x; while (x2 && x2->owner) x2 = x2->owner; const char *dir = x2 ? canvas_getdir(x2)->s_name : "."; ! for (nl = y->env->path; nl; nl = nl->nl_next) { char realname[MAXPDSTRING]; strncpy(realname, dir, MAXPDSTRING);