aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flattr.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-01-01 04:36:59 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-01-01 04:36:59 +0000
commit59e66762250fe61d570c5baf6c9ce6896a09e027 (patch)
tree422e3386845e00ef0994348a7c46f01aea38abbe /externals/grill/flext/source/flattr.cpp
parent0e1fe750cfd8467a80530cbc70326c81f41a8fe5 (diff)
""
svn path=/trunk/; revision=315
Diffstat (limited to 'externals/grill/flext/source/flattr.cpp')
-rw-r--r--externals/grill/flext/source/flattr.cpp64
1 files changed, 37 insertions, 27 deletions
diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp
index c6e88fe5..3a898498 100644
--- a/externals/grill/flext/source/flattr.cpp
+++ b/externals/grill/flext/source/flattr.cpp
@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
-Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net)
+Copyright (c) 2001-2003 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.
@@ -24,8 +24,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
flext_base::attritem::attritem(const t_symbol *t,metharg tp,methfun f,int fl):
item(t,0,NULL),argtp(tp),
fun(f),flags(fl)
-{
-}
+{}
flext_base::attritem::~attritem()
{
@@ -94,6 +93,29 @@ void flext_base::AddAttrib(t_class *c,const char *attr,metharg tp,methfun gfun,m
AddAttrib(ClAttrs(c),ClMeths(c),attr,tp,gfun,sfun);
}
+int flext_base::ListAttr(AtomList &la) const
+{
+ int cnt = attrhead?attrhead->Count():0;
+ int ccnt = clattrhead?clattrhead->Count():0;
+ la(ccnt+cnt);
+
+ int ix = 0;
+ for(int i = 0; i <= 1; ++i) {
+ itemarr *a = i?attrhead:clattrhead;
+ if(a) {
+ for(int ai = 0; ai < a->Size(); ++ai) {
+ for(item *l = a->Item(ai); l; l = l->nxt)
+ {
+ attritem *a = (attritem *)l;
+ if(!a->BothExist() || a->IsGet())
+ SetSymbol(la[ix++],a->tag);
+ }
+ }
+ }
+ }
+ return ix;
+}
+
int flext_base::CheckAttrib(int argc,const t_atom *argv)
{
@@ -120,42 +142,30 @@ bool flext_base::InitAttrib(int argc,const t_atom *argv)
bool flext_base::ListAttrib()
{
if(outattr) {
- int cnt = attrhead?attrhead->Count():0;
- int ccnt = clattrhead?clattrhead->Count():0;
- AtomList la(ccnt+cnt);
-
- int ix = 0;
- for(int i = 0; i <= 1; ++i) {
- itemarr *a = i?attrhead:clattrhead;
- if(a) {
- for(int ai = 0; ai < a->Size(); ++ai) {
- for(item *l = a->Item(ai); l; l = l->nxt)
- {
- attritem *a = (attritem *)l;
- if(!a->BothExist() || a->IsGet())
- SetSymbol(la[ix++],a->tag);
- }
- }
- }
- }
-
- ToOutAnything(outattr,MakeSymbol("attributes"),ix,la.Atoms());
+ AtomList la;
+ int c = ListAttr(la);
+ ToOutAnything(outattr,MakeSymbol("attributes"),c,la.Atoms());
return true;
}
else
return false;
}
-bool flext_base::SetAttrib(const t_symbol *tag,int argc,const t_atom *argv)
+flext_base::attritem *flext_base::FindAttr(const t_symbol *tag,bool get) const
{
- // search for matching attribute
attritem *a = (attritem *)attrhead->Find(tag);
- while(a && (a->tag != tag || a->inlet != 0 || a->IsGet())) a = (attritem *)a->nxt;
+ while(a && (a->tag != tag || a->inlet != 0 || (get?a->IsSet():a->IsGet()))) a = (attritem *)a->nxt;
if(!a) {
a = (attritem *)clattrhead->Find(tag);
- while(a && (a->tag != tag || a->inlet != 0 || a->IsGet())) a = (attritem *)a->nxt;
+ while(a && (a->tag != tag || a->inlet != 0 || (get?a->IsSet():a->IsGet()))) a = (attritem *)a->nxt;
}
+ return a;
+}
+bool flext_base::SetAttrib(const t_symbol *tag,int argc,const t_atom *argv)
+{
+ // search for matching attribute
+ attritem *a = FindAttr(tag,false);
if(a)
return SetAttrib(a,argc,argv);
else {