From 72312b8ee69c00c50a7e7470a3147ff627d98410 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 12 Mar 2003 04:40:48 +0000 Subject: "" svn path=/trunk/; revision=466 --- externals/grill/fftease/build-pd-darwin.sh | 2 +- externals/grill/fftease/config-pd-darwin.txt | 14 +- externals/grill/fftease/makefile.pd-darwin | 4 +- externals/grill/flext/source/fldefs.h | 2 +- externals/grill/pool/build-pd-darwin.sh | 2 +- externals/grill/pool/config-pd-darwin.txt | 57 +- externals/grill/pool/data.cpp | 852 ++++++++---- externals/grill/pool/makefile.pd-darwin | 8 +- externals/grill/pool/pool.cpp | 1842 +++++++++++++++++--------- externals/grill/vasp/makefile.pd-darwin | 3 +- externals/grill/vst/build-pd-darwin.sh | 22 +- externals/grill/vst/config-pd-darwin.txt | 68 +- externals/grill/vst/config-pd-msvc.txt | 75 +- externals/grill/vst/make-files.txt | 14 +- externals/grill/vst/makefile.pd-darwin | 234 ++-- externals/grill/vst/makefile.pd-msvc | 206 ++- externals/grill/xsample/makefile.pd-darwin | 3 +- 17 files changed, 2245 insertions(+), 1163 deletions(-) diff --git a/externals/grill/fftease/build-pd-darwin.sh b/externals/grill/fftease/build-pd-darwin.sh index edd03207..8f21ebcb 100644 --- a/externals/grill/fftease/build-pd-darwin.sh +++ b/externals/grill/fftease/build-pd-darwin.sh @@ -4,7 +4,7 @@ make -f makefile.pd-darwin && { - if [ $INSTPATH != "" ]; then + if [ "${INSTPATH}" != "" ]; then echo Now install as root sudo make -f makefile.pd-darwin install fi diff --git a/externals/grill/fftease/config-pd-darwin.txt b/externals/grill/fftease/config-pd-darwin.txt index fa2127b6..755a8c0e 100644 --- a/externals/grill/fftease/config-pd-darwin.txt +++ b/externals/grill/fftease/config-pd-darwin.txt @@ -10,24 +10,28 @@ # C=gcc # CXX=g++ + +# where is PD installed? +PDDIR=/usr/local/pd + # where are the PD header files? # leave it blank if it is a system directory (like /usr/local/include), # since gcc 3.2 complains about it -PDPATH=/usr/local/pd/src +PDPATH=${PDDIR}/src # where is the PD executable? -PD=/usr/local/pd/bin/pd +PD=${PDDIR}/bin/pd # where do the flext libraries reside? -FLEXTPATH=/usr/local/pd/flext +FLEXTPATH=${PDDIR}/flext # where should flext libraries be built? TARGDIR=./pd-darwin # where should the external be installed? # (leave blank to omit installation) -INSTPATH=/usr/local/pd/extra +INSTPATH=${PDDIR}/extra # additional compiler flags # (check if they fit for your system!) -# UFLAGS=-maltivec +UFLAGS=-malign-power -maltivec diff --git a/externals/grill/fftease/makefile.pd-darwin b/externals/grill/fftease/makefile.pd-darwin index 91f830b3..12c262a4 100644 --- a/externals/grill/fftease/makefile.pd-darwin +++ b/externals/grill/fftease/makefile.pd-darwin @@ -24,9 +24,9 @@ INCLUDES=${PDPATH} ${FLEXTPATH} LIBPATH= FLAGS=-DFLEXT_SYS=2 ${UFLAGS} CFLAGS=-O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes -fno-exceptions -fno-rtti -#CFLAGS=-g LIBS=m LDFLAGS=-bundle -bundle_loader ${PD} +FRAMEWORKS=Carbon # --------------------------------------------- # the rest can stay untouched @@ -57,7 +57,7 @@ $(TARGDIR)/%.co : $(DIR)/%.c $(CC) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@ $(TARGET) : $(patsubst %.c,$(TARGDIR)/%.co,$(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS))) $(FLEXTLIB) - $(CXX) $(LDFLAGS) $^ $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ + $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ chmod 755 $@ $(INSTPATH): diff --git a/externals/grill/flext/source/fldefs.h b/externals/grill/flext/source/fldefs.h index be7ac879..7ba0f1b2 100644 --- a/externals/grill/flext/source/fldefs.h +++ b/externals/grill/flext/source/fldefs.h @@ -486,7 +486,7 @@ static void FLEXT_THR_PRE(M_FUN)(thr_params *p) { \ th->M_FUN(data); \ th->PopThread(); \ } \ - delete data; \ + delete (char *)data; \ } //! Set up a threaded method callback for a boolean argument diff --git a/externals/grill/pool/build-pd-darwin.sh b/externals/grill/pool/build-pd-darwin.sh index edd03207..8f21ebcb 100644 --- a/externals/grill/pool/build-pd-darwin.sh +++ b/externals/grill/pool/build-pd-darwin.sh @@ -4,7 +4,7 @@ make -f makefile.pd-darwin && { - if [ $INSTPATH != "" ]; then + if [ "${INSTPATH}" != "" ]; then echo Now install as root sudo make -f makefile.pd-darwin install fi diff --git a/externals/grill/pool/config-pd-darwin.txt b/externals/grill/pool/config-pd-darwin.txt index 7e412c2d..295a8a52 100644 --- a/externals/grill/pool/config-pd-darwin.txt +++ b/externals/grill/pool/config-pd-darwin.txt @@ -1,27 +1,30 @@ -# pool - hierarchical storage object for PD and Max/MSP -# Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) -# - -# your c++ compiler (define only if it's different than g++) -# CXX=g++ - -# where are the PD header files? -# leave it blank if it is a system directory (like /usr/local/include), -# since gcc 3.2 complains about it -PDPATH=/usr/local/pd/src - -# where is the PD executable? -PD=/usr/local/pd/bin/pd - -# where do the flext libraries reside? -FLEXTPATH=/usr/local/pd/flext - -# where should flext libraries be built? -TARGDIR=./pd-darwin - -# where should pool be installed? -# (leave blank to omit installation) -INSTPATH=/usr/local/pd/extra - - - +# pool - hierarchical storage object for PD and Max/MSP +# Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) +# + +# your c++ compiler (define only if it's different than g++) +# CXX=g++ + +# where are the PD header files? +# leave it blank if it is a system directory (like /usr/local/include), +# since gcc 3.2 complains about it +PDPATH=/usr/local/pd/src + +# where is the PD executable? +PD=/usr/local/pd/bin/pd + +# where do the flext libraries reside? +FLEXTPATH=/usr/local/pd/flext + +# where should flext libraries be built? +TARGDIR=./pd-darwin + +# where should pool be installed? +# (leave blank to omit installation) +INSTPATH=/usr/local/pd/extra + +# additional compiler flags +# (check if they match your system!) +UFLAGS=-malign-power -maltivec + + diff --git a/externals/grill/pool/data.cpp b/externals/grill/pool/data.cpp index 02ee4132..c67c3678 100644 --- a/externals/grill/pool/data.cpp +++ b/externals/grill/pool/data.cpp @@ -1,284 +1,568 @@ -/* - -pool - hierarchical storage object for PD and Max/MSP - -Copyright (c) 2002-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. - -*/ - -#include "pool.h" - -#include -#include -#include -#include - - -pooldata::pooldata(const S *s,I vcnt,I dcnt): - sym(s),nxt(NULL),refs(0), - root(nullatom,NULL,vcnt,dcnt) -{ - FLEXT_LOG1("new pool %s",sym?flext_base::GetString(sym):""); -} - -pooldata::~pooldata() -{ - FLEXT_LOG1("free pool %s",sym?flext_base::GetString(sym):""); -} - - -const A pooldata::nullatom = { A_NULL }; - - -V pooldata::Reset() -{ - root.Reset(); -} - -BL pooldata::MkDir(const AtomList &d,I vcnt,I dcnt) -{ - root.AddDir(d,vcnt,dcnt); - return true; -} - -BL pooldata::ChkDir(const AtomList &d) -{ - return root.GetDir(d) != NULL; -} - -BL pooldata::RmDir(const AtomList &d) -{ - return root.DelDir(d); -} - -BL pooldata::Set(const AtomList &d,const A &key,AtomList *data,BL over) -{ - pooldir *pd = root.GetDir(d); - if(!pd) return false; - pd->SetVal(key,data,over); - return true; -} - -BL pooldata::Clr(const AtomList &d,const A &key) -{ - pooldir *pd = root.GetDir(d); - if(!pd) return false; - pd->ClrVal(key); - return true; -} - -BL pooldata::ClrAll(const AtomList &d,BL rec,BL dironly) -{ - pooldir *pd = root.GetDir(d); - if(!pd) return false; - pd->Clear(rec,dironly); - return true; -} - -flext::AtomList *pooldata::Peek(const AtomList &d,const A &key) -{ - pooldir *pd = root.GetDir(d); - return pd?pd->PeekVal(key):NULL; -} - -poolval *pooldata::Ref(const AtomList &d,const A &key) -{ - pooldir *pd = root.GetDir(d); - return pd?pd->RefVal(key):NULL; -} - -poolval *pooldata::Refi(const AtomList &d,I ix) -{ - pooldir *pd = root.GetDir(d); - return pd?pd->RefVali(ix):NULL; -} - -flext::AtomList *pooldata::Get(const AtomList &d,const A &key) -{ - pooldir *pd = root.GetDir(d); - return pd?pd->GetVal(key):NULL; -} - -I pooldata::CntAll(const AtomList &d) -{ - pooldir *pd = root.GetDir(d); - return pd?pd->CntAll():0; -} - -I pooldata::GetAll(const AtomList &d,A *&keys,AtomList *&lst) -{ - pooldir *pd = root.GetDir(d); - if(pd) - return pd->GetAll(keys,lst); - else { - keys = NULL; lst = NULL; - return 0; - } -} - -I pooldata::CntSub(const AtomList &d) -{ - pooldir *pd = root.GetDir(d); - return pd?pd->CntSub():0; -} - -I pooldata::GetSub(const AtomList &d,const t_atom **&dirs) -{ - pooldir *pd = root.GetDir(d); - if(pd) - return pd->GetSub(dirs); - else { - dirs = NULL; - return 0; - } -} - - -BL pooldata::Paste(const AtomList &d,const pooldir *clip,I depth,BL repl,BL mkdir) -{ - pooldir *pd = root.GetDir(d); - if(pd) - return pd->Paste(clip,depth,repl,mkdir); - else - return false; -} - -pooldir *pooldata::Copy(const AtomList &d,const A &key,BL cut) -{ - pooldir *pd = root.GetDir(d); - if(pd) { - AtomList *val = pd->GetVal(key,cut); - if(val) { - pooldir *ret = new pooldir(nullatom,NULL,pd->VSize(),pd->DSize()); - ret->SetVal(key,val); - return ret; - } - else - return NULL; - } - else - return NULL; -} - -pooldir *pooldata::CopyAll(const AtomList &d,I depth,BL cut) -{ - pooldir *pd = root.GetDir(d); - if(pd) { - // What sizes should we choose here? - pooldir *ret = new pooldir(nullatom,NULL,pd->VSize(),pd->DSize()); - if(pd->Copy(ret,depth,cut)) - return ret; - else { - delete ret; - return NULL; - } - } - else - return NULL; -} - - -static const C *CnvFlnm(C *dst,const C *src,I sz) -{ -#if FLEXT_SYS == FLEXT_SYS_PD && FLEXT_OS == FLEXT_OS_WIN - I i,cnt = strlen(src); - if(cnt >= sz-1) return NULL; - for(i = 0; i < cnt; ++i) - dst[i] = src[i] != '/'?src[i]:'\\'; - dst[i] = 0; - return dst; -#else - return src; -#endif -} - -BL pooldata::LdDir(const AtomList &d,const C *flnm,I depth,BL mkdir) -{ - pooldir *pd = root.GetDir(d); - if(pd) { - C tmp[1024]; - const C *t = CnvFlnm(tmp,flnm,sizeof tmp); - if(t) { - ifstream fl(t); - return fl.good() && pd->LdDir(fl,depth,mkdir); - } - else return false; - } - else - return false; -} - -BL pooldata::SvDir(const AtomList &d,const C *flnm,I depth,BL absdir) -{ - pooldir *pd = root.GetDir(d); - if(pd) { - C tmp[1024]; - const C *t = CnvFlnm(tmp,flnm,sizeof tmp); - if(t) { - ofstream fl(t); - AtomList tmp; - if(absdir) tmp = d; - return fl.good() && pd->SvDir(fl,depth,tmp); - } - else return false; - } - else - return false; -} - -BL pooldata::LdDirXML(const AtomList &d,const C *flnm,I depth,BL mkdir) -{ - pooldir *pd = root.GetDir(d); - if(pd) { - C tmp[1024]; - const C *t = CnvFlnm(tmp,flnm,sizeof tmp); - if(t) { - ifstream fl(t); - BL ret = fl.good() != 0; - if(ret) { - fl.getline(tmp,sizeof tmp); - ret = !strncmp(tmp,"",6); - } - if(ret) - ret = pd->LdDirXML(fl,depth,mkdir); - return ret; - } - } - - return false; -} - -BL pooldata::SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir) -{ - pooldir *pd = root.GetDir(d); - if(pd) { - C tmp[1024]; - const C *t = CnvFlnm(tmp,flnm,sizeof tmp); - if(t) { - ofstream fl(t); - AtomList tmp; - if(absdir) tmp = d; - if(fl.good()) { - fl << "" << endl; - fl << "" << endl; - fl << "" << endl; - BL ret = pd->SvDirXML(fl,depth,tmp); - fl << "" << endl; - return ret; - } - } - } - - return false; -} - - +/* + + + +pool - hierarchical storage object for PD and Max/MSP + + + +Copyright (c) 2002-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. + + + +*/ + + + +#include "pool.h" + + + +#include + +#include + +#include + +#include + + + + + +pooldata::pooldata(const S *s,I vcnt,I dcnt): + + sym(s),nxt(NULL),refs(0), + + root(nullatom,NULL,vcnt,dcnt) + +{ + + FLEXT_LOG1("new pool %s",sym?flext_base::GetString(sym):""); + +} + + + +pooldata::~pooldata() + +{ + + FLEXT_LOG1("free pool %s",sym?flext_base::GetString(sym):""); + +} + + + + + +const A pooldata::nullatom = { A_NULL }; + + + + + +V pooldata::Reset() + +{ + + root.Reset(); + +} + + + +BL pooldata::MkDir(const AtomList &d,I vcnt,I dcnt) + +{ + + root.AddDir(d,vcnt,dcnt); + + return true; + +} + + + +BL pooldata::ChkDir(const AtomList &d) + +{ + + return root.GetDir(d) != NULL; + +} + + + +BL pooldata::RmDir(const AtomList &d) + +{ + + return root.DelDir(d); + +} + + + +BL pooldata::Set(const AtomList &d,const A &key,AtomList *data,BL over) + +{ + + pooldir *pd = root.GetDir(d); + + if(!pd) return false; + + pd->SetVal(key,data,over); + + return true; + +} + + + +BL pooldata::Clr(const AtomList &d,const A &key) + +{ + + pooldir *pd = root.GetDir(d); + + if(!pd) return false; + + pd->ClrVal(key); + + return true; + +} + + + +BL pooldata::ClrAll(const AtomList &d,BL rec,BL dironly) + +{ + + pooldir *pd = root.GetDir(d); + + if(!pd) return false; + + pd->Clear(rec,dironly); + + return true; + +} + + + +flext::AtomList *pooldata::Peek(const AtomList &d,const A &key) + +{ + + pooldir *pd = root.GetDir(d); + + return pd?pd->PeekVal(key):NULL; + +} + + + +poolval *pooldata::Ref(const AtomList &d,const A &key) + +{ + + pooldir *pd = root.GetDir(d); + + return pd?pd->RefVal(key):NULL; + +} + + + +poolval *pooldata::Refi(const AtomList &d,I ix) + +{ + + pooldir *pd = root.GetDir(d); + + return pd?pd->RefVali(ix):NULL; + +} + + + +flext::AtomList *pooldata::Get(const AtomList &d,const A &key) + +{ + + pooldir *pd = root.GetDir(d); + + return pd?pd->GetVal(key):NULL; + +} + + + +I pooldata::CntAll(const AtomList &d) + +{ + + pooldir *pd = root.GetDir(d); + + return pd?pd->CntAll():0; + +} + + + +I pooldata::GetAll(const AtomList &d,A *&keys,AtomList *&lst) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) + + return pd->GetAll(keys,lst); + + else { + + keys = NULL; lst = NULL; + + return 0; + + } + +} + + + +I pooldata::CntSub(const AtomList &d) + +{ + + pooldir *pd = root.GetDir(d); + + return pd?pd->CntSub():0; + +} + + + +I pooldata::GetSub(const AtomList &d,const t_atom **&dirs) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) + + return pd->GetSub(dirs); + + else { + + dirs = NULL; + + return 0; + + } + +} + + + + + +BL pooldata::Paste(const AtomList &d,const pooldir *clip,I depth,BL repl,BL mkdir) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) + + return pd->Paste(clip,depth,repl,mkdir); + + else + + return false; + +} + + + +pooldir *pooldata::Copy(const AtomList &d,const A &key,BL cut) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) { + + AtomList *val = pd->GetVal(key,cut); + + if(val) { + + pooldir *ret = new pooldir(nullatom,NULL,pd->VSize(),pd->DSize()); + + ret->SetVal(key,val); + + return ret; + + } + + else + + return NULL; + + } + + else + + return NULL; + +} + + + +pooldir *pooldata::CopyAll(const AtomList &d,I depth,BL cut) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) { + + // What sizes should we choose here? + + pooldir *ret = new pooldir(nullatom,NULL,pd->VSize(),pd->DSize()); + + if(pd->Copy(ret,depth,cut)) + + return ret; + + else { + + delete ret; + + return NULL; + + } + + } + + else + + return NULL; + +} + + + + + +static const C *CnvFlnm(C *dst,const C *src,I sz) + +{ + +#if FLEXT_SYS == FLEXT_SYS_PD && FLEXT_OS == FLEXT_OS_WIN + + I i,cnt = strlen(src); + + if(cnt >= sz-1) return NULL; + + for(i = 0; i < cnt; ++i) + + dst[i] = src[i] != '/'?src[i]:'\\'; + + dst[i] = 0; + + return dst; + +#else + + return src; + +#endif + +} + + + +BL pooldata::LdDir(const AtomList &d,const C *flnm,I depth,BL mkdir) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) { + + C tmp[1024]; + + const C *t = CnvFlnm(tmp,flnm,sizeof tmp); + + if(t) { + + ifstream fl(t); + + return fl.good() && pd->LdDir(fl,depth,mkdir); + + } + + else return false; + + } + + else + + return false; + +} + + + +BL pooldata::SvDir(const AtomList &d,const C *flnm,I depth,BL absdir) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) { + + C tmp[1024]; + + const C *t = CnvFlnm(tmp,flnm,sizeof tmp); + + if(t) { + + ofstream fl(t); + + AtomList tmp; + + if(absdir) tmp = d; + + return fl.good() && pd->SvDir(fl,depth,tmp); + + } + + else return false; + + } + + else + + return false; + +} + + + +BL pooldata::LdDirXML(const AtomList &d,const C *flnm,I depth,BL mkdir) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) { + + C tmp[1024]; + + const C *t = CnvFlnm(tmp,flnm,sizeof tmp); + + if(t) { + + ifstream fl(t); + + BL ret = fl.good() != 0; + + if(ret) { + + fl.getline(tmp,sizeof tmp); + + ret = !strncmp(tmp,"",6); + + } + + if(ret) + + ret = pd->LdDirXML(fl,depth,mkdir); + + return ret; + + } + + } + + + + return false; + +} + + + +BL pooldata::SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir) + +{ + + pooldir *pd = root.GetDir(d); + + if(pd) { + + C tmp[1024]; + + const C *t = CnvFlnm(tmp,flnm,sizeof tmp); + + if(t) { + + ofstream fl(t); + + AtomList tmp; + + if(absdir) tmp = d; + + if(fl.good()) { + + fl << "" << endl; + + fl << "" << endl; + + fl << "" << endl; + + BL ret = pd->SvDirXML(fl,depth,tmp); + + fl << "" << endl; + + return ret; + + } + + } + + } + + + + return false; + +} + + + + + diff --git a/externals/grill/pool/makefile.pd-darwin b/externals/grill/pool/makefile.pd-darwin index fec83c27..5cc81b82 100644 --- a/externals/grill/pool/makefile.pd-darwin +++ b/externals/grill/pool/makefile.pd-darwin @@ -17,11 +17,11 @@ FLEXTLIB=$(FLEXTPATH)/flext.a # compiler+linker stuff INCLUDES=$(PDPATH) LIBPATH= -FLAGS=-DPD -Dunix -DMACOSX -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes # -maltivec -CFLAGS=-O6 -#CFLAGS=-g +FLAGS=-DFLEXT_SYS=2 +CFLAGS=-O6 ${UFLAGS} -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes LIBS=m LDFLAGS=-bundle -bundle_loader $(PD) +FRAMEWORKS=Carbon # --------------------------------------------- @@ -51,7 +51,7 @@ $(TARGDIR)/%.o : $(DIR)/%.cpp $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ $(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) - $(CXX) $(LDFLAGS) $^ $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ + $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ chmod 755 $@ $(INSTPATH): diff --git a/externals/grill/pool/pool.cpp b/externals/grill/pool/pool.cpp index 68c9a266..d48f4a7a 100644 --- a/externals/grill/pool/pool.cpp +++ b/externals/grill/pool/pool.cpp @@ -1,614 +1,1228 @@ -/* - -pool - hierarchical storage object for PD and Max/MSP - -Copyright (c) 2002-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. - -*/ - -#include "pool.h" - -#include -#include -#include -#include - -#define VBITS 6 -#define DBITS 5 - -inline I compare(I a,I b) { return a == b?0:(a < b?-1:1); } -inline I compare(F a,F b) { return a == b?0:(a < b?-1:1); } - -static I compare(const S *a,const S *b) -{ - if(a == b) - return 0; - else - return strcmp(flext::GetString(a),flext::GetString(b)); -} - -static I compare(const A &a,const A &b) -{ - if(flext::GetType(a) == flext::GetType(b)) { - switch(flext::GetType(a)) { - case A_FLOAT: - return compare(flext::GetFloat(a),flext::GetFloat(b)); -#if FLEXT_SYS == FLEXT_SYS_MAX - case A_LONG: - return compare(flext::GetInt(a),flext::GetInt(b)); -#endif - case A_SYMBOL: - return compare(flext::GetSymbol(a),flext::GetSymbol(b)); -#if FLEXT_SYS == FLEXT_SYS_PD - case A_POINTER: - return flext::GetPointer(a) == flext::GetPointer(b)?0:(flext::GetPointer(a) < flext::GetPointer(b)?-1:1); -#endif - default: - FLEXT_LOG("pool - atom comparison: type not handled"); - return -1; - } - } - else - return flext::GetType(a) < flext::GetType(b)?-1:1; -} - - -poolval::poolval(const A &k,AtomList *d): - data(d),nxt(NULL) -{ - SetAtom(key,k); -} - -poolval::~poolval() -{ - if(data) delete data; - if(nxt) delete nxt; -} - -poolval &poolval::Set(AtomList *d) -{ - if(data) delete data; - data = d; - return *this; -} - -poolval *poolval::Dup() const -{ - return new poolval(key,data?new AtomList(*data):NULL); -} - - -pooldir::pooldir(const A &d,pooldir *p,I vcnt,I dcnt): - parent(p),nxt(NULL),vals(NULL),dirs(NULL), - vbits(vcnt?Int2Bits(vcnt):VBITS),dbits(dcnt?Int2Bits(dcnt):DBITS), - vsize(1<nxt) { - c = compare(argv[0],ix->dir); - if(c <= 0) break; - } - - if(c || !ix) { - pooldir *nd = new pooldir(argv[0],this,vcnt,dcnt); - nd->nxt = ix; - - if(prv) prv->nxt = nd; - else dirs[dix].d = nd; - dirs[dix].cnt++; - ix = nd; - } - - return ix->AddDir(argc-1,argv+1); -} - -pooldir *pooldir::GetDir(I argc,const A *argv,BL rmv) -{ - if(!argc) return this; - - I c = 1,dix = DIdx(argv[0]); - pooldir *prv = NULL,*ix = dirs[dix].d; - for(; ix; prv = ix,ix = ix->nxt) { - c = compare(argv[0],ix->dir); - if(c <= 0) break; - } - - if(c || !ix) - return NULL; - else { - if(argc > 1) - return ix->GetDir(argc-1,argv+1,rmv); - else if(rmv) { - pooldir *nd = ix->nxt; - if(prv) prv->nxt = nd; - else dirs[dix].d = nd; - dirs[dix].cnt--; - ix->nxt = NULL; - return ix; - } - else - return ix; - } -} - -BL pooldir::DelDir(I argc,const A *argv) -{ - pooldir *pd = GetDir(argc,argv,true); - if(pd && pd != this) { - delete pd; - return true; - } - else - return false; -} - -V pooldir::SetVal(const A &key,AtomList *data,BL over) -{ - I c = 1,vix = VIdx(key); - poolval *prv = NULL,*ix = vals[vix].v; - for(; ix; prv = ix,ix = ix->nxt) { - c = compare(key,ix->key); - if(c <= 0) break; - } - - if(c || !ix) { - // no existing data found - - if(data) { - poolval *nv = new poolval(key,data); - nv->nxt = ix; - - if(prv) prv->nxt = nv; - else vals[vix].v = nv; - vals[vix].cnt++; - } - } - else if(over) { - // data exists... only set if overwriting enabled - - if(data) - ix->Set(data); - else { - // delete key - - poolval *nv = ix->nxt; - if(prv) prv->nxt = nv; - else vals[vix].v = nv; - vals[vix].cnt--; - ix->nxt = NULL; - delete ix; - } - } -} - -poolval *pooldir::RefVal(const A &key) -{ - I c = 1,vix = VIdx(key); - poolval *ix = vals[vix].v; - for(; ix; ix = ix->nxt) { - c = compare(key,ix->key); - if(c <= 0) break; - } - - return c || !ix?NULL:ix; -} - - -poolval *pooldir::RefVali(I rix) -{ - for(I vix = 0; vix < vsize; ++vix) - if(rix > vals[vix].cnt) rix -= vals[vix].cnt; - else { - poolval *ix = vals[vix].v; - for(; ix && rix; ix = ix->nxt) --rix; - if(ix && !rix) return ix; - } - return NULL; -} - -flext::AtomList *pooldir::PeekVal(const A &key) -{ - poolval *ix = RefVal(key); - return ix?ix->data:NULL; -} - -flext::AtomList *pooldir::GetVal(const A &key,BL cut) -{ - I c = 1,vix = VIdx(key); - poolval *prv = NULL,*ix = vals[vix].v; - for(; ix; prv = ix,ix = ix->nxt) { - c = compare(key,ix->key); - if(c <= 0) break; - } - - if(c || !ix) - return NULL; - else { - AtomList *ret; - if(cut) { - poolval *nv = ix->nxt; - if(prv) prv->nxt = nv; - else vals[vix].v = nv; - vals[vix].cnt--; - ix->nxt = NULL; - ret = ix->data; ix->data = NULL; - delete ix; - } - else - ret = new AtomList(*ix->data); - return ret; - } -} - -I pooldir::CntAll() const -{ - I cnt = 0; - for(I vix = 0; vix < vsize; ++vix) cnt += vals[vix].cnt; - return cnt; -} - -I pooldir::GetKeys(AtomList &keys) -{ - I cnt = CntAll(); - keys(cnt); - - for(I vix = 0; vix < vsize; ++vix) { - poolval *ix = vals[vix].v; - for(I i = 0; ix; ++i,ix = ix->nxt) - SetAtom(keys[i],ix->key); - } - return cnt; -} - -I pooldir::GetAll(A *&keys,AtomList *&lst,BL cut) -{ - I cnt = CntAll(); - keys = new A[cnt]; - lst = new AtomList[cnt]; - - for(I i = 0,vix = 0; vix < vsize; ++vix) { - poolval *ix = vals[vix].v; - for(; ix; ++i) { - SetAtom(keys[i],ix->key); - lst[i] = *ix->data; - - if(cut) { - poolval *t = ix; - vals[vix].v = ix = ix->nxt; - vals[vix].cnt--; - t->nxt = NULL; delete t; - } - else - ix = ix->nxt; - } - } - return cnt; -} - - -I pooldir::CntSub() const -{ - I cnt = 0; - for(I dix = 0; dix < dsize; ++dix) cnt += dirs[dix].cnt; - return cnt; -} - - -I pooldir::GetSub(const A **&lst) -{ - const I cnt = CntSub(); - lst = new const A *[cnt]; - for(I i = 0,dix = 0; dix < dsize; ++dix) { - pooldir *ix = dirs[dix].d; - for(; ix; ix = ix->nxt) lst[i++] = &ix->dir; - } - return cnt; -} - - -BL pooldir::Paste(const pooldir *p,I depth,BL repl,BL mkdir) -{ - BL ok = true; - - for(I vi = 0; vi < p->vsize; ++vi) { - for(poolval *ix = p->vals[vi].v; ix; ix = ix->nxt) { - SetVal(ix->key,new AtomList(*ix->data),repl); - } - } - - if(ok && depth) { - for(I di = 0; di < p->dsize; ++di) { - for(pooldir *dix = p->dirs[di].d; ok && dix; dix = dix->nxt) { - pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir); - if(ndir) { - ok = ndir->Paste(dix,depth > 0?depth-1:depth,repl,mkdir); - } - } - } - } - - return ok; -} - -BL pooldir::Copy(pooldir *p,I depth,BL cut) -{ - BL ok = true; - - if(cut) { - for(I vi = 0; vi < vsize; ++vi) { - for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) - p->SetVal(ix->key,ix->data); - vals[vi].cnt = 0; - vals[vi].v = NULL; - } - } - else { - for(I vi = 0; vi < vsize; ++vi) { - for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) { - p->SetVal(ix->key,new AtomList(*ix->data)); - } - } - } - - if(ok && depth) { - for(I di = 0; di < dsize; ++di) { - for(pooldir *dix = dirs[di].d; ok && dix; dix = dix->nxt) { - pooldir *ndir = p->AddDir(1,&dix->dir); - if(ndir) - ok = ndir->Copy(dix,depth > 0?depth-1:depth,cut); - else - ok = false; - } - } - } - - return ok; -} - - -static C *ReadAtom(C *c,A *a) -{ - // skip whitespace - while(*c && isspace(*c)) ++c; - if(!*c) return NULL; - - const C *m = c; // remember position - - // check for word type (s = 0,1,2 ... int,float,symbol) - I s = 0; - for(; *c && !isspace(*c); ++c) { - if(!isdigit(*c)) - s = (*c != '.' || s == 1)?2:1; - } - - if(a) { - switch(s) { - case 0: // integer -#if FLEXT_SYS == FLEXT_SYS_MAX - flext::SetInt(*a,atoi(m)); - break; -#endif - case 1: // float - flext::SetFloat(*a,(F)atof(m)); - break; - default: { // anything else is a symbol - C t = *c; *c = 0; - flext::SetString(*a,m); - *c = t; - break; - } - } - } - - return c; -} - -static BL ReadAtoms(istream &is,flext::AtomList &l,C del) -{ - C tmp[1024]; - is.getline(tmp,sizeof tmp,del); - if(is.eof() || !is.good()) return false; - - I i,cnt; - C *t = tmp; - for(cnt = 0; ; ++cnt) { - t = ReadAtom(t,NULL); - if(!t) break; - } - - l(cnt); - if(cnt) { - for(i = 0,t = tmp; i < cnt; ++i) - t = ReadAtom(t,&l[i]); - } - return true; -} - -static V WriteAtom(ostream &os,const A &a) -{ - switch(a.a_type) { - case A_FLOAT: - os << a.a_w.w_float; - break; -#if FLEXT_SYS == FLEXT_SYS_MAX - case A_LONG: - os << a.a_w.w_long; - break; -#endif - case A_SYMBOL: - os << flext::GetString(flext::GetSymbol(a)); - break; - } -} - -static V WriteAtoms(ostream &os,const flext::AtomList &l) -{ - for(I i = 0; i < l.Count(); ++i) { -// if(IsSymbol(l[i]) os << "\""; - WriteAtom(os,l[i]); -// if(IsSymbol(l[i]) os << "\""; - if(i < l.Count()-1) os << ' '; - } -} - -BL pooldir::LdDir(istream &is,I depth,BL mkdir) -{ - for(I i = 1; !is.eof(); ++i) { - AtomList d,k,*v = new AtomList; - BL r = ReadAtoms(is,d,','); - r = r && ReadAtoms(is,k,',') && k.Count() == 1; - r = r && ReadAtoms(is,*v,'\n') && v->Count(); - - if(r) { - if(depth < 0 || d.Count() <= depth) { - pooldir *nd = mkdir?AddDir(d):GetDir(d); - if(nd) { - nd->SetVal(k[0],v); v = NULL; - } - #ifdef FLEXT_DEBUG - else - post("pool - directory was not found",i); - #endif - } - } - else if(!is.eof()) - post("pool - format mismatch encountered, skipped line %i",i); - - if(v) delete v; - } - return true; -} - -BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir) -{ - for(I vi = 0; vi < vsize; ++vi) { - for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) { - WriteAtoms(os,dir); - os << " , "; - WriteAtom(os,ix->key); - os << " , "; - WriteAtoms(os,*ix->data); - os << endl; - } - } - if(depth) { - I nd = depth > 0?depth-1:-1; - for(I di = 0; di < dsize; ++di) { - for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) { - ix->SvDir(os,nd,AtomList(dir).Append(ix->dir)); - } - } - } - return true; -} - -BL pooldir::LdDirXML(istream &is,I depth,BL mkdir) -{ -/* - for(I i = 1; !is.eof(); ++i) { - AtomList d,k,*v = new AtomList; - BL r = ReadAtoms(is,d,','); - r = r && ReadAtoms(is,k,',') && k.Count() == 1; - r = r && ReadAtoms(is,*v,'\n') && v->Count(); - - if(r) { - if(depth < 0 || d.Count() <= depth) { - pooldir *nd = mkdir?AddDir(d):GetDir(d); - if(nd) { - nd->SetVal(k[0],v); v = NULL; - } - #ifdef FLEXT_DEBUG - else - post("pool - directory was not found",i); - #endif - } - } - else if(!is.eof()) - post("pool - format mismatch encountered, skipped line %i",i); - - if(v) delete v; - } - return true; -*/ - return false; -} - -BL pooldir::SvDirXML(ostream &os,I depth,const AtomList &dir) -{ - if(dir.Count()) { - os << "" << endl; - } - - for(I vi = 0; vi < vsize; ++vi) { - for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) { - os << "key); - os << "\">"; - WriteAtoms(os,*ix->data); - os << "" << endl; - } - } - - if(depth) { - I nd = depth > 0?depth-1:-1; - for(I di = 0; di < dsize; ++di) { - for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) { - ix->SvDirXML(os,nd,AtomList(dir).Append(ix->dir)); - } - } - } - - if(dir.Count()) os << "" << endl; - return true; -} - - - - +/* + + + +pool - hierarchical storage object for PD and Max/MSP + + + +Copyright (c) 2002-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. + + + +*/ + + + +#include "pool.h" + + + +#include + +#include + +#include + +#include + + + +#define VBITS 6 + +#define DBITS 5 + + + +inline I compare(I a,I b) { return a == b?0:(a < b?-1:1); } + +inline I compare(F a,F b) { return a == b?0:(a < b?-1:1); } + + + +static I compare(const S *a,const S *b) + +{ + + if(a == b) + + return 0; + + else + + return strcmp(flext::GetString(a),flext::GetString(b)); + +} + + + +static I compare(const A &a,const A &b) + +{ + + if(flext::GetType(a) == flext::GetType(b)) { + + switch(flext::GetType(a)) { + + case A_FLOAT: + + return compare(flext::GetFloat(a),flext::GetFloat(b)); + +#if FLEXT_SYS == FLEXT_SYS_MAX + + case A_LONG: + + return compare(flext::GetInt(a),flext::GetInt(b)); + +#endif + + case A_SYMBOL: + + return compare(flext::GetSymbol(a),flext::GetSymbol(b)); + +#if FLEXT_SYS == FLEXT_SYS_PD + + case A_POINTER: + + return flext::GetPointer(a) == flext::GetPointer(b)?0:(flext::GetPointer(a) < flext::GetPointer(b)?-1:1); + +#endif + + default: + + FLEXT_LOG("pool - atom comparison: type not handled"); + + return -1; + + } + + } + + else + + return flext::GetType(a) < flext::GetType(b)?-1:1; + +} + + + + + +poolval::poolval(const A &k,AtomList *d): + + data(d),nxt(NULL) + +{ + + SetAtom(key,k); + +} + + + +poolval::~poolval() + +{ + + if(data) delete data; + + if(nxt) delete nxt; + +} + + + +poolval &poolval::Set(AtomList *d) + +{ + + if(data) delete data; + + data = d; + + return *this; + +} + + + +poolval *poolval::Dup() const + +{ + + return new poolval(key,data?new AtomList(*data):NULL); + +} + + + + + +pooldir::pooldir(const A &d,pooldir *p,I vcnt,I dcnt): + + parent(p),nxt(NULL),vals(NULL),dirs(NULL), + + vbits(vcnt?Int2Bits(vcnt):VBITS),dbits(dcnt?Int2Bits(dcnt):DBITS), + + vsize(1<nxt) { + + c = compare(argv[0],ix->dir); + + if(c <= 0) break; + + } + + + + if(c || !ix) { + + pooldir *nd = new pooldir(argv[0],this,vcnt,dcnt); + + nd->nxt = ix; + + + + if(prv) prv->nxt = nd; + + else dirs[dix].d = nd; + + dirs[dix].cnt++; + + ix = nd; + + } + + + + return ix->AddDir(argc-1,argv+1); + +} + + + +pooldir *pooldir::GetDir(I argc,const A *argv,BL rmv) + +{ + + if(!argc) return this; + + + + I c = 1,dix = DIdx(argv[0]); + + pooldir *prv = NULL,*ix = dirs[dix].d; + + for(; ix; prv = ix,ix = ix->nxt) { + + c = compare(argv[0],ix->dir); + + if(c <= 0) break; + + } + + + + if(c || !ix) + + return NULL; + + else { + + if(argc > 1) + + return ix->GetDir(argc-1,argv+1,rmv); + + else if(rmv) { + + pooldir *nd = ix->nxt; + + if(prv) prv->nxt = nd; + + else dirs[dix].d = nd; + + dirs[dix].cnt--; + + ix->nxt = NULL; + + return ix; + + } + + else + + return ix; + + } + +} + + + +BL pooldir::DelDir(I argc,const A *argv) + +{ + + pooldir *pd = GetDir(argc,argv,true); + + if(pd && pd != this) { + + delete pd; + + return true; + + } + + else + + return false; + +} + + + +V pooldir::SetVal(const A &key,AtomList *data,BL over) + +{ + + I c = 1,vix = VIdx(key); + + poolval *prv = NULL,*ix = vals[vix].v; + + for(; ix; prv = ix,ix = ix->nxt) { + + c = compare(key,ix->key); + + if(c <= 0) break; + + } + + + + if(c || !ix) { + + // no existing data found + + + + if(data) { + + poolval *nv = new poolval(key,data); + + nv->nxt = ix; + + + + if(prv) prv->nxt = nv; + + else vals[vix].v = nv; + + vals[vix].cnt++; + + } + + } + + else if(over) { + + // data exists... only set if overwriting enabled + + + + if(data) + + ix->Set(data); + + else { + + // delete key + + + + poolval *nv = ix->nxt; + + if(prv) prv->nxt = nv; + + else vals[vix].v = nv; + + vals[vix].cnt--; + + ix->nxt = NULL; + + delete ix; + + } + + } + +} + + + +poolval *pooldir::RefVal(const A &key) + +{ + + I c = 1,vix = VIdx(key); + + poolval *ix = vals[vix].v; + + for(; ix; ix = ix->nxt) { + + c = compare(key,ix->key); + + if(c <= 0) break; + + } + + + + return c || !ix?NULL:ix; + +} + + + + + +poolval *pooldir::RefVali(I rix) + +{ + + for(I vix = 0; vix < vsize; ++vix) + + if(rix > vals[vix].cnt) rix -= vals[vix].cnt; + + else { + + poolval *ix = vals[vix].v; + + for(; ix && rix; ix = ix->nxt) --rix; + + if(ix && !rix) return ix; + + } + + return NULL; + +} + + + +flext::AtomList *pooldir::PeekVal(const A &key) + +{ + + poolval *ix = RefVal(key); + + return ix?ix->data:NULL; + +} + + + +flext::AtomList *pooldir::GetVal(const A &key,BL cut) + +{ + + I c = 1,vix = VIdx(key); + + poolval *prv = NULL,*ix = vals[vix].v; + + for(; ix; prv = ix,ix = ix->nxt) { + + c = compare(key,ix->key); + + if(c <= 0) break; + + } + + + + if(c || !ix) + + return NULL; + + else { + + AtomList *ret; + + if(cut) { + + poolval *nv = ix->nxt; + + if(prv) prv->nxt = nv; + + else vals[vix].v = nv; + + vals[vix].cnt--; + + ix->nxt = NULL; + + ret = ix->data; ix->data = NULL; + + delete ix; + + } + + else + + ret = new AtomList(*ix->data); + + return ret; + + } + +} + + + +I pooldir::CntAll() const + +{ + + I cnt = 0; + + for(I vix = 0; vix < vsize; ++vix) cnt += vals[vix].cnt; + + return cnt; + +} + + + +I pooldir::GetKeys(AtomList &keys) + +{ + + I cnt = CntAll(); + + keys(cnt); + + + + for(I vix = 0; vix < vsize; ++vix) { + + poolval *ix = vals[vix].v; + + for(I i = 0; ix; ++i,ix = ix->nxt) + + SetAtom(keys[i],ix->key); + + } + + return cnt; + +} + + + +I pooldir::GetAll(A *&keys,AtomList *&lst,BL cut) + +{ + + I cnt = CntAll(); + + keys = new A[cnt]; + + lst = new AtomList[cnt]; + + + + for(I i = 0,vix = 0; vix < vsize; ++vix) { + + poolval *ix = vals[vix].v; + + for(; ix; ++i) { + + SetAtom(keys[i],ix->key); + + lst[i] = *ix->data; + + + + if(cut) { + + poolval *t = ix; + + vals[vix].v = ix = ix->nxt; + + vals[vix].cnt--; + + t->nxt = NULL; delete t; + + } + + else + + ix = ix->nxt; + + } + + } + + return cnt; + +} + + + + + +I pooldir::CntSub() const + +{ + + I cnt = 0; + + for(I dix = 0; dix < dsize; ++dix) cnt += dirs[dix].cnt; + + return cnt; + +} + + + + + +I pooldir::GetSub(const A **&lst) + +{ + + const I cnt = CntSub(); + + lst = new const A *[cnt]; + + for(I i = 0,dix = 0; dix < dsize; ++dix) { + + pooldir *ix = dirs[dix].d; + + for(; ix; ix = ix->nxt) lst[i++] = &ix->dir; + + } + + return cnt; + +} + + + + + +BL pooldir::Paste(const pooldir *p,I depth,BL repl,BL mkdir) + +{ + + BL ok = true; + + + + for(I vi = 0; vi < p->vsize; ++vi) { + + for(poolval *ix = p->vals[vi].v; ix; ix = ix->nxt) { + + SetVal(ix->key,new AtomList(*ix->data),repl); + + } + + } + + + + if(ok && depth) { + + for(I di = 0; di < p->dsize; ++di) { + + for(pooldir *dix = p->dirs[di].d; ok && dix; dix = dix->nxt) { + + pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir); + + if(ndir) { + + ok = ndir->Paste(dix,depth > 0?depth-1:depth,repl,mkdir); + + } + + } + + } + + } + + + + return ok; + +} + + + +BL pooldir::Copy(pooldir *p,I depth,BL cut) + +{ + + BL ok = true; + + + + if(cut) { + + for(I vi = 0; vi < vsize; ++vi) { + + for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) + + p->SetVal(ix->key,ix->data); + + vals[vi].cnt = 0; + + vals[vi].v = NULL; + + } + + } + + else { + + for(I vi = 0; vi < vsize; ++vi) { + + for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) { + + p->SetVal(ix->key,new AtomList(*ix->data)); + + } + + } + + } + + + + if(ok && depth) { + + for(I di = 0; di < dsize; ++di) { + + for(pooldir *dix = dirs[di].d; ok && dix; dix = dix->nxt) { + + pooldir *ndir = p->AddDir(1,&dix->dir); + + if(ndir) + + ok = ndir->Copy(dix,depth > 0?depth-1:depth,cut); + + else + + ok = false; + + } + + } + + } + + + + return ok; + +} + + + + + +static C *ReadAtom(C *c,A *a) + +{ + + // skip whitespace + + while(*c && isspace(*c)) ++c; + + if(!*c) return NULL; + + + + const C *m = c; // remember position + + + + // check for word type (s = 0,1,2 ... int,float,symbol) + + I s = 0; + + for(; *c && !isspace(*c); ++c) { + + if(!isdigit(*c)) + + s = (*c != '.' || s == 1)?2:1; + + } + + + + if(a) { + + switch(s) { + + case 0: // integer + +#if FLEXT_SYS == FLEXT_SYS_MAX + + flext::SetInt(*a,atoi(m)); + + break; + +#endif + + case 1: // float + + flext::SetFloat(*a,(F)atof(m)); + + break; + + default: { // anything else is a symbol + + C t = *c; *c = 0; + + flext::SetString(*a,m); + + *c = t; + + break; + + } + + } + + } + + + + return c; + +} + + + +static BL ReadAtoms(istream &is,flext::AtomList &l,C del) + +{ + + C tmp[1024]; + + is.getline(tmp,sizeof tmp,del); + + if(is.eof() || !is.good()) return false; + + + + I i,cnt; + + C *t = tmp; + + for(cnt = 0; ; ++cnt) { + + t = ReadAtom(t,NULL); + + if(!t) break; + + } + + + + l(cnt); + + if(cnt) { + + for(i = 0,t = tmp; i < cnt; ++i) + + t = ReadAtom(t,&l[i]); + + } + + return true; + +} + + + +static V WriteAtom(ostream &os,const A &a) + +{ + + switch(a.a_type) { + + case A_FLOAT: + + os << a.a_w.w_float; + + break; + +#if FLEXT_SYS == FLEXT_SYS_MAX + + case A_LONG: + + os << a.a_w.w_long; + + break; + +#endif + + case A_SYMBOL: + + os << flext::GetString(flext::GetSymbol(a)); + + break; + + } + +} + + + +static V WriteAtoms(ostream &os,const flext::AtomList &l) + +{ + + for(I i = 0; i < l.Count(); ++i) { + +// if(IsSymbol(l[i]) os << "\""; + + WriteAtom(os,l[i]); + +// if(IsSymbol(l[i]) os << "\""; + + if(i < l.Count()-1) os << ' '; + + } + +} + + + +BL pooldir::LdDir(istream &is,I depth,BL mkdir) + +{ + + for(I i = 1; !is.eof(); ++i) { + + AtomList d,k,*v = new AtomList; + + BL r = ReadAtoms(is,d,','); + + r = r && ReadAtoms(is,k,',') && k.Count() == 1; + + r = r && ReadAtoms(is,*v,'\n') && v->Count(); + + + + if(r) { + + if(depth < 0 || d.Count() <= depth) { + + pooldir *nd = mkdir?AddDir(d):GetDir(d); + + if(nd) { + + nd->SetVal(k[0],v); v = NULL; + + } + + #ifdef FLEXT_DEBUG + + else + + post("pool - directory was not found",i); + + #endif + + } + + } + + else if(!is.eof()) + + post("pool - format mismatch encountered, skipped line %i",i); + + + + if(v) delete v; + + } + + return true; + +} + + + +BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir) + +{ + + for(I vi = 0; vi < vsize; ++vi) { + + for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) { + + WriteAtoms(os,dir); + + os << " , "; + + WriteAtom(os,ix->key); + + os << " , "; + + WriteAtoms(os,*ix->data); + + os << endl; + + } + + } + + if(depth) { + + I nd = depth > 0?depth-1:-1; + + for(I di = 0; di < dsize; ++di) { + + for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) { + + ix->SvDir(os,nd,AtomList(dir).Append(ix->dir)); + + } + + } + + } + + return true; + +} + + + +BL pooldir::LdDirXML(istream &is,I depth,BL mkdir) + +{ + +/* + + for(I i = 1; !is.eof(); ++i) { + + AtomList d,k,*v = new AtomList; + + BL r = ReadAtoms(is,d,','); + + r = r && ReadAtoms(is,k,',') && k.Count() == 1; + + r = r && ReadAtoms(is,*v,'\n') && v->Count(); + + + + if(r) { + + if(depth < 0 || d.Count() <= depth) { + + pooldir *nd = mkdir?AddDir(d):GetDir(d); + + if(nd) { + + nd->SetVal(k[0],v); v = NULL; + + } + + #ifdef FLEXT_DEBUG + + else + + post("pool - directory was not found",i); + + #endif + + } + + } + + else if(!is.eof()) + + post("pool - format mismatch encountered, skipped line %i",i); + + + + if(v) delete v; + + } + + return true; + +*/ + + return false; + +} + + + +BL pooldir::SvDirXML(ostream &os,I depth,const AtomList &dir) + +{ + + if(dir.Count()) { + + os << "" << endl; + + } + + + + for(I vi = 0; vi < vsize; ++vi) { + + for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) { + + os << "key); + + os << "\">"; + + WriteAtoms(os,*ix->data); + + os << "" << endl; + + } + + } + + + + if(depth) { + + I nd = depth > 0?depth-1:-1; + + for(I di = 0; di < dsize; ++di) { + + for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) { + + ix->SvDirXML(os,nd,AtomList(dir).Append(ix->dir)); + + } + + } + + } + + + + if(dir.Count()) os << "" << endl; + + return true; + +} + + + + + + + + + diff --git a/externals/grill/vasp/makefile.pd-darwin b/externals/grill/vasp/makefile.pd-darwin index c6d16fc6..34c702d2 100755 --- a/externals/grill/vasp/makefile.pd-darwin +++ b/externals/grill/vasp/makefile.pd-darwin @@ -21,6 +21,7 @@ FLAGS=-DFLEXT_SYS=2 -DFLEXT_THREADS CFLAGS=-O6 ${UFLAGS} -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes LIBS=m LDFLAGS=-bundle -bundle_loader $(PDBIN) +FRAMEWORKS=Carbon # ---------------------------------------------- # the rest can stay untouched @@ -48,7 +49,7 @@ $(TARGDIR)/%.o : $(SRCDIR)/%.cpp $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ $(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) - $(CXX) $(LDFLAGS) $^ $(patsubst %,-l%,$(LIBS)) -o $@ + $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ chmod 755 $@ diff --git a/externals/grill/vst/build-pd-darwin.sh b/externals/grill/vst/build-pd-darwin.sh index f983f8c5..826954b1 100644 --- a/externals/grill/vst/build-pd-darwin.sh +++ b/externals/grill/vst/build-pd-darwin.sh @@ -1,11 +1,11 @@ -#!/bin/sh - -. config-pd-darwin.txt - -make -f makefile.pd-darwin && -{ - if [ $INSTPATH != "" ]; then - echo Now install as root - sudo make -f makefile.pd-darwin install - fi -} +#!/bin/sh + +. config-pd-darwin.txt + +make -f makefile.pd-darwin && +{ + if [ "${INSTPATH}" != "" ]; then + echo Now install as root + sudo make -f makefile.pd-darwin install + fi +} diff --git a/externals/grill/vst/config-pd-darwin.txt b/externals/grill/vst/config-pd-darwin.txt index 24a5b376..4451914c 100644 --- a/externals/grill/vst/config-pd-darwin.txt +++ b/externals/grill/vst/config-pd-darwin.txt @@ -1,33 +1,35 @@ -# FFTease - A set of Live Spectral Processors -# Originally written by Eric Lyon and Christopher Penrose for the Max/MSP platform -# -# Copyright (c)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. -# - -# your c/c++ compilers (define only if not gcc/g++) -# C=gcc -# CXX=g++ - -# where are the PD header files? -# leave it blank if it is a system directory (like /usr/local/include), -# since gcc 3.2 complains about it -PDPATH=/usr/local/pd/src - -# where is the PD executable? -PD=/usr/local/pd/bin/pd - -# where do the flext libraries reside? -FLEXTPATH=/usr/local/pd/flext - - -# where should flext libraries be built? -TARGDIR=./pd-darwin -# where should the external be installed? -# (leave blank to omit installation) -INSTPATH=/usr/local/pd/extra - -# additional compiler flags -# (check if they fit for your system!) -# UFLAGS=-maltivec +# vst~ - VST plugin external for PD +# based on the work of Jarno SeppŠnen and Mark Williamson +# +# Copyright (c)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. +# + +# your c++ compiler (define only if not g++) +# CXX=g++ + +# where is PD installed? +PDDIR=/usr/local/pd + +# where are the PD header files? +# leave it blank if it is a system directory (like /usr/local/include), +# since gcc 3.2 complains about it +PDPATH=${PDDIR}/src + +# where is the PD executable? +PD=${PDDIR}/bin/pd + +# where do the flext libraries reside? +FLEXTPATH=${PDDIR}/flext + + +# where should flext libraries be built? +TARGDIR=./pd-darwin +# where should the external be installed? +# (leave blank to omit installation) +INSTPATH=${PDDIR}/extra + +# additional compiler flags +# (check if they fit for your system!) +UFLAGS=-malign-power -maltivec diff --git a/externals/grill/vst/config-pd-msvc.txt b/externals/grill/vst/config-pd-msvc.txt index 83115226..1cb31aab 100644 --- a/externals/grill/vst/config-pd-msvc.txt +++ b/externals/grill/vst/config-pd-msvc.txt @@ -1,25 +1,50 @@ -# FFTease - A set of Live Spectral Processors -# Originally written by Eric Lyon and Christopher Penrose for the Max/MSP platform -# -# Copyright (c)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. -# - - -# where is PD? -PDPATH=c:\programme\audio\pd - -# where do the flext libraries reside? -FLEXTPATH=$(PDPATH)\flext - -# where is MS VC++? -MSVCPATH=c:\programme\prog\microsoft visual studio\VC98 - - -# where should the external be built? -OUTPATH=pd-msvc - -# where should the external be installed? -# (leave blank to omit installation) -INSTDIR=$(PDPATH)\extra +# vst~ - VST plugin external for PD + +# based on the work of Jarno SeppŠnen and Mark Williamson + +# + +# Copyright (c)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. + +# + + + + + +# where is PD? + +PDPATH=c:\programme\audio\pd + + + +# where do the flext libraries reside? + +FLEXTPATH=$(PDPATH)\flext + + + +# where is MS VC++? + +MSVCPATH=c:\programme\prog\microsoft visual studio\VC98 + + + + + +# where should the external be built? + +OUTPATH=pd-msvc + + + +# where should the external be installed? + +# (leave blank to omit installation) + +INSTDIR=$(PDPATH)\extra + diff --git a/externals/grill/vst/make-files.txt b/externals/grill/vst/make-files.txt index 31a51078..67823ba6 100644 --- a/externals/grill/vst/make-files.txt +++ b/externals/grill/vst/make-files.txt @@ -1,7 +1,7 @@ -# all the source files from the package -SRCS= \ - main.cpp - -HDRS= \ - main.h vst~.h - +# all the source files from the package +SRCS= main.cpp +SRCS_WIN=EditorThread.cpp PopupWindow.cpp VstHost.cpp StdAfx.cpp + +HDRS= \ + main.h vst.h + diff --git a/externals/grill/vst/makefile.pd-darwin b/externals/grill/vst/makefile.pd-darwin index 7872e3d8..d497406b 100644 --- a/externals/grill/vst/makefile.pd-darwin +++ b/externals/grill/vst/makefile.pd-darwin @@ -1,78 +1,156 @@ -# FFTease - A set of Live Spectral Processors -# Originally written by Eric Lyon and Christopher Penrose for the Max/MSP platform -# -# Copyright (c)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. -# -# -# Makefile for gcc @ darwin (OSX) -# -# usage: -# to build run "make -f makefile.pd-darwin" -# to install (as root), do "make -f makefile.pd-darwin install" -# - -CONFIG=config-pd-darwin.txt - -include ${CONFIG} - -FLEXTLIB=${FLEXTPATH}/flext.a - -# compiler+linker stuff -INCLUDES=${PDPATH} ${FLEXTPATH} -LIBPATH= -FLAGS=-DFLEXT_SYS=2 ${UFLAGS} -CFLAGS=-O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes -fno-exceptions -fno-rtti -#CFLAGS=-g -LIBS=m -LDFLAGS=-bundle -bundle_loader ${PD} - -# --------------------------------------------- -# the rest can stay untouched -# ---------------------------------------------- -NAME=fftease - -# all the source files from the package -include make-files.txt - -DIR=src - -TARGET=$(TARGDIR)/$(NAME).pd_darwin -MAKEFILE=makefile.pd-darwin - -# default target -all: $(TARGDIR) $(TARGET) - -$(patsubst %,$(DIR)/%,$(SRCS)): $(patsubst %,$(DIR)/%,$(HDRS)) $(FLEXTLIB) $(MAKEFILE) $(CONFIG) - touch $@ - -$(TARGDIR): - mkdir $(TARGDIR) - -$(TARGDIR)/%.o : $(DIR)/%.cpp - $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@ - -$(TARGDIR)/%.co : $(DIR)/%.c - $(CC) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@ - -$(TARGET) : $(patsubst %.c,$(TARGDIR)/%.co,$(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS))) $(FLEXTLIB) - $(CXX) $(LDFLAGS) $^ $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ - chmod 755 $@ - -$(INSTPATH): - mkdir $(INSTPATH) - -install:: $(INSTPATH) - -install:: $(TARGET) - cp $^ $(INSTPATH) -# chown root.root $(patsubst %,$(INSTPATH)/%,$(notdir $^)) -# chmod 755 $(patsubst %,$(INSTPATH)/%,$(notdir $^)) - -.PHONY: clean - -clean: - rm -f $(TARGDIR)/*.o $(TARGET) - - +# vst~ - VST plugin external for PD + +# based on the work of Jarno SeppŠnen and Mark Williamson + +# + +# Copyright (c)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. + +# + +# + +# Makefile for gcc @ darwin (OSX) + +# + +# usage: + +# to build run "make -f makefile.pd-darwin" + +# to install (as root), do "make -f makefile.pd-darwin install" + +# + + + +CONFIG=config-pd-darwin.txt + + + +include ${CONFIG} + + + +FLEXTLIB=${FLEXTPATH}/flext.a + + + +# compiler+linker stuff + +INCLUDES=${PDPATH} ${FLEXTPATH} + +LIBPATH= + +FLAGS=-DFLEXT_SYS=2 ${UFLAGS} + +CFLAGS=-O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes -fno-exceptions -fno-rtti + +LIBS=m + +LDFLAGS=-bundle -bundle_loader ${PD} + +FRAMEWORKS=Carbon + + + +# --------------------------------------------- + +# the rest can stay untouched + +# ---------------------------------------------- + +NAME=vst~ + + + +# all the source files from the package + +include make-files.txt + + + +DIR=src + + + +TARGET=$(TARGDIR)/$(NAME).pd_darwin + +MAKEFILE=makefile.pd-darwin + + + +# default target + +all: $(TARGDIR) $(TARGET) + + + +$(patsubst %,$(DIR)/%,$(SRCS)): $(patsubst %,$(DIR)/%,$(HDRS)) $(FLEXTLIB) $(MAKEFILE) $(CONFIG) + + touch $@ + + + +$(TARGDIR): + + mkdir $(TARGDIR) + + + +$(TARGDIR)/%.o : $(DIR)/%.cpp + + $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@ + + + +$(TARGDIR)/%.co : $(DIR)/%.c + + $(CC) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@ + + + +$(TARGET) : $(patsubst %.c,$(TARGDIR)/%.co,$(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS))) $(FLEXTLIB) + + $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework%,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ + + chmod 755 $@ + + + +$(INSTPATH): + + mkdir $(INSTPATH) + + + +install:: $(INSTPATH) + + + +install:: $(TARGET) + + cp $^ $(INSTPATH) + +# chown root.root $(patsubst %,$(INSTPATH)/%,$(notdir $^)) + +# chmod 755 $(patsubst %,$(INSTPATH)/%,$(notdir $^)) + + + +.PHONY: clean + + + +clean: + + rm -f $(TARGDIR)/*.o $(TARGET) + + + + + diff --git a/externals/grill/vst/makefile.pd-msvc b/externals/grill/vst/makefile.pd-msvc index 97ffa4a8..9d98c368 100644 --- a/externals/grill/vst/makefile.pd-msvc +++ b/externals/grill/vst/makefile.pd-msvc @@ -1,68 +1,138 @@ -# FFTease - A set of Live Spectral Processors -# Originally written by Eric Lyon and Christopher Penrose for the Max/MSP platform -# -# Copyright (c)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. -# -# -# Makefile for MSVC++ 6 -# -# usage: -# to build run "make -f makefile.pd-msvc" -# - -!include config-pd-msvc.txt - -# includes -INCPATH=/I"$(MSVCPATH)\include" /I"$(PDPATH)\src" /I"$(FLEXTPATH)" -LIBPATH=/LIBPATH:"$(MSVCPATH)\lib" /LIBPATH:"$(PDPATH)\bin" /LIBPATH:"$(FLEXTPATH)" -LIBS=pd.lib flext-pdwin.lib - -# compiler definitions and flags -DEFS=/DPD - -CFLAGS=/GR- /GX- /GD /G6 /Ox - -# the rest can stay untouched -# ---------------------------------------------- - -# all the source files from the package -!include make-files.txt - -# ----------------------------------------------- - -NAME=fftease -DIR=src - -all: $(OUTPATH) $(OUTPATH)\$(NAME).dll - -# remove build -clean: - -del /q $(OUTPATH) > nul - -rmdir $(OUTPATH) > nul - -OBJS= $(SRCS:.c=.obj) -OBJS= $(OBJS:.objpp=.obj) - - -$(OUTPATH): - -mkdir $(OUTPATH) > nul - -{$(DIR)}.cpp{}.obj: - cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)/$@ - -{$(DIR)}.c{}.obj: - cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)/$@ - - -$(OUTPATH)\$(NAME).dll: $(OBJS) - cd $(OUTPATH) - link /DLL /out:$(NAME).dll /INCREMENTAL:NO $** $(LIBS) $(LIBPATH) - @-del *.exp - @-del *.lib - cd .. -!ifdef INSTPATH - @-if not exist $(INSTPATH) mkdir $(INSTPATH) - copy $@ $(INSTPATH) > nul -!endif +# FFTease - A set of Live Spectral Processors + +# Originally written by Eric Lyon and Christopher Penrose for the Max/MSP platform + +# + +# Copyright (c)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. + +# + +# + +# Makefile for MSVC++ 6 + +# + +# usage: + +# to build run "make -f makefile.pd-msvc" + +# + + + +!include config-pd-msvc.txt + + + +# includes + +INCPATH=/I"$(MSVCPATH)\include" /I"$(PDPATH)\src" /I"$(FLEXTPATH)" + +LIBPATH=/LIBPATH:"$(MSVCPATH)\lib" /LIBPATH:"$(PDPATH)\bin" /LIBPATH:"$(FLEXTPATH)" + +LIBS=pd.lib flext-pdwin.lib + + + +# compiler definitions and flags + +DEFS=/DPD + + + +CFLAGS=/GR- /GX- /GD /G6 /Ox + + + +# the rest can stay untouched + +# ---------------------------------------------- + + + +# all the source files from the package + +!include make-files.txt + +SRCS=SRCS+SRCS_WIN + + + +# ----------------------------------------------- + + + +NAME=vst~ + +DIR=src + + + +all: $(OUTPATH) $(OUTPATH)\$(NAME).dll + + + +# remove build + +clean: + + -del /q $(OUTPATH) > nul + + -rmdir $(OUTPATH) > nul + + + +OBJS= $(SRCS:.c=.obj) + +OBJS= $(OBJS:.objpp=.obj) + + + + + +$(OUTPATH): + + -mkdir $(OUTPATH) > nul + + + +{$(DIR)}.cpp{}.obj: + + cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)/$@ + + + +{$(DIR)}.c{}.obj: + + cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)/$@ + + + + + +$(OUTPATH)\$(NAME).dll: $(OBJS) + + cd $(OUTPATH) + + link /DLL /out:$(NAME).dll /INCREMENTAL:NO $** $(LIBS) $(LIBPATH) + + @-del *.exp + + @-del *.lib + + cd .. + +!ifdef INSTPATH + + @-if not exist $(INSTPATH) mkdir $(INSTPATH) + + copy $@ $(INSTPATH) > nul + +!endif + diff --git a/externals/grill/xsample/makefile.pd-darwin b/externals/grill/xsample/makefile.pd-darwin index f51f550f..a7d378cb 100755 --- a/externals/grill/xsample/makefile.pd-darwin +++ b/externals/grill/xsample/makefile.pd-darwin @@ -21,6 +21,7 @@ FLAGS=-DFLEXT_SYS=2 CFLAGS=${UFLAGS} -O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes -funroll-loops -fmove-all-movables -frerun-loop-opt -fno-rtti -fno-exceptions LIBS=m LDFLAGS=-bundle -bundle_loader $(PDBIN) +FRAMEWORKS=Carbon # ---------------------------------------------- # the rest can stay untouched @@ -48,7 +49,7 @@ $(TARGDIR)/%.o : $(SRCDIR)/%.cpp $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ $(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) - $(CXX) $(LDFLAGS) $^ $(patsubst %,-l%,$(LIBS)) -o $@ + $(CXX) $(LDFLAGS) $^ $(patsubst %,-framework %,$(FRAMEWORKS)) $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(LIBS)) -o $@ chmod 755 $@ -- cgit v1.2.1