Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4329/source
Modified Files: flattr.cpp flbase.cpp flbase.h flclass.h flext.cpp fllib.cpp flqueue.cpp flsupport.h flthr.cpp Log Message: enabled FLEXT_(C)ADDMETHOD as an alias of FLEXT_(C)ADDBANG bugfixes and optimizations, especially for DSP under Max/MSP added thisParent type attribute generation is now determined exclusively by the object class setup (not library as before). avoid trying to send empty message bundles - preprocessor symbol FLEXT_COMPATIBLE - if defined don't implement specialities of either PD or Max/MSP small changes for attribute functions - Max: fixed reported bug (#67), where list elements are distributed over inlets
Index: flqueue.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flqueue.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** flqueue.cpp 13 Feb 2006 19:40:08 -0000 1.38 --- flqueue.cpp 24 May 2006 12:20:57 -0000 1.39 *************** *** 379,387 **** clock_delay(qclk,0); #endif - #elif FLEXT_SYS == FLEXT_SYS_JMAX - #if FLEXT_QMODE == 0 - // this is dangerous because there may be other timers on this object! - fts_timebase_add_call(fts_get_timebase(), (fts_object_t *)thisHdr(), QTick, NULL, 0); - #endif #else #error Not implemented --- 379,382 ---- *************** *** 411,414 **** --- 406,410 ---- #elif FLEXT_QMODE == 2 LaunchThread(QWorker,NULL); + // very unelegant... but waiting should be ok, since happens only on loading while(!qustarted) Sleep(0.001); #elif FLEXT_QMODE == 0 && (FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX)
Index: flbase.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbase.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** flbase.cpp 26 Sep 2005 13:59:34 -0000 1.26 --- flbase.cpp 24 May 2006 12:20:57 -0000 1.27 *************** *** 45,49 **** int flext_obj::m_holdaargc = 0; const t_atom *flext_obj::m_holdaargv = NULL; ! bool flext_obj::process_attributes = false;
bool flext_obj::initing = false; --- 45,49 ---- int flext_obj::m_holdaargc = 0; const t_atom *flext_obj::m_holdaargv = NULL; ! //bool flext_obj::process_attributes = false;
bool flext_obj::initing = false; *************** *** 51,55 **** bool flext_obj::init_ok;
! void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
#if FLEXT_SYS == FLEXT_SYS_MAX --- 51,55 ---- bool flext_obj::init_ok;
! //void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
#if FLEXT_SYS == FLEXT_SYS_MAX
Index: flsupport.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** flsupport.h 15 May 2006 23:03:52 -0000 1.104 --- flsupport.h 24 May 2006 12:20:57 -0000 1.105 *************** *** 1146,1152 **** static void Sleep(double s);
- //! Sleep for a very short amount of time, just to let other threads wake up - static void MiniSleep(); - /*! \brief Class encapsulating a timer with callback functionality. This class can either be used with FLEXT_ADDTIMER or used as a base class with an overloaded virtual Work function. --- 1146,1149 ----
Index: flext.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flext.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** flext.cpp 15 May 2006 23:03:52 -0000 1.44 --- flext.cpp 24 May 2006 12:20:57 -0000 1.45 *************** *** 181,185 **** AddMessageMethods(c,IsDSP(id));
! if(process_attributes) { AddMethod(id,0,"getattributes",cb_ListAttrib); AddMethod(id,0,"getmethods",cb_ListMethods); --- 181,186 ---- AddMessageMethods(c,IsDSP(id));
! if(HasAttributes(id)) { ! // if(process_attributes) { AddMethod(id,0,"getattributes",cb_ListAttrib); AddMethod(id,0,"getmethods",cb_ListMethods);
Index: flbase.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbase.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** flbase.h 15 May 2006 23:03:52 -0000 1.37 --- flbase.h 24 May 2006 12:20:57 -0000 1.38 *************** *** 115,119 **** \note Use that in the static class setup function (also library setup function) */ ! static void ProcessAttributes(bool attr); //{ process_attributes = attr; }
//! Virtual function called at creation time (but after the constructor) --- 115,119 ---- \note Use that in the static class setup function (also library setup function) */ ! // static void ProcessAttributes(bool attr); //{ process_attributes = attr; }
//! Virtual function called at creation time (but after the constructor) *************** *** 157,160 **** --- 157,161 ---- static t_class *getClass(t_classid id); + static bool HasAttributes(t_classid id); static bool IsDSP(t_classid id); static bool IsLib(t_classid id); *************** *** 205,209 **** mutable flext_hdr *x_obj;
! static bool process_attributes;
private: --- 206,210 ---- mutable flext_hdr *x_obj;
! // static bool process_attributes;
private: *************** *** 251,255 ****
// Definitions for library objects ! static void lib_init(const char *name,void setupfun(),bool attr); static void obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),FLEXT_CLASSDEF(flext_obj) *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...); #if FLEXT_SYS == FLEXT_SYS_MAX --- 252,256 ----
// Definitions for library objects ! static void lib_init(const char *name,void setupfun()); static void obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),FLEXT_CLASSDEF(flext_obj) *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...); #if FLEXT_SYS == FLEXT_SYS_MAX *************** *** 308,311 **** --- 309,313 ---- public: \ typedef NEW_CLASS thisType; \ + typedef PARENT_CLASS thisParent; \ static FLEXT_CLASSDEF(flext_obj) *__init__(int argc,t_atom *argv); \ static void __free__(flext_hdr *hdr) { \ *************** *** 313,317 **** hdr->flext_hdr::~flext_hdr(); \ } \ ! static void __setup__(t_classid classid) { PARENT_CLASS::__setup__(classid); }
--- 315,319 ---- hdr->flext_hdr::~flext_hdr(); \ } \ ! static void __setup__(t_classid classid) { thisParent::__setup__(classid); }
*************** *** 319,322 **** --- 321,325 ---- public: \ typedef NEW_CLASS thisType; \ + typedef PARENT_CLASS thisParent; \ static FLEXT_CLASSDEF(flext_obj) *__init__(int argc,t_atom *argv); \ static void __free__(flext_hdr *hdr) { \ *************** *** 325,330 **** } \ static void __setup__(t_classid classid) { \ ! PARENT_CLASS::__setup__(classid); \ ! NEW_CLASS::SETUPFUN(classid); \ }
--- 328,333 ---- } \ static void __setup__(t_classid classid) { \ ! thisParent::__setup__(classid); \ ! thisType::SETUPFUN(classid); \ }
*************** *** 350,356 **** // specify that to define the library itself #if FLEXT_SYS == FLEXT_SYS_PD ! #define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT void NAME##_setup() { flext_obj::lib_init(#NAME,SETUPFUN,FLEXT_ATTRIBUTES); } #elif FLEXT_SYS == FLEXT_SYS_MAX ! #define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT int main() { flext_obj::lib_init(#NAME,SETUPFUN,FLEXT_ATTRIBUTES); return 0; } #else #error Platform not supported --- 353,359 ---- // specify that to define the library itself #if FLEXT_SYS == FLEXT_SYS_PD ! #define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT void NAME##_setup() { flext_obj::lib_init(#NAME,SETUPFUN); } #elif FLEXT_SYS == FLEXT_SYS_MAX ! #define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT int main() { flext_obj::lib_init(#NAME,SETUPFUN); return 0; } #else #error Platform not supported
Index: flattr.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flattr.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** flattr.cpp 11 Oct 2005 22:22:48 -0000 1.35 --- flattr.cpp 24 May 2006 12:20:57 -0000 1.36 *************** *** 236,243 **** // search for matching attribute AttrItem *a = FindAttrib(tag,false,true); ! if(a) ! return SetAttrib(tag,a,argc,argv); ! else ! return true; }
--- 236,240 ---- // search for matching attribute AttrItem *a = FindAttrib(tag,false,true); ! return a && SetAttrib(tag,a,argc,argv); }
Index: fllib.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/fllib.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** fllib.cpp 15 May 2006 23:03:52 -0000 1.37 --- fllib.cpp 24 May 2006 12:20:57 -0000 1.38 *************** *** 164,167 **** --- 164,168 ----
t_class *flext_obj::getClass(t_classid cl) { return cl->clss; } + bool flext_obj::HasAttributes(t_classid cl) { return cl->attr; } bool flext_obj::IsDSP(t_classid cl) { return cl->dsp; } bool flext_obj::IsLib(t_classid cl) { return cl->lib != NULL; } *************** *** 177,181 **** static flext_library *curlib = NULL;
! void flext_obj::lib_init(const char *name,void setupfun(),bool attr) { // make new library instance --- 178,182 ---- static flext_library *curlib = NULL;
! void flext_obj::lib_init(const char *name,void setupfun()) { // make new library instance *************** *** 184,189 **** flext::Setup();
- process_attributes = attr; - // first register all classes try { --- 185,188 ---- *************** *** 237,241 **** else { FLEXT_ASSERT(!curlib); ! process_attributes = attr; }
--- 236,240 ---- else { FLEXT_ASSERT(!curlib); ! // process_attributes = attr; }
*************** *** 270,274 **** lo->lib = curlib; lo->dsp = dsp; ! lo->attr = process_attributes;
// post("ADDCLASS %s,%s = %p -> LIBOBJ %p -> %p (lib=%i,dsp=%i)",idname,names,*cl,lo,lo->clss,lib?1:0,dsp?1:0); --- 269,273 ---- lo->lib = curlib; lo->dsp = dsp; ! lo->attr = attr;
// post("ADDCLASS %s,%s = %p -> LIBOBJ %p -> %p (lib=%i,dsp=%i)",idname,names,*cl,lo,lo->clss,lib?1:0,dsp?1:0);
Index: flthr.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flthr.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** flthr.cpp 6 Dec 2005 21:52:26 -0000 1.33 --- flthr.cpp 24 May 2006 12:20:57 -0000 1.34 *************** *** 645,648 **** #endif
- #endif // FLEXT_THREADS --- 645,647 ----
Index: flclass.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flclass.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** flclass.h 15 May 2006 23:03:52 -0000 1.68 --- flclass.h 24 May 2006 12:20:57 -0000 1.69 *************** *** 395,398 **** --- 395,399 ---- void AddMethodDef(int inlet,const char *tag = NULL) { AddMethodDef(inlet,MakeSymbol(tag)); }
+ void AddMethod(int inlet,bool (*m)(flext_base *)) { AddMethod(ThMeths(),inlet,sym_bang,(methfun)m,a_null); } void AddMethod(int inlet,bool (*m)(flext_base *,int,t_atom *)) { AddMethod(ThMeths(),inlet,sym_list,(methfun)m,a_list,a_null); } void AddMethod(int inlet,bool (*m)(flext_base *,int,const t_atom *)) { AddMethod(ThMeths(),inlet,sym_list,(methfun)m,a_list,a_null); } *************** *** 443,446 **** --- 444,448 ---- */
+ static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *)) { AddMethod(ClMeths(c),inlet,sym_bang,(methfun)m,a_null); } static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,int,t_atom *)) { AddMethod(ClMeths(c),inlet,sym_list,(methfun)m,a_list,a_null); } static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,int,const t_atom *)) { AddMethod(ClMeths(c),inlet,sym_list,(methfun)m,a_list,a_null); } *************** *** 621,624 **** --- 623,633 ---- bool DumpAttrib(const char *attr) const { return DumpAttrib(MakeSymbol(attr)); }
+ // check for attribute symbol @ + static int CheckAttrib(int argc,const t_atom *argv); + // check for attribute symbol @ + static int CheckAttrib(const AtomList &args,int offset = 0) { return CheckAttrib(args.Count()-offset,args.Atoms()+offset)+offset; } + + //! List attributes + bool ListAttrib() const; //! List attributes void ListAttrib(AtomList &a) const; *************** *** 626,629 **** --- 635,640 ---- bool GetAttrib(const t_symbol *s,AtomList &a) const; //! Set an attribute value + bool SetAttrib(const t_symbol *s,int argc,const t_atom *argv); + //! Set an attribute value bool SetAttrib(const t_symbol *s,const AtomList &a) { return SetAttrib(s,a.Count(),a.Atoms()); }
*************** *** 921,931 **** AttrItem *FindAttrib(const t_symbol *tag,bool get,bool msg = false) const;
- static int CheckAttrib(int argc,const t_atom *argv); bool InitAttrib(int argc,const t_atom *argv);
- bool ListAttrib() const; bool DumpAttrib(const t_symbol *tag,AttrItem *a) const; bool GetAttrib(const t_symbol *tag,AttrItem *a,AtomList &l) const; - bool SetAttrib(const t_symbol *s,int argc,const t_atom *argv); bool SetAttrib(const t_symbol *tag,AttrItem *a,int argc,const t_atom *argv); bool SetAttrib(const t_symbol *tag,AttrItem *a,const AtomList &l) { return SetAttrib(tag,a,l.Count(),l.Atoms()); } --- 932,939 ----