aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r--externals/grill/flext/source/flattr.cpp2
-rw-r--r--externals/grill/flext/source/flbind.cpp26
-rw-r--r--externals/grill/flext/source/flclass.h51
-rw-r--r--externals/grill/flext/source/fldefs_methbind.h7
-rw-r--r--externals/grill/flext/source/fldsp.cpp12
-rw-r--r--externals/grill/flext/source/flsupport.cpp3
-rw-r--r--externals/grill/flext/source/flsupport.h13
7 files changed, 87 insertions, 27 deletions
diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp
index 8b5ede86..0cdc74c9 100644
--- a/externals/grill/flext/source/flattr.cpp
+++ b/externals/grill/flext/source/flattr.cpp
@@ -44,7 +44,7 @@ void flext_base::AddAttrib(itemarr *aa,itemarr *ma,const char *attr,metharg tp,m
// bind attribute to a method
methitem *mi = new methitem(0,asym,a);
- mi->SetArgs(sfun,1,&tp);
+ mi->SetArgs(sfun,1,new metharg(tp));
ma->Add(mi);
}
diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp
index fe1846e2..53f041c6 100644
--- a/externals/grill/flext/source/flbind.cpp
+++ b/externals/grill/flext/source/flbind.cpp
@@ -77,6 +77,18 @@ flext_base::binditem::~binditem()
}
}
+#if FLEXT_SYS == FLEXT_SYS_PD
+ //! Bind object to a symbol
+ bool flext_base::Bind(const t_symbol *sym) { pd_bind(&thisHdr()->ob_pd,const_cast<t_symbol *>(sym)); return true; }
+ //! Unbind object from a symbol
+ bool flext_base::Unbind(const t_symbol *sym) { pd_unbind(&thisHdr()->ob_pd,const_cast<t_symbol *>(sym)); return true; }
+#elif FLEXT_SYS == FLEXT_SYS_MAX
+ //! Bind object to a symbol
+ bool flext_base::Bind(const t_symbol *sym) { if(sym->s_thing) return false; else { const_cast<t_symbol *>(sym)->s_thing = (t_object *)thisHdr(); return true; } }
+ //! Unbind object from a symbol
+ bool flext_base::Unbind(const t_symbol *sym) { if(sym->s_thing != (t_object *)thisHdr()) return false; else { const_cast<t_symbol *>(sym)->s_thing = NULL; return true; } }
+#endif
+
bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbol *s,int argc,t_atom *argv,void *data),void *data)
{
if(!bindhead)
@@ -123,16 +135,18 @@ bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbo
}
-bool flext_base::UnbindMethod(const t_symbol *sym)
+bool flext_base::UnbindMethod(const t_symbol *sym,void **data)
{
- item *it = bindhead?bindhead->Find(sym,0):NULL;
+ bool ok = false;
+ binditem *it = bindhead?(binditem *)bindhead->Find(sym,0):NULL;
+ void *d = NULL;
if(it) {
- bool ok = bindhead->Remove(it);
+ d = it->px->data;
+ ok = bindhead->Remove(it);
if(ok) delete it;
- return ok;
}
- else
- return true;
+ if(data) *data = d;
+ return ok;
}
void flext_base::pxbnd_object::px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv)
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index 676cb4a9..4fa4f614 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -391,37 +391,48 @@ public:
#if FLEXT_SYS == FLEXT_SYS_PD
//! Bind object to a symbol
- bool Bind(const t_symbol *s) { pd_bind(&thisHdr()->ob_pd,const_cast<t_symbol *>(s)); return true; }
+ bool Bind(const t_symbol *sym);
//! Unbind object from a symbol
- bool Unbind(const t_symbol *s) { pd_unbind(&thisHdr()->ob_pd,const_cast<t_symbol *>(s)); return true; }
-#elif FLEXT_SYS == FLEXT_SYS_MAX
- //! Bind object to a symbol
- bool Bind(const t_symbol *s) { if(s->s_thing) return false; else { const_cast<t_symbol *>(s)->s_thing = (t_object *)thisHdr(); return true; } }
- //! Unbind object from a symbol
- bool Unbind(const t_symbol *s) { if(s->s_thing != (t_object *)thisHdr()) return false; else { const_cast<t_symbol *>(s)->s_thing = NULL; return true; } }
+ bool Unbind(const t_symbol *sym);
#endif
#if FLEXT_SYS == FLEXT_SYS_JMAX
//! Bind object to a symbol (as string)
- bool Bind(const char *c); // ** TODO **
+ bool Bind(const char *sym); // ** TODO **
//! Unbind object from a symbol (as string)
- bool Unbind(const char *c); // ** TODO **
+ bool Unbind(const char *sym); // ** TODO **
#else
//! Bind object to a symbol (as string)
- bool Bind(const char *c) { return Bind(MakeSymbol(c)); }
+ bool Bind(const char *sym) { return Bind(MakeSymbol(sym)); }
//! Unbind object from a symbol (as string)
- bool Unbind(const char *c) { return Unbind(MakeSymbol(c)); }
+ bool Unbind(const char *sym) { return Unbind(MakeSymbol(sym)); }
#endif
- //! Bind a method to a symbol
- bool BindMethod(const t_symbol *s,bool (*m)(flext_base *,t_symbol *s,int argc,t_atom *argv,void *data),void *data = NULL);
- //! Unbind a method from a symbol
- bool UnbindMethod(const t_symbol *s);
-
- //! Bind a method to a symbol (as string)
- bool BindMethod(const char *c,bool (*m)(flext_base *,t_symbol *s,int argc,t_atom *argv,void *data),void *data = NULL) { return BindMethod(MakeSymbol(c),m,data); }
- //! Unbind a method from a symbol (as string)
- bool UnbindMethod(const char *c) { return UnbindMethod(MakeSymbol(c)); }
+ /*! \brief Bind a method to a symbol
+ \param sym Symbol to bind to
+ \param meth Function to bind
+ \param data User data that is passed to the function
+ \return true on success
+ */
+ bool BindMethod(const t_symbol *sym,bool (*meth)(flext_base *obj,t_symbol *sym,int argc,t_atom *argv,void *data),void *data = NULL);
+ /*! \brief Unbind a method from a symbol
+ \param data returns data pointer specified with BindMethod
+ \return true on success
+ */
+ bool UnbindMethod(const t_symbol *sym,void **data = NULL);
+
+ /*! \brief Bind a method to a symbol (as string)
+ \param sym Symbol to bind to
+ \param meth Function to bind
+ \param data User data that is passed to the function
+ \return true on success
+ */
+ bool BindMethod(const char *sym,bool (*meth)(flext_base *obj,t_symbol *sym,int argc,t_atom *argv,void *data),void *data = NULL) { return BindMethod(MakeSymbol(sym),meth,data); }
+ /*! \brief Unbind a method from a symbol (as string)
+ \param data returns data pointer specified with BindMethod
+ \return true on success
+ */
+ bool UnbindMethod(const char *sym,void **data = NULL) { return UnbindMethod(MakeSymbol(sym),data); }
//! @} FLEXT_C_BIND
diff --git a/externals/grill/flext/source/fldefs_methbind.h b/externals/grill/flext/source/fldefs_methbind.h
index 977e22f8..70b29300 100644
--- a/externals/grill/flext/source/fldefs_methbind.h
+++ b/externals/grill/flext/source/fldefs_methbind.h
@@ -34,6 +34,13 @@ BindMethod(SYM,FLEXT_CALL_PRE(M_FUN),DATA)
\
UnbindMethod(SYM)
+/*! \brief Unbind any handler for a method from a symbol and return user data pointer by DATA
+ \note Memory associated to the DATA parameter of FLEXT_BINDMETHOD will *not* be freed here.
+*/
+#define FLEXT_UNBINDMETHOD_X(SYM,DATA) \
+\
+UnbindMethod(SYM,&DATA)
+
//! @} FLEXT_D_BINDMETHOD
diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp
index 2c33387f..252f2da7 100644
--- a/externals/grill/flext/source/fldsp.cpp
+++ b/externals/grill/flext/source/fldsp.cpp
@@ -79,8 +79,18 @@ flext_dsp::~flext_dsp()
#if FLEXT_SYS == FLEXT_SYS_JMAX
fts_dsp_object_delete(thisHdr());
#endif
+
+/*
+#if FLEXT_SYS == FLEXT_SYS_MAX
+ // switch off dsp as the dsp function might get called afterwards (?!)
+ thisHdr()->z_disabled = true;
+
if(invecs) delete[] invecs;
if(outvecs) delete[] outvecs;
+#elif FLEXT_SYS == FLEXT_SYS_PD
+ dspon = false;
+#endif
+*/
}
#if FLEXT_SYS == FLEXT_SYS_JMAX
@@ -91,6 +101,7 @@ void flext_dsp::dspmeth(fts_word_t *w)
t_int *flext_dsp::dspmeth(t_int *w)
{
flext_dsp *obj = (flext_dsp *)w[1];
+/*
#ifdef FLEXT_DEBUG
if(!obj->thisHdr()) {
// object is already deleted!
@@ -98,6 +109,7 @@ t_int *flext_dsp::dspmeth(t_int *w)
return w+3;
}
#endif
+*/
#if FLEXT_SYS == FLEXT_SYS_MAX
if(!obj->thisHdr()->z_disabled)
#else
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index 26ddc51f..20474812 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -29,6 +29,9 @@ const t_symbol *flext::sym_anything = NULL;
const t_symbol *flext::sym_signal = NULL;
#endif
+int flext::Version() { return FLEXT_VERSION; }
+const char *flext::VersionStr() { return FLEXT_VERSTR; }
+
void flext::Setup()
{
static bool issetup = false;
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index f4b81c58..2235e854 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -38,6 +38,19 @@ class FLEXT_SHARE flext {
*/
public:
+// --- version -----------------------------------------------
+
+ /*! \brief Flext version number
+
+ Return the version number of the flext library.
+ For statically linked flext this is identical to the header definition FLEXT_VERSION,
+ otherwise it reflects the version number of the shared flext library.
+ */
+ static int Version();
+
+ //! Flext version string
+ static const char *VersionStr();
+
// --- console output -----------------------------------------------
#if FLEXT_SYS == FLEXT_SYS_JMAX