[PD-cvs] pd/src g_all_guis.c,1.1.1.4.2.4.2.38,1.1.1.4.2.4.2.39 g_all_guis.h,1.1.1.4.2.2.2.33,1.1.1.4.2.2.2.34
Mathieu Bouchard
matju at users.sourceforge.net
Fri Aug 13 17:51:30 CEST 2004
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21022
Modified Files:
Tag: impd_0_37
g_all_guis.c g_all_guis.h
Log Message:
adding pd_saveargs() (written three months ago)
Index: g_all_guis.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_all_guis.h,v
retrieving revision 1.1.1.4.2.2.2.33
retrieving revision 1.1.1.4.2.2.2.34
diff -C2 -d -r1.1.1.4.2.2.2.33 -r1.1.1.4.2.2.2.34
*** g_all_guis.h 13 May 2004 14:37:20 -0000 1.1.1.4.2.2.2.33
--- g_all_guis.h 13 Aug 2004 15:51:28 -0000 1.1.1.4.2.2.2.34
***************
*** 145,146 ****
--- 145,147 ----
EXTERN /*bool*/ int iemgui_loadbang (/*t_iemgui*/ void *x);
EXTERN /*bool*/ int iemgui_forward (/*t_iemgui*/ void *x); /* was x_put_in2out */
+ EXTERN int pd_saveargs(t_binbuf *b, char *fmt, ...);
Index: g_all_guis.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_all_guis.c,v
retrieving revision 1.1.1.4.2.4.2.38
retrieving revision 1.1.1.4.2.4.2.39
diff -C2 -d -r1.1.1.4.2.4.2.38 -r1.1.1.4.2.4.2.39
*** g_all_guis.c 13 May 2004 14:37:20 -0000 1.1.1.4.2.4.2.38
--- g_all_guis.c 13 Aug 2004 15:51:28 -0000 1.1.1.4.2.4.2.39
***************
*** 164,168 ****
void iemgui_select(t_gobj *z, t_glist *glist, int selected)
! {t_iemgui *x = (t_iemgui *)z; sys_vgui("canvas_select_object .x%x %x %d; ",glist,z,selected); pd_changed(z);}
void iemgui_delete(t_gobj *z, t_glist *glist)
--- 164,168 ----
void iemgui_select(t_gobj *z, t_glist *glist, int selected)
! {sys_vgui("canvas_select_object .x%x %x %d; ",glist,z,selected); pd_changed(z);}
void iemgui_delete(t_gobj *z, t_glist *glist)
***************
*** 187,263 ****
*/
! int pd_scanargs(int argc, t_atom *argv, char *fmt, ...) {
! int i=0;
! int optional=0;
! va_list val;
! va_start(val,fmt);
! for (i=0; i<argc; i++) {
! switch (fmt[i]) {
! case 0 : goto err; /* too many args */
! case '*': goto break1; /* rest is any type */
! case 'F': case 'f': case 'd': case 'i': case 'c': case 'b': if (!IS_A_FLOAT(argv,i)) goto err;
! break;
! case 'S': case 's': if (!IS_A_SYMBOL(argv,i)) goto err;
! break;
! case '?': case 'a': break; /* skip */
! case ';': optional=1; break;
! default: post("WARNING: bug using pd_scanargs()"); goto err; /* WHAT? */
! }
}
! if (fmt[i]!=0 && !optional) goto err; /* not enough args */
break1:
! for (i=0; i<argc; i++) {
! /*fprintf(stderr,"i=%d fmt[i]=%c\n",i,fmt[i]);*/
! switch (fmt[i]) {
! case '*': case ';': goto break2;
! case '?': case 'F': case 'S': break; /* skip */
! case 'd': { /* sigh */
! double *p = va_arg(val,double*);
! *p = atom_getfloatarg(i,argc,argv);
! /*fprintf(stderr," getting double*=0x%08x, *=%f\n",p,*p);*/
! } break;
! case 'f': {
! float *p = va_arg(val,float*);
! *p = atom_getfloatarg(i,argc,argv);
! /*fprintf(stderr," getting float*=0x%08x, *=%f\n",p,*p);*/
! } break;
! case 'i': {
! int *p = va_arg(val, int*);
! *p = atom_getintarg(i,argc,argv);
! /*fprintf(stderr," getting int*=0x%08x, *=%d\n",p,*p);*/
! } break;
! case 'c': { /* colour, from IEM format to RGB 8:8:8 format */
! int *p = va_arg(val, int*);
! *p = convert_color(atom_getintarg(i,argc,argv));
! } break;
! case 'b': { /* 0 or 1 */
! int *p = va_arg(val, int*);
! *p = !!atom_getintarg(i,argc,argv);
! } break;
! case 's': {
! t_symbol **p = va_arg(val,t_symbol**);
! *p = atom_getsymbolarg(i,argc,argv);
! /*fprintf(stderr," getting t_symbol**=0x%08x, *=%s\n",p, (*p)->s_name);*/
! } break;
! case 'a': {
! t_symbol **p = va_arg(val,t_symbol**);
! if (IS_A_SYMBOL(argv,i))
! *p = atom_getsymbolarg(i,argc,argv);
! else if (IS_A_FLOAT(argv,i)) {
! char str[80];
! sprintf(str, "%d", (int)atom_getintarg(i,argc,argv));
! *p = gensym(str);
! } else *p = gensym("empty");
!
! } break;
! default: post("WARNING: bug using pd_scanargs()"); goto err; /* WHAT? */
! }
}
break2:
! va_end(val);
! return 1;
err:
! post("WARNING: pd_scanargs failed; fmt=%s, i=%d",fmt,i);
! return 0;
}
--- 187,277 ----
*/
! EXTERN int pd_scanargs(int argc, t_atom *argv, char *fmt, ...) {
! int i=0;
! int optional=0;
! va_list val;
! va_start(val,fmt);
! for (i=0; i<argc; i++) {
! switch (fmt[i]) {
! case 0 : goto err; /* too many args */
! case '*': goto break1; /* rest is any type */
! case 'F': case 'f': case 'd': case 'i': case 'c': case 'b':
! if (!IS_A_FLOAT(argv,i)) goto err; break;
! case 'S': case 's': if (!IS_A_SYMBOL(argv,i)) goto err; break;
! case '?': case 'a': break; /* skip */
! case ';': optional=1; break;
! default: post("WARNING: bug using pd_scanargs()"); goto err; /* WHAT? */
}
! }
! if (fmt[i]!=0 && !optional) goto err; /* not enough args */
break1:
! for (i=0; i<argc; i++) {
! switch (fmt[i]) {
! case '*': case ';': goto break2;
! case '?': case 'F': case 'S': break; /* skip */
! case 'd': *(va_arg(val,double*)) = atom_getfloatarg(i,argc,argv); break;
! case 'f': *(va_arg(val,float*)) = atom_getfloatarg(i,argc,argv); break;
! case 'i': *(va_arg(val, int*)) = atom_getintarg(i,argc,argv); break;
! case 'b': *(va_arg(val, int*)) = !!atom_getintarg(i,argc,argv); break; /* 0 or 1 */
! case 'c': { /* colour, from IEM format to RGB 8:8:8 format */
! *(va_arg(val, int*)) = convert_color(atom_getintarg(i,argc,argv));
! } break;
! case 's': *(va_arg(val,t_symbol**))=atom_getsymbolarg(i,argc,argv); break;
! case 'a': {
! t_symbol **p = va_arg(val,t_symbol**);
! if (IS_A_SYMBOL(argv,i))
! *p = atom_getsymbolarg(i,argc,argv);
! else if (IS_A_FLOAT(argv,i)) {
! char str[80];
! sprintf(str, "%d", (int)atom_getintarg(i,argc,argv));
! *p = gensym(str);
! } else *p = gensym("empty");
! } break;
! default: post("WARNING: bug using pd_scanargs()"); goto err; /* WHAT? */
}
+ }
break2:
! va_end(val);
! return 1;
err:
! post("WARNING: pd_scanargs failed; fmt=%s, i=%d",fmt,i);
! return 0;
! }
!
! /* exceptionally we're using pointers for each of the args even though
! we are saving. this is so we can copy+paste pd_scanargs lines almost
! directly. in the future, this could be merged with pd_scanargs and
! made declarative, by storing a list of &(0->x_blah) relative offsets
! into each struct...
! */
! EXTERN int pd_saveargs(t_binbuf *b, char *fmt, ...) {
! int i=0;
! t_atom a;
! va_list val;
! va_start(val,fmt);
! for (i=0; ; i++) {
! switch (fmt[i]) {
! case 0: goto break2;
! case ';': break; /* skip */
! case '?': case 'F': case 'S': break; /* skip */
! case 'd': SETFLOAT(&a,*(va_arg(val,double*))); break;
! case 'f': SETFLOAT(&a,*(va_arg(val,float *))); break;
! case 'i': SETFLOAT(&a,*(va_arg(val, int *))); break;
! case 'b': SETFLOAT(&a,!!*(va_arg(val,int *))); break;
! case 'c': /* colour, from IEM format to RGB 8:8:8 format */
! SETFLOAT(&a,convert_color2(*(va_arg(val, int *)))); break;
! case 'a':
! case 's': { t_symbol *s = *(va_arg(val,t_symbol**));
! SETSYMBOL(&a,s?s:gensym("empty")); } break;
! default: post("WARNING: bug using pd_saveargs()"); goto err; /* WHAT? */
! }
! binbuf_add(b,1,&a);
! }
! break2:
! va_end(val);
! return 1;
! err:
! post("WARNING: pd_saveargs failed; fmt=%s, i=%d",fmt,i);
! return 0;
}
***************
*** 283,287 ****
/*c->c_wb==&text_widgetbehavior ?
rtext_gettag(glist_findrtext(can,(t_text *)self)) :*/
! (unsigned)self,n,s);
binbuf_free(buf);
free(s);
--- 297,301 ----
/*c->c_wb==&text_widgetbehavior ?
rtext_gettag(glist_findrtext(can,(t_text *)self)) :*/
! (unsigned)self,n-1,s);
binbuf_free(buf);
free(s);
***************
*** 315,319 ****
i+=snprintf(buf+i,n-i,"\n");
if (i>=n) goto over;
- fprintf(stderr,"%s",buf);
sys_gui(buf);
return;
--- 329,332 ----
***************
*** 356,360 ****
EXTERN void iemgui_draw(t_iemgui *self, t_glist *glist, int mode) {
! fprintf(stderr,"self=%08x, self->te_binbuf=%08x\n",self,self->x_obj.te_binbuf);
if (!self->x_obj.te_binbuf) {
pd_error(self,"trying to upload without binbuf");
--- 369,373 ----
EXTERN void iemgui_draw(t_iemgui *self, t_glist *glist, int mode) {
! //fprintf(stderr,"self=%08x, self->te_binbuf=%08x\n",self,self->x_obj.te_binbuf);
if (!self->x_obj.te_binbuf) {
pd_error(self,"trying to upload without binbuf");
More information about the Pd-cvs
mailing list