From 0aac9d7803bc367ec22ed9df292d8a71d6013b55 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 19 Apr 2003 02:32:31 +0000 Subject: "" svn path=/trunk/; revision=578 --- externals/grill/flext/readme.txt | 3 ++- externals/grill/flext/source/flbind.cpp | 32 +++++++++++++++++--------------- externals/grill/flext/source/flclass.h | 31 ++++++++++++++++++++++++------- externals/grill/flext/source/flitem.cpp | 14 +++++++++----- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/externals/grill/flext/readme.txt b/externals/grill/flext/readme.txt index a97b98f2..177a7f35 100644 --- a/externals/grill/flext/readme.txt +++ b/externals/grill/flext/readme.txt @@ -115,8 +115,9 @@ see flext.h, fldefs.h and flclass.h for the documented base definitions and clas Version history: 0.4.4: -- fix deadly bug for Max/MSP method-to-symbol-binding proxies +- fixed deadly bug for Max/MSP method-to-symbol-binding proxies - some fixes for CodeWarrior Mach-O compilation +- fixed destruction bug for hashed "item arrays" 0.4.3: - added forgotten flext_base::ToQueueString method diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp index 80ba36fb..9f840f34 100644 --- a/externals/grill/flext/source/flbind.cpp +++ b/externals/grill/flext/source/flbind.cpp @@ -60,6 +60,22 @@ flext_base::binditem::binditem(int in,const t_symbol *sym,bool (*f)(flext_base * item(sym,0,NULL),fun(f),px(p) {} +flext_base::binditem::~binditem() +{ + if(px) { +#if FLEXT_SYS == FLEXT_SYS_PD + pd_unbind(&px->obj.ob_pd,const_cast(tag)); +#elif FLEXT_SYS == FLEXT_SYS_MAX + if(tag->s_thing == (t_object *)px) + const_cast(tag)->s_thing = NULL; + else + error("%s - Binding not found",thisName()); +#else +# pragma warning("Not implemented") +#endif + object_free(&px->obj); + } +} bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbol *s,int argc,t_atom *argv,void *data),void *data) { @@ -112,21 +128,7 @@ bool flext_base::UnbindMethod(const t_symbol *sym) item *it = bindhead?bindhead->Find(sym,0):NULL; if(it) { bool ok = bindhead->Remove(it); - if(ok) { - pxbnd_object *px = ((binditem *)it)->px; -#if FLEXT_SYS == FLEXT_SYS_PD - pd_unbind(&px->obj.ob_pd,const_cast(sym)); -#elif FLEXT_SYS == FLEXT_SYS_MAX - if(sym->s_thing == (t_object *)px) - const_cast(sym)->s_thing = NULL; - else - error("%s - Binding not found",thisName()); -#else -# pragma warning("Not implemented") -#endif - object_free(&px->obj); - delete it; - } + if(ok) delete it; return ok; } else diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index 6e105551..7296c223 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -536,7 +536,7 @@ protected: class item { public: item(const t_symbol *t,int inl,attritem *a); - ~item(); + virtual ~item(); bool IsAttr() const { return attr != NULL; } @@ -546,22 +546,34 @@ protected: item *nxt; }; + //! This class holds hashed item entries class itemarr { public: itemarr(); ~itemarr(); - + + //! Add an entry void Add(item *it); + //! Remove an entry bool Remove(item *it); + //! Find an entry in the item array item *Find(const t_symbol *tag,int inlet = 0) const; + + //! Create hash table out of the preliminary linked lists void Finalize(); + //! Query whether the array has been finalized bool Ready() const { return bits >= 0; } + //! Number of items in the array int Count() const { return cnt; } + //! Number of array slots (0 if not finalized) int Size() const { return bits?1<