aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--externals/grill/flext/changes.txt4
-rw-r--r--externals/grill/flext/flext.vcproj3
-rw-r--r--externals/grill/flext/source/flattr.cpp52
-rw-r--r--externals/grill/flext/source/flattr_ed.cpp12
-rw-r--r--externals/grill/flext/source/flbind.cpp54
-rw-r--r--externals/grill/flext/source/flclass.h69
-rwxr-xr-xexternals/grill/flext/source/flitem.cpp79
-rwxr-xr-xexternals/grill/flext/source/fllib.cpp14
-rwxr-xr-xexternals/grill/flext/source/flmeth.cpp10
-rwxr-xr-xexternals/grill/flext/source/flmsg.cpp32
-rw-r--r--externals/grill/flext/source/flsupport.cpp6
-rw-r--r--externals/grill/flext/source/flsupport.h45
12 files changed, 248 insertions, 132 deletions
diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt
index 6e5ef3a7..e8133f37 100644
--- a/externals/grill/flext/changes.txt
+++ b/externals/grill/flext/changes.txt
@@ -15,11 +15,11 @@ Version history:
0.4.6:
- added a text edit window for list attributes
-- finally use global allocator operators (MFC doesn't like but who cares)
+- finally use global allocator operators (MFC doesn't like it but who cares)
- fixed entry of local variables with attribute editor
- help window for attribute editor
- appended lacking ~ for tilde object help patches
-- STL containers for all kinds of attribute, method, class handling
+- uniform STL container for all kinds of attribute, method, class handling
- support for MinGW
0.4.5:
diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj
index 7c4600b0..24d79d8f 100644
--- a/externals/grill/flext/flext.vcproj
+++ b/externals/grill/flext/flext.vcproj
@@ -176,6 +176,7 @@
Optimization="0"
AdditionalIncludeDirectories="c:\programme\audio\pd\src,f:\prog\audio\sndobj\include,f:\prog\audio\stk\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS=2;FLEXT_USE_SIMD"
+ StringPooling="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
RuntimeTypeInfo="TRUE"
@@ -184,7 +185,7 @@
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
- DebugInformationFormat="4"
+ DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp
index 2901b828..37497c88 100644
--- a/externals/grill/flext/source/flattr.cpp
+++ b/externals/grill/flext/source/flattr.cpp
@@ -32,9 +32,13 @@ flext_base::AttrItem::AttrItem(metharg tp,methfun f,int fl):
counter(NULL)
{}
-flext_base::AttrItem::~AttrItem()
+
+flext_base::AttrDataCont::AttrDataCont() {}
+
+flext_base::AttrDataCont::~AttrDataCont()
{
-// if(nxt) delete nxt;
+ for(iterator it = begin(); it != end(); ++it)
+ if(it.data()) delete it.data();
}
@@ -96,7 +100,7 @@ void flext_base::AddAttrib(t_classid c,const char *attr,metharg tp,methfun gfun,
void flext_base::ListAttrib(AtomList &la) const
{
- typedef std::map<int,const t_symbol *> AttrList;
+ typedef DataMap<int,const t_symbol *> AttrList;
AttrList list[2];
int i;
@@ -105,9 +109,9 @@ void flext_base::ListAttrib(AtomList &la) const
if(a && a->Contained(0)) {
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;
+ for(Item *al = as.data(); al; al = al->nxt) {
+ AttrItem *aa = (AttrItem *)al;
+ list[i][aa->index] = as.key();
break;
}
}
@@ -119,7 +123,7 @@ void flext_base::ListAttrib(AtomList &la) const
AttrList::iterator it;
for(i = 0; i <= 1; ++i)
for(it = list[i].begin(); it != list[i].end(); ++it)
- SetSymbol(la[ix++],it->second);
+ SetSymbol(la[ix++],it.data());
}
int flext_base::CheckAttrib(int argc,const t_atom *argv)
@@ -144,7 +148,15 @@ bool flext_base::InitAttrib(int argc,const t_atom *argv)
AttrItem *attr = FindAttrib(tag,false,true);
if(attr) {
// make an entry (there are none beforehand...)
- AttrData &a = (*attrdata)[tag];
+ 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);
@@ -172,23 +184,17 @@ flext_base::AttrItem *flext_base::FindAttrib(const t_symbol *tag,bool get,bool m
// first search within object scope
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; }
- }
+ for(Item *lst = attrhead->FindList(tag); lst; lst = lst->nxt) {
+ AttrItem *b = (AttrItem *)lst;
+ if(get?b->IsGet():b->IsSet()) { a = b; break; }
}
}
// 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; }
- }
+ for(Item *lst = clattrhead->FindList(tag); lst; lst = lst->nxt) {
+ AttrItem *b = (AttrItem *)lst;
+ if(get?b->IsGet():b->IsSet()) { a = b; break; }
}
}
@@ -370,9 +376,9 @@ bool flext_base::BangAttribAll()
if(a) {
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);
+ for(Item *al = as.data(); al; al = al->nxt) {
+ AttrItem *a = (AttrItem *)al;
+ if(a->IsGet() && a->BothExist()) BangAttrib(as.key(),a);
}
}
}
diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp
index 4d9f76ee..797eec19 100644
--- a/externals/grill/flext/source/flattr_ed.cpp
+++ b/externals/grill/flext/source/flattr_ed.cpp
@@ -436,7 +436,7 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
if(it == th->attrdata->end())
sv = 0,initdata = NULL;
else {
- const AttrData &a = it->second;
+ const AttrData &a = *it.data();
if(a.IsSaved())
sv = 2;
else if(a.IsInit())
@@ -573,7 +573,7 @@ void flext_base::cb_GfxSave(t_gobj *c, t_binbuf *b)
AttrDataCont::iterator it = th->attrdata->find(sym);
if(it != th->attrdata->end()) {
- const AttrData &a = it->second;
+ const AttrData &a = *it.data();
if(a.IsInit() && a.IsInitValue()) {
lref = &a.GetInitValue();
/*
@@ -670,18 +670,20 @@ bool flext_base::cb_AttrDialog(flext_base *th,int argc,const t_atom *argv)
if(sv >= 1) {
// if data not present create it
if(it == th->attrdata->end()) {
- AttrDataPair pair; pair.first = aname;
+ AttrDataCont::pair pair;
+ pair.key() = aname;
+ pair.data() = new AttrData;
it = th->attrdata->insert(th->attrdata->begin(),pair);
}
- AttrData &a = it->second;
+ AttrData &a = *it.data();
a.SetSave(sv == 2);
a.SetInit(true);
a.SetInitValue(icnt,argv+ioffs);
}
else {
if(it != th->attrdata->end()) {
- AttrData &a = it->second;
+ AttrData &a = *it.data();
// if data is present reset flags
a.SetSave(false);
a.SetInit(false);
diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp
index 01b23b6f..5a8f0743 100644
--- a/externals/grill/flext/source/flbind.cpp
+++ b/externals/grill/flext/source/flbind.cpp
@@ -99,19 +99,16 @@ bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbo
bindhead = new ItemCont;
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;
- }
+ 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;
}
+ }
}
SetupBindProxy();
@@ -166,8 +163,8 @@ bool flext_base::UnbindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_sym
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;
+ for(Item *i = si.data(); i; i = i->nxt) {
+ BindItem *item = (BindItem *)i;
if(!fun || item->fun == fun) { it = item; break; }
}
}
@@ -188,18 +185,15 @@ bool flext_base::GetBoundMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_s
{
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;
+ 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;
- }
+ // go through all items with matching tag
+ if(item->fun == fun) {
+ data = item->px->data;
+ return true;
}
+ }
}
return false;
}
@@ -209,13 +203,13 @@ bool flext_base::UnbindAll()
if(bindhead && bindhead->Contained(0)) {
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);
+ Item *lst = si.data();
+ while(lst) {
+ Item *nxt = lst->nxt;
+ BindItem *it = (BindItem *)lst;
+ it->Unbind(si.key());
delete it;
- lst.pop_front();
+ lst = nxt;
}
}
set.clear();
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index 18af3baa..0102784f 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -20,11 +20,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flbase.h"
#include "flsupport.h"
-#include <map>
-#include <set>
-#include <list>
-#include <vector>
-
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
@@ -604,45 +599,61 @@ protected:
class Item
{
public:
- Item(AttrItem *a): attr(a) {}
- virtual ~Item() {}
+ Item(AttrItem *a): attr(a),nxt(NULL) {}
+ virtual ~Item();
bool IsAttr() const { return attr != NULL; }
AttrItem *attr;
+ Item *nxt;
};
- typedef std::list<Item *> ItemList;
-
- typedef std::map<const t_symbol *,ItemList> ItemSet;
- typedef std::vector<ItemSet> ItemVec;
+ class ItemSet:
+ public DataMap<const t_symbol *,Item *>
+ {
+ public:
+ ItemSet();
+ ~ItemSet();
+ };
- //! This class holds hashed item entries
- class ItemCont:
- private ItemVec
+ /*! This class holds hashed item entries
+ \note not thread-safe!
+ */
+ class ItemCont
{
public:
- typedef ItemVec::iterator iterator;
- typedef ItemVec::const_iterator const_iterator;
+ ItemCont();
+ ~ItemCont();
- ItemCont(): members(0) {}
+ int Min() const { return -1; }
+ int Max() const { return size-2; }
- bool Contained(int i) const { return i+1 < (int)size(); }
+ bool Contained(int i) const { return i+1 < size; }
//! Add an entry
void Add(Item *it,const t_symbol *tag,int inlet = 0);
//! Remove an entry
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);
+ Item *FindList(const t_symbol *tag,int inlet = 0);
+
//! Get list for an inlet
- ItemSet &GetInlet(int inlet = 0) { return (*this)[inlet+1]; }
+ 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)
int Members() const { return members; }
protected:
+
+ void Resize(int nsz);
+
int members;
+ int memsize,size;
+ ItemSet **cont;
};
//! \brief This represents an item of the method list
@@ -667,7 +678,6 @@ protected:
{
public:
AttrItem(metharg tp,methfun fun,int flags);
- virtual ~AttrItem();
enum {
afl_get = 0x01, afl_set = 0x02,
@@ -710,9 +720,13 @@ protected:
int flags;
};
- typedef std::map<const t_symbol *,AttrData> AttrDataCont;
- typedef std::pair<const t_symbol *,AttrData> AttrDataPair;
-
+ 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
void ToSysBang(int n) const;
@@ -734,6 +748,7 @@ public:
public:
BindItem(bool (*f)(flext_base *,t_symbol *s,int,t_atom *,void *),pxbnd_object *px);
virtual ~BindItem();
+
void Unbind(const t_symbol *s);
bool (*fun)(flext_base *,t_symbol *s,int,t_atom *,void *);
@@ -796,9 +811,9 @@ private:
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);
+ 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;
mutable AttrDataCont *attrdata;
diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp
index 3dec5965..c8697279 100755
--- a/externals/grill/flext/source/flitem.cpp
+++ b/externals/grill/flext/source/flitem.cpp
@@ -15,27 +15,75 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#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)
{
- FLEXT_ASSERT(inlet >= -1);
- if(!Contained(inlet)) resize(inlet+2);
+ if(!Contained(inlet)) Resize(inlet+2);
ItemSet &set = GetInlet(inlet);
- set[tag].push_back(item);
+ Item *&lst = set[tag];
+ if(!lst)
+ lst = item;
+ else
+ for(;;)
+ if(!lst->nxt) { lst->nxt = item; break; }
+ else lst = lst->nxt;
members++;
}
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);
+ 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;
}
}
@@ -44,27 +92,24 @@ bool flext_base::ItemCont::Remove(Item *item,const t_symbol *tag,int inlet)
return false;
}
-flext_base::ItemList *flext_base::ItemCont::FindList(const t_symbol *tag,int inlet)
+flext_base::Item *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;
+ if(as != ai.end()) return as.data();
}
return NULL;
}
// --- class item lists (methods and attributes) ----------------
-typedef std::map<flext_base::t_classid,flext_base::ItemCont *> ClassMap;
-typedef std::vector<ClassMap> ClassArr;
+typedef DataMap<flext_base::t_classid,flext_base::ItemCont *> ClassMap;
-static ClassArr classarr;
+static ClassMap classarr[2];
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);
if(it == map.end()) {
@@ -73,5 +118,5 @@ flext_base::ItemCont *flext_base::GetClassArr(t_classid c,int ix)
return cont;
}
else
- return it->second;
+ return it.data();
}
diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp
index c727bcb5..ed07a35d 100755
--- a/externals/grill/flext/source/fllib.cpp
+++ b/externals/grill/flext/source/fllib.cpp
@@ -124,21 +124,23 @@ libclass::libclass(t_class *&cl,flext_obj *(*newf)(int,t_atom *),void (*freef)(f
clss(cl),
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;
-
- static LibMap libnames;
-
+// typedef std::map<const t_symbol *,libclass *> LibMap;
LibMap::iterator it = libnames.find(s);
if(it == libnames.end()) {
if(o) libnames[s] = o;
return o;
}
else
- return it->second;
+ return it.data();
}
diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp
index 6f8e5844..776461dd 100755
--- a/externals/grill/flext/source/flmeth.cpp
+++ b/externals/grill/flext/source/flmeth.cpp
@@ -93,7 +93,7 @@ void flext_base::AddMethod(ItemCont *ma,int inlet,const char *tag,methfun fun,me
void flext_base::ListMethods(AtomList &la,int inlet) const
{
- typedef std::map<int,const t_symbol *> MethList;
+ typedef DataMap<int,const t_symbol *> MethList;
MethList list[2];
int i;
@@ -102,12 +102,12 @@ void flext_base::ListMethods(AtomList &la,int inlet) const
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;
+ 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->first;
+ list[i][aa->index] = as.key();
break;
}
}
@@ -120,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->second);
+ SetSymbol(la[ix++],it.data());
}
bool flext_base::ListMethods(int inlet) const
diff --git a/externals/grill/flext/source/flmsg.cpp b/externals/grill/flext/source/flmsg.cpp
index b778940f..e586274e 100755
--- a/externals/grill/flext/source/flmsg.cpp
+++ b/externals/grill/flext/source/flmsg.cpp
@@ -72,10 +72,10 @@ bool flext_base::CallMeth(const MethItem &m,int argc,const t_atom *argv)
return ret;
}
-bool flext_base::TryMethTag(ItemList &lst,const t_symbol *tag,int argc,const t_atom *argv)
+bool flext_base::TryMethTag(Item *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;
+ for(; lst; lst = lst->nxt) {
+ MethItem *m = (MethItem *)lst;
// FLEXT_LOG3("found method tag %s: inlet=%i, argc=%i",GetString(tag),m->inlet,argc);
@@ -103,10 +103,10 @@ bool flext_base::TryMethTag(ItemList &lst,const t_symbol *tag,int argc,const t_a
return false;
}
-bool flext_base::TryMethSym(ItemList &lst,const t_symbol *s)
+bool flext_base::TryMethSym(Item *lst,const t_symbol *s)
{
- for(ItemList::iterator it = lst.begin(); it != lst.end(); ++it) {
- MethItem *m = (MethItem *)*it;
+ for(; lst; lst = lst->nxt) {
+ MethItem *m = (MethItem *)lst;
if(!m->IsAttr()) {
// FLEXT_LOG3("found symbol method for %s: inlet=%i, symbol=%s",GetString(m->tag),m->inlet,GetString(s));
@@ -118,10 +118,10 @@ bool flext_base::TryMethSym(ItemList &lst,const t_symbol *s)
return false;
}
-bool flext_base::TryMethAny(ItemList &lst,const t_symbol *s,int argc,const t_atom *argv)
+bool flext_base::TryMethAny(Item *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;
+ for(; lst; lst = lst->nxt) {
+ MethItem *m = (MethItem *)lst;
if(!m->IsAttr() && m->argc == 1 && m->args[0] == a_any) {
// FLEXT_LOG4("found any method for %s: inlet=%i, symbol=%s, argc=%i",GetString(m->tag),m->inlet,GetString(s),argc);
@@ -137,21 +137,21 @@ bool flext_base::TryMethAny(ItemList &lst,const t_symbol *s,int argc,const t_ato
*/
bool flext_base::FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv)
{
- ItemList *lst;
+ 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((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;
+ 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((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
return inlet >= 0 && FindMeth(-1,s,argc,argv);
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index 6c203124..543c1235 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -298,3 +298,9 @@ void flext_root::error(const char *fmt,...)
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); }
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index d61f6013..f8191fd3 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -17,6 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flstdc.h"
#include <new>
+#include <map>
/*! \defgroup FLEXT_SUPPORT Flext support classes
@{
@@ -1146,6 +1147,50 @@ inline bool operator <=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF
inline bool operator >(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) > 0; }
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
#endif