From 74e28b058aaf629d94ad7d44a9add3062e89441d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sun, 22 Feb 2004 03:34:00 +0000 Subject: "" svn path=/trunk/; revision=1326 --- externals/grill/flext/source/flmeth.cpp | 53 ++++++++++++++------------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'externals/grill/flext/source/flmeth.cpp') diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp index ce49b5c5..6f8e5844 100755 --- a/externals/grill/flext/source/flmeth.cpp +++ b/externals/grill/flext/source/flmeth.cpp @@ -2,7 +2,7 @@ flext - C++ layer for Max/MSP and pd (pure data) externals -Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) +Copyright (c) 2001-2004 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. @@ -20,8 +20,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include -flext_base::MethItem::MethItem(int in,const t_symbol *tg,AttrItem *conn): - Item(tg,in,conn),index(0), +flext_base::MethItem::MethItem(AttrItem *conn): + Item(conn),index(0), argc(0),args(NULL) ,fun(NULL) {} @@ -41,7 +41,8 @@ void flext_base::MethItem::SetArgs(methfun _fun,int _argc,metharg *_args) void flext_base::AddMethodDef(int inlet,const char *tag) { - methhead->Add(new MethItem(inlet,tag?MakeSymbol(tag):NULL)); + const t_symbol *t = tag?MakeSymbol(tag):NULL; + methhead->Add(new MethItem,t,inlet); } /*! \brief Add a method to the queue @@ -84,42 +85,32 @@ void flext_base::AddMethod(ItemCont *ma,int inlet,const char *tag,methfun fun,me va_end(marker); } - MethItem *mi = new MethItem(inlet,MakeSymbol(tag)); - + MethItem *mi = new MethItem; + mi->index = ma->Members(); mi->SetArgs(fun,argc,args); - - ma->Add(mi); - - // set index - MethItem *last = (MethItem *)ma->Last(); - if(last) mi->index = last->index+1; + ma->Add(mi,MakeSymbol(tag),inlet); } - -struct methless : public std::binary_function -{ - 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 MethList; + typedef std::map MethList; MethList list[2]; int i; for(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); - } + if(a && a->Contained(inlet)) { + ItemSet &ai = a->GetInlet(inlet); + for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { + for(ItemList::iterator al = as->second.begin(); al != as->second.end(); ++al) { + MethItem *aa = (MethItem *)*al; + + // check it's not related to an attribute + if(!aa->IsAttr()) { + list[i][aa->index] = as->first; + break; + } + } } } } @@ -129,7 +120,7 @@ void flext_base::ListMethods(AtomList &la,int inlet) const MethList::iterator it; for(i = 0; i <= 1; ++i) for(it = list[i].begin(); it != list[i].end(); ++it) - SetSymbol(la[ix++],(*it)->tag); + SetSymbol(la[ix++],it->second); } bool flext_base::ListMethods(int inlet) const -- cgit v1.2.1