Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1597/source
Modified Files: flattr.cpp flattr_ed.cpp flbind.cpp flclass.h flitem.cpp fllib.cpp flmeth.cpp flmsg.cpp flsupport.cpp flsupport.h Log Message: ""
Index: flattr.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flattr.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** flattr.cpp 22 Feb 2004 03:33:59 -0000 1.20 --- flattr.cpp 6 Mar 2004 03:25:48 -0000 1.21 *************** *** 33,39 **** {}
! flext_base::AttrItem::~AttrItem() { ! // if(nxt) delete nxt; }
--- 33,43 ---- {}
! ! flext_base::AttrDataCont::AttrDataCont() {} ! ! flext_base::AttrDataCont::~AttrDataCont() { ! for(iterator it = begin(); it != end(); ++it) ! if(it.data()) delete it.data(); }
*************** *** 97,101 **** void flext_base::ListAttrib(AtomList &la) const { ! typedef std::map<int,const t_symbol *> AttrList; AttrList list[2];
--- 101,105 ---- void flext_base::ListAttrib(AtomList &la) const { ! typedef DataMap<int,const t_symbol *> AttrList; AttrList list[2];
*************** *** 106,112 **** ItemSet &ai = a->GetInlet(); for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { ! for(ItemList::iterator al = as->second.begin(); al != as->second.end(); ++al) { ! AttrItem *aa = (AttrItem *)*al; ! list[i][aa->index] = as->first; break; } --- 110,116 ---- ItemSet &ai = a->GetInlet(); for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { ! for(Item *al = as.data(); al; al = al->nxt) { ! AttrItem *aa = (AttrItem *)al; ! list[i][aa->index] = as.key(); break; } *************** *** 120,124 **** for(i = 0; i <= 1; ++i) for(it = list[i].begin(); it != list[i].end(); ++it) ! SetSymbol(la[ix++],it->second); }
--- 124,128 ---- for(i = 0; i <= 1; ++i) for(it = list[i].begin(); it != list[i].end(); ++it) ! SetSymbol(la[ix++],it.data()); }
*************** *** 145,149 **** if(attr) { // make an entry (there are none beforehand...) ! AttrData &a = (*attrdata)[tag]; a.SetInit(true); a.SetInitValue(nxt-cur-1,argv+cur+1); --- 149,161 ---- if(attr) { // make an entry (there are none beforehand...) ! AttrDataCont::iterator it = attrdata->find(tag); ! if(it == attrdata->end()) { ! AttrDataCont::pair pair; ! pair.key() = tag; ! pair.data() = new AttrData; ! it = attrdata->insert(attrdata->begin(),pair); ! } ! ! AttrData &a = *it.data(); a.SetInit(true); a.SetInitValue(nxt-cur-1,argv+cur+1); *************** *** 173,182 **** AttrItem *a = NULL; { ! ItemList *lst = attrhead->FindList(tag); ! if(lst) { ! for(ItemList::iterator it = lst->begin(); it != lst->end(); ++it) { ! AttrItem *b = (AttrItem *)*it; ! if(get?b->IsGet():b->IsSet()) { a = b; break; } ! } } } --- 185,191 ---- AttrItem *a = NULL; { ! for(Item *lst = attrhead->FindList(tag); lst; lst = lst->nxt) { ! AttrItem *b = (AttrItem *)lst; ! if(get?b->IsGet():b->IsSet()) { a = b; break; } } } *************** *** 184,193 **** // then (if nothing found) search within class scope if(!a) { ! ItemList *lst = clattrhead->FindList(tag); ! if(lst) { ! for(ItemList::iterator it = lst->begin(); it != lst->end(); ++it) { ! AttrItem *b = (AttrItem *)*it; ! if(get?b->IsGet():b->IsSet()) { a = b; break; } ! } } } --- 193,199 ---- // then (if nothing found) search within class scope if(!a) { ! for(Item *lst = clattrhead->FindList(tag); lst; lst = lst->nxt) { ! AttrItem *b = (AttrItem *)lst; ! if(get?b->IsGet():b->IsSet()) { a = b; break; } } } *************** *** 371,377 **** ItemSet &ai = a->GetInlet(); // \todo need to check for presence of inlet 0? for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { ! for(ItemList::iterator al = as->second.begin(); al != as->second.end(); ++al) { ! AttrItem *a = (AttrItem *)*al; ! if(a->IsGet() && a->BothExist()) BangAttrib(as->first,a); } } --- 377,383 ---- ItemSet &ai = a->GetInlet(); // \todo need to check for presence of inlet 0? for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { ! for(Item *al = as.data(); al; al = al->nxt) { ! AttrItem *a = (AttrItem *)al; ! if(a->IsGet() && a->BothExist()) BangAttrib(as.key(),a); } }
Index: flattr_ed.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flattr_ed.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** flattr_ed.cpp 22 Feb 2004 03:33:59 -0000 1.19 --- flattr_ed.cpp 6 Mar 2004 03:25:48 -0000 1.20 *************** *** 437,441 **** sv = 0,initdata = NULL; else { ! const AttrData &a = it->second; if(a.IsSaved()) sv = 2; --- 437,441 ---- sv = 0,initdata = NULL; else { ! const AttrData &a = *it.data(); if(a.IsSaved()) sv = 2; *************** *** 574,578 ****
if(it != th->attrdata->end()) { ! const AttrData &a = it->second; if(a.IsInit() && a.IsInitValue()) { lref = &a.GetInitValue(); --- 574,578 ----
if(it != th->attrdata->end()) { ! const AttrData &a = *it.data(); if(a.IsInit() && a.IsInitValue()) { lref = &a.GetInitValue(); *************** *** 671,679 **** // if data not present create it if(it == th->attrdata->end()) { ! AttrDataPair pair; pair.first = aname; it = th->attrdata->insert(th->attrdata->begin(),pair); }
! AttrData &a = it->second; a.SetSave(sv == 2); a.SetInit(true); --- 671,681 ---- // if data not present create it if(it == th->attrdata->end()) { ! AttrDataCont::pair pair; ! pair.key() = aname; ! pair.data() = new AttrData; it = th->attrdata->insert(th->attrdata->begin(),pair); }
! AttrData &a = *it.data(); a.SetSave(sv == 2); a.SetInit(true); *************** *** 682,686 **** else { if(it != th->attrdata->end()) { ! AttrData &a = it->second; // if data is present reset flags a.SetSave(false); --- 684,688 ---- else { if(it != th->attrdata->end()) { ! AttrData &a = *it.data(); // if data is present reset flags a.SetSave(false);
Index: flbind.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbind.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** flbind.cpp 22 Feb 2004 03:34:00 -0000 1.12 --- flbind.cpp 6 Mar 2004 03:25:48 -0000 1.13 *************** *** 100,116 **** else { // Search for symbol ! ItemList *lst = bindhead->FindList(sym); ! ! if(lst) ! for(ItemList::iterator it = lst->begin(); it != lst->end(); ++it) { ! BindItem *item = (BindItem *)*it;
! // go through all items with matching tag ! if(item->fun == fun) { ! // function already registered -> bail out! ! post("%s - Symbol already bound with this method",thisName()); ! return false; ! } } }
--- 100,113 ---- else { // Search for symbol ! for(Item *it = bindhead->FindList(sym); it; it = it->nxt) { ! BindItem *item = (BindItem *)it;
! // go through all items with matching tag ! if(item->fun == fun) { ! // function already registered -> bail out! ! post("%s - Symbol already bound with this method",thisName()); ! return false; } + } }
*************** *** 167,172 **** BindItem *it = NULL; for(ItemSet::iterator si = it1; si != it2 && !it; ++si) { ! for(ItemList::iterator i = si->second.begin(); i != si->second.end(); ++i) { ! BindItem *item = (BindItem *)*i; if(!fun || item->fun == fun) { it = item; break; } } --- 164,169 ---- BindItem *it = NULL; for(ItemSet::iterator si = it1; si != it2 && !it; ++si) { ! for(Item *i = si.data(); i; i = i->nxt) { ! BindItem *item = (BindItem *)i; if(!fun || item->fun == fun) { it = item; break; } } *************** *** 189,204 **** if(bindhead) { // Search for symbol ! ItemList *lst = bindhead->FindList(sym); ! ! if(lst) ! for(ItemList::iterator it = lst->begin(); it != lst->end(); ++it) { ! BindItem *item = (BindItem *)*it;
! // go through all items with matching tag ! if(item->fun == fun) { ! data = item->px->data; ! return true; ! } } } return false; --- 186,198 ---- if(bindhead) { // Search for symbol ! for(Item *it = bindhead->FindList(sym); it; it = it->nxt) { ! BindItem *item = (BindItem *)it;
! // go through all items with matching tag ! if(item->fun == fun) { ! data = item->px->data; ! return true; } + } } return false; *************** *** 210,220 **** ItemSet &set = bindhead->GetInlet(); for(ItemSet::iterator si = set.begin(); si != set.end(); ++si) { ! ItemList &lst = si->second; ! while(!lst.empty()) { ! // eventual allocated data in item is not freed! ! BindItem *it = (BindItem *)lst.front(); ! it->Unbind(si->first); delete it; ! lst.pop_front(); } } --- 204,214 ---- ItemSet &set = bindhead->GetInlet(); for(ItemSet::iterator si = set.begin(); si != set.end(); ++si) { ! Item *lst = si.data(); ! while(lst) { ! Item *nxt = lst->nxt; ! BindItem *it = (BindItem *)lst; ! it->Unbind(si.key()); delete it; ! lst = nxt; } }
Index: flclass.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flclass.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** flclass.h 22 Feb 2004 03:34:00 -0000 1.41 --- flclass.h 6 Mar 2004 03:25:48 -0000 1.42 *************** *** 21,29 **** #include "flsupport.h"
- #include <map> - #include <set> - #include <list> - #include <vector> - #ifdef _MSC_VER #pragma warning(disable: 4786) --- 21,24 ---- *************** *** 605,632 **** { public: ! Item(AttrItem *a): attr(a) {} ! virtual ~Item() {} bool IsAttr() const { return attr != NULL; }
AttrItem *attr; };
! typedef std::list<Item *> ItemList; ! ! typedef std::map<const t_symbol *,ItemList> ItemSet; ! typedef std::vector<ItemSet> ItemVec;
! //! This class holds hashed item entries ! class ItemCont: ! private ItemVec { public: ! typedef ItemVec::iterator iterator; ! typedef ItemVec::const_iterator const_iterator;
! ItemCont(): members(0) {}
! bool Contained(int i) const { return i+1 < (int)size(); }
//! Add an entry --- 600,633 ---- { public: ! Item(AttrItem *a): attr(a),nxt(NULL) {} ! virtual ~Item(); bool IsAttr() const { return attr != NULL; }
AttrItem *attr; + Item *nxt; };
! class ItemSet: ! public DataMap<const t_symbol *,Item *> ! { ! public: ! ItemSet(); ! ~ItemSet(); ! };
! /*! This class holds hashed item entries ! \note not thread-safe! ! */ ! class ItemCont { public: ! ItemCont(); ! ~ItemCont();
! int Min() const { return -1; } ! int Max() const { return size-2; }
! bool Contained(int i) const { return i+1 < size; }
//! Add an entry *************** *** 635,641 **** bool Remove(Item *it,const t_symbol *tag,int inlet = 0); //! Find an entry list in the Item array ! ItemList *FindList(const t_symbol *tag,int inlet = 0); //! Get list for an inlet ! ItemSet &GetInlet(int inlet = 0) { return (*this)[inlet+1]; }
//! Get counter for total members (for index of new item) --- 636,647 ---- bool Remove(Item *it,const t_symbol *tag,int inlet = 0); //! Find an entry list in the Item array ! Item *FindList(const t_symbol *tag,int inlet = 0); ! //! Get list for an inlet ! ItemSet &GetInlet(int inlet = 0) ! { ! FLEXT_ASSERT(inlet >= Min() && inlet <= Max()); ! return *cont[inlet+1]; ! }
//! Get counter for total members (for index of new item) *************** *** 643,647 **** --- 649,658 ----
protected: + + void Resize(int nsz); + int members; + int memsize,size; + ItemSet **cont; };
*************** *** 668,672 **** public: AttrItem(metharg tp,methfun fun,int flags); - virtual ~AttrItem();
enum { --- 679,682 ---- *************** *** 711,717 **** };
! typedef std::map<const t_symbol *,AttrData> AttrDataCont; ! typedef std::pair<const t_symbol *,AttrData> AttrDataPair; !
// these outlet functions don't check for thread but send directly to the real-time system --- 721,731 ---- };
! class AttrDataCont: ! public DataMap<const t_symbol *,AttrData *> ! { ! public: ! AttrDataCont(); ! ~AttrDataCont(); ! };
// these outlet functions don't check for thread but send directly to the real-time system *************** *** 735,738 **** --- 749,753 ---- BindItem(bool (*f)(flext_base *,t_symbol *s,int,t_atom *,void *),pxbnd_object *px); virtual ~BindItem(); + void Unbind(const t_symbol *s);
*************** *** 797,803 **** bool CallMeth(const MethItem &m,int argc,const t_atom *argv); bool FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv); ! bool TryMethTag(ItemList &lst,const t_symbol *tag,int argc,const t_atom *argv); ! bool TryMethSym(ItemList &lst,const t_symbol *s); ! bool TryMethAny(ItemList &lst,const t_symbol *s,int argc,const t_atom *argv);
mutable ItemCont *attrhead,*clattrhead; --- 812,818 ---- bool CallMeth(const MethItem &m,int argc,const t_atom *argv); bool FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv); ! bool TryMethTag(Item *lst,const t_symbol *tag,int argc,const t_atom *argv); ! bool TryMethSym(Item *lst,const t_symbol *s); ! bool TryMethAny(Item *lst,const t_symbol *s,int argc,const t_atom *argv);
mutable ItemCont *attrhead,*clattrhead;
Index: flitem.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flitem.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** flitem.cpp 22 Feb 2004 03:34:00 -0000 1.10 --- flitem.cpp 6 Mar 2004 03:25:48 -0000 1.11 *************** *** 16,25 **** #include <string.h>
void flext_base::ItemCont::Add(Item *item,const t_symbol *tag,int inlet) { ! FLEXT_ASSERT(inlet >= -1); ! if(!Contained(inlet)) resize(inlet+2); ItemSet &set = GetInlet(inlet); ! set[tag].push_back(item); members++; } --- 16,73 ---- #include <string.h>
+ + flext_base::Item::~Item() + { + if(nxt) delete nxt; + } + + flext_base::ItemSet::ItemSet() {} + + flext_base::ItemSet::~ItemSet() + { + for(iterator it = begin(); it != end(); ++it) + if(it.data()) delete it.data(); + } + + flext_base::ItemCont::ItemCont(): + memsize(0),size(0),members(0),cont(NULL) + {} + + flext_base::ItemCont::~ItemCont() + { + if(cont) { + for(int i = 0; i < size; ++i) delete cont[i]; + delete[] cont; + } + } + + void flext_base::ItemCont::Resize(int nsz) + { + if(nsz > memsize) { + int nmemsz = nsz+10; // increment maximum allocation size + ItemSet **ncont = new ItemSet *[nmemsz]; // make new array + if(cont) { + memcpy(ncont,cont,size*sizeof(*cont)); // copy existing entries + delete[] cont; + } + cont = ncont; // set current array + memsize = nmemsz; // set new allocation size + } + + // make new items + while(size < nsz) cont[size++] = new ItemSet; + } + void flext_base::ItemCont::Add(Item *item,const t_symbol *tag,int inlet) { ! if(!Contained(inlet)) Resize(inlet+2); ItemSet &set = GetInlet(inlet); ! Item *&lst = set[tag]; ! if(!lst) ! lst = item; ! else ! for(;;) ! if(!lst->nxt) { lst->nxt = item; break; } ! else lst = lst->nxt; members++; } *************** *** 27,40 **** bool flext_base::ItemCont::Remove(Item *item,const t_symbol *tag,int inlet) { - FLEXT_ASSERT(inlet >= -1); if(Contained(inlet)) { ItemSet &set = GetInlet(inlet); ItemSet::iterator it = set.find(tag); if(it != set.end()) { ! ItemList &lst = it->second; ! for(ItemList::iterator lit = lst.begin(); lit != lst.end(); ++lit) { ! if(*lit == item) { ! delete *lit; ! lst.erase(lit); return true; } --- 75,88 ---- bool flext_base::ItemCont::Remove(Item *item,const t_symbol *tag,int inlet) { if(Contained(inlet)) { ItemSet &set = GetInlet(inlet); ItemSet::iterator it = set.find(tag); if(it != set.end()) { ! for(Item *lit = it.data(),*prv = NULL; lit; prv = lit,lit = lit->nxt) { ! if(lit == item) { ! if(prv) prv->nxt = lit->nxt; ! else it.data() = lit->nxt; ! ! lit->nxt = NULL; delete lit; return true; } *************** *** 45,55 **** }
! flext_base::ItemList *flext_base::ItemCont::FindList(const t_symbol *tag,int inlet) { - FLEXT_ASSERT(inlet >= -1); if(Contained(inlet)) { ItemSet &ai = GetInlet(inlet); ItemSet::iterator as = ai.find(tag); ! if(as != ai.end()) return &as->second; } return NULL; --- 93,102 ---- }
! flext_base::Item *flext_base::ItemCont::FindList(const t_symbol *tag,int inlet) { if(Contained(inlet)) { ItemSet &ai = GetInlet(inlet); ItemSet::iterator as = ai.find(tag); ! if(as != ai.end()) return as.data(); } return NULL; *************** *** 58,69 **** // --- class item lists (methods and attributes) ----------------
! typedef std::map<flext_base::t_classid,flext_base::ItemCont *> ClassMap; ! typedef std::vector<ClassMap> ClassArr;
! static ClassArr classarr;
flext_base::ItemCont *flext_base::GetClassArr(t_classid c,int ix) { - if(ix >= (int)classarr.size()) classarr.resize(ix+1); ClassMap &map = classarr[ix]; ClassMap::iterator it = map.find(c); --- 105,114 ---- // --- class item lists (methods and attributes) ----------------
! typedef DataMap<flext_base::t_classid,flext_base::ItemCont *> ClassMap;
! static ClassMap classarr[2];
flext_base::ItemCont *flext_base::GetClassArr(t_classid c,int ix) { ClassMap &map = classarr[ix]; ClassMap::iterator it = map.find(c); *************** *** 74,77 **** } else ! return it->second; } --- 119,122 ---- } else ! return it.data(); }
Index: fllib.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/fllib.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** fllib.cpp 22 Feb 2004 03:34:00 -0000 1.21 --- fllib.cpp 6 Mar 2004 03:25:48 -0000 1.22 *************** *** 125,136 **** argc(0),argv(NULL) {} ! //! Store or retrieve registered classes static libclass *FindName(const t_symbol *s,libclass *o = NULL) { ! typedef std::map<const t_symbol *,libclass *> LibMap; ! ! static LibMap libnames; ! LibMap::iterator it = libnames.find(s); if(it == libnames.end()) { --- 125,138 ---- argc(0),argv(NULL) {} ! ! ! typedef DataMap<const t_symbol *,libclass *> LibMap; ! ! static LibMap libnames; ! //! Store or retrieve registered classes static libclass *FindName(const t_symbol *s,libclass *o = NULL) { ! // typedef std::map<const t_symbol *,libclass *> LibMap; LibMap::iterator it = libnames.find(s); if(it == libnames.end()) { *************** *** 139,143 **** } else ! return it->second; }
--- 141,145 ---- } else ! return it.data(); }
Index: flmeth.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flmeth.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** flmeth.cpp 22 Feb 2004 03:34:00 -0000 1.8 --- flmeth.cpp 6 Mar 2004 03:25:48 -0000 1.9 *************** *** 94,98 **** void flext_base::ListMethods(AtomList &la,int inlet) const { ! typedef std::map<int,const t_symbol *> MethList; MethList list[2];
--- 94,98 ---- void flext_base::ListMethods(AtomList &la,int inlet) const { ! typedef DataMap<int,const t_symbol *> MethList; MethList list[2];
*************** *** 103,112 **** 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; } --- 103,112 ---- ItemSet &ai = a->GetInlet(inlet); for(ItemSet::iterator as = ai.begin(); as != ai.end(); ++as) { ! for(Item *al = as.data(); al; al = al->nxt) { ! MethItem *aa = (MethItem *)al;
// check it's not related to an attribute if(!aa->IsAttr()) { ! list[i][aa->index] = as.key(); break; } *************** *** 121,125 **** for(i = 0; i <= 1; ++i) for(it = list[i].begin(); it != list[i].end(); ++it) ! SetSymbol(la[ix++],it->second); }
--- 121,125 ---- for(i = 0; i <= 1; ++i) for(it = list[i].begin(); it != list[i].end(); ++it) ! SetSymbol(la[ix++],it.data()); }
Index: flmsg.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flmsg.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** flmsg.cpp 22 Feb 2004 03:34:00 -0000 1.10 --- flmsg.cpp 6 Mar 2004 03:25:48 -0000 1.11 *************** *** 73,80 **** }
! bool flext_base::TryMethTag(ItemList &lst,const t_symbol *tag,int argc,const t_atom *argv) { ! for(ItemList::iterator it = lst.begin(); it != lst.end(); ++it) { ! MethItem *m = (MethItem *)*it;
// FLEXT_LOG3("found method tag %s: inlet=%i, argc=%i",GetString(tag),m->inlet,argc); --- 73,80 ---- }
! bool flext_base::TryMethTag(Item *lst,const t_symbol *tag,int argc,const t_atom *argv) { ! for(; lst; lst = lst->nxt) { ! MethItem *m = (MethItem *)lst;
// FLEXT_LOG3("found method tag %s: inlet=%i, argc=%i",GetString(tag),m->inlet,argc); *************** *** 104,111 **** }
! bool flext_base::TryMethSym(ItemList &lst,const t_symbol *s) { ! for(ItemList::iterator it = lst.begin(); it != lst.end(); ++it) { ! MethItem *m = (MethItem *)*it;
if(!m->IsAttr()) { --- 104,111 ---- }
! bool flext_base::TryMethSym(Item *lst,const t_symbol *s) { ! for(; lst; lst = lst->nxt) { ! MethItem *m = (MethItem *)lst;
if(!m->IsAttr()) { *************** *** 119,126 **** }
! bool flext_base::TryMethAny(ItemList &lst,const t_symbol *s,int argc,const t_atom *argv) { ! for(ItemList::iterator it = lst.begin(); it != lst.end(); ++it) { ! MethItem *m = (MethItem *)*it;
if(!m->IsAttr() && m->argc == 1 && m->args[0] == a_any) { --- 119,126 ---- }
! bool flext_base::TryMethAny(Item *lst,const t_symbol *s,int argc,const t_atom *argv) { ! for(; lst; lst = lst->nxt) { ! MethItem *m = (MethItem *)lst;
if(!m->IsAttr() && m->argc == 1 && m->args[0] == a_any) { *************** *** 138,156 **** bool flext_base::FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv) { ! ItemList *lst;
// search for exactly matching tag ! if((lst = methhead->FindList(s,inlet)) != NULL && TryMethTag(*lst,s,argc,argv)) return true; ! if((lst = clmethhead->FindList(s,inlet)) != NULL && TryMethTag(*lst,s,argc,argv)) return true; // if no list args, then search for pure symbol if(!argc) { ! if((lst = methhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(*lst,s)) return true; ! if((lst = clmethhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(*lst,s)) return true; } // otherwise search for anything ! if((lst = methhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(*lst,s,argc,argv)) return true; ! if((lst = clmethhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(*lst,s,argc,argv)) return true;
// if nothing found try any inlet --- 138,156 ---- bool flext_base::FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv) { ! Item *lst;
// search for exactly matching tag ! if((lst = methhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; ! if((lst = clmethhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; // if no list args, then search for pure symbol if(!argc) { ! if((lst = methhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(lst,s)) return true; ! if((lst = clmethhead->FindList(sym_symbol,inlet)) != NULL && TryMethSym(lst,s)) return true; } // otherwise search for anything ! if((lst = methhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; ! if((lst = clmethhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true;
// if nothing found try any inlet
Index: flsupport.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** flsupport.cpp 22 Feb 2004 03:34:00 -0000 1.31 --- flsupport.cpp 6 Mar 2004 03:25:48 -0000 1.32 *************** *** 299,300 **** --- 299,306 ---- va_end(ap); } + + + AnyMap::AnyMap() {} + AnyMap::~AnyMap() {} + AnyMap::iterator AnyMap::find(unsigned int k) { return Parent::find(k); } + unsigned int &AnyMap::operator [](unsigned int k) { return Parent::operator [](k); }
Index: flsupport.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** flsupport.h 22 Feb 2004 03:34:00 -0000 1.64 --- flsupport.h 6 Mar 2004 03:25:48 -0000 1.65 *************** *** 18,21 **** --- 18,22 ---- #include "flstdc.h" #include <new> + #include <map>
/*! \defgroup FLEXT_SUPPORT Flext support classes *************** *** 1147,1150 **** --- 1148,1195 ---- inline bool operator >=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) >= 0; }
+ + class AnyMap: + public std::map<unsigned int,unsigned int> + { + typedef std::map<unsigned int,unsigned int> Parent; + public: + AnyMap(); + ~AnyMap(); + iterator find(unsigned int k); + unsigned int &operator [](unsigned int k); + + typedef std::pair<unsigned int,unsigned int> pair; + }; + + template <class K,class T> + class DataMap: + public AnyMap + { + public: + class iterator: + public AnyMap::iterator + { + public: + iterator() {} + iterator(AnyMap::iterator it): AnyMap::iterator(it) {} + + inline K &key() const { return *(K *)&((*this)->first); } + inline T &data() const { return *(T *)&((*this)->second); } + }; + + class pair: + public AnyMap::pair + { + public: + inline K &key() const { return *(K *)&first; } + inline T &data() const { return *(T *)&second; } + }; + + inline iterator find(K k) { return AnyMap::find(*(unsigned int *)&k); } + inline T &operator [](K k) { return *(T *)&(AnyMap::operator [](*(unsigned int *)&k)); } + inline void erase(K k) { AnyMap::erase(*(unsigned int *)&k); } + }; + + //! @} // FLEXT_SUPPORT