Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14570
Modified Files:
Tag: desiredata
builtins.c
Log Message:
interleaved code of [i] [f] [symbol] [bang]; interleaved code of [s] [r]; interleaved code of [timer] [cputime] [realtime]
Index: builtins.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins.c,v
retrieving revision 1.1.2.42
retrieving revision 1.1.2.43
diff -C2 -d -r1.1.2.42 -r1.1.2.43
*** builtins.c 20 Jul 2007 08:10:55 -0000 1.1.2.42
--- builtins.c 20 Jul 2007 08:34:16 -0000 1.1.2.43
***************
*** 869,875 ****
LARGE_INTEGER kerneltime;
LARGE_INTEGER usertime;
! int warned;
#endif
};
static void cputime_bang(t_cputime *x) {
#ifdef UNISTD
--- 869,879 ----
LARGE_INTEGER kerneltime;
LARGE_INTEGER usertime;
! bool warned;
#endif
};
+ static t_class *realtime_class; struct t_realtime : t_object {double setrealtime;};
+ static t_class *timer_class; struct t_timer : t_object {double settime;};
+
+
static void cputime_bang(t_cputime *x) {
#ifdef UNISTD
***************
*** 905,908 ****
--- 909,918 ----
outlet_float(x->outlet, elapsedcpu);
}
+
+ static void realtime_bang(t_realtime *x) {x->setrealtime = sys_getrealtime();}
+ static void timer_bang(t_timer *x ) {x->settime = clock_getsystime();}
+ static void realtime_bang2(t_realtime *x) {outlet_float(x->outlet, (sys_getrealtime() - x->setrealtime) * 1000.);}
+ static void timer_bang2(t_timer *x ) {outlet_float(x->outlet, clock_gettimesince(x->settime));}
+
static void *cputime_new() {
t_cputime *x = (t_cputime *)pd_new(cputime_class);
***************
*** 915,932 ****
return x;
}
- static void cputime_setup() {
- cputime_class = class_new2("cputime",cputime_new,0,sizeof(t_cputime),0,"");
- class_addbang(cputime_class, cputime_bang);
- class_addmethod2(cputime_class, cputime_bang2, "bang2","");
- }
-
- static t_class *realtime_class;
- struct t_realtime : t_object {double setrealtime;};
- static void realtime_bang(t_realtime *x) {
- x->setrealtime = sys_getrealtime();
- }
- static void realtime_bang2(t_realtime *x) {
- outlet_float(x->outlet, (sys_getrealtime() - x->setrealtime) * 1000.);
- }
static void *realtime_new() {
t_realtime *x = (t_realtime *)pd_new(realtime_class);
--- 925,928 ----
***************
*** 936,943 ****
return x;
}
! static void realtime_setup() {
realtime_class = class_new2("realtime",realtime_new,0,sizeof(t_realtime),0,"");
class_addbang(realtime_class, realtime_bang);
! class_addmethod2(realtime_class, realtime_bang2, "bang2","");
}
--- 932,952 ----
return x;
}
! static void *timer_new(t_floatarg f) {
! t_timer *x = (t_timer *)pd_new(timer_class);
! timer_bang(x);
! outlet_new(x, gensym("float"));
! inlet_new(x, x, gensym("bang"), gensym("bang2"));
! return x;
! }
! static void timer_setup() {
realtime_class = class_new2("realtime",realtime_new,0,sizeof(t_realtime),0,"");
+ cputime_class = class_new2("cputime", cputime_new, 0,sizeof(t_cputime), 0,"");
+ timer_class = class_new2("timer", timer_new, 0,sizeof(t_timer), 0,"F");
class_addbang(realtime_class, realtime_bang);
! class_addbang(cputime_class, cputime_bang);
! class_addbang(timer_class, timer_bang);
! class_addmethod2(realtime_class,realtime_bang2,"bang2","");
! class_addmethod2(cputime_class, cputime_bang2, "bang2","");
! class_addmethod2(timer_class, timer_bang2, "bang2","");
}
***************
*** 1143,1194 ****
}
! static t_class *pdint_class;
! struct t_pdint : t_object {t_float f;};
! static void *pdint_new(t_floatarg f) {
! t_pdint *x = (t_pdint *)pd_new(pdint_class);
! x->f = f;
! outlet_new(x, &s_float);
! floatinlet_new(x, &x->f);
! return x;
! }
static void pdint_bang(t_pdint *x) {outlet_float(x->outlet, (t_float)(int)x->f);}
static void pdint_float(t_pdint *x, t_float f) {x->f = f; pdint_bang(x);}
- void pdint_setup() {
- pdint_class = class_new2("int",pdint_new,0,sizeof(t_pdint),0,"F");
- class_addcreator2("i",pdint_new,"F");
- class_addbang(pdint_class, pdint_bang);
- class_addfloat(pdint_class, pdint_float);
- }
- static t_class *pdfloat_class;
- struct t_pdfloat : t_object {t_float f;};
- static void *pdfloat_new(t_pd *dummy, t_float f) {
- t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class);
- x->f = f;
- outlet_new(x, &s_float);
- floatinlet_new(x, &x->f);
- pd_set_newest((t_pd *)x);
- return x;
- }
- static void *pdfloat_new2(t_floatarg f) {return pdfloat_new(0, f);}
static void pdfloat_bang(t_pdfloat *x) {outlet_float(x->outlet, x->f);}
static void pdfloat_float(t_pdfloat *x, t_float f) {x->f=f; pdfloat_bang(x);}
- void pdfloat_setup() {
- pdfloat_class = class_new2("float",pdfloat_new,0,sizeof(t_pdfloat),0,"F");
- class_addcreator2("f",pdfloat_new2,"F");
- class_addbang(pdfloat_class, pdfloat_bang);
- class_addfloat(pdfloat_class, pdfloat_float);
- }
- static t_class *pdsymbol_class;
- struct t_pdsymbol : t_object {t_symbol *s;};
- static void *pdsymbol_new(t_pd *dummy, t_symbol *s) {
- t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class);
- x->s = s;
- outlet_new(x, &s_symbol);
- symbolinlet_new(x, &x->s);
- pd_set_newest((t_pd *)x);
- return x;
- }
static void pdsymbol_bang(t_pdsymbol *x) {outlet_symbol(x->outlet, x->s);}
static void pdsymbol_symbol( t_pdsymbol *x, t_symbol *s ) {x->s=s; pdsymbol_bang(x);}
--- 1152,1166 ----
}
! static t_class *pdint_class; struct t_pdint : t_object {t_float f;};
! static t_class *pdfloat_class; struct t_pdfloat : t_object {t_float f;};
! static t_class *pdsymbol_class; struct t_pdsymbol : t_object {t_symbol *s;};
! static t_class *bang_class; struct t_bang : t_object {};
!
static void pdint_bang(t_pdint *x) {outlet_float(x->outlet, (t_float)(int)x->f);}
static void pdint_float(t_pdint *x, t_float f) {x->f = f; pdint_bang(x);}
static void pdfloat_bang(t_pdfloat *x) {outlet_float(x->outlet, x->f);}
static void pdfloat_float(t_pdfloat *x, t_float f) {x->f=f; pdfloat_bang(x);}
static void pdsymbol_bang(t_pdsymbol *x) {outlet_symbol(x->outlet, x->s);}
static void pdsymbol_symbol( t_pdsymbol *x, t_symbol *s ) {x->s=s; pdsymbol_bang(x);}
***************
*** 1207,1220 ****
}
#endif
- void pdsymbol_setup() {
- pdsymbol_class = class_new2("symbol",pdsymbol_new,0,sizeof(t_pdsymbol),0,"S");
- class_addbang(pdsymbol_class, pdsymbol_bang);
- class_addsymbol(pdsymbol_class, pdsymbol_symbol);
- class_addanything(pdsymbol_class, pdsymbol_anything);
- }
! /* -------------------------- bang ------------------------------ */
! static t_class *bang_class;
! struct t_bang : t_object {};
static void *bang_new(t_pd *dummy) {
t_bang *x = (t_bang *)pd_new(bang_class);
--- 1179,1201 ----
}
#endif
! static void *pdint_new(t_floatarg f) {
! t_pdint *x = (t_pdint *)pd_new(pdint_class);
! x->f = f; outlet_new(x, &s_float); floatinlet_new(x, &x->f);
! return x;
! }
! static void *pdfloat_new(t_pd *dummy, t_float f) {
! t_pdfloat *x = (t_pdfloat *)pd_new(pdfloat_class);
! x->f = f; outlet_new(x, &s_float); floatinlet_new(x, &x->f);
! pd_set_newest((t_pd *)x);
! return x;
! }
! static void *pdfloat_new2(t_floatarg f) {return pdfloat_new(0, f);}
! static void *pdsymbol_new(t_pd *dummy, t_symbol *s) {
! t_pdsymbol *x = (t_pdsymbol *)pd_new(pdsymbol_class);
! x->s = s; outlet_new(x, &s_symbol);symbolinlet_new(x, &x->s);
! pd_set_newest((t_pd *)x);
! return x;
! }
static void *bang_new(t_pd *dummy) {
t_bang *x = (t_bang *)pd_new(bang_class);
***************
*** 1225,1229 ****
static void *bang_new2(t_bang f) {return bang_new(0);}
static void bang_bang(t_bang *x) {outlet_bang(x->outlet);}
! void bang_setup() {
t_class *c = bang_class = class_new2("bang",bang_new,0,sizeof(t_bang),0,"");
class_addcreator2("b",bang_new2,"");
--- 1206,1223 ----
static void *bang_new2(t_bang f) {return bang_new(0);}
static void bang_bang(t_bang *x) {outlet_bang(x->outlet);}
!
! void misc_setup() {
! pdint_class = class_new2("int",pdint_new,0,sizeof(t_pdint),0,"F");
! class_addcreator2("i",pdint_new,"F");
! class_addbang(pdint_class, pdint_bang);
! class_addfloat(pdint_class, pdint_float);
! pdfloat_class = class_new2("float",pdfloat_new,0,sizeof(t_pdfloat),0,"F");
! class_addcreator2("f",pdfloat_new2,"F");
! class_addbang(pdfloat_class, pdfloat_bang);
! class_addfloat(pdfloat_class, pdfloat_float);
! pdsymbol_class = class_new2("symbol",pdsymbol_new,0,sizeof(t_pdsymbol),0,"S");
! class_addbang(pdsymbol_class, pdsymbol_bang);
! class_addsymbol(pdsymbol_class, pdsymbol_symbol);
! class_addanything(pdsymbol_class, pdsymbol_anything);
t_class *c = bang_class = class_new2("bang",bang_new,0,sizeof(t_bang),0,"");
class_addcreator2("b",bang_new2,"");
***************
*** 1235,1244 ****
}
! /* -------------------- send ------------------------------ */
- static t_class *send_class;
- struct t_send : t_object {
- t_symbol *sym;
- };
static void send_bang( t_send *x) { if (x->sym->thing) pd_bang(x->sym->thing);}
static void send_float( t_send *x, t_float f) { if (x->sym->thing) pd_float(x->sym->thing,f);}
--- 1229,1237 ----
}
! /* -------------------- send & receive ------------------------------ */
!
! static t_class * send_class; struct t_send : t_object {t_symbol *sym;};
! static t_class *receive_class; struct t_receive : t_object {t_symbol *sym;};
static void send_bang( t_send *x) { if (x->sym->thing) pd_bang(x->sym->thing);}
static void send_float( t_send *x, t_float f) { if (x->sym->thing) pd_float(x->sym->thing,f);}
***************
*** 1247,1271 ****
static void send_list( t_send *x, t_symbol *s, int argc, t_atom *argv) {if (x->sym->thing) pd_list(x->sym->thing,s,argc,argv);}
static void send_anything(t_send *x, t_symbol *s, int argc, t_atom *argv) {if (x->sym->thing) typedmess(x->sym->thing,s,argc,argv);}
- static void *send_new(t_symbol *s) {
- t_send *x = (t_send *)pd_new(send_class);
- if (!*s->name) symbolinlet_new(x, &x->sym);
- x->sym = s;
- return x;
- }
- static void send_setup() {
- t_class *c = send_class = class_new2("send",send_new,0,sizeof(t_send),0,"S");
- class_addcreator2("s",send_new,"S");
- class_addbang(c, send_bang);
- class_addfloat(c, send_float);
- class_addsymbol(c, send_symbol);
- class_addpointer(c, send_pointer);
- class_addlist(c, send_list);
- class_addanything(c, send_anything);
- }
- static t_class *receive_class;
- struct t_receive : t_object {
- t_symbol *sym;
- };
static void receive_bang( t_receive *x) { outlet_bang(x->outlet);}
static void receive_float( t_receive *x, t_float f) { outlet_float(x->outlet, f);}
--- 1240,1244 ----
***************
*** 1282,1287 ****
}
static void receive_free(t_receive *x) {pd_unbind(x, x->sym);}
! static void receive_setup() {
! t_class *c = receive_class = class_new2("receive",receive_new,receive_free,sizeof(t_receive),CLASS_NOINLET,"S");
class_addcreator2("r",receive_new,"S");
class_addbang(c, receive_bang);
--- 1255,1276 ----
}
static void receive_free(t_receive *x) {pd_unbind(x, x->sym);}
!
! static void *send_new(t_symbol *s) {
! t_send *x = (t_send *)pd_new(send_class);
! if (!*s->name) symbolinlet_new(x, &x->sym);
! x->sym = s;
! return x;
! }
! static void sendreceive_setup() {
! t_class *c;
! c = send_class = class_new2("send",send_new,0,sizeof(t_send),0,"S");
! class_addcreator2("s",send_new,"S");
! class_addbang(c, send_bang);
! class_addfloat(c, send_float);
! class_addsymbol(c, send_symbol);
! class_addpointer(c, send_pointer);
! class_addlist(c, send_list);
! class_addanything(c, send_anything);
! c = receive_class = class_new2("receive",receive_new,receive_free,sizeof(t_receive),CLASS_NOINLET,"S");
class_addcreator2("r",receive_new,"S");
class_addbang(c, receive_bang);
***************
*** 2721,2745 ****
}
- static t_class *timer_class;
- struct t_timer : t_object {double settime;};
- static void timer_bang(t_timer *x) {
- x->settime = clock_getsystime();
- }
- static void timer_bang2(t_timer *x) {
- outlet_float(x->outlet, clock_gettimesince(x->settime));
- }
- static void *timer_new(t_floatarg f) {
- t_timer *x = (t_timer *)pd_new(timer_class);
- timer_bang(x);
- outlet_new(x, gensym("float"));
- inlet_new(x, x, gensym("bang"), gensym("bang2"));
- return x;
- }
- static void timer_setup() {
- timer_class = class_new2("timer",timer_new,0,sizeof(t_timer),0,"F");
- class_addbang(timer_class, timer_bang);
- class_addmethod2(timer_class,timer_bang2,"bang2","");
- }
-
static t_class *pipe_class;
struct t_hang2 {
--- 2710,2713 ----
***************
*** 2764,2769 ****
t_gpointer *gp;
int nptr = 0;
! int i;
! float deltime;
if (argc) {
if (argv[argc-1].a_type != A_FLOAT) {
--- 2732,2736 ----
t_gpointer *gp;
int nptr = 0;
! float deltime=0;
if (argc) {
if (argv[argc-1].a_type != A_FLOAT) {
***************
*** 2771,2779 ****
atom_ostream(&argv[argc-1], os);
post("pipe: %s: bad time delay value", os.str().data());
- deltime = 0;
} else deltime = argv[argc-1].a_float;
argc--;
}
- else deltime = 0;
if (!argc) {
argv = &defarg;
--- 2738,2744 ----
***************
*** 2783,2786 ****
--- 2748,2752 ----
x->n = argc;
vec = x->vec = (t_atom *)getbytes(argc * sizeof(*x->vec));
+ int i;
for (i = argc, ap = argv; i--; ap++) if (ap->a_type == A_SYMBOL && *ap->a_symbol->name == 'p') nptr++;
gp = x->gp = (t_gpointer *)t_getbytes(nptr * sizeof(*gp));
***************
*** 2793,2801 ****
} else if (ap->a_type == A_SYMBOL) {
char c = *ap->a_symbol->name;
! if (c == 's') {
SETSYMBOL(vp, &s_symbol);
outlet_new(x, &s_symbol);
if (i) symbolinlet_new(x, &vp->a_symbol);
! } else if (c == 'p') {
vp->a_type = A_POINTER;
vp->a_pointer = gp;
--- 2759,2767 ----
} else if (ap->a_type == A_SYMBOL) {
char c = *ap->a_symbol->name;
! if (c=='s') {
SETSYMBOL(vp, &s_symbol);
outlet_new(x, &s_symbol);
if (i) symbolinlet_new(x, &vp->a_symbol);
! } else if (c=='p') {
vp->a_type = A_POINTER;
vp->a_pointer = gp;
***************
*** 2804,2813 ****
if (i) pointerinlet_new(x, gp);
gp++;
! } else {
! if (c != 'f') error("pack: %s: bad type", ap->a_symbol->name);
SETFLOAT(vp,0);
outlet_new(x, &s_float);
if (i) floatinlet_new(x, &vp->a_float);
! }
}
}
--- 2770,2778 ----
if (i) pointerinlet_new(x, gp);
gp++;
! } else if (c=='f') {
SETFLOAT(vp,0);
outlet_new(x, &s_float);
if (i) floatinlet_new(x, &vp->a_float);
! } else error("pack: %s: bad type", ap->a_symbol->name);
}
}
***************
*** 3029,3034 ****
loadbang_setup();
namecanvas_setup();
- cputime_setup();
- realtime_setup();
print_setup();
delay_setup();
--- 2994,2997 ----
***************
*** 3037,3046 ****
timer_setup();
pipe_setup();
! pdint_setup();
! pdfloat_setup();
! pdsymbol_setup();
! bang_setup();
! send_setup();
! receive_setup();
select_setup();
route_setup();
--- 3000,3005 ----
timer_setup();
pipe_setup();
! misc_setup();
! sendreceive_setup();
select_setup();
route_setup();