Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1:/tmp/cvs-serv2681/source
Modified Files: flbind.cpp flclass.h Log Message: ""
Index: flbind.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbind.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** flbind.cpp 25 Jul 2003 02:32:45 -0000 1.10 --- flbind.cpp 20 Oct 2003 02:32:51 -0000 1.11 *************** *** 96,103 **** else { // Search for symbol ! if(bindhead->Find(sym,0)) { ! post("%s - Symbol already bound",thisName()); ! return false; ! }
if(bindhead->Count() > 20) { --- 96,108 ---- else { // Search for symbol ! flext_base::BindItem *item = (flext_base::BindItem *)bindhead->Find(sym,0); ! ! // go through all items with matching tag ! for(; item && item->tag == sym; item = (flext_base::BindItem *)item->nxt) ! if(item->fun == fun) { ! // function already registered -> bail out! ! post("%s - Symbol already bound with this method",thisName()); ! return false; ! }
if(bindhead->Count() > 20) { *************** *** 154,163 **** } else { ! int sz = bindhead->Size(); if(!sz) sz = 1;
for(int i = 0; i < sz; ++i) { for(it = (BindItem *)bindhead->GetItem(i); it; it = (BindItem *)it->nxt) { ! if(it->tag == sym && (!fun || it->fun == fun)) break; } if(it) break; --- 159,170 ---- } else { ! // any tag ! ! int sz = bindhead->Count(); if(!sz) sz = 1;
for(int i = 0; i < sz; ++i) { for(it = (BindItem *)bindhead->GetItem(i); it; it = (BindItem *)it->nxt) { ! if(!fun || it->fun == fun) break; } if(it) break; *************** *** 173,181 **** }
bool flext_base::UnbindAll() { // bool memleak = false;
! int sz = bindhead->Size(); if(!sz) sz = 1;
--- 180,204 ---- }
+ bool flext_base::GetBoundMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbol *s,int argc,t_atom *argv,void *data),void *&data) + { + if(bindhead) { + // Search for symbol + flext_base::BindItem *item = (flext_base::BindItem *)bindhead->Find(sym,0); + + // go through all items with matching tag + for(; item && item->tag == sym; item = (flext_base::BindItem *)item->nxt) + if(item->fun == fun) { + data = item->px->data; + return true; + } + } + return false; + } + bool flext_base::UnbindAll() { // bool memleak = false;
! int sz = bindhead->Count(); if(!sz) sz = 1;
Index: flclass.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flclass.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** flclass.h 24 Sep 2003 02:34:55 -0000 1.38 --- flclass.h 20 Oct 2003 02:32:51 -0000 1.39 *************** *** 438,441 **** --- 438,448 ---- */ 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 Get data of bound method of a symbol + \param sym Symbol to bind to + \param meth Function to bind + \param data Reference to returned user data + \return true on success (symbol/method combination was found) + */ + bool GetBoundMethod(const t_symbol *sym,bool (*meth)(flext_base *obj,t_symbol *sym,int argc,t_atom *argv,void *data),void *&data);
//! \brief Bind a method to a symbol (as string) *************** *** 443,446 **** --- 450,455 ---- //! \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); } + //! \brief Get data of bound method of a symbol (as string) + bool GetBoundMethod(const char *sym,bool (*meth)(flext_base *obj,t_symbol *sym,int argc,t_atom *argv,void *data),void *&data) { return GetBoundMethod(MakeSymbol(sym),meth,data); }
/*! Unbind all symbol bindings