[PD-cvs] externals/grill/flext/source flatom.cpp, 1.14, 1.15 flbase.h, 1.35, 1.36 flclass.h, 1.66, 1.67 flext.cpp, 1.42, 1.43 flout.cpp, 1.25, 1.26 flqueue.cpp, 1.34, 1.35 flsupport.cpp, 1.55, 1.56 flsupport.h, 1.101, 1.102

Thomas Grill xovo at users.sourceforge.net
Mon Dec 12 01:18:23 CET 2005


Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22644/source

Modified Files:
	flatom.cpp flbase.h flclass.h flext.cpp flout.cpp flqueue.cpp 
	flsupport.cpp flsupport.h 
Log Message:
new flext::CopyAtoms function
fixed dangerous spot (also memory leak) with message queuing
flext::Forward has more incarnations now
fixed and cleaned up library related stuff, especially co-existance of Max message and DSP library objects
some minor changes after valgrind run
more pthreads V2 fixes
added message bundles (flext::MsgBundle)
save some space saving inlet pointers
fix uninitialized pointer
update docs


Index: flqueue.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flqueue.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** flqueue.cpp	6 Dec 2005 21:52:26 -0000	1.34
--- flqueue.cpp	12 Dec 2005 00:18:21 -0000	1.35
***************
*** 39,129 ****
  static void Trigger();
  
! class qmsg:
      public flext,
!     public Fifo::Cell
  {
  public:
!     inline qmsg &Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
!     {
!         th = t;
!         out = o;
!         msg(s,ac,av);
!         return *this;
!     }
! 
!     inline qmsg &Set(const t_symbol *r,const t_symbol *s,int ac,const t_atom *av)
!     {
!         th = NULL;
!         recv = r;
!         msg(s,ac,av);
!         return *this;
!     }
  
!     // \note PD sys lock must already be held by caller
!     inline void Send() const
      {
!         if(th) {
!             if(out < 0)
!                 // message to self
!                 th->CbMethodHandler(-1-out,msg.Header(),msg.Count(),msg.Atoms()); 
!             else
!                 // message to outlet
!                 th->ToSysAnything(out,msg.Header(),msg.Count(),msg.Atoms());
          }
-         else
-             flext::Forward(recv,msg,true);
      }
- 
- private:
-     flext_base *th;
-     union {
-         int out;
-         const t_symbol *recv;
-     };
-     AtomAnything msg;
  };
  
  
  
! typedef PooledFifo<qmsg> QueueFifo;
  
! class Queue:
      public flext,
!     public QueueFifo
  {
  public:
!     inline bool Empty() const { return Size() == 0; }
  
!     inline void Push(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
      {
!         qmsg *m = QueueFifo::New();
!         FLEXT_ASSERT(m);
!         m->Set(t,o,s,ac,av);
!         Put(m);
!         Trigger();
      }
  
!     inline void Push(const t_symbol *r,const t_symbol *s,int ac,const t_atom *av)
      {
!         qmsg *m = QueueFifo::New();
!         FLEXT_ASSERT(m);
!         m->Set(r,s,ac,av);
!         Put(m);
!         Trigger();
      }
  
!     inline void Push(flext_base *th,int o) // bang
      { 
!         Push(th,o,sym_bang,0,NULL);
      }
  
!     inline void Push(flext_base *th,int o,float dt) 
      { 
          t_atom at; 
          SetFloat(at,dt);
!         Push(th,o,sym_float,1,&at);
      }
  
!     inline void Push(flext_base *th,int o,int dt) 
      { 
          t_atom at; 
--- 39,117 ----
  static void Trigger();
  
! 
! class flext::MsgBundle;
! 
! typedef PooledFifo<flext::MsgBundle> QueueFifo;
! 
! class Queue:
      public flext,
!     public QueueFifo
  {
  public:
!     inline bool Empty() const { return Size() == 0; }
  
!     inline void Push(MsgBundle *m)
      {
!         if(m) {
!             Put(m);
!             Trigger();
          }
      }
  };
  
+ static Queue queue;
  
  
! #define STATSIZE 8
  
! class flext::MsgBundle:
      public flext,
!     public Fifo::Cell
  {
  public:
!     static MsgBundle *New()
!     {
!         MsgBundle *m = queue.New();
!         m->msg.Init();
!         return m;
!     }
  
!     static void Free(MsgBundle *m)
!     {       
!         for(Msg *mi = m->msg.nxt; mi; ) {
!             Msg *mn = mi->nxt;
!             mi->Free();
!             delete mi;
!             mi = mn;
!         }
!         m->msg.Free();
!         queue.Free(m);
!     }
! 
!     inline MsgBundle &Add(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
      {
!         Get()->Set(t,o,s,ac,av);
!         return *this;
      }
  
!     inline MsgBundle &Add(const t_symbol *r,const t_symbol *s,int ac,const t_atom *av)
      {
!         Get()->Set(r,s,ac,av);
!         return *this;
      }
  
!     inline MsgBundle &Add(flext_base *th,int o) // bang
      { 
!         return Add(th,o,sym_bang,0,NULL);
      }
  
!     inline MsgBundle &Add(flext_base *th,int o,float dt) 
      { 
          t_atom at; 
          SetFloat(at,dt);
!         return Add(th,o,sym_float,1,&at);
      }
  
!     inline MsgBundle &Add(flext_base *th,int o,int dt) 
      { 
          t_atom at; 
***************
*** 137,151 ****
  #error Not implemented!
  #endif
!         Push(th,o,sym,1,&at);
      }
  
!     inline void Push(flext_base *th,int o,const t_symbol *dt) 
      { 
          t_atom at; 
          SetSymbol(at,dt);
!         Push(th,o,sym_symbol,1,&at);
      }
  
!     void Push(flext_base *th,int o,const t_atom &a) 
      { 
          const t_symbol *sym;
--- 125,139 ----
  #error Not implemented!
  #endif
!         return Add(th,o,sym,1,&at);
      }
  
!     inline MsgBundle &Add(flext_base *th,int o,const t_symbol *dt) 
      { 
          t_atom at; 
          SetSymbol(at,dt);
!         return Add(th,o,sym_symbol,1,&at);
      }
  
!     inline MsgBundle &Add(flext_base *th,int o,const t_atom &a) 
      { 
          const t_symbol *sym;
***************
*** 164,179 ****
          else {
              error("atom type not supported");
!             return;
          }
!         Push(th,o,sym,1,&a);
      }
  
!     inline void Push(flext_base *th,int o,int argc,const t_atom *argv) 
      {
!         Push(th,o,sym_list,argc,argv);
      }
- };
  
! static Queue queue;
  
  
--- 152,268 ----
          else {
              error("atom type not supported");
!             return *this;
          }
!         return Add(th,o,sym,1,&a);
      }
  
!     inline MsgBundle &Add(flext_base *th,int o,int argc,const t_atom *argv) 
      {
!         return Add(th,o,sym_list,argc,argv);
      }
  
!     // \note PD sys lock must already be held by caller
!     inline void Send() const
!     {
!         FLEXT_ASSERT(msg.Ok());
! 
!         const Msg *m = &msg;
!         do {
!             m->Send();
!             m = m->nxt;
!         } while(m);
!     }
! 
! private:
! 
!     class Msg {
!     public:
!         inline bool Ok() const { return th || recv; }
! 
!         void Init()
!         {
!             th = NULL;
!             recv = NULL;
!             nxt = NULL;
!             argc = 0;
!         }
! 
!         void Free()
!         {
!             if(argc > STATSIZE) {
!                 FLEXT_ASSERT(argv);
!                 delete[] argv;
!             }
!         }
! 
!         void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av)
!         {
!             FLEXT_ASSERT(t);
!             th = t;
!             out = o;
!             SetMsg(s,ac,av);
! }
! 
!         void Set(const t_symbol *r,const t_symbol *s,int ac,const t_atom *av)
!         {
!             FLEXT_ASSERT(r);
!             th = NULL;
!             recv = r;
!             SetMsg(s,ac,av);
!         }
! 
!         void Send() const
!         {
!             if(th) {
!                 if(out < 0)
!                     // message to self
!                     th->CbMethodHandler(-1-out,sym,argc,argc > STATSIZE?argv:argl); 
!                 else
!                     // message to outlet
!                     th->ToSysAnything(out,sym,argc,argc > STATSIZE?argv:argl);
!             }
!             else
!                 flext::SysForward(recv,sym,argc,argc > STATSIZE?argv:argl);
!         }
! 
!         Msg *nxt;
! 
!     protected:
!         flext_base *th;
!         union {
!             int out;
!             const t_symbol *recv;
!         };
!         const t_symbol *sym;
!         int argc;
!         union {
!             t_atom *argv;
!             t_atom argl[STATSIZE];
!         };
! 
!         void SetMsg(const t_symbol *s,int cnt,const t_atom *lst)
!         {
!             sym = s;
!             argc = cnt;
!             if(cnt > STATSIZE) {
!                 argv = new t_atom[cnt];
!                 flext::CopyAtoms(cnt,argv,lst);
!             }
!             else
!                 flext::CopyAtoms(cnt,argl,lst);
!         }
! 
!     } msg;
! 
!     Msg *Get()
!     {
!         Msg *m = &msg;
!         if(m->Ok()) {
!             for(; m->nxt; m = m->nxt) {}
!             m = m->nxt = new Msg;
!         }
!         return m;
!     }
! };
  
  
***************
*** 202,209 ****
      #endif
  
!         qmsg *q;
          while((q = queue.Get()) != NULL) {
              q->Send();
!             queue.Free(q);
          }
  
--- 291,298 ----
      #endif
  
!         flext::MsgBundle *q;
          while((q = queue.Get()) != NULL) {
              q->Send();
!             flext::MsgBundle::Free(q);
          }
  
***************
*** 330,386 ****
  }
  
  void flext_base::ToQueueBang(int o) const 
  {
!     queue.Push(const_cast<flext_base *>(this),o);
  }
  
  void flext_base::ToQueueFloat(int o,float f) const
  {
!     queue.Push(const_cast<flext_base *>(this),o,f);
  }
  
  void flext_base::ToQueueInt(int o,int f) const
  {
!     queue.Push(const_cast<flext_base *>(this),o,f);
  }
  
  void flext_base::ToQueueSymbol(int o,const t_symbol *s) const
  {
!     queue.Push(const_cast<flext_base *>(this),o,s);
  }
  
  void flext_base::ToQueueAtom(int o,const t_atom &at) const
  {
!     queue.Push(const_cast<flext_base *>(this),o,at);
  }
  
  void flext_base::ToQueueList(int o,int argc,const t_atom *argv) const
  {
!     queue.Push(const_cast<flext_base *>(this),o,argc,argv);
  }
  
  void flext_base::ToQueueAnything(int o,const t_symbol *s,int argc,const t_atom *argv) const
  {
!     queue.Push(const_cast<flext_base *>(this),o,s,argc,argv);
  }
  
  
! bool flext::Forward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv,bool direct)
  {
!     if(direct || IsSystemThread()) {
!         void *cl = recv->s_thing;
!         if(!cl) return false;
!         
  #if FLEXT_SYS == FLEXT_SYS_PD
!         pd_typedmess((t_class **)cl,(t_symbol *)s,argc,(t_atom *)argv);
  #elif FLEXT_SYS == FLEXT_SYS_MAX
!         typedmess(recv->s_thing,(t_symbol *)s,argc,(t_atom *)argv);
  #else
  #error Not implemented
  #endif
!     }
!     else
!         // send over queue
!         queue.Push(recv,s,argc,argv);
      return true;
  }
--- 419,561 ----
  }
  
+ 
+ flext::MsgBundle *flext::MsgNew() 
+ { 
+     return MsgBundle::New(); 
+ }
+ 
+ void flext::MsgFree(MsgBundle *m) 
+ { 
+     MsgBundle::Free(m); 
+ }
+ 
+ void flext::ToSysMsg(MsgBundle *m)
+ {
+     m->Send();
+     queue.Free(m);
+ }
+ 
+ void flext::ToQueueMsg(MsgBundle *m)
+ {
+     queue.Push(m);
+ }
+ 
+ 
+ 
  void flext_base::ToQueueBang(int o) const 
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o);
!     queue.Push(m);
  }
  
  void flext_base::ToQueueFloat(int o,float f) const
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o,f);
!     queue.Push(m);
  }
  
  void flext_base::ToQueueInt(int o,int f) const
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o,f);
!     queue.Push(m);
  }
  
  void flext_base::ToQueueSymbol(int o,const t_symbol *s) const
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o,s);
!     queue.Push(m);
  }
  
  void flext_base::ToQueueAtom(int o,const t_atom &at) const
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o,at);
!     queue.Push(m);
  }
  
  void flext_base::ToQueueList(int o,int argc,const t_atom *argv) const
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o,argc,argv);
!     queue.Push(m);
  }
  
  void flext_base::ToQueueAnything(int o,const t_symbol *s,int argc,const t_atom *argv) const
  {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(const_cast<flext_base *>(this),o,s,argc,argv);
!     queue.Push(m);
  }
  
  
! void flext_base::MsgAddBang(MsgBundle *m,int n) const 
! { 
!     m->Add(const_cast<flext_base *>(this),n);
! }
! 
! void flext_base::MsgAddFloat(MsgBundle *m,int n,float f) const
  {
!     m->Add(const_cast<flext_base *>(this),n,f);
! }
! 
! void flext_base::MsgAddInt(MsgBundle *m,int n,int f) const
! {
!     m->Add(const_cast<flext_base *>(this),n,f);
! }
! 
! void flext_base::MsgAddSymbol(MsgBundle *m,int n,const t_symbol *s) const
! {
!     m->Add(const_cast<flext_base *>(this),n,s);
! }
! 
! void flext_base::MsgAddAtom(MsgBundle *m,int n,const t_atom &at) const
! {
!     m->Add(const_cast<flext_base *>(this),n,at);
! }
! 
! void flext_base::MsgAddList(MsgBundle *m,int n,int argc,const t_atom *argv) const
! {
!     m->Add(const_cast<flext_base *>(this),n,argc,argv);
! }
! 
! void flext_base::MsgAddAnything(MsgBundle *m,int n,const t_symbol *s,int argc,const t_atom *argv) const
! {
!     m->Add(const_cast<flext_base *>(this),n,s,argc,argv);
! }
! 
! 
! 
! 
! bool flext::SysForward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv)
! {
!     void *cl = recv->s_thing;
!     if(!cl) return false;
!     
  #if FLEXT_SYS == FLEXT_SYS_PD
!     pd_typedmess((t_class **)cl,(t_symbol *)s,argc,(t_atom *)argv);
  #elif FLEXT_SYS == FLEXT_SYS_MAX
!     typedmess(recv->s_thing,(t_symbol *)s,argc,(t_atom *)argv);
  #else
  #error Not implemented
  #endif
!     return true;
! }
! 
! bool flext::QueueForward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv)
! {
!     MsgBundle *m = MsgBundle::New();
!     m->Add(recv,s,argc,argv);
!     // send over queue
!     queue.Push(m);
!     return true;
! }
! 
! bool flext::MsgForward(MsgBundle *m,const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv)
! {
!     m->Add(recv,s,argc,argv);
      return true;
  }

Index: flout.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flout.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** flout.cpp	10 Dec 2005 21:34:08 -0000	1.25
--- flout.cpp	12 Dec 2005 00:18:21 -0000	1.26
***************
*** 46,55 ****
  #if defined(FLEXT_THREADS)
      #if FLEXT_QMODE == 2
!         #define CHKTHR() ((IsSystemThread() || IsThread(flext::thrmsgid)) && !InDsp())
      #else
!         #define CHKTHR() (IsSystemThread() && !InDsp())
      #endif
  #else
!     #define CHKTHR() (!InDsp())
  #endif
  
--- 46,55 ----
  #if defined(FLEXT_THREADS)
      #if FLEXT_QMODE == 2
!         #define CHKTHR() ((IsSystemThread() || IsThread(flext::thrmsgid)) && !InDSP())
      #else
!         #define CHKTHR() (IsSystemThread() && !InDSP())
      #endif
  #else
!     #define CHKTHR() (!InDSP())
  #endif
  
***************
*** 62,65 ****
--- 62,72 ----
  void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysAnything(n,s,argc,argv); else ToQueueAnything(n,s,argc,argv); }
  
+ void flext::ToOutMsg(MsgBundle *mb) { if(CHKTHR()) ToSysMsg(mb); else ToQueueMsg(mb); }
+ 
+ bool flext::Forward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv)
+ {
+     return CHKTHR()?SysForward(recv,s,argc,argv):QueueForward(recv,s,argc,argv); 
+ }
+ 
  
  bool flext_base::InitInlets()
***************
*** 87,91 ****
  
  #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
!     inlets = new px_object *[incnt];
  #endif
      
--- 94,98 ----
  
  #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
!     inlets = incnt > 1?new px_object *[incnt]:NULL;
  #endif
      
***************
*** 105,109 ****
  //            if(xi.desc && *xi.desc) class_settip(thisClass(),gensym(xi.desc));
  #endif
-             inlets[0] = NULL;
          }       
  
--- 112,115 ----
***************
*** 114,118 ****
                  case xlet_float:
                  case xlet_int: {
!                     inlets[ix] = NULL;
                      char sym[] = "ft??";
                      if(ix >= 10) { 
--- 120,124 ----
                  case xlet_float:
                  case xlet_int: {
!                     inlets[ix-1] = NULL;
                      char sym[] = "ft??";
                      if(ix >= 10) { 
***************
*** 134,150 ****
                  }
                  case xlet_sym: 
!                     (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
!                     in = inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol);  
                      break;
                  case xlet_list:
!                     (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
!                     in = inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list);  
                      break;
                  case xlet_any:
!                     (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
!                     in = inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, 0, 0);  
                      break;
                  case xlet_sig:
!                     inlets[ix] = NULL;
                      if(compatibility && inlist[ix-1].tp != xlet_sig) {
                          post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
--- 140,156 ----
                  }
                  case xlet_sym: 
!                     (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
!                     in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol);  
                      break;
                  case xlet_list:
!                     (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
!                     in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list);  
                      break;
                  case xlet_any:
!                     (inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix);  // proxy for 2nd inlet messages 
!                     in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, 0, 0);  
                      break;
                  case xlet_sig:
!                     inlets[ix-1] = NULL;
                      if(compatibility && inlist[ix-1].tp != xlet_sig) {
                          post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
***************
*** 159,163 ****
                      break;
                  default:
!                     inlets[ix] = NULL;
                      error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)inlist[ix].tp);
                      ok = false;
--- 165,169 ----
                      break;
                  default:
!                     inlets[ix-1] = NULL;
                      error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)inlist[ix].tp);
                      ok = false;
***************
*** 181,185 ****
              xlet &xi = inlist[ix];
              if(ix == 0) {
-                 inlets[ix] = NULL;
                  if(xi.tp != xlet_any) {
                      error("%s: Leftmost inlet must be of type signal or anything",thisName());
--- 187,190 ----
***************
*** 190,194 ****
                  switch(xi.tp) {
                      case xlet_sig:
!                         inlets[ix] = NULL;
                          error("%s: All signal inlets must be left-aligned",thisName());
                          ok = false;
--- 195,199 ----
                  switch(xi.tp) {
                      case xlet_sig:
!                         inlets[ix-1] = NULL;
                          error("%s: All signal inlets must be left-aligned",thisName());
                          ok = false;
***************
*** 196,200 ****
                      case xlet_float: {
  						if(ix < 10) {
! 							inlets[ix] = NULL;
                              floatin(x_obj,ix);
  							break;
--- 201,205 ----
                      case xlet_float: {
  						if(ix < 10) {
! 							inlets[ix-1] = NULL;
                              floatin(x_obj,ix);
  							break;
***************
*** 205,209 ****
                      case xlet_int: {
  						if(ix < 10) {
! 							inlets[ix] = NULL;
                              intin(x_obj,ix);
  							break;
--- 210,214 ----
                      case xlet_int: {
  						if(ix < 10) {
! 							inlets[ix-1] = NULL;
                              intin(x_obj,ix);
  							break;
***************
*** 216,223 ****
                      case xlet_sym:
                      case xlet_list:
!                         inlets[ix] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet);  
                          break;
                      default:
!                         inlets[ix] = NULL;
                          error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)xi.tp);
                          ok = false;
--- 221,228 ----
                      case xlet_sym:
                      case xlet_list:
!                         inlets[ix-1] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet);  
                          break;
                      default:
!                         inlets[ix-1] = NULL;
                          error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)xi.tp);
                          ok = false;
***************
*** 226,230 ****
          }
          
!         while(ix >= 0) inlets[ix--] = NULL;
  	}
  #else
--- 231,235 ----
          }
          
!         while(ix > 0) inlets[ix--] = NULL;
  	}
  #else
***************
*** 267,271 ****
  
  #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
!     outlets = new outlet *[outcnt+procattr];
  
      // type info is now in list array
--- 272,279 ----
  
  #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
!     if(outcnt+procattr)
!         outlets = new outlet *[outcnt+procattr];
!     else
!         outlets = NULL;
  
      // type info is now in list array

Index: flsupport.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v
retrieving revision 1.101
retrieving revision 1.102
diff -C2 -d -r1.101 -r1.102
*** flsupport.h	10 Dec 2005 21:34:08 -0000	1.101
--- flsupport.h	12 Dec 2005 00:18:21 -0000	1.102
***************
*** 340,343 ****
--- 340,346 ----
  	static void CopyAtom(t_atom *dst,const t_atom *src) { *dst = *src; }
  
+ 	//! Copy atoms
+ 	static void CopyAtoms(int cnt,t_atom *dst,const t_atom *src);
+ 
  	//! Print an atom
  	static bool PrintAtom(const t_atom &a,char *buf,size_t bufsz);
***************
*** 708,732 ****
  
  
! //!		@} FLEXT_S_ATOM
  
  
  // --- messages -------------------------------------------------------	
  
  	/*!	\defgroup FLEXT_S_MSG Flext message handling 
  		@{ 
  	*/
  
!     //! Send a message to a symbol (bound to an object)
!     static bool Forward(const t_symbol *sym,const t_symbol *s,int argc,const t_atom *argv,bool forcedirect = false);
  
!     static bool Forward(const t_symbol *sym,const AtomAnything &args,bool forcedirect = false) { return Forward(sym,args.Header(),args.Count(),args.Atoms(),forcedirect); }
!     static bool Forward(const char *sym,const AtomAnything &args,bool forcedirect = false) { return Forward(MakeSymbol(sym),args.Header(),args.Count(),args.Atoms(),forcedirect); }
  
!     static bool Forward(const t_symbol *sym,int argc,const t_atom *argv,bool forcedirect = false) { return Forward(sym,sym_list,argc,argv,forcedirect); }
  
!     static bool Forward(const t_symbol *sym,const AtomList &args,bool forcedirect = false) { return Forward(sym,args.Count(),args.Atoms(),forcedirect); }
!     static bool Forward(const char *sym,const AtomList &args,bool forcedirect = false) { return Forward(MakeSymbol(sym),args.Count(),args.Atoms(),forcedirect); }
  
! //!		@} FLEXT_S_MSG
  
      
--- 711,776 ----
  
  
!     //!	@} FLEXT_S_ATOM
  
  
  // --- messages -------------------------------------------------------	
  
+ 	/*!	\defgroup FLEXT_S_MSGBUNDLE Flext message handling 
+ 		@{ 
+ 	*/
+ 
+     class MsgBundle;
+ 
+     //! Make new message bundle
+     static MsgBundle *MsgNew();
+ 
+     //! Destroy message bundle
+     static void MsgFree(MsgBundle *mb);
+ 
+     //! Send (and destroy) message bundle
+     static void ToSysMsg(MsgBundle *mb);
+ 
+     //! Send (and destroy) message bundle
+     static void ToOutMsg(MsgBundle *mb);
+ 
+     //! Send low priority (and destroy) message bundle
+     static void ToQueueMsg(MsgBundle *mb);
+ 
+     //! @} FLEXT_S_MSGBUNDLE
+ 
+ 
  	/*!	\defgroup FLEXT_S_MSG Flext message handling 
  		@{ 
  	*/
  
!     static bool Forward(const t_symbol *sym,const t_symbol *s,int argc,const t_atom *argv);
!     static bool Forward(const t_symbol *sym,const AtomAnything &args) { return Forward(sym,args.Header(),args.Count(),args.Atoms()); }
!     static bool Forward(const char *sym,const AtomAnything &args) { return Forward(MakeSymbol(sym),args.Header(),args.Count(),args.Atoms()); }
!     static bool Forward(const t_symbol *sym,int argc,const t_atom *argv) { return Forward(sym,sym_list,argc,argv); }
!     static bool Forward(const t_symbol *sym,const AtomList &args) { return Forward(sym,args.Count(),args.Atoms()); }
!     static bool Forward(const char *sym,const AtomList &args) { return Forward(MakeSymbol(sym),args.Count(),args.Atoms()); }
  
!     static bool SysForward(const t_symbol *sym,const t_symbol *s,int argc,const t_atom *argv);
!     static bool SysForward(const t_symbol *sym,const AtomAnything &args) { return SysForward(sym,args.Header(),args.Count(),args.Atoms()); }
!     static bool SysForward(const char *sym,const AtomAnything &args) { return SysForward(MakeSymbol(sym),args.Header(),args.Count(),args.Atoms()); }
!     static bool SysForward(const t_symbol *sym,int argc,const t_atom *argv) { return SysForward(sym,sym_list,argc,argv); }
!     static bool SysForward(const t_symbol *sym,const AtomList &args) { return SysForward(sym,args.Count(),args.Atoms()); }
!     static bool SysForward(const char *sym,const AtomList &args) { return SysForward(MakeSymbol(sym),args.Count(),args.Atoms()); }
  
!     static bool QueueForward(const t_symbol *sym,const t_symbol *s,int argc,const t_atom *argv);
!     static bool QueueForward(const t_symbol *sym,const AtomAnything &args) { return QueueForward(sym,args.Header(),args.Count(),args.Atoms()); }
!     static bool QueueForward(const char *sym,const AtomAnything &args) { return QueueForward(MakeSymbol(sym),args.Header(),args.Count(),args.Atoms()); }
!     static bool QueueForward(const t_symbol *sym,int argc,const t_atom *argv) { return QueueForward(sym,sym_list,argc,argv); }
!     static bool QueueForward(const t_symbol *sym,const AtomList &args) { return QueueForward(sym,args.Count(),args.Atoms()); }
!     static bool QueueForward(const char *sym,const AtomList &args) { return QueueForward(MakeSymbol(sym),args.Count(),args.Atoms()); }
  
!     static bool MsgForward(MsgBundle *mb,const t_symbol *sym,const t_symbol *s,int argc,const t_atom *argv);
!     static bool MsgForward(MsgBundle *mb,const t_symbol *sym,const AtomAnything &args) { return MsgForward(mb,sym,args.Header(),args.Count(),args.Atoms()); }
!     static bool MsgForward(MsgBundle *mb,const char *sym,const AtomAnything &args) { return MsgForward(mb,MakeSymbol(sym),args.Header(),args.Count(),args.Atoms()); }
!     static bool MsgForward(MsgBundle *mb,const t_symbol *sym,int argc,const t_atom *argv) { return MsgForward(mb,sym,sym_list,argc,argv); }
!     static bool MsgForward(MsgBundle *mb,const t_symbol *sym,const AtomList &args) { return MsgForward(mb,sym,args.Count(),args.Atoms()); }
!     static bool MsgForward(MsgBundle *mb,const char *sym,const AtomList &args) { return MsgForward(mb,MakeSymbol(sym),args.Count(),args.Atoms()); }
  
!     //! @} FLEXT_S_MSG
  
      
***************
*** 1165,1168 ****
--- 1209,1215 ----
  //!		@} FLEXT_S_TIMER
  
+     //! Check if we are in DSP time
+     static bool InDSP() { return indsp; }
+ 
  // --- SIMD functionality -----------------------------------------------
  
***************
*** 1211,1214 ****
--- 1258,1264 ----
  	static const t_symbol *sym_attributes;
  	static const t_symbol *sym_methods;
+ 
+     //! flag if we are within DSP
+     static bool indsp;
  };
  

Index: flext.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flext.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** flext.cpp	3 Nov 2005 20:29:28 -0000	1.42
--- flext.cpp	12 Dec 2005 00:18:21 -0000	1.43
***************
*** 21,25 ****
  
  bool flext_base::compatibility = true;
- bool flext_base::indsp = false;
  const t_symbol *flext_base::curtag = NULL;
  
--- 21,24 ----
***************
*** 114,124 ****
  
      if(inlets) {
!         for(int ix = 0; ix < incnt; ++ix)
!             if(inlets[ix]) {
                  // release proxy object
  #if FLEXT_SYS == FLEXT_SYS_PD
!                 pd_free(&inlets[ix]->obj.ob_pd);
  #elif FLEXT_SYS == FLEXT_SYS_MAX
!                 freeobject((object *)inlets[ix]);
  #endif
              }
--- 113,124 ----
  
      if(inlets) {
!         FLEXT_ASSERT(incnt > 1);
!         for(int ix = 1; ix < incnt; ++ix)
!             if(inlets[ix-1]) {
                  // release proxy object
  #if FLEXT_SYS == FLEXT_SYS_PD
!                 pd_free(&inlets[ix-1]->obj.ob_pd);
  #elif FLEXT_SYS == FLEXT_SYS_MAX
!                 freeobject((object *)inlets[ix-1]);
  #endif
              }

Index: flbase.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbase.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** flbase.h	11 Oct 2005 22:22:48 -0000	1.35
--- flbase.h	12 Dec 2005 00:18:21 -0000	1.36
***************
*** 161,166 ****
  
          bool HasAttributes() const;
-         bool IsDSP() const;
          bool IsLib() const;
  
  #if FLEXT_SYS == FLEXT_SYS_MAX
--- 161,166 ----
  
          bool HasAttributes() const;
          bool IsLib() const;
+         bool IsDSP() const;
  
  #if FLEXT_SYS == FLEXT_SYS_MAX

Index: flatom.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flatom.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** flatom.cpp	22 Mar 2005 04:56:28 -0000	1.14
--- flatom.cpp	12 Dec 2005 00:18:21 -0000	1.15
***************
*** 49,53 ****
  }
  
! static void copyatoms(int cnt,t_atom *dst,const t_atom *src)
  {
      if(dst < src)
--- 49,53 ----
  }
  
! void flext::CopyAtoms(int cnt,t_atom *dst,const t_atom *src)
  {
      if(dst < src)
***************
*** 64,71 ****
          if(cnt == sz) return; // no change
  
!         t_atom *l = new t_atom[sz];
!         if(keepix >= 0)
!             // keep contents
!             copyatoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),l+keepto,lst+keepix);
          delete[] lst;
          lst = l,cnt = sz;
--- 64,77 ----
          if(cnt == sz) return; // no change
  
!         t_atom *l;
!         if(sz) {
!             l = new t_atom[sz];
!             if(keepix >= 0)
!                 // keep contents
!                 CopyAtoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),l+keepto,lst+keepix);
!         }
!         else
!             l = NULL;
! 
          delete[] lst;
          lst = l,cnt = sz;
***************
*** 73,77 ****
      else {
          FLEXT_ASSERT(cnt == 0);
!         lst = new t_atom[cnt = sz];
      }
  }
--- 79,83 ----
      else {
          FLEXT_ASSERT(cnt == 0);
!         if(sz) lst = new t_atom[cnt = sz];
      }
  }
***************
*** 95,99 ****
  
      // argv can be NULL independently from argc
!     if(argv) copyatoms(argc,lst+offs,argv);
  
  	return *this;
--- 101,105 ----
  
      // argv can be NULL independently from argc
!     if(argv) CopyAtoms(argc,lst+offs,argv);
  
  	return *this;
***************
*** 121,125 ****
              if(keepix >= 0)
                  // keep contents
!                 copyatoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),predata+keepto,lst+keepix);
              AtomList::Free();
          }
--- 127,131 ----
              if(keepix >= 0)
                  // keep contents
!                 CopyAtoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),predata+keepto,lst+keepix);
              AtomList::Free();
          }

Index: flsupport.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** flsupport.cpp	10 Dec 2005 21:34:08 -0000	1.55
--- flsupport.cpp	12 Dec 2005 00:18:21 -0000	1.56
***************
*** 43,46 ****
--- 43,48 ----
  const t_symbol *flext::sym_methods = NULL;
  
+ bool flext::indsp = false;
+ 
  
  int flext::Version() { return FLEXT_VERSION; }
***************
*** 78,82 ****
      sym_size = flext::MakeSymbol("size");
  #endif
! 
      sym_attributes = flext::MakeSymbol("attributes");
      sym_methods = flext::MakeSymbol("methods");
--- 80,84 ----
      sym_size = flext::MakeSymbol("size");
  #endif
!     
      sym_attributes = flext::MakeSymbol("attributes");
      sym_methods = flext::MakeSymbol("methods");

Index: flclass.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flclass.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** flclass.h	19 Nov 2005 23:10:53 -0000	1.66
--- flclass.h	12 Dec 2005 00:18:21 -0000	1.67
***************
*** 193,198 ****
  	int CntOutSig() const { return outsigs; }
  
-     //! Check if we are in DSP time
-     static bool InDsp() { return indsp; }
  
  	//! Retrieve currently processed message tag (NULL if no message processing)
--- 193,196 ----
***************
*** 250,285 ****
  	*/
  
! 	//! Output bang (index n starts with 0)
  	void ToQueueBang(int n) const;
  
! 	//! Output float (index n starts with 0)
  	void ToQueueFloat(int n,float f) const;
  
! 	//! Output integer (index n starts with 0)
  	void ToQueueInt(int n,int f) const;
  
! 	//! Output boolean (index n starts with 0)
  	void ToQueueBool(int n,bool f) const { ToQueueInt(n,f?1:0); }
  
! 	//! Output symbol (index n starts with 0)
  	void ToQueueSymbol(int n,const t_symbol *s) const;
! 	//! Output string aka symbol (to appointed outlet)
  	void ToQueueString(int n,const char *s) const { ToQueueSymbol(n,MakeSymbol(s)); }
  
! 	//! Output atom (index n starts with 0)
  	void ToQueueAtom(int n,const t_atom &at) const; 
  
! 	//! Output list (index n starts with 0)
  	void ToQueueList(int n,int argc,const t_atom *argv) const; 
! 	//! Output list (index n starts with 0)
  	void ToQueueList(int n,const AtomList &list) const  { ToQueueList(n,list.Count(),list.Atoms()); }
  
! 	//! Output anything (index n starts with 0)
  	void ToQueueAnything(int n,const t_symbol *s,int argc,const t_atom *argv)  const;
! 	//! Output anything (index n starts with 0)
  	void ToQueueAnything(int n,const AtomAnything &any) const  { ToQueueAnything(n,any.Header(),any.Count(),any.Atoms()); }
  
  
! 	//! Send bang to self (inlet n)
      void ToSelfBang(int n) const { ToQueueBang(-1-n); }
  
--- 248,289 ----
  	*/
  
! 	//! Output low priority bang (index n starts with 0)
  	void ToQueueBang(int n) const;
  
! 	//! Output low priority float (index n starts with 0)
  	void ToQueueFloat(int n,float f) const;
  
! 	//! Output low priority integer (index n starts with 0)
  	void ToQueueInt(int n,int f) const;
  
! 	//! Output low priority boolean (index n starts with 0)
  	void ToQueueBool(int n,bool f) const { ToQueueInt(n,f?1:0); }
  
! 	//! Output low priority symbol (index n starts with 0)
  	void ToQueueSymbol(int n,const t_symbol *s) const;
! 	//! Output low priority string aka symbol (to appointed outlet)
  	void ToQueueString(int n,const char *s) const { ToQueueSymbol(n,MakeSymbol(s)); }
  
! 	//! Output low priority atom (index n starts with 0)
  	void ToQueueAtom(int n,const t_atom &at) const; 
  
! 	//! Output low priority list (index n starts with 0)
  	void ToQueueList(int n,int argc,const t_atom *argv) const; 
! 	//! Output low priority list (index n starts with 0)
  	void ToQueueList(int n,const AtomList &list) const  { ToQueueList(n,list.Count(),list.Atoms()); }
  
! 	//! Output low priority anything (index n starts with 0)
  	void ToQueueAnything(int n,const t_symbol *s,int argc,const t_atom *argv)  const;
! 	//! Output low priority anything (index n starts with 0)
  	void ToQueueAnything(int n,const AtomAnything &any) const  { ToQueueAnything(n,any.Header(),any.Count(),any.Atoms()); }
  
+     //!	@} FLEXT_C_IO_QUEUE
  
! 
! 	/*!	\defgroup FLEXT_C_IO_SELF Output of data to inlets/outlets of this object
! 		@{ 
! 	*/
! 
!     //! Send bang to self (inlet n)
      void ToSelfBang(int n) const { ToQueueBang(-1-n); }
  
***************
*** 311,315 ****
  	void ToSelfAnything(int n,const AtomAnything &any) const { ToSelfAnything(n,any.Header(),any.Count(),any.Atoms()); }
  
! //!		@} FLEXT_C_IO_QUEUE
  
  //!	@} FLEXT_C_INOUT
--- 315,388 ----
  	void ToSelfAnything(int n,const AtomAnything &any) const { ToSelfAnything(n,any.Header(),any.Count(),any.Atoms()); }
  
!     //!	@} FLEXT_C_IO_SELF
! 
! 
! 	/*!	\defgroup FLEXT_C_IO_MESSAGEBUNDLE Output of data via message bundles
! 
!         These are used to assure the sending of several messages from a second thread to the same logical time
! 
! 		@{ 
! 	*/
! 
! 	//! Output bang (index n starts with 0)
! 	void MsgAddBang(MsgBundle *mb,int n) const;
! 
! 	//! Output float (index n starts with 0)
! 	void MsgAddFloat(MsgBundle *mb,int n,float f) const;
! 
! 	//! Output integer (index n starts with 0)
! 	void MsgAddInt(MsgBundle *mb,int n,int f) const;
! 
! 	//! Output boolean (index n starts with 0)
! 	void MsgAddBool(MsgBundle *mb,int n,bool f) const { MsgAddInt(mb,n,f?1:0); }
! 
! 	//! Output symbol (index n starts with 0)
! 	void MsgAddSymbol(MsgBundle *mb,int n,const t_symbol *s) const;
! 	//! Output string aka symbol (to appointed outlet)
! 	void MsgAddString(MsgBundle *mb,int n,const char *s) const { MsgAddSymbol(mb,n,MakeSymbol(s)); }
! 
! 	//! Output atom (index n starts with 0)
! 	void MsgAddAtom(MsgBundle *mb,int n,const t_atom &at) const;
! 
! 	//! Output list (index n starts with 0)
! 	void MsgAddList(MsgBundle *mb,int n,int argc,const t_atom *argv) const; 
! 	//! Output list (index n starts with 0)
! 	void MsgAddList(MsgBundle *mb,int n,const AtomList &list) const { MsgAddList(mb,n,list.Count(),list.Atoms()); }
! 
! 	//! Output anything (index n starts with 0)
! 	void MsgAddAnything(MsgBundle *mb,int n,const t_symbol *s,int argc,const t_atom *argv) const;
! 	//! Output anything (index n starts with 0)
! 	void MsgAddAnything(MsgBundle *mb,int n,const AtomAnything &any) const { MsgAddAnything(mb,n,any.Header(),any.Count(),any.Atoms()); }
! 
!     void MsgSelfBang(MsgBundle *mb,int n) const { MsgAddBang(mb,-1-n); }
! 
! 	//! Send float to self (inlet n)
!     void MsgSelfFloat(MsgBundle *mb,int n,float f) const { MsgAddFloat(mb,-1-n,f); }
! 
! 	//! Send integer to self (inlet n)
!     void MsgSelfInt(MsgBundle *mb,int n,int f) const { MsgAddInt(mb,-1-n,f); }
! 
! 	//! Send boolean to self (inlet n)
! 	void MsgSelfBool(MsgBundle *mb,int n,bool f) const { MsgSelfInt(mb,n,f?1:0); }
! 
! 	//! Send symbol to self (inlet n)
!     void MsgSelfSymbol(MsgBundle *mb,int n,const t_symbol *s) const { MsgAddSymbol(mb,-1-n,s); }
! 	//! Send string aka symbol to self (inlet 0)
! 	void MsgSelfString(MsgBundle *mb,int n,const char *s) const { MsgSelfSymbol(mb,n,MakeSymbol(s)); }
! 
! 	//! Output atom (index n starts with 0)
!     void MsgSelfAtom(MsgBundle *mb,int n,const t_atom &at) const { MsgAddAtom(mb,-1-n,at); }
! 
! 	//! Send list to self (inlet n)
!     void MsgSelfList(MsgBundle *mb,int n,int argc,const t_atom *argv) const { MsgAddList(mb,-1-n,argc,argv); }
! 	//! Send list to self (inlet n)
! 	void MsgSelfList(MsgBundle *mb,int n,const AtomList &list) const { MsgSelfList(mb,n,list.Count(),list.Atoms()); }
! 
! 	//! Send anything to self (inlet n)
!     void MsgSelfAnything(MsgBundle *mb,int n,const t_symbol *s,int argc,const t_atom *argv) const { MsgAddAnything(mb,-1-n,s,argc,argv); }
! 	//! Send anything to self (inlet n)
! 	void MsgSelfAnything(MsgBundle *mb,int n,const AtomAnything &any) const { MsgSelfAnything(mb,n,any.Header(),any.Count(),any.Atoms()); }
! 
!     //! @} FLEXT_C_IO_MESSAGEBUNDLE
  
  //!	@} FLEXT_C_INOUT
***************
*** 765,768 ****
--- 838,843 ----
  	void ToSysAtom(int n,const t_atom &at) const;
  
+ 	static void ToSysMsg(MsgBundle *mb);
+ 
  	// add class method handlers
  	static void AddMessageMethods(t_class *c);
***************
*** 799,805 ****
  	static void AddAttrib(t_classid c,const t_symbol *attr,metharg tp,methfun gfun,methfun sfun);
  
-     //! flag if we are within DSP
-     static bool indsp;
- 
  private:
  
--- 874,877 ----





More information about the Pd-cvs mailing list