From 6c11b94129b43ddb663122a4d6274489e63bca3d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Mon, 20 Oct 2003 02:32:51 +0000 Subject: "" svn path=/trunk/; revision=1109 --- externals/grill/flext/changes.txt | 1 + externals/grill/flext/flext.vcproj | 660 +++++++++++++++++++++++++++++++- externals/grill/flext/source/flbind.cpp | 37 +- externals/grill/flext/source/flclass.h | 9 + 4 files changed, 689 insertions(+), 18 deletions(-) (limited to 'externals/grill/flext') diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index f24da9fb..b1999338 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -35,6 +35,7 @@ Version history: - added support for patcher arguments for attributes (use # instead of $ to save them with a patch) - moved memory functions and console output from flext to super-base-class flext_root and derived all helper classes from that - changed FLEXT_THREAD_X: wrappers doesn't delete the passed data pointer anymore -> the called method is responsible for that (and it knows the type....) +- enabled binding of more than one function to a symbol and added flext_base::GetBoundMethod 0.4.4: - fixed deadly bug for Max/MSP method-to-symbol-binding proxies diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj index 9b67b2dd..659a37ec 100644 --- a/externals/grill/flext/flext.vcproj +++ b/externals/grill/flext/flext.vcproj @@ -124,7 +124,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -812,6 +922,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -929,6 +1059,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -1046,6 +1196,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -1163,6 +1333,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + + + + + + + @@ -1407,6 +1617,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -1530,6 +1760,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -1653,6 +1903,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + - - - - + Name="Max Threaded Debug|Win32"> + Name="Max Threaded Release|Win32"> + PreprocessorDefinitions="" + BasicRuntimeChecks="3" + BrowseInformation="1"/> + + + + + + + + + + @@ -1894,6 +2184,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2011,6 +2321,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2128,6 +2458,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2245,6 +2595,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2362,6 +2732,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2479,6 +2869,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2596,6 +3006,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -2713,6 +3143,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + + + + + + + @@ -2954,6 +3424,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -3071,6 +3561,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -3191,6 +3701,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -3308,6 +3838,26 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + + + + + + + @@ -3559,6 +4129,28 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll BasicRuntimeChecks="3" BrowseInformation="1"/> + + + + + + @@ -3598,6 +4190,18 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll + + + + + + + + + + + + @@ -3764,6 +4390,18 @@ copy F:\prog\max\flext\max-msvc\flext.max.dll f:\prog\dll + + + + + + Find(sym,0)) { - post("%s - Symbol already bound",thisName()); - return false; - } + 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) { // Hash it! @@ -153,12 +158,14 @@ bool flext_base::UnbindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_sym } } else { - int sz = bindhead->Size(); + // 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(it->tag == sym && (!fun || it->fun == fun)) break; + if(!fun || it->fun == fun) break; } if(it) break; } @@ -172,11 +179,27 @@ bool flext_base::UnbindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_sym return ok; } +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->Size(); + int sz = bindhead->Count(); if(!sz) sz = 1; for(int i = 0; i < sz; ++i) { diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index fa5337b7..17842bd2 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -437,11 +437,20 @@ public: \return true on success */ 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) 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) 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 \note Memory associated to data pointers passed by BindMethod will not be freed! -- cgit v1.2.1