aboutsummaryrefslogtreecommitdiff
path: root/externals
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-04-19 02:32:31 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-04-19 02:32:31 +0000
commit0aac9d7803bc367ec22ed9df292d8a71d6013b55 (patch)
tree7ae307e7702884375d7da9dde0a630e419ea88ce /externals
parentda9c21b096e47f09ab24279b17d293aead832ad2 (diff)
""
svn path=/trunk/; revision=578
Diffstat (limited to 'externals')
-rw-r--r--externals/grill/flext/readme.txt3
-rw-r--r--externals/grill/flext/source/flbind.cpp32
-rw-r--r--externals/grill/flext/source/flclass.h31
-rwxr-xr-xexternals/grill/flext/source/flitem.cpp14
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<t_symbol *>(tag));
+#elif FLEXT_SYS == FLEXT_SYS_MAX
+ if(tag->s_thing == (t_object *)px)
+ const_cast<t_symbol *>(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<t_symbol *>(sym));
-#elif FLEXT_SYS == FLEXT_SYS_MAX
- if(sym->s_thing == (t_object *)px)
- const_cast<t_symbol *>(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<<bits:0; }
+
+ //! Get an array slot
item *Item(int ix) { return arr[ix]; }
protected:
+ //! Calculate a hash value
static int Hash(const t_symbol *,int inlet,int bits);
item **arr;
@@ -573,7 +585,7 @@ protected:
public item {
public:
methitem(int inlet,const t_symbol *tg,attritem *conn = NULL);
- ~methitem();
+ virtual ~methitem();
void SetArgs(methfun fun,int argc,metharg *args);
@@ -587,7 +599,7 @@ protected:
public item {
public:
attritem(const t_symbol *tag,metharg tp,methfun fun,int flags);
- ~attritem();
+ virtual ~attritem();
enum {
afl_getset = 0x01, afl_get = 0x00, afl_set = 0x01,
@@ -608,12 +620,12 @@ private:
class pxbnd_object;
public:
- //! \brief This represents an item of the method list
+ //! \brief This represents an item of the symbol-bound method list
class binditem:
public item {
public:
binditem(int inlet,const t_symbol *sym,bool (*f)(flext_base *,t_symbol *s,int,t_atom *,void *),pxbnd_object *px);
- ~binditem();
+ virtual ~binditem();
bool (*fun)(flext_base *,t_symbol *s,int,t_atom *,void *);
pxbnd_object *px;
@@ -773,14 +785,19 @@ private:
void init(flext_base *b,binditem *it,void *d) { base = b; item = it; data = d; }
static void px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv);
};
-
+
+ //! create proxy class for symbol binding
static void SetupBindProxy();
// ---------
+ //! set up inlet proxies
static void SetProxies(t_class *c);
+ //! initialize inlets (according to class or object constructor definitions)
bool InitInlets();
+
+ //! initialize outlets (according to class or object constructor definitions)
bool InitOutlets();
// callback functions
diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp
index 7af91fea..1980f26c 100755
--- a/externals/grill/flext/source/flitem.cpp
+++ b/externals/grill/flext/source/flitem.cpp
@@ -30,16 +30,20 @@ flext_base::itemarr::itemarr():
arr(new item *[2]),cnt(0),bits(-1)
{
arr[0] = arr[1] = NULL;
-// post("NEWARR %p",this);
}
flext_base::itemarr::~itemarr()
{
-// post("DELARR %p",this);
- int c = Ready()?Size():2;
+ if(Ready()) {
+ // if finalized, the array has several slots
+ int c = Size();
+ for(int i = 0; i < c; ++i)
+ if(arr[i]) delete arr[i];
+ }
+ else
+ // the array only has a head (arr[0]) and a tail (arr[1]) pointer
+ delete arr[0];
- for(int i = 0; i < c; ++i)
- if(arr[i]) delete arr[i];
delete[] arr;
}