From 59e66762250fe61d570c5baf6c9ce6896a09e027 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 1 Jan 2003 04:36:59 +0000 Subject: "" svn path=/trunk/; revision=315 --- externals/grill/flext/source/flattr.cpp | 64 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'externals/grill/flext/source/flattr.cpp') 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 { -- cgit v1.2.1