From 576b21b58cced4bb319131114fca3590d58a3f6b Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 24 May 2006 12:20:57 +0000 Subject: 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 svn path=/trunk/; revision=5113 --- externals/grill/flext/changes.txt | 3 +++ externals/grill/flext/flext.vcproj | 2 +- externals/grill/flext/source/flattr.cpp | 5 +---- externals/grill/flext/source/flbase.cpp | 4 ++-- externals/grill/flext/source/flbase.h | 19 +++++++++++-------- externals/grill/flext/source/flclass.h | 14 +++++++++++--- externals/grill/flext/source/flext.cpp | 3 ++- externals/grill/flext/source/fllib.cpp | 9 ++++----- externals/grill/flext/source/flqueue.cpp | 6 +----- externals/grill/flext/source/flsupport.h | 3 --- externals/grill/flext/source/flthr.cpp | 1 - 11 files changed, 36 insertions(+), 33 deletions(-) (limited to 'externals') diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index 4ab40413..011a607c 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -30,6 +30,9 @@ Version history: - optimizations around method registration - preprocessor symbol FLEXT_COMPATIBLE - if defined don't implement specialities of either PD or Max/MSP - Max: fixed reported bug (#67), where list elements are distributed over inlets +- added thisParent type, which refers to the class from which the current flext class is derived (as given in FLEXT_HEADER) +- bang method can also by added with FLEXT_(C)ADDMETHOD (FLEXT_(C)ADDBANG is still an alias) +- attribute generation is now determined exclusively by each object class setup (not library is before) 0.5.0: - fixes for 64 bit builds (size_t is integer type of pointer size) diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj index ab81651c..b65507d9 100644 --- a/externals/grill/flext/flext.vcproj +++ b/externals/grill/flext/flext.vcproj @@ -224,7 +224,7 @@ Optimization="2" InlineFunctionExpansion="1" AdditionalIncludeDirectories="c:\programme\audio\pd\src;c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB;FLEXT_SYS=2;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_EXPORTS" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;FLEXT_SYS=2;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_EXPORTS;_WIN32_WINNT=0x501" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp index 68791894..2054f7d4 100644 --- a/externals/grill/flext/source/flattr.cpp +++ b/externals/grill/flext/source/flattr.cpp @@ -235,10 +235,7 @@ bool flext_base::SetAttrib(const t_symbol *tag,int argc,const t_atom *argv) { // search for matching attribute AttrItem *a = FindAttrib(tag,false,true); - if(a) - return SetAttrib(tag,a,argc,argv); - else - return true; + return a && SetAttrib(tag,a,argc,argv); } bool flext_base::SetAttrib(const t_symbol *tag,AttrItem *a,int argc,const t_atom *argv) diff --git a/externals/grill/flext/source/flbase.cpp b/externals/grill/flext/source/flbase.cpp index cbb46aec..a1cc37d3 100644 --- a/externals/grill/flext/source/flbase.cpp +++ b/externals/grill/flext/source/flbase.cpp @@ -44,13 +44,13 @@ const t_symbol *flext_obj::m_holdname = NULL; flext_class *flext_obj::m_holdclass = NULL; int flext_obj::m_holdaargc = 0; const t_atom *flext_obj::m_holdaargv = NULL; -bool flext_obj::process_attributes = false; +//bool flext_obj::process_attributes = false; bool flext_obj::initing = false; bool flext_obj::exiting = false; bool flext_obj::init_ok; -void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; } +//void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; } #if FLEXT_SYS == FLEXT_SYS_MAX static const t_symbol *sym__shP = NULL; diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index b696ea68..6b5eba51 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -114,7 +114,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj): /*! \brief Enable/disable attribute procession (default = false) \note Use that in the static class setup function (also library setup function) */ - static void ProcessAttributes(bool attr); //{ process_attributes = attr; } +// static void ProcessAttributes(bool attr); //{ process_attributes = attr; } //! Virtual function called at creation time (but after the constructor) // this also guarantees that there are no instances of flext_obj @@ -156,6 +156,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj): //! Get class pointer from class id 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); @@ -204,7 +205,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj): //! backpointer to object header mutable flext_hdr *x_obj; - static bool process_attributes; +// static bool process_attributes; private: @@ -250,7 +251,7 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj): static bool Exiting() { return exiting; } // Definitions for library objects - static void lib_init(const char *name,void setupfun(),bool attr); + 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 static flext_hdr *obj_new(const t_symbol *s,short argc,t_atom *argv); @@ -307,25 +308,27 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj): #define FLEXT_REALHDR(NEW_CLASS, PARENT_CLASS) \ 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) { \ FLEXT_CLASSDEF(flext_obj) *mydata = hdr->data; delete mydata; \ hdr->flext_hdr::~flext_hdr(); \ } \ -static void __setup__(t_classid classid) { PARENT_CLASS::__setup__(classid); } +static void __setup__(t_classid classid) { thisParent::__setup__(classid); } #define FLEXT_REALHDR_S(NEW_CLASS, PARENT_CLASS,SETUPFUN) \ 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) { \ FLEXT_CLASSDEF(flext_obj) *mydata = hdr->data; delete mydata; \ hdr->flext_hdr::~flext_hdr(); \ } \ static void __setup__(t_classid classid) { \ - PARENT_CLASS::__setup__(classid); \ - NEW_CLASS::SETUPFUN(classid); \ + thisParent::__setup__(classid); \ + thisType::SETUPFUN(classid); \ } @@ -349,9 +352,9 @@ static void __setup__(t_classid classid) { \ // 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); } +#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,FLEXT_ATTRIBUTES); return 0; } +#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 #endif diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index 25284f01..4356ee8f 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -394,6 +394,7 @@ public: void AddMethodDef(int inlet,const t_symbol *tag = NULL) { ThMeths()->Add(new MethItem,tag,inlet); } 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); } void AddMethod(int inlet,const t_symbol *tag,bool (*m)(flext_base *)) { AddMethod(ThMeths(),inlet,tag,(methfun)m,a_null); } // pure method @@ -442,6 +443,7 @@ public: @{ */ + 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); } static void AddMethod(t_classid c,int inlet,const t_symbol *tag,bool (*m)(flext_base *)) { AddMethod(ClMeths(c),inlet,tag,(methfun)m,a_null); } // pure method @@ -620,11 +622,20 @@ protected: //! Dump an attribute to the attribute outlet 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; //! Get an attribute value 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()); } // get and set the attribute @@ -920,13 +931,10 @@ private: 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()); } // get and set the attribute diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp index acbbf2ad..afb7cdff 100644 --- a/externals/grill/flext/source/flext.cpp +++ b/externals/grill/flext/source/flext.cpp @@ -180,7 +180,8 @@ void flext_base::Setup(t_classid id) #endif AddMessageMethods(c,IsDSP(id)); - if(process_attributes) { + if(HasAttributes(id)) { +// if(process_attributes) { AddMethod(id,0,"getattributes",cb_ListAttrib); AddMethod(id,0,"getmethods",cb_ListMethods); diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp index 4670858b..13690a24 100755 --- a/externals/grill/flext/source/fllib.cpp +++ b/externals/grill/flext/source/fllib.cpp @@ -163,6 +163,7 @@ static flext_class *FindName(const t_symbol *s,flext_class *o = NULL) 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; } @@ -176,15 +177,13 @@ bool flext_obj::NeedDSP() const { return clss->dsp || (clss->lib && clss->lib->d static flext_library *curlib = NULL; -void flext_obj::lib_init(const char *name,void setupfun(),bool attr) +void flext_obj::lib_init(const char *name,void setupfun()) { // make new library instance curlib = new flext_library(MakeSymbol(name)); flext::Setup(); - process_attributes = attr; - // first register all classes try { setupfun(); @@ -236,7 +235,7 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha } else { FLEXT_ASSERT(!curlib); - process_attributes = attr; +// process_attributes = attr; } // set dynamic class pointer @@ -269,7 +268,7 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha flext_class *lo = new flext_class(*cl,newfun,freefun); lo->lib = curlib; lo->dsp = dsp; - lo->attr = process_attributes; + 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); diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 13b45c5c..2053c4de 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -378,11 +378,6 @@ static void Trigger() // qelem_front(qclk); 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 #endif @@ -410,6 +405,7 @@ void flext_base::StartQueue() #endif #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) // qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick)); diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 772347f0..dcc0acc2 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -1145,9 +1145,6 @@ public: */ 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. */ diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp index 8f2a5966..da40d240 100644 --- a/externals/grill/flext/source/flthr.cpp +++ b/externals/grill/flext/source/flthr.cpp @@ -644,5 +644,4 @@ bool flext::ThrCond::TimedWait(double ftm) } #endif - #endif // FLEXT_THREADS -- cgit v1.2.1