Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13034
Modified Files: Tag: desiredata kernel.c Log Message: removed i_ and iu_ in t_inlet structs
Index: kernel.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/kernel.c,v retrieving revision 1.1.2.22 retrieving revision 1.1.2.23 diff -C2 -d -r1.1.2.22 -r1.1.2.23 *** kernel.c 3 Jan 2007 04:12:13 -0000 1.1.2.22 --- kernel.c 3 Jan 2007 04:25:27 -0000 1.1.2.23 *************** *** 41,47 ****
void *getbytes(size_t nbytes) { - void *ret; if (nbytes < 1) nbytes = 1; ! ret = (void *)calloc(nbytes, 1); if (!ret) post("pd: getbytes() failed -- out of memory"); return ret; --- 41,46 ----
void *getbytes(size_t nbytes) { if (nbytes < 1) nbytes = 1; ! void *ret = (void *)calloc(nbytes, 1); if (!ret) post("pd: getbytes() failed -- out of memory"); return ret; *************** *** 49,54 ****
void *copybytes(void *src, size_t nbytes) { ! void *ret; ! ret = getbytes(nbytes); if (nbytes) memcpy(ret, src, nbytes); return ret; --- 48,52 ----
void *copybytes(void *src, size_t nbytes) { ! void *ret = getbytes(nbytes); if (nbytes) memcpy(ret, src, nbytes); return ret; *************** *** 111,116 **** /* TB: copy to aligned vector memory */ void *copyalignedbytes(void *src, size_t nbytes) { ! void *ret; ! ret = getalignedbytes(nbytes); if (nbytes) memcpy(ret, src, nbytes); return ret; --- 109,113 ---- /* TB: copy to aligned vector memory */ void *copyalignedbytes(void *src, size_t nbytes) { ! void *ret = getalignedbytes(nbytes); if (nbytes) memcpy(ret, src, nbytes); return ret; *************** *** 125,130 **** } t_hashentry;
! struct _hash { ! t_pd pd; long capa; long size; --- 122,126 ---- } t_hashentry;
! struct _hash : t_pd { long capa; long size; *************** *** 218,238 **** safe to return if there's an error. */
! t_float atom_getfloat(t_atom *a) { ! return a->a_type==A_FLOAT ? a->a_float : 0; ! } ! ! t_int atom_getint(t_atom *a) {return (t_int)atom_getfloat(a);} ! ! /* why return &s_float here? */ ! t_symbol *atom_getsymbol(t_atom *a) { ! return a->a_type==A_SYMBOL ? a->a_symbol : &s_float; ! }
t_symbol *atom_gensym(t_atom *a) { /* this works better for graph labels */ - char buf[30]; if (a->a_type == A_SYMBOL) return a->a_symbol; ! else if (a->a_type == A_FLOAT) sprintf(buf, "%g", a->a_float); ! else strcpy(buf, "???"); ! return gensym(buf); }
--- 214,225 ---- safe to return if there's an error. */
! t_float atom_getfloat( t_atom *a) {return a->a_type==A_FLOAT ? a->a_float : 0;} ! t_int atom_getint( t_atom *a) {return (t_int)atom_getfloat(a);} ! t_symbol *atom_getsymbol(t_atom *a) {return a->a_type==A_SYMBOL ? a->a_symbol : &s_symbol;}
t_symbol *atom_gensym(t_atom *a) { /* this works better for graph labels */ if (a->a_type == A_SYMBOL) return a->a_symbol; ! if (a->a_type == A_FLOAT) {char buf[30]; sprintf(buf, "%g", a->a_float); return gensym(buf);} ! return gensym("???"); }
*************** *** 514,539 ****
union inletunion { ! t_symbol *iu_symto; ! t_gpointer *iu_pointerslot; ! t_float *iu_floatslot; ! t_symbol **iu_symslot; ! t_sample iu_floatsignalvalue; };
! struct _inlet { ! t_pd i_pd; ! struct _inlet *i_next; ! t_object *i_owner; ! t_pd *i_dest; ! t_symbol *i_symfrom; ! union inletunion i_un; ! t_symbol* i_tip; };
- #define i_symto i_un.iu_symto - #define i_pointerslot i_un.iu_pointerslot - #define i_floatslot i_un.iu_floatslot - #define i_symslot i_un.iu_symslot - static t_class *inlet_class, *pointerinlet_class, *floatinlet_class, *symbolinlet_class;
--- 501,520 ----
union inletunion { ! t_symbol *symto; ! t_gpointer *pointerslot; ! t_float *floatslot; ! t_symbol **symslot; ! t_sample floatsignalvalue; };
! struct _inlet : t_pd { ! struct _inlet *next; ! t_object *owner; ! t_pd *dest; ! t_symbol *symfrom; ! union inletunion u; ! t_symbol* tip; };
static t_class *inlet_class, *pointerinlet_class, *floatinlet_class, *symbolinlet_class;
*************** *** 549,554 **** t_inlet *y = owner->ob_inlet, *y2; if (y) { ! while ((y2 = y->i_next)) y = y2; ! y->i_next = x; } else owner->ob_inlet = x; } --- 530,535 ---- t_inlet *y = owner->ob_inlet, *y2; if (y) { ! while ((y2 = y->next)) y = y2; ! y->next = x; } else owner->ob_inlet = x; } *************** *** 556,565 **** t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1, t_symbol *s2) { t_inlet *x = (t_inlet *)pd_new(inlet_class); ! x->i_owner = owner; ! x->i_dest = dest; ! if (s1 == &s_signal) x->i_un.iu_floatsignalvalue = 0; else x->i_symto = s2; ! x->i_symfrom = s1; ! x->i_next = 0; ! x->i_tip = gensym("?"); object_append_inlet(owner,x); return x; --- 537,546 ---- t_inlet *inlet_new(t_object *owner, t_pd *dest, t_symbol *s1, t_symbol *s2) { t_inlet *x = (t_inlet *)pd_new(inlet_class); ! x->owner = owner; ! x->dest = dest; ! if (s1 == &s_signal) x->u.floatsignalvalue = 0; else x->u.symto = s2; ! x->symfrom = s1; ! x->next = 0; ! x->tip = gensym("?"); object_append_inlet(owner,x); return x; *************** *** 568,585 **** t_inlet *signalinlet_new(t_object *owner, t_float f) { t_inlet *x = inlet_new(owner, owner, &s_signal, &s_signal); ! x->i_un.iu_floatsignalvalue = f; return x; }
static void inlet_wrong(t_inlet *x, t_symbol *s) { ! pd_error(x->i_owner, "inlet: expected '%s' but got '%s'", x->i_symfrom->s_name, s->s_name); }
! void inlet_settip(t_inlet* i,t_symbol* s) {i->i_tip = s;}
char* inlet_tip(t_inlet* i,int num) { if (num < 0) return "???"; ! while (num-- && i) i = i->i_next; ! if (i && i->i_tip) return i->i_tip->s_name; return "?"; } --- 549,566 ---- t_inlet *signalinlet_new(t_object *owner, t_float f) { t_inlet *x = inlet_new(owner, owner, &s_signal, &s_signal); ! x->u.floatsignalvalue = f; return x; }
static void inlet_wrong(t_inlet *x, t_symbol *s) { ! pd_error(x->owner, "inlet: expected '%s' but got '%s'", x->symfrom->s_name, s->s_name); }
! void inlet_settip(t_inlet* i,t_symbol* s) {i->tip = s;}
char* inlet_tip(t_inlet* i,int num) { if (num < 0) return "???"; ! while (num-- && i) i = i->next; ! if (i && i->tip) return i->tip->s_name; return "?"; } *************** *** 587,632 **** /* LATER figure out how to make these efficient: */ static void inlet_bang(t_inlet *x) { ! if (x->i_symfrom == &s_bang) pd_vmess(x->i_dest, x->i_symto, ""); ! else if (!x->i_symfrom) pd_bang(x->i_dest); else inlet_wrong(x, &s_bang); } static void inlet_pointer(t_inlet *x, t_gpointer *gp) { ! if (x->i_symfrom == &s_pointer) pd_vmess(x->i_dest, x->i_symto, "p", gp); ! else if (!x->i_symfrom) pd_pointer(x->i_dest, gp); else inlet_wrong(x, &s_pointer); } static void inlet_float(t_inlet *x, t_float f) { ! if (x->i_symfrom == &s_float) pd_vmess(x->i_dest, x->i_symto, "f", (t_floatarg)f); ! else if (x->i_symfrom == &s_signal) x->i_un.iu_floatsignalvalue = f; ! else if (!x->i_symfrom) pd_float(x->i_dest, f); else inlet_wrong(x, &s_float); }
static void inlet_symbol(t_inlet *x, t_symbol *s) { ! if (x->i_symfrom == &s_symbol) pd_vmess(x->i_dest, x->i_symto, "s", s); ! else if (!x->i_symfrom) pd_symbol(x->i_dest, s); else inlet_wrong(x, &s_symbol); }
static void inlet_list(t_inlet *x, t_symbol *s, int argc, t_atom *argv) { ! if (x->i_symfrom == &s_list || x->i_symfrom == &s_float ! || x->i_symfrom == &s_symbol || x->i_symfrom == &s_pointer) ! typedmess(x->i_dest, x->i_symto, argc, argv); ! else if (!x->i_symfrom) pd_list(x->i_dest, s, argc, argv); else inlet_wrong(x, &s_list); }
static void inlet_anything(t_inlet *x, t_symbol *s, int argc, t_atom *argv) { ! if (x->i_symfrom == s) typedmess(x->i_dest, x->i_symto, argc, argv); ! else if (!x->i_symfrom) typedmess(x->i_dest, s, argc, argv); else inlet_wrong(x, s); }
void inlet_free(t_inlet *x) { ! t_object *y = x->i_owner; t_inlet *x2; ! if (y->ob_inlet == x) y->ob_inlet = x->i_next; ! else for (x2 = y->ob_inlet; x2; x2 = x2->i_next) if (x2->i_next == x) { ! x2->i_next = x->i_next; break; } --- 568,613 ---- /* LATER figure out how to make these efficient: */ static void inlet_bang(t_inlet *x) { ! if (x->symfrom == &s_bang) pd_vmess(x->dest, x->u.symto, ""); ! else if (!x->symfrom) pd_bang(x->dest); else inlet_wrong(x, &s_bang); } static void inlet_pointer(t_inlet *x, t_gpointer *gp) { ! if (x->symfrom == &s_pointer) pd_vmess(x->dest, x->u.symto, "p", gp); ! else if (!x->symfrom) pd_pointer(x->dest, gp); else inlet_wrong(x, &s_pointer); } static void inlet_float(t_inlet *x, t_float f) { ! if (x->symfrom == &s_float) pd_vmess(x->dest, x->u.symto, "f", (t_floatarg)f); ! else if (x->symfrom == &s_signal) x->u.floatsignalvalue = f; ! else if (!x->symfrom) pd_float(x->dest, f); else inlet_wrong(x, &s_float); }
static void inlet_symbol(t_inlet *x, t_symbol *s) { ! if (x->symfrom == &s_symbol) pd_vmess(x->dest, x->u.symto, "s", s); ! else if (!x->symfrom) pd_symbol(x->dest, s); else inlet_wrong(x, &s_symbol); }
static void inlet_list(t_inlet *x, t_symbol *s, int argc, t_atom *argv) { ! if (x->symfrom == &s_list || x->symfrom == &s_float ! || x->symfrom == &s_symbol || x->symfrom == &s_pointer) ! typedmess(x->dest, x->u.symto, argc, argv); ! else if (!x->symfrom) pd_list(x->dest, s, argc, argv); else inlet_wrong(x, &s_list); }
static void inlet_anything(t_inlet *x, t_symbol *s, int argc, t_atom *argv) { ! if (x->symfrom == s) typedmess(x->dest, x->u.symto, argc, argv); ! else if (!x->symfrom) typedmess(x->dest, s, argc, argv); else inlet_wrong(x, s); }
void inlet_free(t_inlet *x) { ! t_object *y = x->owner; t_inlet *x2; ! if (y->ob_inlet == x) y->ob_inlet = x->next; ! else for (x2 = y->ob_inlet; x2; x2 = x2->next) if (x2->next == x) { ! x2->next = x->next; break; } *************** *** 637,652 ****
static void pointerinlet_pointer(t_inlet *x, t_gpointer *gp) { ! gpointer_unset(x->i_pointerslot); ! *(x->i_pointerslot) = *gp; if (gp->gp_stub) gp->gp_stub->gs_refcount++; }
! static void floatinlet_float( t_inlet *x, t_float f) { *(x->i_floatslot) = f; } ! static void symbolinlet_symbol(t_inlet *x, t_symbol *s) { *(x->i_symslot) = s; }
#define COMMON \ ! x->i_owner = owner; \ ! x->i_dest = 0; \ ! x->i_next = 0; \ object_append_inlet(owner,x); \ return x; --- 618,633 ----
static void pointerinlet_pointer(t_inlet *x, t_gpointer *gp) { ! gpointer_unset(x->u.pointerslot); ! *(x->u.pointerslot) = *gp; if (gp->gp_stub) gp->gp_stub->gs_refcount++; }
! static void floatinlet_float( t_inlet *x, t_float f) { *(x->u.floatslot) = f; } ! static void symbolinlet_symbol(t_inlet *x, t_symbol *s) { *(x->u.symslot) = s; }
#define COMMON \ ! x->owner = owner; \ ! x->dest = 0; \ ! x->next = 0; \ object_append_inlet(owner,x); \ return x; *************** *** 654,666 **** t_inlet *floatinlet_new(t_object *owner, t_float *fp) { t_inlet *x = (t_inlet *)pd_new(floatinlet_class); ! x->i_symfrom = &s_float; x->i_floatslot = fp; COMMON } t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp) { t_inlet *x = (t_inlet *)pd_new(symbolinlet_class); ! x->i_symfrom = &s_symbol; x->i_symslot = sp; COMMON } t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp) { t_inlet *x = (t_inlet *)pd_new(pointerinlet_class); ! x->i_symfrom = &s_pointer; x->i_pointerslot = gp; COMMON } #undef COMMON --- 635,647 ---- t_inlet *floatinlet_new(t_object *owner, t_float *fp) { t_inlet *x = (t_inlet *)pd_new(floatinlet_class); ! x->symfrom = &s_float; x->u.floatslot = fp; COMMON } t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp) { t_inlet *x = (t_inlet *)pd_new(symbolinlet_class); ! x->symfrom = &s_symbol; x->u.symslot = sp; COMMON } t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp) { t_inlet *x = (t_inlet *)pd_new(pointerinlet_class); ! x->symfrom = &s_pointer; x->u.pointerslot = gp; COMMON } #undef COMMON *************** *** 676,683 **** t_inlet *ip = ((t_object *)x)->ob_inlet; if (!argc) return; ! for (count = argc-1, ap = argv+1; ip && count--; ap++, ip = ip->i_next) { ! if (ap->a_type == A_POINTER) pd_pointer(&ip->i_pd, ap->a_w.w_gpointer); ! else if (ap->a_type == A_FLOAT) pd_float(&ip->i_pd, ap->a_float); ! else pd_symbol(&ip->i_pd, ap->a_symbol); } if (argv->a_type == A_POINTER) pd_pointer(x, argv->a_w.w_gpointer); --- 657,664 ---- t_inlet *ip = ((t_object *)x)->ob_inlet; if (!argc) return; ! for (count = argc-1, ap = argv+1; ip && count--; ap++, ip = ip->next) { ! if (ap->a_type == A_POINTER) pd_pointer(ip,ap->a_w.w_gpointer); ! else if (ap->a_type == A_FLOAT) pd_float(ip,ap->a_float); ! else pd_symbol(ip,ap->a_symbol); } if (argv->a_type == A_POINTER) pd_pointer(x, argv->a_w.w_gpointer); *************** *** 786,790 **** }
! #define each_inlet(i,obj) for ( t_inlet *i=obj->ob_inlet; i; i=i->i_next) #define each_outlet(o,obj) for (t_outlet *o=obj->ob_outlet; o; o=o->o_next)
--- 767,771 ---- }
! #define each_inlet(i,obj) for ( t_inlet *i=obj->ob_inlet; i; i=i->next) #define each_outlet(o,obj) for (t_outlet *o=obj->ob_outlet; o; o=o->o_next)
*************** *** 867,871 **** if (ISINLET(y)) { t_inlet *i = (t_inlet *)y; ! t_object *dest = i->i_owner; int n = dest->ob_pd->firstin; each_inlet(i2,dest) if (i2==i) break; else n++; --- 848,852 ---- if (ISINLET(y)) { t_inlet *i = (t_inlet *)y; ! t_object *dest = i->owner; int n = dest->ob_pd->firstin; each_inlet(i2,dest) if (i2==i) break; else n++; *************** *** 891,897 **** void obj_moveinletfirst(t_object *x, t_inlet *i) { if (x->ob_inlet == i) return; ! each_inlet(i2,x) if (i2->i_next == i) { ! i2->i_next = i->i_next; ! i->i_next = x->ob_inlet; x->ob_inlet = i; return; --- 872,878 ---- void obj_moveinletfirst(t_object *x, t_inlet *i) { if (x->ob_inlet == i) return; ! each_inlet(i2,x) if (i2->next == i) { ! i2->next = i->next; ! i->next = x->ob_inlet; x->ob_inlet = i; return; *************** *** 913,917 **** int obj_nsiginlets(t_object *x) { int n=0; ! each_inlet(i,x) if (i->i_symfrom == &s_signal) n++; if (x->ob_pd->firstin && x->ob_pd->floatsignalin) n++; return n; --- 894,898 ---- int obj_nsiginlets(t_object *x) { int n=0; ! each_inlet(i,x) if (i->symfrom == &s_signal) n++; if (x->ob_pd->firstin && x->ob_pd->floatsignalin) n++; return n; *************** *** 929,933 **** if (!m--) return 0; else n++; } ! each_inlet(i,x) if (i->i_symfrom == &s_signal) { if (!m) return n; n++; m--; --- 910,914 ---- if (!m--) return 0; else n++; } ! each_inlet(i,x) if (i->symfrom == &s_signal) { if (!m) return n; n++; m--; *************** *** 950,955 **** else m--; } ! for (i = x->ob_inlet; i && m; i = i->i_next, m--) {} ! return i && i->i_symfrom==&s_signal; } int obj_issignaloutlet(t_object *x, int m) { --- 931,936 ---- else m--; } ! for (i = x->ob_inlet; i && m; i = i->next, m--) {} ! return i && i->symfrom==&s_signal; } int obj_issignaloutlet(t_object *x, int m) { *************** *** 966,971 **** n++; } ! for (i = x->ob_inlet; i; i = i->i_next, m--) if (i->i_symfrom == &s_signal) { ! if (m == 0) return &i->i_un.iu_floatsignalvalue; n++; } --- 947,952 ---- n++; } ! for (i = x->ob_inlet; i; i = i->next, m--) if (i->symfrom == &s_signal) { ! if (m == 0) return &i->u.floatsignalvalue; n++; } *************** *** 976,980 **** int inlet_getsignalindex(t_inlet *x) { int n=0; t_inlet *i; ! for (i = x->i_owner->ob_inlet; i && i != x; i = i->i_next) if (i->i_symfrom == &s_signal) n++; return n; } --- 957,961 ---- int inlet_getsignalindex(t_inlet *x) { int n=0; t_inlet *i; ! for (i = x->owner->ob_inlet; i && i != x; i = i->next) if (i->symfrom == &s_signal) n++; return n; }