aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flmeth.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-07-29 02:32:56 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-07-29 02:32:56 +0000
commitf7e8bf39ce93d52d60cc6fd5e6a83539f9d598db (patch)
tree6c093f44a4b48444e7c7970a12512feb8c2ce367 /externals/grill/flext/source/flmeth.cpp
parent1504a2e019bfecb07c93da78d8df9b6c99ee7a52 (diff)
""
svn path=/trunk/; revision=800
Diffstat (limited to 'externals/grill/flext/source/flmeth.cpp')
-rwxr-xr-xexternals/grill/flext/source/flmeth.cpp66
1 files changed, 65 insertions, 1 deletions
diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp
index 3637529e..e911d563 100755
--- a/externals/grill/flext/source/flmeth.cpp
+++ b/externals/grill/flext/source/flmeth.cpp
@@ -17,8 +17,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <stdarg.h>
#include "flinternal.h"
+#include <set>
+
+
flext_base::MethItem::MethItem(int in,const t_symbol *tg,AttrItem *conn):
- Item(tg,in,conn),
+ Item(tg,in,conn),index(0),
argc(0),args(NULL)
,fun(NULL)
{}
@@ -86,4 +89,65 @@ void flext_base::AddMethod(ItemCont *ma,int inlet,const char *tag,methfun fun,me
mi->SetArgs(fun,argc,args);
ma->Add(mi);
+
+ // set index
+ MethItem *last = (MethItem *)ma->Last();
+ if(last) mi->index = last->index+1;
+}
+
+
+struct methless : public std::binary_function <flext_base::MethItem *,flext_base::MethItem *, bool>
+{
+ bool operator()(const flext_base::MethItem *l,const flext_base::MethItem *r) const {
+ return l->index != r->index?l->index < r->index:strcmp(flext::GetString(l->tag),flext::GetString(r->tag)) < 0;
+ }
+};
+
+void flext_base::ListMethods(AtomList &la,int inlet) const
+{
+ typedef std::set<MethItem *,methless> MethList;
+ MethList list[2];
+
+ for(int i = 0; i <= 1; ++i) {
+ ItemCont *a = i?methhead:clmethhead;
+ if(a) {
+ for(int ai = 0; ai < a->Size(); ++ai) {
+ for(Item *l = a->GetItem(ai); l; l = l->nxt) {
+ MethItem *aa = (MethItem *)l;
+
+ // match inlet and see check it's not related to an attribute
+ if(aa->inlet == inlet && !aa->IsAttr())
+ list[i].insert(aa);
+ }
+ }
+ }
+ }
+
+ la(list[0].size()+list[1].size());
+ int ix = 0;
+ MethList::iterator it;
+ for(i = 0; i <= 1; ++i)
+ for(it = list[i].begin(); it != list[i].end(); ++it)
+ SetSymbol(la[ix++],(*it)->tag);
+}
+
+bool flext_base::ListMethods(int inlet) const
+{
+ if(procattr) {
+ AtomList la;
+ ListMethods(la,inlet);
+ ToOutAnything(GetOutAttr(),MakeSymbol("methods"),la.Count(),la.Atoms());
+ return true;
+ }
+ else
+ return false;
+}
+
+bool flext_base::cb_ListMethods(flext_base *c,int argc,const t_atom *argv)
+{
+ if(argc == 0 || (argc == 1 && CanbeInt(argv[0])))
+ return c->ListMethods(argc?GetAInt(argv[0]):0);
+ else
+ return false;
}
+