[PD-cvs] pd/src builtins.c,1.1.2.21,1.1.2.22
Mathieu Bouchard
matju at users.sourceforge.net
Sat Jun 30 04:22:31 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4655
Modified Files:
Tag: desiredata
builtins.c
Log Message:
new object class [unpost]
Index: builtins.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v
retrieving revision 1.1.2.21
retrieving revision 1.1.2.22
diff -C2 -d -r1.1.2.21 -r1.1.2.22
*** builtins.c 28 Jun 2007 22:56:53 -0000 1.1.2.21
--- builtins.c 30 Jun 2007 02:22:29 -0000 1.1.2.22
***************
*** 2887,2893 ****
static t_class *timer_class;
! struct t_timer : t_object {
! double settime;
! };
static void timer_bang(t_timer *x) {
x->settime = clock_getsystime();
--- 2887,2891 ----
static t_class *timer_class;
! struct t_timer : t_object {double settime;};
static void timer_bang(t_timer *x) {
x->settime = clock_getsystime();
***************
*** 3076,3079 ****
--- 3074,3126 ----
}
+ static t_class *unpost_class;
+ struct t_unpost : t_object {
+ t_outlet *o0,*o1;
+ char buf[MAXPDSTRING];
+ };
+ static t_unpost *current_unpost;
+
+ void *unpost_new (t_symbol *s) {
+ t_unpost *x = (t_unpost *)pd_new(unpost_class);
+ x->o0 = outlet_new(x,&s_symbol);
+ x->o1 = outlet_new(x,&s_symbol);
+ return x;
+ }
+ extern t_printhook sys_printhook;
+ void unpost_printhook (const char *s) {
+ char *b = current_unpost->buf;
+ size_t n = strlen(b);
+ snprintf(b+n,MAXPDSTRING-n,"%s",s);
+ b[MAXPDSTRING-1]=0;
+ char *p;
+ for (;;) {
+ p = strchr(b+n,'\n');
+ if (!p) break;
+ fprintf(stderr,"pos=%d len=%d\n",b-current_unpost->buf,p-b);
+ fprintf(stderr,"data=%.*s\n",p-b,b);
+ t_symbol *s = gensym2(b,p-b);
+ fprintf(stderr," sym=%.*s\n",s->s_name);
+ outlet_symbol(current_unpost->o1,s);
+ b=p+1;
+ }
+ char *q = strdup(b); /* well i could use memmove, but i'm not supposed to use strcpy because of overlap */
+ strcpy(current_unpost->buf,q);
+ free(q);
+ }
+ void unpost_anything (t_unpost *x, t_symbol *s, int argc, t_atom *argv) {
+ t_printhook backup1 = sys_printhook;
+ t_unpost *backup2 = current_unpost;
+ sys_printhook = unpost_printhook;
+ current_unpost = x;
+ x->buf[0] = 0;
+ outlet_anything(x->o0,s,argc,argv);
+ sys_printhook = backup1;
+ current_unpost = backup2;
+ }
+
+ static void unpost_setup() {
+ unpost_class = class_new2("unpost",unpost_new,0,sizeof(t_unpost),0,"");
+ class_addanything(unpost_class, unpost_anything);
+ }
void builtins_setup() {
***************
*** 3152,3154 ****
--- 3199,3202 ----
arithmetic_setup();
midi_setup();
+ unpost_setup();
}
More information about the Pd-cvs
mailing list