aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-07-29 02:32:56 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-07-29 02:32:56 +0000
commitf7e8bf39ce93d52d60cc6fd5e6a83539f9d598db (patch)
tree6c093f44a4b48444e7c7970a12512feb8c2ce367 /externals/grill/flext
parent1504a2e019bfecb07c93da78d8df9b6c99ee7a52 (diff)
""
svn path=/trunk/; revision=800
Diffstat (limited to 'externals/grill/flext')
-rw-r--r--externals/grill/flext/changes.txt1
-rw-r--r--externals/grill/flext/flext.vcproj20
-rw-r--r--externals/grill/flext/source/flattr.cpp99
-rw-r--r--externals/grill/flext/source/flattr_ed.cpp113
-rw-r--r--externals/grill/flext/source/flclass.h11
-rwxr-xr-xexternals/grill/flext/source/flitem.cpp3
-rwxr-xr-xexternals/grill/flext/source/flmeth.cpp66
7 files changed, 194 insertions, 119 deletions
diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt
index b23910b4..67496aa0 100644
--- a/externals/grill/flext/changes.txt
+++ b/externals/grill/flext/changes.txt
@@ -27,6 +27,7 @@ Version history:
- added flext::CmpAtom and AtomList::operator < methods ... useful for using lists as keys for STL
- make use of new PD thread locking (PD functions sys_lock() and sys_unlock())
- better FLEXT_OSAPI resolution
+- ListAttributes (or the getattributes message) now lists attributes in the order they were created (first class, then object scope)
0.4.4:
- fixed deadly bug for Max/MSP method-to-symbol-binding proxies
diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj
index 68281237..cd299062 100644
--- a/externals/grill/flext/flext.vcproj
+++ b/externals/grill/flext/flext.vcproj
@@ -369,7 +369,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="pd.lib pthreadVC.lib stk_d.lib sndobj.lib"
- OutputFile=".\pd-msvc\flext_ld.dll"
+ OutputFile=".\pd-msvc\flext_d.dll"
AdditionalLibraryDirectories="f:\prog\packs\pthreads;&quot;f:\prog\pd\pd-cvs\bin&quot;;F:\prog\audio\stk\lib;F:\prog\audio\sndobj\lib"
GenerateDebugInformation="TRUE"
OptimizeReferences="1"
@@ -379,7 +379,7 @@
<Tool
Name="VCPostBuildEventTool"
Description="copy flext to maestra"
- CommandLine="copy F:\prog\max\flext\pd-msvc\flext_ld.dll F:\prog\maestra\dev\debug"/>
+ CommandLine="copy F:\prog\max\flext\pd-msvc\flext_d.dll f:\prog\maestra\dev\debug"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
@@ -412,11 +412,13 @@
Optimization="3"
GlobalOptimizations="FALSE"
InlineFunctionExpansion="2"
- OmitFramePointers="FALSE"
+ FavorSizeOrSpeed="0"
+ EnableFiberSafeOptimizations="FALSE"
AdditionalIncludeDirectories="f:\prog\pd\pd-cvs\src,f:\prog\packs\pthreads,f:\prog\audio\sndobj\include,f:\prog\audio\stk\include"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS_PD;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_SHARED;FLEXT_EXPORTS;FLEXT_PDLOCK"
+ PreprocessorDefinitions="WIN32;_LIB;FLEXT_SYS_PD;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_SHARED;FLEXT_EXPORTS;FLEXT_PDLOCK"
StringPooling="TRUE"
RuntimeLibrary="2"
+ EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="flext.h"
@@ -434,9 +436,9 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="pd.lib pthreadVC.lib stk.lib sndobj.lib"
- OutputFile=".\pd-msvc\flext_l.dll"
+ OutputFile=".\pd-msvc\flext.dll"
AdditionalLibraryDirectories="f:\prog\packs\pthreads;&quot;f:\prog\pd\pd-cvs\bin&quot;;F:\prog\audio\stk\lib;F:\prog\audio\sndobj\lib"
- GenerateDebugInformation="TRUE"
+ GenerateDebugInformation="FALSE"
OptimizeReferences="1"
ImportLibrary="./pd-msvc/flext_l.lib"/>
<Tool
@@ -444,9 +446,9 @@
<Tool
Name="VCPostBuildEventTool"
Description="copy flext to maestra"
- CommandLine="copy F:\prog\max\flext\source\*.h F:\prog\maestra\dev\api\include
-copy F:\prog\max\flext\pd-msvc\flext_l.lib F:\prog\maestra\dev\api\lib
-copy F:\prog\max\flext\pd-msvc\flext_l.dll F:\prog\maestra\dev\Release
+ CommandLine="copy F:\prog\max\flext\source\*.h f:\prog\maestra\dev\api\include
+copy F:\prog\max\flext\pd-msvc\flext_l.lib f:\prog\maestra\dev\api\lib
+copy F:\prog\max\flext\pd-msvc\flext.dll f:\prog\maestra\dev\release
"/>
<Tool
Name="VCPreBuildEventTool"/>
diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp
index 97c1dd34..40c811de 100644
--- a/externals/grill/flext/source/flattr.cpp
+++ b/externals/grill/flext/source/flattr.cpp
@@ -14,7 +14,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include <string.h>
-#include <stdlib.h>
+
+#include <set>
+
#ifdef __MWERKS__
#define STD std
@@ -23,7 +25,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
flext_base::AttrItem::AttrItem(const t_symbol *t,metharg tp,methfun f,int fl):
- Item(t,0,NULL),
+ Item(t,0,NULL),index(0),
flags(fl),argtp(tp),fun(f)
{}
@@ -38,9 +40,14 @@ void flext_base::AddAttrib(ItemCont *aa,ItemCont *ma,const char *attr,metharg tp
{
const t_symbol *asym = MakeSymbol(attr);
-// if(sfun) // if commented out, there will be a warning at run-time (more user-friendly)
+ if(sfun) // if commented out, there will be a warning at run-time (more user-friendly)
{
AttrItem *a = new AttrItem(asym,tp,sfun,AttrItem::afl_bothexist|AttrItem::afl_set);
+
+ // set index of item to the next higher value
+ AttrItem *last = (AttrItem *)aa->Last();
+ if(last) a->index = last->index+1;
+
aa->Add(a);
// bind attribute to a method
@@ -49,9 +56,14 @@ void flext_base::AddAttrib(ItemCont *aa,ItemCont *ma,const char *attr,metharg tp
ma->Add(mi);
}
-// if(gfun) // if commented out, there will be a warning at run-time (more user-friendly)
+ if(gfun) // if commented out, there will be a warning at run-time (more user-friendly)
{
AttrItem *a = new AttrItem(asym,tp,gfun,AttrItem::afl_bothexist|AttrItem::afl_get);
+
+ // set index of item to the next higher value
+ AttrItem *last = (AttrItem *)aa->Last();
+ if(last) a->index = last->index+1;
+
aa->Add(a);
static char tmp[256] = "get";
@@ -77,20 +89,26 @@ void flext_base::AddAttrib(t_classid c,const char *attr,metharg tp,methfun gfun,
AddAttrib(ClAttrs(c),ClMeths(c),attr,tp,gfun,sfun);
}
-
+/*
//! Sorting function for pure symbol atom lists (used with qsort below)
static int sortcmp(const void *a, const void *b)
{
return strcmp(flext::GetString(*(t_atom *)a),flext::GetString(*(t_atom *)b));
}
+*/
-int flext_base::ListAttrib(AtomList &la) const
+struct attrless : public std::binary_function<flext_base::AttrItem *,flext_base::AttrItem *, bool>
{
- int cnt = attrhead?attrhead->Count():0;
- int ccnt = clattrhead?clattrhead->Count():0;
- la(ccnt+cnt);
+ bool operator()(const flext_base::AttrItem *l,const flext_base::AttrItem *r) const {
+ return l->index != r->index?l->index < r->index:strcmp(flext::GetString(l->tag),flext::GetString(r->tag)) < 0;
+ }
+};
+
+void flext_base::ListAttrib(AtomList &la) const
+{
+ typedef std::set<AttrItem *,attrless> AttrList;
+ AttrList list[2];
- int ix = 0;
for(int i = 0; i <= 1; ++i) {
ItemCont *a = i?attrhead:clattrhead;
if(a) {
@@ -99,44 +117,21 @@ int flext_base::ListAttrib(AtomList &la) const
AttrItem *aa = (AttrItem *)l;
// only list once!
- if(!aa->BothExist() || aa->IsGet())
- SetSymbol(la[ix++],aa->tag);
+ if(!aa->BothExist() || aa->IsGet())
+ list[i].insert(aa);
}
}
}
}
- qsort(la.Atoms(),ix,sizeof(t_atom),sortcmp);
- return ix;
-}
-
-int flext_base::ListMethods(AtomList &la,int inlet) const
-{
- int cnt = methhead?methhead->Count():0;
- int ccnt = clmethhead?clmethhead->Count():0;
- la(ccnt+cnt);
-
+ la(list[0].size()+list[1].size());
int ix = 0;
- for(int i = 0; i <= 1; ++i) {
- ItemCont *a = i?methhead:clmethhead;
- if(a) {
- for(int ai = 0; ai < a->Size(); ++ai) {
- for(Item *l = a->GetItem(ai); l; l = l->nxt) {
- MethItem *aa = (MethItem *)l;
-
- // match inlet and see that it's not related to an attribute
- if(aa->inlet == inlet && !aa->IsAttr())
- SetSymbol(la[ix++],aa->tag);
- }
- }
- }
- }
-
- qsort(la.Atoms(),ix,sizeof(t_atom),sortcmp);
- return ix;
+ AttrList::iterator it;
+ for(i = 0; i <= 1; ++i)
+ for(it = list[i].begin(); it != list[i].end(); ++it)
+ SetSymbol(la[ix++],(*it)->tag);
}
-
int flext_base::CheckAttrib(int argc,const t_atom *argv)
{
int offs = 0;
@@ -174,34 +169,14 @@ bool flext_base::ListAttrib() const
{
if(procattr) {
AtomList la;
- int c = ListAttrib(la);
- ToOutAnything(GetOutAttr(),MakeSymbol("attributes"),c,la.Atoms());
- return true;
- }
- else
- return false;
-}
-
-bool flext_base::ListMethods(int inlet) const
-{
- if(procattr) {
- AtomList la;
- int c = ListMethods(la,inlet);
- ToOutAnything(GetOutAttr(),MakeSymbol("methods"),c,la.Atoms());
+ ListAttrib(la);
+ ToOutAnything(GetOutAttr(),MakeSymbol("attributes"),la.Count(),la.Atoms());
return true;
}
else
return false;
}
-bool flext_base::cb_ListMethods(flext_base *c,int argc,const t_atom *argv)
-{
- if(argc == 0 || (argc == 1 && CanbeInt(argv[0])))
- return c->ListMethods(argc?GetAInt(argv[0]):0);
- else
- return false;
-}
-
flext_base::AttrItem *flext_base::FindAttrib(const t_symbol *tag,bool get,bool msg) const
{
// first search within object scope
diff --git a/externals/grill/flext/source/flattr_ed.cpp b/externals/grill/flext/source/flattr_ed.cpp
index ea756fd2..8a5f6c7d 100644
--- a/externals/grill/flext/source/flattr_ed.cpp
+++ b/externals/grill/flext/source/flattr_ed.cpp
@@ -66,30 +66,36 @@ void flext_base::SetAttrEditor(t_classid c)
"global $var_attr_val\n"
"set var_attr_save [concat [concat var_save_$ix]_$vid ]\n"
"global $var_attr_save\n"
+ "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n"
+ "global $var_attr_type\n"
- "lappend lst [eval concat $$var_attr_name]\n"
-
- // process current value
- "set len [llength [expr $$var_attr_val]]\n"
- "if { $len == 1 } {\n"
- // it's an atom
- "lappend lst [expr $$var_attr_val]\n"
- "} else {\n"
- // it's a list
- "set lst [concat $lst {list} $len [expr $$var_attr_val]]\n"
- "}\n"
+ "if { [expr $$var_attr_type] != 0 } {\n"
+ // attribute is puttable
+
+ "lappend lst [eval concat $$var_attr_name]\n"
+
+ // process current value
+ "set len [llength [expr $$var_attr_val]]\n"
+ "if { $len == 1 } {\n"
+ // it's an atom
+ "lappend lst [expr $$var_attr_val]\n"
+ "} else {\n"
+ // it's a list
+ "set lst [concat $lst {list} $len [expr $$var_attr_val]]\n"
+ "}\n"
- // process init value
- "set len [llength [expr $$var_attr_init]]\n"
- "if { $len == 1 } {\n"
- // it's an atom
- "lappend lst [expr $$var_attr_init]\n"
- "} else {\n"
- // it's a list
- "set lst [concat $lst {list} $len [expr $$var_attr_init]]\n"
- "}\n"
+ // process init value
+ "set len [llength [expr $$var_attr_init]]\n"
+ "if { $len == 1 } {\n"
+ // it's an atom
+ "lappend lst [expr $$var_attr_init]\n"
+ "} else {\n"
+ // it's a list
+ "set lst [concat $lst {list} $len [expr $$var_attr_init]]\n"
+ "}\n"
- "lappend lst [eval concat $$var_attr_save]\n"
+ "lappend lst [eval concat $$var_attr_save]\n"
+ "}\n"
"}\n"
"set cmd [concat $id attributedialog $lst \\;]\n"
@@ -167,31 +173,50 @@ void flext_base::SetAttrEditor(t_classid c)
"global $var_attr_save\n"
"set $var_attr_save $asv\n"
+ // get type flag
+ "set var_attr_type [concat [concat var_type_$ix]_$vid ]\n"
+ "global $var_attr_type\n"
+ "set $var_attr_type $afl\n"
+
// add dialog elements to window
// attribute label
"label $id.label-$ix -text \"$an :\" -font {Helvetica 8 bold}\n"
"grid config $id.label-$ix -column 0 -row $row -padx 5 -sticky {e}\n"
- // entry field for initial value
- "entry $id.init-$ix -textvariable $var_attr_init\n"
- "grid config $id.init-$ix -column 1 -row $row -padx 5 -sticky {ew}\n"
-
- "button $id.b2i-$ix -text {<-} -height 1 -command \" flext_copyval $var_attr_init $var_attr_val \"\n"
- "grid config $id.b2i-$ix -column 2 -row $row -sticky {ew}\n"
- "button $id.b2c-$ix -text {->} -height 1 -command \" flext_copyval $var_attr_val $var_attr_init \"\n"
- "grid config $id.b2c-$ix -column 3 -row $row -sticky {ew}\n"
-
- // entry field for current value
- "entry $id.val-$ix -textvariable $var_attr_val\n"
- "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
-
-// "tk_optionMenu $id.opt-$ix $var_attr_save {don't save} {initialize} {always save}\n"
-// "grid config $id.opt-$ix -column 5 -row $ix \n"
-
- // radiobuttons
- "foreach {i c} {0 black 1 blue 2 red} {\n"
- "radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n"
- "grid config $id.b$i-$ix -column [expr $i + 5] -row $row \n"
+
+ "if { $afl != 0 } {\n"
+ // attribute is puttable
+
+ // entry field for current value
+ "entry $id.val-$ix -textvariable $var_attr_val\n"
+ "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
+
+ // entry field for initial value
+ "entry $id.init-$ix -textvariable $var_attr_init\n"
+ "grid config $id.init-$ix -column 1 -row $row -padx 5 -sticky {ew}\n"
+
+ "button $id.b2i-$ix -text {<-} -height 1 -command \" flext_copyval $var_attr_init $var_attr_val \"\n"
+ "grid config $id.b2i-$ix -column 2 -row $row -sticky {ew}\n"
+ "button $id.b2c-$ix -text {->} -height 1 -command \" flext_copyval $var_attr_val $var_attr_init \"\n"
+ "grid config $id.b2c-$ix -column 3 -row $row -sticky {ew}\n"
+
+ // "tk_optionMenu $id.opt-$ix $var_attr_save {don't save} {initialize} {always save}\n"
+ // "grid config $id.opt-$ix -column 5 -row $ix \n"
+
+ // radiobuttons
+ "foreach {i c} {0 black 1 blue 2 red} {\n"
+ "radiobutton $id.b$i-$ix -value $i -foreground $c -variable $var_attr_save \n"
+ "grid config $id.b$i-$ix -column [expr $i + 5] -row $row \n"
+ "}\n"
+ "} else {\n"
+ // attribute is gettable only
+
+ // entry field for current value (read-only)
+ "entry $id.val-$ix -textvariable $var_attr_val -state disabled\n"
+ "grid config $id.val-$ix -column 4 -row $row -padx 5 -sticky {ew}\n"
+
+ "label $id.readonly-$ix -text \"read-only\"\n"
+ "grid config $id.readonly-$ix -column 5 -columnspan 3 -row $row -padx 5 -sticky {ew}\n"
"}\n"
// increase counter
@@ -263,7 +288,8 @@ void flext_base::cb_GfxProperties(t_gobj *c, t_glist *)
STD::sprintf(b, " } { "); b += strlen(b);
AtomList la;
- int cnt = th->ListAttrib(la);
+ th->ListAttrib(la);
+ int cnt = la.Count();
for(int i = 0; i < cnt; ++i) {
const t_symbol *sym = GetSymbol(la[i]);
@@ -367,7 +393,8 @@ void flext_base::cb_GfxSave(t_gobj *c, t_binbuf *b)
// process the attributes
AtomList la;
- cnt = th->ListAttrib(la);
+ th->ListAttrib(la);
+ cnt = la.Count();
char attrname[100];
*attrname= '@';
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index fce496a8..0f7df9c2 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -531,14 +531,14 @@ protected:
bool DumpAttrib(const char *attr) const { return DumpAttrib(MakeSymbol(attr)); }
//! List attributes
- int ListAttrib(AtomList &a) const;
+ void ListAttrib(AtomList &a) const;
//! Get an attribute value
bool GetAttrib(const t_symbol *s,AtomList &a) const;
//! Set an attribute value
bool SetAttrib(const t_symbol *s,const AtomList &a) { return SetAttrib(s,a.Count(),a.Atoms()); }
//! List methods
- int ListMethods(AtomList &a,int inlet = 0) const;
+ void ListMethods(AtomList &a,int inlet = 0) const;
/*! \addtogroup FLEXT_C_INOUT
@{
@@ -606,6 +606,11 @@ protected:
//! Create hash table out of the preliminary linked lists
void Finalize();
+
+ //! Get first element
+ Item *First() { return !Ready()?arr[0]:NULL; }
+ //! Get last element
+ Item *Last() { return !Ready()?arr[1]:NULL; }
//! Query whether the array has been finalized
bool Ready() const { return bits >= 0; }
@@ -634,6 +639,7 @@ protected:
void SetArgs(methfun fun,int argc,metharg *args);
+ int index;
int argc;
metharg *args;
methfun fun;
@@ -656,6 +662,7 @@ protected:
bool IsSet() const { return (flags&afl_getset) == afl_set; }
bool BothExist() const { return (flags&afl_bothexist) != 0; }
+ int index;
int flags;
metharg argtp;
methfun fun;
diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp
index c2b36057..ffd7f3f1 100755
--- a/externals/grill/flext/source/flitem.cpp
+++ b/externals/grill/flext/source/flitem.cpp
@@ -117,8 +117,7 @@ bool flext_base::ItemCont::Remove(Item *it)
void flext_base::ItemCont::Finalize()
{
- if(!Ready())
- {
+ if(!Ready()) {
bits = Int2Bits(cnt); // at least enough bits to hold all items
// post("This=%p, Count %i, Bits %i",this,cnt,bits);
diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp
index 3637529e..e911d563 100755
--- a/externals/grill/flext/source/flmeth.cpp
+++ b/externals/grill/flext/source/flmeth.cpp
@@ -17,8 +17,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <stdarg.h>
#include "flinternal.h"
+#include <set>
+
+
flext_base::MethItem::MethItem(int in,const t_symbol *tg,AttrItem *conn):
- Item(tg,in,conn),
+ Item(tg,in,conn),index(0),
argc(0),args(NULL)
,fun(NULL)
{}
@@ -86,4 +89,65 @@ void flext_base::AddMethod(ItemCont *ma,int inlet,const char *tag,methfun fun,me
mi->SetArgs(fun,argc,args);
ma->Add(mi);
+
+ // set index
+ MethItem *last = (MethItem *)ma->Last();
+ if(last) mi->index = last->index+1;
+}
+
+
+struct methless : public std::binary_function <flext_base::MethItem *,flext_base::MethItem *, bool>
+{
+ bool operator()(const flext_base::MethItem *l,const flext_base::MethItem *r) const {
+ return l->index != r->index?l->index < r->index:strcmp(flext::GetString(l->tag),flext::GetString(r->tag)) < 0;
+ }
+};
+
+void flext_base::ListMethods(AtomList &la,int inlet) const
+{
+ typedef std::set<MethItem *,methless> MethList;
+ MethList list[2];
+
+ for(int i = 0; i <= 1; ++i) {
+ ItemCont *a = i?methhead:clmethhead;
+ if(a) {
+ for(int ai = 0; ai < a->Size(); ++ai) {
+ for(Item *l = a->GetItem(ai); l; l = l->nxt) {
+ MethItem *aa = (MethItem *)l;
+
+ // match inlet and see check it's not related to an attribute
+ if(aa->inlet == inlet && !aa->IsAttr())
+ list[i].insert(aa);
+ }
+ }
+ }
+ }
+
+ la(list[0].size()+list[1].size());
+ int ix = 0;
+ MethList::iterator it;
+ for(i = 0; i <= 1; ++i)
+ for(it = list[i].begin(); it != list[i].end(); ++it)
+ SetSymbol(la[ix++],(*it)->tag);
+}
+
+bool flext_base::ListMethods(int inlet) const
+{
+ if(procattr) {
+ AtomList la;
+ ListMethods(la,inlet);
+ ToOutAnything(GetOutAttr(),MakeSymbol("methods"),la.Count(),la.Atoms());
+ return true;
+ }
+ else
+ return false;
+}
+
+bool flext_base::cb_ListMethods(flext_base *c,int argc,const t_atom *argv)
+{
+ if(argc == 0 || (argc == 1 && CanbeInt(argv[0])))
+ return c->ListMethods(argc?GetAInt(argv[0]):0);
+ else
+ return false;
}
+