aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/pool
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-10-30 03:59:01 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-10-30 03:59:01 +0000
commit3e1c082a5050a890eb05e81a5472f0c346600fb7 (patch)
tree115f5bb9c50ff2dab3b67bb0fbd70a1ea1c3df2f /externals/grill/pool
parentf0de7e1aa940335ba2130f9f318539e2432c44a1 (diff)
better symbol handling
added seti, clri name changes for svn repository more inlined functions svn path=/trunk/; revision=2191
Diffstat (limited to 'externals/grill/pool')
-rw-r--r--externals/grill/pool/help-pool.pd102
-rw-r--r--externals/grill/pool/pool.vcproj6
-rw-r--r--externals/grill/pool/readme.txt3
-rw-r--r--externals/grill/pool/source/data.cpp21
-rw-r--r--externals/grill/pool/source/main.cpp223
-rw-r--r--externals/grill/pool/source/pool.cpp35
-rw-r--r--externals/grill/pool/source/pool.h112
7 files changed, 330 insertions, 172 deletions
diff --git a/externals/grill/pool/help-pool.pd b/externals/grill/pool/help-pool.pd
index e93b8ea6..3f198dd9 100644
--- a/externals/grill/pool/help-pool.pd
+++ b/externals/grill/pool/help-pool.pd
@@ -1,4 +1,4 @@
-#N canvas 4 3 931 701 12;
+#N canvas 4 3 939 709 12;
#X msg 296 105 set 1 2 3;
#X obj 238 631 print K;
#X msg 607 211 getall;
@@ -6,18 +6,18 @@
#X obj 189 660 print V;
#X obj 287 605 print D;
#X msg 296 164 set A l m;
-#X msg 299 193 set 2 34;
-#X msg 429 102 clr A;
-#X msg 429 165 get A;
-#X msg 429 190 get 2;
+#X msg 297 195 set 2 34;
+#X msg 427 307 clr A;
+#X msg 429 105 get A;
+#X msg 429 130 get 2;
#X msg 31 132 echodir \$1;
#X obj 31 111 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 31 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X msg 31 234 absdir \$1;
-#X text 428 82 clear value;
-#X text 425 143 get value;
+#X text 426 287 clear value;
+#X text 425 83 get value;
#X obj 336 576 print C;
#X text 408 576 command;
#X text 360 605 directory (abs or rel to current);
@@ -42,7 +42,7 @@
#X text 34 291 set pool name;
#X text 31 89 at each command;
#X text 31 73 echo current dir;
-#X text 293 80 set values;
+#X text 295 82 set values;
#X text 26 194 (default on);
#X text 18 178 report absolute dirs;
#X msg 34 452 help;
@@ -53,7 +53,6 @@
#X msg 609 366 cntrec;
#X text 677 364 ... and subdirs;
#X text 673 378 (depth may be given);
-#X text 295 258 set but don't replace;
#N canvas 472 45 420 631 dirs 0;
#X msg 111 40 mkdir fld1;
#X msg 113 135 chdir;
@@ -201,12 +200,12 @@ the folder containing the current patcher will be used.;
#X msg 139 132 getechodir;
#X msg 130 234 getabsdir;
#X msg 141 314 getpool;
-#X msg 297 279 add 2 14;
+#X msg 297 345 add 2 14;
#X obj 260 478 pool @valcnt 10 @dircnt 5;
#X text 330 437 expected value and directory counts;
#X text 330 452 can be given for optimal performance;
-#X msg 429 215 get 3;
-#X msg 300 224 set 3 -1 1;
+#X msg 429 155 get 3;
+#X msg 295 222 set 3 -1 1;
#X msg 32 518 getmethods;
#X text 328 466 (see attributes in properties dialog);
#X text 715 638 console printout;
@@ -229,38 +228,51 @@ the folder containing the current patcher will be used.;
#X text 272 13 a hierarchical storage object \, (C)2002-2004 Thomas
Grill;
#X text 272 33 http://grrrr.org;
-#X connect 0 0 70 0;
-#X connect 2 0 70 0;
-#X connect 3 0 70 0;
-#X connect 6 0 70 0;
-#X connect 7 0 70 0;
-#X connect 8 0 70 0;
-#X connect 9 0 70 0;
-#X connect 10 0 70 0;
-#X connect 11 0 70 0;
+#X msg 428 225 geti \$1;
+#X text 426 185 get indexed element;
+#X obj 427 205 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+10 -262144 -1 -1 0 256;
+#X text 297 309 set but don't replace;
+#X text 294 256 set value at index;
+#X msg 295 276 seti 3 Uhu;
+#X text 424 343 clear value at index;
+#X msg 425 363 clri 2;
+#X connect 0 0 69 0;
+#X connect 2 0 69 0;
+#X connect 3 0 69 0;
+#X connect 6 0 69 0;
+#X connect 7 0 69 0;
+#X connect 8 0 69 0;
+#X connect 9 0 69 0;
+#X connect 10 0 69 0;
+#X connect 11 0 69 0;
#X connect 12 0 11 0;
#X connect 13 0 14 0;
-#X connect 14 0 70 0;
-#X connect 22 0 70 0;
-#X connect 23 0 70 0;
-#X connect 25 0 70 0;
-#X connect 27 0 70 0;
-#X connect 32 0 70 0;
-#X connect 33 0 70 0;
-#X connect 44 0 70 0;
-#X connect 47 0 70 0;
-#X connect 49 0 70 0;
-#X connect 60 0 70 0;
-#X connect 65 0 70 0;
-#X connect 66 0 70 0;
-#X connect 67 0 70 0;
-#X connect 68 0 70 0;
-#X connect 69 0 70 0;
-#X connect 70 0 4 0;
-#X connect 70 1 1 0;
-#X connect 70 2 5 0;
-#X connect 70 3 17 0;
-#X connect 70 4 63 0;
-#X connect 73 0 70 0;
-#X connect 74 0 70 0;
-#X connect 75 0 70 0;
+#X connect 14 0 69 0;
+#X connect 22 0 69 0;
+#X connect 23 0 69 0;
+#X connect 25 0 69 0;
+#X connect 27 0 69 0;
+#X connect 32 0 69 0;
+#X connect 33 0 69 0;
+#X connect 44 0 69 0;
+#X connect 47 0 69 0;
+#X connect 49 0 69 0;
+#X connect 59 0 69 0;
+#X connect 64 0 69 0;
+#X connect 65 0 69 0;
+#X connect 66 0 69 0;
+#X connect 67 0 69 0;
+#X connect 68 0 69 0;
+#X connect 69 0 4 0;
+#X connect 69 1 1 0;
+#X connect 69 2 5 0;
+#X connect 69 3 17 0;
+#X connect 69 4 62 0;
+#X connect 72 0 69 0;
+#X connect 73 0 69 0;
+#X connect 74 0 69 0;
+#X connect 80 0 69 0;
+#X connect 82 0 80 0;
+#X connect 85 0 69 0;
+#X connect 87 0 69 0;
diff --git a/externals/grill/pool/pool.vcproj b/externals/grill/pool/pool.vcproj
index 07976285..ebffd5f1 100644
--- a/externals/grill/pool/pool.vcproj
+++ b/externals/grill/pool/pool.vcproj
@@ -26,7 +26,7 @@
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
- UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough=""
PrecompiledHeaderFile=".\pd-msvc/r/pool.pch"
AssemblerListingLocation=".\pd-msvc/r/"
ObjectFile=".\pd-msvc/r/"
@@ -92,7 +92,7 @@
StringPooling="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
- UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough=""
PrecompiledHeaderFile=".\pd-msvc/d/pool.pch"
AssemblerListingLocation=".\pd-msvc/d/"
ObjectFile=".\pd-msvc/d/"
@@ -298,7 +298,7 @@
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
- UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough=""
PrecompiledHeaderFile=".\pd-msvc/r/pool.pch"
WarningLevel="3"
SuppressStartupBanner="TRUE"
diff --git a/externals/grill/pool/readme.txt b/externals/grill/pool/readme.txt
index 33636fec..5f0ec965 100644
--- a/externals/grill/pool/readme.txt
+++ b/externals/grill/pool/readme.txt
@@ -89,6 +89,9 @@ Version history:
0.2.1:
- fixed "cntsub"... directories in current directory have been forgotten
- store/create also empty dirs with file I/O
+- more inlined functions and better symbol handling
+- added "seti" message to set elements at index
+- added "clri" message to erase elements at index
0.2.0:
- attributes (pool,private,echodir,absdir)
diff --git a/externals/grill/pool/source/data.cpp b/externals/grill/pool/source/data.cpp
index 0bc6b70d..2bccee41 100644
--- a/externals/grill/pool/source/data.cpp
+++ b/externals/grill/pool/source/data.cpp
@@ -32,7 +32,7 @@ pooldata::~pooldata()
const A pooldata::nullatom = { A_NULL };
-
+/*
V pooldata::Reset()
{
root.Reset();
@@ -44,6 +44,7 @@ BL pooldata::MkDir(const AtomList &d,I vcnt,I dcnt)
return true;
}
+
BL pooldata::ChkDir(const AtomList &d)
{
return root.GetDir(d) != NULL;
@@ -70,6 +71,14 @@ BL pooldata::Clr(const AtomList &d,const A &key)
return true;
}
+V pooldata::Clri(const AtomList &d,I ix)
+{
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->ClrVali(ix);
+ return true;
+}
+
BL pooldata::ClrAll(const AtomList &d,BL rec,BL dironly)
{
pooldir *pd = root.GetDir(d);
@@ -107,6 +116,7 @@ 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)
{
@@ -128,11 +138,13 @@ I pooldata::PrintAll(const AtomList &d)
return pd?pd->PrintAll(tmp,sizeof tmp):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)
{
@@ -149,10 +161,7 @@ I pooldata::GetSub(const AtomList &d,const t_atom **&dirs)
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;
+ return pd && pd->Paste(clip,depth,repl,mkdir);
}
pooldir *pooldata::Copy(const AtomList &d,const A &key,BL cut)
@@ -290,5 +299,3 @@ BL pooldata::SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir)
return false;
}
-
-
diff --git a/externals/grill/pool/source/main.cpp b/externals/grill/pool/source/main.cpp
index eb3ae8e6..15d0edf7 100644
--- a/externals/grill/pool/source/main.cpp
+++ b/externals/grill/pool/source/main.cpp
@@ -16,6 +16,8 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define VCNT 64
#define DCNT 16
+const t_symbol *sym_echo = flext::MakeSymbol("echo");
+
class pool:
public flext_base
{
@@ -23,7 +25,7 @@ class pool:
public:
pool(I argc,const A *argv);
- ~pool();
+ virtual ~pool();
static V setup(t_classid);
@@ -55,9 +57,11 @@ protected:
V m_rmsub(I argc,const A *argv) { m_rmdir(argc,argv,false); }
// handle data
- V m_set(I argc,const A *argv) { set(MakeSymbol("set"),argc,argv,true); }
- V m_add(I argc,const A *argv) { set(MakeSymbol("add"),argc,argv,false); }
+ V m_set(I argc,const A *argv) { set(argc,argv,true); }
+ V m_seti(I argc,const A *argv); // set value at index
+ V m_add(I argc,const A *argv) { set(argc,argv,false); }
V m_clr(I argc,const A *argv);
+ V m_clri(I ix); // clear value at index
V m_clrall(); // only values
V m_clrrec(); // also subdirectories
V m_clrsub(); // only subdirectories
@@ -79,15 +83,15 @@ protected:
V m_printroot() { m_printrec(0,NULL,true); } // print values recursively from root
// cut/copy/paste
- V m_paste(I argc,const A *argv) { paste(MakeSymbol("paste"),argc,argv,true); } // paste contents of clipboard
- V m_pasteadd(I argc,const A *argv) { paste(MakeSymbol("pasteadd"),argc,argv,false); } // paste but don't replace
+ V m_paste(I argc,const A *argv) { paste(thisTag(),argc,argv,true); } // paste contents of clipboard
+ V m_pasteadd(I argc,const A *argv) { paste(thisTag(),argc,argv,false); } // paste but don't replace
V m_clrclip(); // clear clipboard
- V m_cut(I argc,const A *argv) { copy(MakeSymbol("cut"),argc,argv,true); } // cut value into clipboard
- V m_copy(I argc,const A *argv) { copy(MakeSymbol("copy"),argc,argv,false); } // copy value into clipboard
- V m_cutall() { copyall(MakeSymbol("cutall"),true,0); } // cut all values in current directory into clipboard
- V m_copyall() { copyall(MakeSymbol("copyall"),false,0); } // copy all values in current directory into clipboard
- V m_cutrec(I argc,const A *argv) { copyrec(MakeSymbol("cutrec"),argc,argv,true); } // cut directory (and subdirs) into clipboard
- V m_copyrec(I argc,const A *argv) { copyrec(MakeSymbol("copyrec"),argc,argv,false); } // cut directory (and subdirs) into clipboard
+ V m_cut(I argc,const A *argv) { copy(thisTag(),argc,argv,true); } // cut value into clipboard
+ V m_copy(I argc,const A *argv) { copy(thisTag(),argc,argv,false); } // copy value into clipboard
+ V m_cutall() { copyall(thisTag(),true,0); } // cut all values in current directory into clipboard
+ V m_copyall() { copyall(thisTag(),false,0); } // copy all values in current directory into clipboard
+ V m_cutrec(I argc,const A *argv) { copyrec(thisTag(),argc,argv,true); } // cut directory (and subdirs) into clipboard
+ V m_copyrec(I argc,const A *argv) { copyrec(thisTag(),argc,argv,false); } // cut directory (and subdirs) into clipboard
// load/save from/to file
V m_load(I argc,const A *argv) { load(argc,argv,false); }
@@ -115,7 +119,7 @@ private:
enum get_t { get_norm,get_cnt,get_print };
- V set(const S *tag,I argc,const A *argv,BL over);
+ V set(I argc,const A *argv,BL over);
V getdir(const S *tag);
I getrec(const S *tag,I level,BL order,get_t how = get_norm,const AtomList &rdir = AtomList());
I getsub(const S *tag,I level,BL order,get_t how = get_norm,const AtomList &rdir = AtomList());
@@ -132,7 +136,7 @@ private:
V svdir(I argc,const A *argv,BL xml); // save values in current dir
V svrec(I argc,const A *argv,BL xml); // save values recursively
- V echodir() { if(echo) getdir(MakeSymbol("echo")); }
+ V echodir() { if(echo) getdir(sym_echo); }
BL priv,absdir,echo;
I vcnt,dcnt;
@@ -173,8 +177,10 @@ private:
FLEXT_CALLBACK_V(m_rmsub)
FLEXT_CALLBACK_V(m_set)
+ FLEXT_CALLBACK_V(m_seti)
FLEXT_CALLBACK_V(m_add)
FLEXT_CALLBACK_V(m_clr)
+ FLEXT_CALLBACK_I(m_clri)
FLEXT_CALLBACK(m_clrall)
FLEXT_CALLBACK(m_clrrec)
FLEXT_CALLBACK(m_clrsub)
@@ -239,8 +245,6 @@ V pool::setup(t_classid c)
FLEXT_CADDATTR_VAR1(c,"dircnt",dcnt);
FLEXT_CADDMETHOD_(c,0,"reset",m_reset);
- FLEXT_CADDMETHOD_(c,0,"set",m_set);
- FLEXT_CADDMETHOD_(c,0,"add",m_add);
FLEXT_CADDMETHOD_(c,0,"getdir",m_getdir);
FLEXT_CADDMETHOD_(c,0,"mkdir",m_mkdir);
FLEXT_CADDMETHOD_(c,0,"chdir",m_chdir);
@@ -253,7 +257,10 @@ V pool::setup(t_classid c)
FLEXT_CADDMETHOD_(c,0,"rmsub",m_rmsub);
FLEXT_CADDMETHOD_(c,0,"set",m_set);
+ FLEXT_CADDMETHOD_(c,0,"seti",m_seti);
+ FLEXT_CADDMETHOD_(c,0,"add",m_add);
FLEXT_CADDMETHOD_(c,0,"clr",m_clr);
+ FLEXT_CADDMETHOD_(c,0,"clri",m_clri);
FLEXT_CADDMETHOD_(c,0,"clrall",m_clrall);
FLEXT_CADDMETHOD_(c,0,"clrrec",m_clrrec);
FLEXT_CADDMETHOD_(c,0,"clrsub",m_clrsub);
@@ -392,19 +399,19 @@ V pool::getdir(const S *tag)
ToOutList(2,curdir);
}
-V pool::m_getdir() { getdir(MakeSymbol("getdir")); }
+V pool::m_getdir() { getdir(thisTag()); }
V pool::m_mkdir(I argc,const A *argv,BL abs,BL chg)
{
- const char *nm = chg?"mkchdir":"mkdir";
+// const char *nm = chg?"mkchdir":"mkdir";
if(!ValChk(argc,argv))
- post("%s - %s: invalid directory name",thisName(),nm);
+ post("%s - %s: invalid directory name",thisName(),GetString(thisTag()));
else {
AtomList ndir;
if(abs) ndir(argc,argv);
else (ndir = curdir).Append(argc,argv);
if(!pl->MkDir(ndir,vcnt,dcnt)) {
- post("%s - %s: directory couldn't be created",thisName(),nm);
+ post("%s - %s: directory couldn't be created",thisName(),GetString(thisTag()));
}
else if(chg)
// change to newly created directory
@@ -417,13 +424,13 @@ V pool::m_mkdir(I argc,const A *argv,BL abs,BL chg)
V pool::m_chdir(I argc,const A *argv,BL abs)
{
if(!ValChk(argc,argv))
- post("%s - chdir: invalid directory name",thisName());
+ post("%s - %s: invalid directory name",thisName(),GetString(thisTag()));
else {
AtomList prv(curdir);
if(abs) curdir(argc,argv);
else curdir.Append(argc,argv);
if(!pl->ChkDir(curdir)) {
- post("%s - chdir: directory couldn't be changed",thisName());
+ post("%s - %s: directory couldn't be changed",thisName(),GetString(thisTag()));
curdir = prv;
}
}
@@ -437,26 +444,26 @@ V pool::m_updir(I argc,const A *argv)
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - updir: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
if(lvls < 0)
- post("%s - updir: invalid level specification - set to 1",thisName());
+ post("%s - %s: invalid level specification - set to 1",thisName(),GetString(thisTag()));
}
else
- post("%s - updir: invalid level specification - set to 1",thisName());
+ post("%s - %s: invalid level specification - set to 1",thisName(),GetString(thisTag()));
}
AtomList prv(curdir);
if(lvls > curdir.Count()) {
- post("%s - updir: level exceeds directory depth - corrected",thisName());
+ post("%s - %s: level exceeds directory depth - corrected",thisName(),GetString(thisTag()));
curdir();
}
else
curdir.Part(0,curdir.Count()-lvls);
if(!pl->ChkDir(curdir)) {
- post("%s - updir: directory couldn't be changed",thisName());
+ post("%s - %s: directory couldn't be changed",thisName(),GetString(thisTag()));
curdir = prv;
}
@@ -469,22 +476,36 @@ V pool::m_rmdir(I argc,const A *argv,BL abs)
else curdir.Append(argc,argv);
if(!pl->RmDir(curdir))
- post("%s - rmdir: directory couldn't be removed",thisName());
+ post("%s - %s: directory couldn't be removed",thisName(),GetString(thisTag()));
curdir();
echodir();
}
-V pool::set(const S *tag,I argc,const A *argv,BL over)
+V pool::set(I argc,const A *argv,BL over)
{
if(!argc || !KeyChk(argv[0]))
- post("%s - %s: invalid key",thisName(),GetString(tag));
+ post("%s - %s: invalid key",thisName(),GetString(thisTag()));
else if(!ValChk(argc-1,argv+1)) {
- post("%s - %s: invalid data values",thisName(),GetString(tag));
+ post("%s - %s: invalid data values",thisName(),GetString(thisTag()));
}
else
if(!pl->Set(curdir,argv[0],new AtomList(argc-1,argv+1),over))
- post("%s - %s: value couldn't be set",thisName(),GetString(tag));
+ post("%s - %s: value couldn't be set",thisName(),GetString(thisTag()));
+
+ echodir();
+}
+
+V pool::m_seti(I argc,const A *argv)
+{
+ if(!argc || !CanbeInt(argv[0]))
+ post("%s - %s: invalid index",thisName(),GetString(thisTag()));
+ else if(!ValChk(argc-1,argv+1)) {
+ post("%s - %s: invalid data values",thisName(),GetString(thisTag()));
+ }
+ else
+ if(!pl->Seti(curdir,GetAInt(argv[0]),new AtomList(argc-1,argv+1)))
+ post("%s - %s: value couldn't be set",thisName(),GetString(thisTag()));
echodir();
}
@@ -492,13 +513,25 @@ V pool::set(const S *tag,I argc,const A *argv,BL over)
V pool::m_clr(I argc,const A *argv)
{
if(!argc || !KeyChk(argv[0]))
- post("%s - clr: invalid key",thisName());
+ post("%s - %s: invalid key",thisName(),GetString(thisTag()));
else {
if(argc > 1)
- post("%s - clr: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(!pl->Clr(curdir,argv[0]))
- post("%s - clr: value couldn't be cleared",thisName());
+ post("%s - %s: value couldn't be cleared",thisName(),GetString(thisTag()));
+ }
+
+ echodir();
+}
+
+V pool::m_clri(I ix)
+{
+ if(ix < 0)
+ post("%s - %s: invalid index",thisName(),GetString(thisTag()));
+ else {
+ if(!pl->Clri(curdir,ix))
+ post("%s - %s: value couldn't be cleared",thisName(),GetString(thisTag()));
}
echodir();
@@ -507,7 +540,7 @@ V pool::m_clr(I argc,const A *argv)
V pool::m_clrall()
{
if(!pl->ClrAll(curdir,false))
- post("%s - clrall: values couldn't be cleared",thisName());
+ post("%s - %s: values couldn't be cleared",thisName(),GetString(thisTag()));
echodir();
}
@@ -515,7 +548,7 @@ V pool::m_clrall()
V pool::m_clrrec()
{
if(!pl->ClrAll(curdir,true))
- post("%s - clrrec: values couldn't be cleared",thisName());
+ post("%s - %s: values couldn't be cleared",thisName(),GetString(thisTag()));
echodir();
}
@@ -523,7 +556,7 @@ V pool::m_clrrec()
V pool::m_clrsub()
{
if(!pl->ClrAll(curdir,true,true))
- post("%s - clrsub: directories couldn't be cleared",thisName());
+ post("%s - %s: directories couldn't be cleared",thisName(),GetString(thisTag()));
echodir();
}
@@ -531,14 +564,14 @@ V pool::m_clrsub()
V pool::m_get(I argc,const A *argv)
{
if(!argc || !KeyChk(argv[0]))
- post("%s - get: invalid key",thisName());
+ post("%s - %s: invalid key",thisName(),GetString(thisTag()));
else {
if(argc > 1)
- post("%s - get: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
poolval *r = pl->Ref(curdir,argv[0]);
- ToOutAnything(3,MakeSymbol("get"),0,NULL);
+ ToOutAnything(3,thisTag(),0,NULL);
if(absdir)
ToOutList(2,curdir);
else
@@ -559,11 +592,11 @@ V pool::m_get(I argc,const A *argv)
V pool::m_geti(I ix)
{
if(ix < 0)
- post("%s - geti: invalid index",thisName());
+ post("%s - %s: invalid index",thisName(),GetString(thisTag()));
else {
poolval *r = pl->Refi(curdir,ix);
- ToOutAnything(3,MakeSymbol("geti"),0,NULL);
+ ToOutAnything(3,thisTag(),0,NULL);
if(absdir)
ToOutList(2,curdir);
else
@@ -581,7 +614,7 @@ V pool::m_geti(I ix)
echodir();
}
-I pool::getrec(const S *tag,I level,BL order,get_t how,const AtomList &rdir)
+I pool::getrec(const t_symbol *tag,I level,BL order,get_t how,const AtomList &rdir)
{
AtomList gldir(curdir);
gldir.Append(rdir);
@@ -634,7 +667,7 @@ I pool::getrec(const S *tag,I level,BL order,get_t how,const AtomList &rdir)
V pool::m_getall()
{
- getrec(MakeSymbol("getall"),0,false);
+ getrec(thisTag(),0,false);
ToOutBang(3);
echodir();
@@ -642,7 +675,7 @@ V pool::m_getall()
V pool::m_ogetall()
{
- getrec(MakeSymbol("ogetall"),0,true);
+ getrec(thisTag(),0,true);
ToOutBang(3);
echodir();
@@ -654,13 +687,13 @@ V pool::m_getrec(I argc,const A *argv)
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - getrec: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
- post("%s - getrec: invalid level specification - set to infinite",thisName());
+ post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(thisTag()));
}
- getrec(MakeSymbol("getrec"),lvls,false);
+ getrec(thisTag(),lvls,false);
ToOutBang(3);
echodir();
@@ -673,13 +706,13 @@ V pool::m_ogetrec(I argc,const A *argv)
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - ogetrec: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
- post("%s - ogetrec: invalid level specification - set to infinite",thisName());
+ post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(thisTag()));
}
- getrec(MakeSymbol("ogetrec"),lvls,true);
+ getrec(thisTag(),lvls,true);
ToOutBang(3);
echodir();
@@ -727,14 +760,14 @@ V pool::m_getsub(I argc,const A *argv)
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - getsub: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
- post("%s - getsub: invalid level specification - set to 0",thisName());
+ post("%s - %s: invalid level specification - set to 0",thisName(),GetString(thisTag()));
}
- getsub(MakeSymbol("getsub"),lvls,false);
+ getsub(thisTag(),lvls,false);
ToOutBang(3);
echodir();
@@ -747,14 +780,14 @@ V pool::m_ogetsub(I argc,const A *argv)
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - ogetsub: superfluous arguments ignored",thisName());
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
- post("%s - ogetsub: invalid level specification - set to 0",thisName());
+ post("%s - %s: invalid level specification - set to 0",thisName(),GetString(thisTag()));
}
- getsub(MakeSymbol("ogetsub"),lvls,true);
+ getsub(thisTag(),lvls,true);
ToOutBang(3);
echodir();
@@ -763,9 +796,8 @@ V pool::m_ogetsub(I argc,const A *argv)
V pool::m_cntall()
{
- const S *tag = MakeSymbol("cntall");
- I cnt = getrec(tag,0,false,get_cnt);
- ToOutSymbol(3,tag);
+ I cnt = getrec(thisTag(),0,false,get_cnt);
+ ToOutSymbol(3,thisTag());
ToOutBang(2);
ToOutBang(1);
ToOutInt(0,cnt);
@@ -775,21 +807,19 @@ V pool::m_cntall()
V pool::m_cntrec(I argc,const A *argv)
{
- const S *tag = MakeSymbol("cntrec");
-
I lvls = -1;
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag));
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
- post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(tag));
+ post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(thisTag()));
}
- I cnt = getrec(tag,lvls,false,get_cnt);
- ToOutSymbol(3,tag);
+ I cnt = getrec(thisTag(),lvls,false,get_cnt);
+ ToOutSymbol(3,thisTag());
ToOutBang(2);
ToOutBang(1);
ToOutInt(0,cnt);
@@ -800,21 +830,19 @@ V pool::m_cntrec(I argc,const A *argv)
V pool::m_cntsub(I argc,const A *argv)
{
- const S *tag = MakeSymbol("cntsub");
-
I lvls = 0;
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
- post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag));
+ post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
- post("%s - %s: invalid level specification - set to 0",thisName(),GetString(tag));
+ post("%s - %s: invalid level specification - set to 0",thisName(),GetString(thisTag()));
}
- I cnt = getsub(tag,lvls,false,get_cnt);
- ToOutSymbol(3,tag);
+ I cnt = getsub(thisTag(),lvls,false,get_cnt);
+ ToOutSymbol(3,thisTag());
ToOutBang(2);
ToOutBang(1);
ToOutInt(0,cnt);
@@ -824,8 +852,7 @@ V pool::m_cntsub(I argc,const A *argv)
V pool::m_printall()
{
- const S *tag = MakeSymbol("printall");
- I cnt = getrec(tag,0,false,get_print);
+ I cnt = getrec(thisTag(),0,false,get_print);
post("");
}
@@ -938,19 +965,18 @@ V pool::copyrec(const S *tag,I argc,const A *argv,BL cut)
V pool::load(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"loadx":"load";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - %s: no filename given",thisName(),sym);
+ post("%s - %s: no filename given",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LoadXML(fl.c_str()):pl->Load(fl.c_str())))
- post("%s - %s: error loading data",thisName(),sym);
+ post("%s - %s: error loading data",thisName(),GetString(thisTag()));
}
echodir();
@@ -958,19 +984,18 @@ V pool::load(I argc,const A *argv,BL xml)
V pool::save(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"savex":"save";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - %s: no filename given",thisName(),sym);
+ post("%s - %s: no filename given",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SaveXML(fl.c_str()):pl->Save(fl.c_str())))
- post("%s - %s: error saving data",thisName(),sym);
+ post("%s - %s: error saving data",thisName(),GetString(thisTag()));
}
echodir();
@@ -978,19 +1003,18 @@ V pool::save(I argc,const A *argv,BL xml)
V pool::lddir(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"ldxdir":"lddir";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - %s: invalid filename",thisName(),sym);
+ post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LdDirXML(curdir,fl.c_str(),0):pl->LdDir(curdir,fl.c_str(),0)))
- post("%s - %s: directory couldn't be loaded",thisName(),sym);
+ post("%s - %s: directory couldn't be loaded",thisName(),GetString(thisTag()));
}
echodir();
@@ -998,7 +1022,6 @@ V pool::lddir(I argc,const A *argv,BL xml)
V pool::ldrec(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"ldxrec":"ldrec";
const C *flnm = NULL;
I depth = -1;
BL mkdir = true;
@@ -1008,24 +1031,24 @@ V pool::ldrec(I argc,const A *argv,BL xml)
if(argc >= 2) {
if(CanbeInt(argv[1])) depth = GetAInt(argv[1]);
else
- post("%s - %s: invalid depth argument - set to -1",thisName(),sym);
+ post("%s - %s: invalid depth argument - set to -1",thisName(),GetString(thisTag()));
if(argc >= 3) {
if(CanbeBool(argv[2])) mkdir = GetABool(argv[2]);
else
- post("%s - %s: invalid mkdir argument - set to true",thisName(),sym);
+ post("%s - %s: invalid mkdir argument - set to true",thisName(),GetString(thisTag()));
- if(argc > 3) post("%s - %s: superfluous arguments ignored",thisName(),sym);
+ if(argc > 3) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
}
}
}
if(!flnm)
- post("%s - %s: invalid filename",thisName(),sym);
+ post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LdDirXML(curdir,fl.c_str(),depth,mkdir):pl->LdDir(curdir,fl.c_str(),depth,mkdir)))
- post("%s - %s: directory couldn't be saved",thisName(),sym);
+ post("%s - %s: directory couldn't be saved",thisName(),GetString(thisTag()));
}
echodir();
@@ -1033,19 +1056,18 @@ V pool::ldrec(I argc,const A *argv,BL xml)
V pool::svdir(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"svxdir":"svdir";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - %s: invalid filename",thisName(),sym);
+ post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SvDirXML(curdir,fl.c_str(),0,absdir):pl->SvDir(curdir,fl.c_str(),0,absdir)))
- post("%s - %s: directory couldn't be saved",thisName(),sym);
+ post("%s - %s: directory couldn't be saved",thisName(),GetString(thisTag()));
}
echodir();
@@ -1053,19 +1075,18 @@ V pool::svdir(I argc,const A *argv,BL xml)
V pool::svrec(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"svxrec":"svrec";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - %s: invalid filename",thisName(),sym);
+ post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SvDirXML(curdir,fl.c_str(),-1,absdir):pl->SvDir(curdir,fl.c_str(),-1,absdir)))
- post("%s - %s: directory couldn't be saved",thisName(),sym);
+ post("%s - %s: directory couldn't be saved",thisName(),GetString(thisTag()));
}
echodir();
@@ -1096,7 +1117,7 @@ V pool::ToOutAtom(I ix,const t_atom &a)
else if(IsInt(a))
ToOutInt(ix,GetInt(a));
else
- post("%s - output atom: type not supported!",thisName());
+ post("%s - %s type not supported!",thisName(),GetString(thisTag()));
}
diff --git a/externals/grill/pool/source/pool.cpp b/externals/grill/pool/source/pool.cpp
index a4f0805e..815d76a9 100644
--- a/externals/grill/pool/source/pool.cpp
+++ b/externals/grill/pool/source/pool.cpp
@@ -191,7 +191,7 @@ BL pooldir::DelDir(I argc,const A *argv)
V pooldir::SetVal(const A &key,AtomList *data,BL over)
{
- I c = 1,vix = VIdx(key);
+ 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);
@@ -228,6 +228,38 @@ V pooldir::SetVal(const A &key,AtomList *data,BL over)
}
}
+BL pooldir::SetVali(I rix,AtomList *data)
+{
+ poolval *prv = NULL,*ix = NULL;
+ for(I vix = 0; vix < vsize; ++vix)
+ if(rix > vals[vix].cnt) rix -= vals[vix].cnt;
+ else {
+ ix = vals[vix].v;
+ for(; ix && rix; prv = ix,ix = ix->nxt) --rix;
+ if(ix && !rix) break;
+ }
+
+ if(ix) {
+ // data exists... overwrite it
+
+ 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;
+ }
+ return true;
+ }
+ else
+ return false;
+}
+
poolval *pooldir::RefVal(const A &key)
{
I c = 1,vix = VIdx(key);
@@ -240,7 +272,6 @@ poolval *pooldir::RefVal(const A &key)
return c || !ix?NULL:ix;
}
-
poolval *pooldir::RefVali(I rix)
{
for(I vix = 0; vix < vsize; ++vix)
diff --git a/externals/grill/pool/source/pool.h b/externals/grill/pool/source/pool.h
index 5b4397c2..64fa1507 100644
--- a/externals/grill/pool/source/pool.h
+++ b/externals/grill/pool/source/pool.h
@@ -69,7 +69,9 @@ public:
pooldir *AddDir(const AtomList &d,I vcnt = 0,I dcnt = 0) { return AddDir(d.Count(),d.Atoms(),vcnt,dcnt); }
V SetVal(const A &key,AtomList *data,BL over = true);
+ BL SetVali(I ix,AtomList *data);
V ClrVal(const A &key) { SetVal(key,NULL); }
+ BL ClrVali(I ix) { return SetVali(ix,NULL); }
AtomList *PeekVal(const A &key);
AtomList *GetVal(const A &key,BL cut = false);
I CntAll() const;
@@ -116,6 +118,7 @@ private:
BL LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d);
};
+
class pooldata:
public flext
{
@@ -126,22 +129,103 @@ public:
V Push() { ++refs; }
BL Pop() { return --refs > 0; }
- V Reset();
- BL MkDir(const AtomList &d,I vcnt = 0,I dcnt = 0);
- BL ChkDir(const AtomList &d);
- BL RmDir(const AtomList &d);
-
- BL Set(const AtomList &d,const A &key,AtomList *data,BL over = true);
- BL Clr(const AtomList &d,const A &key);
- BL ClrAll(const AtomList &d,BL rec,BL dironly = false);
- AtomList *Peek(const AtomList &d,const A &key);
- AtomList *Get(const AtomList &d,const A &key);
- poolval *Ref(const AtomList &d,const A &key);
- poolval *Refi(const AtomList &d,I ix);
- I CntAll(const AtomList &d);
+ V Reset() { root.Reset(); }
+
+ BL MkDir(const AtomList &d,I vcnt = 0,I dcnt = 0)
+ {
+ root.AddDir(d,vcnt,dcnt);
+ return true;
+ }
+
+ BL ChkDir(const AtomList &d)
+ {
+ return root.GetDir(d) != NULL;
+ }
+
+ BL RmDir(const AtomList &d)
+ {
+ return root.DelDir(d);
+ }
+
+ BL Set(const AtomList &d,const A &key,AtomList *data,BL over = true)
+ {
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->SetVal(key,data,over);
+ return true;
+ }
+
+ BL Seti(const AtomList &d,I ix,AtomList *data)
+ {
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->SetVali(ix,data);
+ return true;
+ }
+
+ BL Clr(const AtomList &d,const A &key)
+ {
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->ClrVal(key);
+ return true;
+ }
+
+ BL Clri(const AtomList &d,I ix)
+ {
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->ClrVali(ix);
+ return true;
+ }
+
+ BL ClrAll(const AtomList &d,BL rec,BL dironly = false)
+ {
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->Clear(rec,dironly);
+ return true;
+ }
+
+ AtomList *Peek(const AtomList &d,const A &key)
+ {
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->PeekVal(key):NULL;
+ }
+
+ AtomList *Get(const AtomList &d,const A &key)
+ {
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->GetVal(key):NULL;
+ }
+
+ poolval *Ref(const AtomList &d,const A &key)
+ {
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->RefVal(key):NULL;
+ }
+
+ poolval *Refi(const AtomList &d,I ix)
+ {
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->RefVali(ix):NULL;
+ }
+
+ I CntAll(const AtomList &d)
+ {
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->CntAll():0;
+ }
+
I PrintAll(const AtomList &d);
I GetAll(const AtomList &d,A *&keys,AtomList *&lst);
- I CntSub(const AtomList &d);
+
+ I CntSub(const AtomList &d)
+ {
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->CntSub():0;
+ }
+
I GetSub(const AtomList &d,const t_atom **&dirs);
BL Paste(const AtomList &d,const pooldir *clip,I depth = -1,BL repl = true,BL mkdir = true);