From 8b042a66a4fd811589412747e38e8c7ee784db3c Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 15 May 2003 02:32:38 +0000 Subject: "" svn path=/trunk/; revision=618 --- externals/grill/flext/source/flbind.cpp | 35 +++++++++++++++++++++------ externals/grill/flext/source/flclass.h | 22 ++++++----------- externals/grill/flext/source/fldefs_attrvar.h | 4 +-- 3 files changed, 37 insertions(+), 24 deletions(-) (limited to 'externals/grill/flext/source') diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp index 53f041c6..d2a00129 100644 --- a/externals/grill/flext/source/flbind.cpp +++ b/externals/grill/flext/source/flbind.cpp @@ -135,17 +135,36 @@ bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbo } -bool flext_base::UnbindMethod(const t_symbol *sym,void **data) +bool flext_base::UnbindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbol *s,int argc,t_atom *argv,void *data),void **data) { bool ok = false; - binditem *it = bindhead?(binditem *)bindhead->Find(sym,0):NULL; - void *d = NULL; - if(it) { - d = it->px->data; - ok = bindhead->Remove(it); - if(ok) delete it; + + if(bindhead) { + void *d = NULL; + binditem *it = NULL; + if(sym) { + it = (binditem *)bindhead->Find(sym,0); + while(it) { + if(it->tag == sym && (!fun || it->fun == fun)) break; + } + } + else { + int sz = bindhead->Size(); + if(!sz) sz = 1; + + for(int i = 0; i < sz; ++i) { + for(it = (binditem *)bindhead->Item(0); it; it = (binditem *)it->nxt) { + if(it->tag == sym && (!fun || it->fun == fun)) break; + } + if(it) break; + } + } + if(it) { + if(data) *data = it->px->data; + ok = bindhead->Remove(it); + if(ok) delete it; + } } - if(data) *data = d; return ok; } diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index 4fa4f614..4cbeb03f 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -416,23 +416,17 @@ public: */ 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 sym Symbol to unbind from (if NULL... unbind all functions) + \param meth Method to unbind (if NULL ... unbind all functions bound to symbol) \param data returns data pointer specified with BindMethod \return true on success */ - bool UnbindMethod(const t_symbol *sym,void **data = NULL); + bool UnbindMethod(const t_symbol *sym,bool (*meth)(flext_base *obj,t_symbol *sym,int argc,t_atom *argv,void *data) = NULL,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 - */ + //! \brief Bind a method to a symbol (as string) 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); } + //! \brief Unbind a method from a symbol (as string) + bool UnbindMethod(const char *sym,bool (*meth)(flext_base *obj,t_symbol *sym,int argc,t_atom *argv,void *data) = NULL,void **data = NULL) { return UnbindMethod(MakeSymbol(sym),meth,data); } //! @} FLEXT_C_BIND @@ -492,7 +486,7 @@ protected: void AddAttrib(const char *attr,bool (*get)(flext_base *,float &),bool (*set)(flext_base *,float &)) { AddAttrib(attr,a_float,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,int &),bool (*set)(flext_base *,int &)) { AddAttrib(attr,a_int,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,const t_symbol *&),bool (*set)(flext_base *,const t_symbol *&)) { AddAttrib(attr,a_symbol,(methfun)get,(methfun)set); } - void AddAttrib(const char *attr,bool (*get)(flext_base *,t_symbol *&),bool (*set)(flext_base *,t_symbol *&)) { AddAttrib(attr,a_symbol,(methfun)get,(methfun)set); } + void AddAttrib(const char *attr,bool (*get)(flext_base *,t_symptr &),bool (*set)(flext_base *,t_symptr &)) { AddAttrib(attr,a_symbol,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,AtomList *&),bool (*set)(flext_base *,AtomList *&)) { AddAttrib(attr,a_LIST,(methfun)get,(methfun)set); } void AddAttrib(const char *attr,bool (*get)(flext_base *,AtomAnything *&),bool (*set)(flext_base *,AtomAnything *&)) { AddAttrib(attr,a_ANY,(methfun)get,(methfun)set); } @@ -505,7 +499,7 @@ protected: static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,float &),bool (*set)(flext_base *,float &)) { AddAttrib(c,attr,a_float,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,int &),bool (*set)(flext_base *,int &)) { AddAttrib(c,attr,a_int,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,const t_symbol *&),bool (*set)(flext_base *,const t_symbol *&)) { AddAttrib(c,attr,a_symbol,(methfun)get,(methfun)set); } - static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,t_symbol *&),bool (*set)(flext_base *,t_symbol *&)) { AddAttrib(c,attr,a_symbol,(methfun)get,(methfun)set); } + static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,t_symptr &),bool (*set)(flext_base *,t_symptr &)) { AddAttrib(c,attr,a_symbol,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,AtomList *&),bool (*set)(flext_base *,AtomList *&)) { AddAttrib(c,attr,a_LIST,(methfun)get,(methfun)set); } static void AddAttrib(t_classid c,const char *attr,bool (*get)(flext_base *,AtomAnything *&),bool (*set)(flext_base *,AtomAnything *&)) { AddAttrib(c,attr,a_ANY,(methfun)get,(methfun)set); } diff --git a/externals/grill/flext/source/fldefs_attrvar.h b/externals/grill/flext/source/fldefs_attrvar.h index 876f49f2..f0a04987 100644 --- a/externals/grill/flext/source/fldefs_attrvar.h +++ b/externals/grill/flext/source/fldefs_attrvar.h @@ -50,7 +50,7 @@ FLEXT_ATTRSET_(VAR,int) //! Declare an implicite set function for a symbol attribute #define FLEXT_ATTRSET_S(VAR) \ \ -FLEXT_ATTRSET_(VAR,t_symptr) +FLEXT_ATTRSET_(VAR,const t_symbol *) //! Declare an implicite set function for a boolean attribute #define FLEXT_ATTRSET_B(VAR) \ @@ -86,7 +86,7 @@ FLEXT_ATTRGET_(VAR,int) //! Declare an implicite get function for a symbol attribute #define FLEXT_ATTRGET_S(VAR) \ \ -FLEXT_ATTRGET_(VAR,t_symptr) +FLEXT_ATTRGET_(VAR,const t_symbol *) //! Declare an implicite get function for a boolean attribute #define FLEXT_ATTRGET_B(VAR) \ -- cgit v1.2.1