[PD-cvs] pd/src m_obj.c,1.2.4.3.2.10.2.4,1.2.4.3.2.10.2.5
Mathieu Bouchard
matju at users.sourceforge.net
Wed Dec 13 04:39:24 CET 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11253
Modified Files:
Tag: desiredata
m_obj.c
Log Message:
shrunk by 200 lines
Index: m_obj.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_obj.c,v
retrieving revision 1.2.4.3.2.10.2.4
retrieving revision 1.2.4.3.2.10.2.5
diff -C2 -d -r1.2.4.3.2.10.2.4 -r1.2.4.3.2.10.2.5
*** m_obj.c 13 Dec 2006 02:17:15 -0000 1.2.4.3.2.10.2.4
--- m_obj.c 13 Dec 2006 03:39:22 -0000 1.2.4.3.2.10.2.5
***************
*** 10,16 ****
/* T.Grill - define for a modified, more portable method to detect stack overflows */
- #define NEWSTACKMETH
/* tb: threadsafe stack overflow detection */
#ifdef ATOMIC
#include "m_atomic.h"
--- 10,18 ----
/* T.Grill - define for a modified, more portable method to detect stack overflows */
/* tb: threadsafe stack overflow detection */
+ #define ENTER STACK_INC; if(stackcount >= STACKITER) {outlet_stackerror(x); LEAVE; return;}
+ #define LEAVE STACK_DEC;
+
#ifdef ATOMIC
#include "m_atomic.h"
***************
*** 93,157 ****
}
! void inlet_settip(t_inlet* i,t_symbol* s)
! {
! i->i_tip = s;
! }
!
! void glob_tooltips(t_pd *dummy, t_float f)
! {
! sys_tooltips = f;
! }
! char* inlet_tip(t_inlet* i,int num)
! {
if (num < 0) return "???";
! while (num-- && i)
! i = i->i_next;
!
! if (i)
! if (i->i_tip) {
! return i->i_tip->s_name;
! }
return "?";
}
/* 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)
! {
t_atom at;
if (x->i_symfrom == &s_list || x->i_symfrom == &s_float
--- 95,133 ----
}
! void inlet_settip(t_inlet* i,t_symbol* s) {i->i_tip = s;}
! void glob_tooltips(t_pd *dummy, t_float f) {sys_tooltips = f;}
! 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 "?";
}
/* 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) {
t_atom at;
if (x->i_symfrom == &s_list || x->i_symfrom == &s_float
***************
*** 162,171 ****
}
! 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);
}
--- 138,144 ----
}
! 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);
}
***************
*** 187,192 ****
/* ----- pointerinlets, floatinlets, syminlets: optimized inlets ------- */
! static void pointerinlet_pointer(t_inlet *x, t_gpointer *gp)
! {
gpointer_unset(x->i_pointerslot);
*(x->i_pointerslot) = *gp;
--- 160,164 ----
/* ----- pointerinlets, floatinlets, syminlets: optimized inlets ------- */
! static void pointerinlet_pointer(t_inlet *x, t_gpointer *gp) {
gpointer_unset(x->i_pointerslot);
*(x->i_pointerslot) = *gp;
***************
*** 194,257 ****
}
! t_inlet *pointerinlet_new(t_object *owner, t_gpointer *gp)
! {
! t_inlet *x = (t_inlet *)pd_new(pointerinlet_class), *y, *y2;
! x->i_owner = owner;
! x->i_dest = 0;
! x->i_symfrom = &s_pointer;
! x->i_pointerslot = gp;
! x->i_next = 0;
! if (y = owner->ob_inlet)
! {
! while (y2 = y->i_next) y = y2;
! y->i_next = x;
! }
! else owner->ob_inlet = x;
! return (x);
! }
! static void floatinlet_float(t_inlet *x, t_float f)
! {
! *(x->i_floatslot) = f;
! }
! t_inlet *floatinlet_new(t_object *owner, t_float *fp)
! {
t_inlet *x = (t_inlet *)pd_new(floatinlet_class), *y, *y2;
! x->i_owner = owner;
! x->i_dest = 0;
! x->i_symfrom = &s_float;
! x->i_floatslot = fp;
! x->i_next = 0;
! if (y = owner->ob_inlet)
! {
! while (y2 = y->i_next) y = y2;
! y->i_next = x;
! }
! else owner->ob_inlet = x;
! return (x);
! }
!
! static void symbolinlet_symbol(t_inlet *x, t_symbol *s)
! {
! *(x->i_symslot) = s;
}
!
! t_inlet *symbolinlet_new(t_object *owner, t_symbol **sp)
! {
t_inlet *x = (t_inlet *)pd_new(symbolinlet_class), *y, *y2;
! x->i_owner = owner;
! x->i_dest = 0;
! x->i_symfrom = &s_symbol;
! x->i_symslot = sp;
! x->i_next = 0;
! if (y = owner->ob_inlet)
! {
! while (y2 = y->i_next) y = y2;
! y->i_next = x;
! }
! else owner->ob_inlet = x;
! return (x);
}
/* ---------------------- routine to handle lists ---------------------- */
--- 166,195 ----
}
! 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; \
! if (y = owner->ob_inlet) { \
! while (y2 = y->i_next) y = y2; \
! y->i_next = x; \
! } else owner->ob_inlet = x; \
! return x;
! t_inlet *floatinlet_new(t_object *owner, t_float *fp) {
t_inlet *x = (t_inlet *)pd_new(floatinlet_class), *y, *y2;
! 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), *y, *y2;
! 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), *y, *y2;
+ x->i_symfrom = &s_pointer; x->i_pointerslot = gp; COMMON
+ }
+ #undef COMMON
/* ---------------------- routine to handle lists ---------------------- */
***************
*** 266,279 ****
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_w.w_float);
! else pd_symbol(&ip->i_pd, ap->a_w.w_symbol);
}
! if (argv->a_type == A_POINTER) pd_pointer(&x->ob_pd, argv->a_w.w_gpointer);
! else if (argv->a_type == A_FLOAT) pd_float(&x->ob_pd, argv->a_w.w_float);
! else pd_symbol(&x->ob_pd, argv->a_w.w_symbol);
! }
void obj_init(void)
--- 204,216 ----
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_w.w_float);
! else pd_symbol(&ip->i_pd, ap->a_w.w_symbol);
}
! if (argv->a_type == A_POINTER) pd_pointer(&x->ob_pd, argv->a_w.w_gpointer);
! else if (argv->a_type == A_FLOAT) pd_float(&x->ob_pd, argv->a_w.w_float);
! else pd_symbol(&x->ob_pd, argv->a_w.w_symbol);
! }
void obj_init(void)
***************
*** 288,337 ****
class_addanything(inlet_class, inlet_anything);
! pointerinlet_class = class_new(gensym("inlet"), 0, 0,
! sizeof(t_inlet), CLASS_PD, 0);
class_addpointer(pointerinlet_class, pointerinlet_pointer);
- floatinlet_class = class_new(gensym("inlet"), 0, 0,
- sizeof(t_inlet), CLASS_PD, 0);
- class_addfloat(floatinlet_class, (t_method)floatinlet_float);
-
- symbolinlet_class = class_new(gensym("inlet"), 0, 0,
- sizeof(t_inlet), CLASS_PD, 0);
- class_addsymbol(symbolinlet_class, symbolinlet_symbol);
-
}
/* --------------------------- outlets ------------------------------ */
- #ifdef NEWSTACKMETH
/* T.Grill - count iterations rather than watch the stack pointer */
static int stackcount = 0; /* iteration counter */
#define STACKITER 1000 /* maximum iterations allowed */
- #else
- static char *stacklimit, *topstack;
- #define STACKSIZE 1000000
- #endif
static int outlet_eventno;
!
! /* set a stack limit (on each incoming event that can set off messages)
! for the outlet functions to check to prevent stack overflow from message
! recursion */
!
! void outlet_setstacklim(void)
! {
! #ifndef NEWSTACKMETH
! char c;
! topstack = &c;
! stacklimit = (&c) - STACKSIZE;
! #endif
! outlet_eventno++;
! }
!
! /* get a number unique to the (clock, MIDI, GUI, etc.) event we're on */
! int sched_geteventno( void)
! {
! return (outlet_eventno);
! }
typedef struct _outconnect {
--- 225,247 ----
class_addanything(inlet_class, inlet_anything);
! floatinlet_class = class_new(gensym("inlet"), 0, 0, sizeof(t_inlet), CLASS_PD, 0);
! symbolinlet_class = class_new(gensym("inlet"), 0, 0, sizeof(t_inlet), CLASS_PD, 0);
! pointerinlet_class = class_new(gensym("inlet"), 0, 0, sizeof(t_inlet), CLASS_PD, 0);
! class_addfloat( floatinlet_class, floatinlet_float);
! class_addsymbol( symbolinlet_class, symbolinlet_symbol);
class_addpointer(pointerinlet_class, pointerinlet_pointer);
}
/* --------------------------- outlets ------------------------------ */
/* T.Grill - count iterations rather than watch the stack pointer */
static int stackcount = 0; /* iteration counter */
#define STACKITER 1000 /* maximum iterations allowed */
+ /* this is fairly obsolete stuff, I think */
static int outlet_eventno;
! void outlet_setstacklim(void) {outlet_eventno++;}
! int sched_geteventno( void) {return outlet_eventno;}
typedef struct _outconnect {
***************
*** 391,525 ****
}
! static void outlet_stackerror(t_outlet *x)
! {
! pd_error(x->o_owner, "stack overflow");
! #ifndef NEWSTACKMETH
! stacklimit = topstack;
! #endif
! }
!
! void outlet_bang(t_outlet *x)
! {
! t_outconnect *oc;
! #ifdef NEWSTACKMETH
! STACK_INC;
! if(stackcount >= STACKITER)
! #else
! char c;
! if (&c < stacklimit)
! #endif
! outlet_stackerror(x);
! else
! for (oc = x->o_connections; oc; oc = oc->oc_next)
! pd_bang(oc->oc_to);
! #ifdef NEWSTACKMETH
! STACK_DEC;
! #endif
! }
!
! void outlet_pointer(t_outlet *x, t_gpointer *gp)
! {
! t_outconnect *oc;
! t_gpointer gpointer;
! #ifdef NEWSTACKMETH
! STACK_INC;
! if(stackcount >= STACKITER)
! #else
! char c;
! if (&c < stacklimit)
! #endif
! outlet_stackerror(x);
! else
! {
! gpointer = *gp;
! for (oc = x->o_connections; oc; oc = oc->oc_next)
! pd_pointer(oc->oc_to, &gpointer);
! }
! #ifdef NEWSTACKMETH
! STACK_DEC;
! #endif
! }
!
! void outlet_float(t_outlet *x, t_float f)
! {
! t_outconnect *oc;
! #ifdef NEWSTACKMETH
! STACK_INC;
! if(stackcount >= STACKITER)
! #else
! char c;
! if (&c < stacklimit)
! #endif
! outlet_stackerror(x);
! else
! for (oc = x->o_connections; oc; oc = oc->oc_next)
! pd_float(oc->oc_to, f);
! #ifdef NEWSTACKMETH
! STACK_DEC;
! #endif
! }
!
! void outlet_symbol(t_outlet *x, t_symbol *s)
! {
! t_outconnect *oc;
! #ifdef NEWSTACKMETH
! STACK_INC;
! if(stackcount >= STACKITER)
! #else
! char c;
! if (&c < stacklimit)
! #endif
! outlet_stackerror(x);
! else
! for (oc = x->o_connections; oc; oc = oc->oc_next)
! pd_symbol(oc->oc_to, s);
! #ifdef NEWSTACKMETH
! STACK_DEC;
! #endif
! }
!
! void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv)
! {
! t_outconnect *oc;
! #ifdef NEWSTACKMETH
! STACK_INC;
! if(stackcount >= STACKITER)
! #else
! char c;
! if (&c < stacklimit)
! #endif
! outlet_stackerror(x);
! else
! for (oc = x->o_connections; oc; oc = oc->oc_next)
! pd_list(oc->oc_to, s, argc, argv);
! #ifdef NEWSTACKMETH
! STACK_DEC;
! #endif
! }
! void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv)
! {
! t_outconnect *oc;
! #ifdef NEWSTACKMETH
! STACK_INC;
! if(stackcount >= STACKITER)
! #else
! char c;
! if (&c < stacklimit)
! #endif
! outlet_stackerror(x);
! else
! for (oc = x->o_connections; oc; oc = oc->oc_next)
! typedmess(oc->oc_to, s, argc, argv);
! #ifdef NEWSTACKMETH
! STACK_DEC;
! #endif
! }
! /* get the outlet's declared symbol */
! t_symbol *outlet_getsymbol(t_outlet *x)
! {
! return (x->o_sym);
! }
void outlet_free(t_outlet *x)
--- 301,334 ----
}
! static void outlet_stackerror(t_outlet *x) {pd_error(x->o_owner, "stack overflow");}
! void outlet_bang(t_outlet *x) {ENTER{
! t_outconnect *oc;
! for (oc = x->o_connections; oc; oc = oc->oc_next) pd_bang(oc->oc_to);
! }LEAVE}
! void outlet_pointer(t_outlet *x, t_gpointer *gp) {ENTER{
! t_outconnect *oc;
! t_gpointer gpointer = *gp;
! for (oc = x->o_connections; oc; oc = oc->oc_next) pd_pointer(oc->oc_to, &gpointer);
! }LEAVE}
! void outlet_float(t_outlet *x, t_float f) {ENTER{
! t_outconnect *oc;
! for (oc = x->o_connections; oc; oc = oc->oc_next) pd_float(oc->oc_to, f);
! }LEAVE}
! void outlet_symbol(t_outlet *x, t_symbol *s) {ENTER{
! t_outconnect *oc;
! for (oc = x->o_connections; oc; oc = oc->oc_next) pd_symbol(oc->oc_to, s);
! }LEAVE}
! void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv) {ENTER{
! t_outconnect *oc;
! for (oc = x->o_connections; oc; oc = oc->oc_next) pd_list(oc->oc_to, s, argc, argv);
! }LEAVE}
! void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv) {ENTER{
! t_outconnect *oc;
! for (oc = x->o_connections; oc; oc = oc->oc_next) typedmess(oc->oc_to, s, argc, argv);
! }LEAVE}
! /* get the outlet's declared symbol */
! t_symbol *outlet_getsymbol(t_outlet *x) {return x->o_sym;}
void outlet_free(t_outlet *x)
***************
*** 553,558 ****
oc->outlet = outno;
oc->inlet = inno;
! /* append it to the end of the list */
! /* LATER we might cache the last "oc" to make this faster. */
if ((oc2 = o->o_connections)) {
while (oc2->oc_next) oc2 = oc2->oc_next;
--- 362,367 ----
oc->outlet = outno;
oc->inlet = inno;
! /* append it to the end of the list */
! /* LATER we might cache the last "oc" to make this faster. */
if ((oc2 = o->o_connections)) {
while (oc2->oc_next) oc2 = oc2->oc_next;
***************
*** 592,610 ****
/* ------ traversal routines for code that can't see our structures ------ */
! int obj_noutlets(t_object *x)
! {
! int n;
! t_outlet *o;
for (o = x->ob_outlet, n = 0; o; o = o->o_next) n++;
! return (n);
}
! int obj_ninlets(t_object *x)
! {
! int n;
! t_inlet *i;
for (i = x->ob_inlet, n = 0; i; i = i->i_next) n++;
if (x->ob_pd->c_firstin) n++;
! return (n);
}
--- 401,415 ----
/* ------ traversal routines for code that can't see our structures ------ */
! int obj_noutlets(t_object *x) {
! int n; t_outlet *o;
for (o = x->ob_outlet, n = 0; o; o = o->o_next) n++;
! return n;
}
! int obj_ninlets(t_object *x) {
! int n; t_inlet *i;
for (i = x->ob_inlet, n = 0; i; i = i->i_next) n++;
if (x->ob_pd->c_firstin) n++;
! return n;
}
***************
*** 651,662 ****
}
! /* move an inlet or outlet to the head of the list */
! void obj_moveinletfirst(t_object *x, t_inlet *i)
! {
t_inlet *i2;
if (x->ob_inlet == i) return;
! else for (i2 = x->ob_inlet; i2; i2 = i2->i_next)
! if (i2->i_next == i)
! {
i2->i_next = i->i_next;
i->i_next = x->ob_inlet;
--- 456,464 ----
}
! /* move an inlet or outlet to the head of the list */
! void obj_moveinletfirst(t_object *x, t_inlet *i) {
t_inlet *i2;
if (x->ob_inlet == i) return;
! for (i2 = x->ob_inlet; i2; i2 = i2->i_next) if (i2->i_next == i) {
i2->i_next = i->i_next;
i->i_next = x->ob_inlet;
***************
*** 665,676 ****
}
}
!
! void obj_moveoutletfirst(t_object *x, t_outlet *o)
! {
t_outlet *o2;
if (x->ob_outlet == o) return;
! else for (o2 = x->ob_outlet; o2; o2 = o2->o_next)
! if (o2->o_next == o)
! {
o2->o_next = o->o_next;
o->o_next = x->ob_outlet;
--- 467,474 ----
}
}
! void obj_moveoutletfirst(t_object *x, t_outlet *o) {
t_outlet *o2;
if (x->ob_outlet == o) return;
! for (o2 = x->ob_outlet; o2; o2 = o2->o_next) if (o2->o_next == o) {
o2->o_next = o->o_next;
o->o_next = x->ob_outlet;
***************
*** 680,688 ****
}
! /* routines for DSP sorting, which are used in d_ugen.c and g_canvas.c */
! /* LATER try to consolidate all the slightly different routines. */
! int obj_nsiginlets(t_object *x)
! {
int n;
t_inlet *i;
--- 478,485 ----
}
! /* routines for DSP sorting, which are used in d_ugen.c and g_canvas.c */
! /* LATER try to consolidate all the slightly different routines. */
! int obj_nsiginlets(t_object *x) {
int n;
t_inlet *i;
***************
*** 693,697 ****
}
! /* get the index, among signal inlets, of the mth inlet overall */
int obj_siginletindex(t_object *x, int m)
{
--- 490,494 ----
}
! /* get the index, among signal inlets, of the mth inlet overall */
int obj_siginletindex(t_object *x, int m)
{
More information about the Pd-cvs
mailing list