From 21e2f111c461725446457f0d768a95b71c17c847 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 14 Aug 2003 02:32:51 +0000 Subject: "" svn path=/trunk/; revision=844 --- externals/grill/flext/source/flatom_pr.cpp | 36 +++++++++++++++++++----------- externals/grill/flext/source/flattr_ed.cpp | 36 +++++++++++------------------- externals/grill/flext/source/fldsp.cpp | 11 +++++---- externals/grill/flext/source/flsupport.h | 5 ++++- 4 files changed, 47 insertions(+), 41 deletions(-) (limited to 'externals/grill/flext/source') diff --git a/externals/grill/flext/source/flatom_pr.cpp b/externals/grill/flext/source/flatom_pr.cpp index e700df8a..e90892e8 100644 --- a/externals/grill/flext/source/flatom_pr.cpp +++ b/externals/grill/flext/source/flatom_pr.cpp @@ -21,39 +21,49 @@ WARRANTIES, see the file, "license.txt," in this distribution. // \TODO take bufsz into account! bool flext::PrintAtom(const t_atom &a,char *buf,int bufsz) { + bool ok = true; if(IsFloat(a)) { - sprintf(buf,"%g",GetFloat(a)); + STD::sprintf(buf,"%g",GetFloat(a)); } else if(IsInt(a)) { - sprintf(buf,"%i",GetInt(a)); + STD::sprintf(buf,"%i",GetInt(a)); } else if(IsSymbol(a)) { - strcpy(buf,GetString(a)); + STD::strcpy(buf,GetString(a)); } else if(IsPointer(a)) { - sprintf(buf,"%p",GetPointer(a)); + STD::sprintf(buf,"%p",GetPointer(a)); + } + else if(a.a_type == A_DOLLAR) { + STD::sprintf(buf,"$%d",a.a_w.w_index); } - else + else if(a.a_type == A_DOLLSYM) { + STD::sprintf(buf,"$%s",GetString(a)); + } + else { ERRINTERNAL(); - return true; + ok = false; + } + return ok; } -bool flext::AtomList::Print(char *buffer,int buflen) const +bool flext::PrintList(int argc,const t_atom *argv,char *buf,int bufsz) { bool ok = true; - for(int i = 0; ok && i < Count(); ++i) { - if(i) { *(buffer++) = ' '; --buflen; } // prepend space - if(PrintAtom((*this)[i],buffer,buflen)) { - int len = strlen(buffer); - buffer += len,buflen -= len; + for(int i = 0; ok && i < argc && bufsz > 0; ++i) { + if(i) { *(buf++) = ' '; --bufsz; } // prepend space + + if(PrintAtom(argv[i],buf,bufsz)) { + int len = strlen(buf); + buf += len,bufsz -= len; } else ok = false; } + *buf = 0; return ok; } - bool flext::ScanAtom(t_atom &a,const char *buf) { // skip whitespace diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp index a52de29f..2153a485 100644 --- a/externals/grill/flext/source/flattr_ed.cpp +++ b/externals/grill/flext/source/flattr_ed.cpp @@ -305,26 +305,6 @@ void flext_base::SetAttrEditor(t_classid c) ); } -static int PrintList(char *buf,int argc,const t_atom *argv) -{ - char *b = buf; - for(int j = 0; j < argc; ++j) { - const t_atom &at = argv[j]; - if(flext::IsString(at)) - STD::sprintf(b,"%s",flext::GetString(at)); - else if(flext::IsFloat(at)) - STD::sprintf(b,"%g",flext::GetFloat(at)); - else if(flext::IsInt(at)) - STD::sprintf(b,"%i",flext::GetInt(at)); - else - FLEXT_ASSERT(false); - b += strlen(b); - - if(j < argc-1) *(b++) = ' '; - } - return b-buf; -} - void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) { flext_base *th = thisObject(c); @@ -337,7 +317,8 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) int argc = binbuf_getnatom(x->te_binbuf); t_atom *argv = binbuf_getvec(x->te_binbuf); - b += PrintList(b,argc,argv); + + PrintList(argc,argv,b,sizeof(buf)+buf-b); b += strlen(b); STD::sprintf(b, " } { "); b += strlen(b); @@ -393,7 +374,7 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) // Retrieve attribute value th->GetAttrib(gattr,lv); - b += PrintList(b,lv.Count(),lv.Atoms()); + PrintList(lv.Count(),lv.Atoms(),b,sizeof(buf)+buf-b); b += strlen(b); } else { strcpy(b,"{}"); b += strlen(b); @@ -405,7 +386,7 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *) // if there is initialization data take this, otherwise take the current data const AtomList &lp = initdata?*initdata:lv; - b += PrintList(b,lp.Count(),lp.Atoms()); + PrintList(lp.Count(),lp.Atoms(),b,sizeof(buf)+buf-b); b += strlen(b); } else { strcpy(b,"{}"); b += strlen(b); @@ -450,12 +431,21 @@ void flext_base::cb_GfxVis(t_gobj *c, t_glist *gl, int vis) static void BinbufAdd(t_binbuf *b,const t_atom &at) { + char tbuf[MAXPDSTRING]; if(flext::IsString(at)) binbuf_addv(b,"s",flext::GetSymbol(at)); else if(flext::IsFloat(at)) binbuf_addv(b,"f",flext::GetFloat(at)); else if(flext::IsInt(at)) binbuf_addv(b,"i",flext::GetInt(at)); + else if(at.a_type == A_DOLLAR) { + sprintf(tbuf, "$%d", at.a_w.w_index); + binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); + } + else if(at.a_type == A_DOLLSYM) { + sprintf(tbuf, "$%s", at.a_w.w_symbol->s_name); + binbuf_addv(b,"s",flext::MakeSymbol(tbuf)); + } else FLEXT_ASSERT(false); } diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp index 0161683c..c5d6ea22 100644 --- a/externals/grill/flext/source/fldsp.cpp +++ b/externals/grill/flext/source/fldsp.cpp @@ -141,7 +141,8 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp) obj->srate = sp[0]->s_sr; obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ? #endif - + +/* #if FLEXT_SYS == FLEXT_SYS_PD obj->chnsin = sys_get_inchannels(); obj->chnsout = sys_get_outchannels(); @@ -152,13 +153,15 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp) #else #error #endif - +*/ // store in and out signal vectors - int i,in = obj->CntInSig(),out = obj->CntOutSig(); + int i; + int in = obj->chnsin = obj->CntInSig(); + int out = obj->chnsout = obj->CntOutSig(); #if FLEXT_SYS == FLEXT_SYS_PD // min. 1 input channel! (CLASS_MAININLET in pd...) - if(!in) in = 1; + if(!in) { obj->chnsin = in = 1; } #endif if(obj->invecs) delete[] obj->invecs; diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 99938676..bf37c355 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -224,6 +224,9 @@ public: //! Copy a list of atoms static t_atom *CopyList(int argc,const t_atom *argv); + //! Print an atom list + static bool PrintList(int argc,const t_atom *argv,char *buf,int bufsz); + //! Copy a memory region static void CopyMem(void *dst,const void *src,int bytes); //! Copy a sample array @@ -532,7 +535,7 @@ public: AtomList &Part(int offs,int len) { return (*this = GetPart(offs,len)); } //! Represent as a string - bool Print(char *buffer,int buflen) const; + bool Print(char *buffer,int buflen) const { return flext::PrintList(Count(),Atoms(),buffer,buflen); } protected: int cnt; -- cgit v1.2.1