aboutsummaryrefslogtreecommitdiff
path: root/externals
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-03-22 04:56:29 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-03-22 04:56:29 +0000
commit848cad880af05c8c1153c21503d434eaaf8eab95 (patch)
tree37bfa5353a2a69f43370c79da2518ef07d476d01 /externals
parentdccb7f1e9f8454ddca9e1013e4c930f9cc699e86 (diff)
optimized AtomList functions
no more static assignment of symbols (problems with Metrowerks) fixed bugs in SIMD code for non-power-of-2 lengths install flcontainers.h small update of linkage styles etc. new: FLEXT_WARN, FLEXT_ERROR macros svn path=/trunk/; revision=2640
Diffstat (limited to 'externals')
-rw-r--r--externals/grill/flext/flext.vcproj2
-rw-r--r--externals/grill/flext/package.txt2
-rw-r--r--externals/grill/flext/source/flatom.cpp46
-rwxr-xr-xexternals/grill/flext/source/flatom_app.cpp76
-rw-r--r--externals/grill/flext/source/flstdc.h40
-rw-r--r--externals/grill/flext/source/flsupport.h114
6 files changed, 143 insertions, 137 deletions
diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj
index b110ed08..14ac8344 100644
--- a/externals/grill/flext/flext.vcproj
+++ b/externals/grill/flext/flext.vcproj
@@ -121,7 +121,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\data\prog\pd\pd-cvs\src;c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include"
+ AdditionalIncludeDirectories="c:\data\pd\pd-cvs\src;c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS_PD;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
diff --git a/externals/grill/flext/package.txt b/externals/grill/flext/package.txt
index dd74d18c..f93be714 100644
--- a/externals/grill/flext/package.txt
+++ b/externals/grill/flext/package.txt
@@ -32,7 +32,7 @@ SRCS= \
flbase.cpp flext.cpp flbuf.cpp fldsp.cpp fllib.cpp \
flxlet.cpp flattr.cpp flattr_ed.cpp flsupport.cpp \
flutil.cpp flatom.cpp flatom_pr.cpp flthr.cpp fltimer.cpp flsimd.cpp flout.cpp \
- flatom_app.cpp flatom_part.cpp flitem.cpp flmeth.cpp flmsg.cpp \
+ flatom_part.cpp flitem.cpp flmeth.cpp flmsg.cpp \
flproxy.cpp flqueue.cpp flbind.cpp
HDRS= \
flprefix.h flstdc.h flbase.h flclass.h flext.h flsupport.h flmap.h fldsp.h flinternal.h flcontainers.h \
diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp
index bf057c00..ae133425 100644
--- a/externals/grill/flext/source/flatom.cpp
+++ b/externals/grill/flext/source/flatom.cpp
@@ -48,15 +48,32 @@ t_atom *flext::CopyList(int argc,const t_atom *argv)
return dst;
}
-void flext::AtomList::Alloc(int sz)
+static void copyatoms(int cnt,t_atom *dst,const t_atom *src)
+{
+ if(dst < src)
+ // forward
+ memcpy(dst,src,cnt*sizeof(t_atom));
+ else
+ // backwards
+ while(cnt--) dst[cnt] = src[cnt];
+}
+
+void flext::AtomList::Alloc(int sz,int keepix,int keeplen,int keepto)
{
if(lst) {
if(cnt == sz) return; // no change
+
+ t_atom *l = new t_atom[sz];
+ if(keepix >= 0)
+ // keep contents
+ copyatoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),l+keepto,lst+keepix);
delete[] lst;
+ lst = l,cnt = sz;
}
- else
+ else {
FLEXT_ASSERT(cnt == 0);
- lst = new t_atom[cnt = sz];
+ lst = new t_atom[cnt = sz];
+ }
}
flext::AtomList::~AtomList() { Free(); }
@@ -76,10 +93,8 @@ flext::AtomList &flext::AtomList::Set(int argc,const t_atom *argv,int offs,bool
int ncnt = argc+offs;
if(resize) Alloc(ncnt);
- // argv can be NULL indepently from argc
- if(argv)
- for(int i = 0; i < argc; ++i)
- SetAtom(lst[offs+i],argv[i]);
+ // argv can be NULL independently from argc
+ if(argv) copyatoms(argc,lst+offs,argv);
return *this;
}
@@ -88,7 +103,7 @@ int flext::AtomList::Compare(const AtomList &a) const
{
if(Count() == a.Count()) {
for(int i = 0; i < Count(); ++i) {
- int cmp = CmpAtom((*this)[i],a[i]);
+ int cmp = CmpAtom(lst[i],a[i]);
if(cmp) return cmp;
}
return 0;
@@ -99,10 +114,19 @@ int flext::AtomList::Compare(const AtomList &a) const
flext::AtomListStaticBase::~AtomListStaticBase() { Free(); }
-void flext::AtomListStaticBase::Alloc(int sz)
+void flext::AtomListStaticBase::Alloc(int sz,int keepix,int keeplen,int keepto)
{
- if(sz < precnt) lst = predata,cnt = sz;
- else AtomList::Alloc(sz);
+ if(sz < precnt) {
+ if(lst != predata && lst) {
+ if(keepix >= 0)
+ // keep contents
+ copyatoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),predata+keepto,lst+keepix);
+ AtomList::Free();
+ }
+ lst = predata,cnt = sz;
+ }
+ else
+ AtomList::Alloc(sz,keepix,keeplen,keepto);
}
void flext::AtomListStaticBase::Free()
diff --git a/externals/grill/flext/source/flatom_app.cpp b/externals/grill/flext/source/flatom_app.cpp
deleted file mode 100755
index d028202b..00000000
--- a/externals/grill/flext/source/flatom_app.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-
-flext - C++ layer for Max/MSP and pd (pure data) externals
-
-Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-
-*/
-
-/*! \file flatom_app.cpp
- \brief Definitions for handling the t_atom type and lists thereof.
-*/
-
-#include "flext.h"
-
-
-flext::AtomList &flext::AtomList::Append(const t_atom &a)
-{
- t_atom *nlst = new t_atom[cnt+1];
- for(int i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]);
- SetAtom(nlst[cnt],a);
-
- if(lst) delete[] lst;
- lst = nlst;
- ++cnt;
-
- return *this;
-}
-
-flext::AtomList &flext::AtomList::Append(int argc,const t_atom *argv)
-{
- if(argc) {
- t_atom *nlst = new t_atom[cnt+argc];
- int i;
- for(i = 0; i < cnt; ++i) SetAtom(nlst[i],lst[i]);
- if(argv)
- for(i = 0; i < argc; ++i) SetAtom(nlst[cnt+i],argv[i]);
-
- if(lst) delete[] lst;
- lst = nlst;
- cnt += argc;
- }
- return *this;
-}
-
-flext::AtomList &flext::AtomList::Prepend(const t_atom &a)
-{
- t_atom *nlst = new t_atom[cnt+1];
- for(int i = 0; i < cnt; ++i) SetAtom(nlst[i+1],lst[i]);
- SetAtom(nlst[0],a);
-
- if(lst) delete[] lst;
- lst = nlst;
- ++cnt;
-
- return *this;
-}
-
-flext::AtomList &flext::AtomList::Prepend(int argc,const t_atom *argv)
-{
- if(argc) {
- t_atom *nlst = new t_atom[cnt+argc];
- int i;
-
- if(argv)
- for(i = 0; i < argc; ++i) SetAtom(nlst[i],argv[i]);
- for(i = 0; i < cnt; ++i) SetAtom(nlst[argc+i],lst[i]);
-
- if(lst) delete[] lst;
- lst = nlst;
- cnt += argc;
- }
- return *this;
-}
-
diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h
index 75e17d57..fcf43934 100644
--- a/externals/grill/flext/source/flstdc.h
+++ b/externals/grill/flext/source/flstdc.h
@@ -26,6 +26,12 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <math.h>
#endif
+#ifdef FLEXT_DEBUG
+#if FLEXT_OS == FLEXT_OS_WIN
+#include <crtdbg.h>
+#endif
+#endif
+
// PD stuff
#if FLEXT_SYS == FLEXT_SYS_PD
@@ -223,15 +229,31 @@ typedef t_symbol *t_symptr;
// -------------------------
#ifdef FLEXT_LOGGING
-
/* If FLEXT_LOGGING is defined implement logging */
+
+#if FLEXT_OS == FLEXT_OS_WIN
+#define FLEXT_LOG(s) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s)
+#define FLEXT_LOG1(s,v1) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1)
+#define FLEXT_LOG2(s,v1,v2) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2)
+#define FLEXT_LOG3(s,v1,v2,v3) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3)
+#define FLEXT_LOG4(s,v1,v2,v3,v4) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4)
+#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5)
+#define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6)
+#define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7)
+#define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7,v8)
+#define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7,v8,v9)
+#else
#define FLEXT_LOG(s) post(s)
#define FLEXT_LOG1(s,v1) post(s,v1)
#define FLEXT_LOG2(s,v1,v2) post(s,v1,v2)
#define FLEXT_LOG3(s,v1,v2,v3) post(s,v1,v2,v3)
#define FLEXT_LOG4(s,v1,v2,v3,v4) post(s,v1,v2,v3,v4)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) post(s,v1,v2,v3,v4,v5)
-
+#define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) post(s,v1,v2,v3,v4,v5,v6)
+#define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) post(s,v1,v2,v3,v4,v5,v6,v7)
+#define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) post(s,v1,v2,v3,v4,v5,v6,v7,v8)
+#define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) post(s,v1,v2,v3,v4,v5,v6,v7,v8,v9)
+#endif
#else
@@ -242,13 +264,27 @@ typedef t_symbol *t_symptr;
#define FLEXT_LOG3(s,v1,v2,v3) ((void)0)
#define FLEXT_LOG4(s,v1,v2,v3,v4) ((void)0)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) ((void)0)
+#define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) ((void)0)
+#define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) ((void)0)
+#define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) ((void)0)
+#define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) ((void)0)
#endif
#ifdef FLEXT_DEBUG
+#if FLEXT_OS == FLEXT_OS_WIN
+#define FLEXT_ASSERT(b) (!(b)?_CrtDbgReport(_CRT_ASSERT,__FILE__,__LINE__,"flext",#b):1)
+#define FLEXT_WARN(str) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",NULL)
+#define FLEXT_ERROR(str) _CrtDbgReport(_CRT_ERROR,__FILE__,__LINE__,"flext",NULL)
+#else
#define FLEXT_ASSERT(b) (!(b)?(error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__),0):1)
+#define FLEXT_WARN(str) error("Warning: in " __FILE__ " line %i",(int)__LINE__)
+#define FLEXT_ERROR(str) error("Error: in " __FILE__ " line %i",(int)__LINE__)
+#endif
#else
#define FLEXT_ASSERT(b) (1)
+#define FLEXT_WARN(str) (1)
+#define FLEXT_ERROR(str) error("Error: in " __FILE__ " line %i",(int)__LINE__)
#endif
#define ERRINTERNAL() error("flext: Internal error in file " __FILE__ ", line %i - please report",(int)__LINE__)
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index 9c5a7a41..39713b1c 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -34,10 +34,10 @@ class FLEXT_SHARE FLEXT_CLASSDEF(flext_root) {
public:
// --- console output -----------------------------------------------
- //! post message to console, with line feed (limited to 1k chars!)
- static void post(const char *fmt,...);
- //! post error message to console (limited to 1k chars!)
- static void error(const char *fmt,...);
+ //! post message to console, with line feed (limited to 1k chars!)
+ static void post(const char *fmt,...);
+ //! post error message to console (limited to 1k chars!)
+ static void error(const char *fmt,...);
// --- memory -------------------------------------------------------
@@ -45,33 +45,33 @@ public:
@{
*/
- /*! Overloaded new memory allocation method
- \note this uses a fast allocation method of the real-time system
- \warning Max/MSP (or MacOS) allows only 32K in overdrive mode!
- */
- void *operator new(size_t bytes);
- //! Overloaded delete method
- void operator delete(void *blk);
-
- inline void *operator new(size_t,void *p) { return p; }
- inline void operator delete(void *,void *) {}
-
- #ifndef __MRC__ // doesn't allow new[] overloading?!
- inline void *operator new[](size_t bytes) { return operator new(bytes); }
- inline void operator delete[](void *blk) { operator delete(blk); }
-
- inline void *operator new[](size_t,void *p) { return p; }
- inline void operator delete[](void *,void *) {}
- #endif
-
- //! Get an aligned memory block
- static void *NewAligned(size_t bytes,int bitalign = 128);
- //! Free an aligned memory block
- static void FreeAligned(void *blk);
- //! Test for alignment
- static bool IsAligned(void *ptr,int bitalign = 128) {
- return (reinterpret_cast<size_t>(ptr)&(bitalign-1)) == 0;
- }
+ /*! Overloaded new memory allocation method
+ \note this uses a fast allocation method of the real-time system
+ \warning Max/MSP (or MacOS) allows only 32K in overdrive mode!
+ */
+ void *operator new(size_t bytes);
+ //! Overloaded delete method
+ void operator delete(void *blk);
+
+ inline void *operator new(size_t,void *p) { return p; }
+ inline void operator delete(void *,void *) {}
+
+ #ifndef __MRC__ // doesn't allow new[] overloading?!
+ inline void *operator new[](size_t bytes) { return operator new(bytes); }
+ inline void operator delete[](void *blk) { operator delete(blk); }
+
+ inline void *operator new[](size_t,void *p) { return p; }
+ inline void operator delete[](void *,void *) {}
+ #endif
+
+ //! Get an aligned memory block
+ static void *NewAligned(size_t bytes,int bitalign = 128);
+ //! Free an aligned memory block
+ static void FreeAligned(void *blk);
+ //! Test for alignment
+ static bool IsAligned(void *ptr,int bitalign = 128) {
+ return (reinterpret_cast<size_t>(ptr)&(bitalign-1)) == 0;
+ }
//! @} FLEXT_S_MEMORY
};
@@ -140,6 +140,14 @@ public:
//! Flext version string
static const char *VersionStr();
+// --- special typedefs ---------------------------------------------
+
+ typedef t_float Float;
+ typedef t_int Int;
+ typedef t_sample Sample;
+ typedef const t_symbol *Symbol;
+ typedef t_atom Atom;
+
// --- buffer/array stuff -----------------------------------------
/*! \defgroup FLEXT_S_BUFFER Buffer handling
@@ -593,16 +601,30 @@ public:
//! Get a pointer to the list of atoms
const t_atom *Atoms() const { return lst; }
- //! Append an atom to the list
- AtomList &Append(const t_atom &a);
- //! Append an atom list to the list
- AtomList &Append(int argc,const t_atom *argv = NULL);
//! Append an atom list to the list
+ AtomList &Append(int argc,const t_atom *argv = NULL)
+ {
+ int c = Count();
+ Alloc(c+argc,0,c);
+ Set(argc,argv,c);
+ return *this;
+ }
+
+ //! Prepend an atom list to the list
+ AtomList &Prepend(int argc,const t_atom *argv = NULL)
+ {
+ int c = Count();
+ Alloc(c+argc,0,c,argc);
+ Set(argc,argv);
+ return *this;
+ }
+
+ //! Append an atom to the list
+ AtomList &Append(const t_atom &a) { return Append(1,&a); }
+ //! Append an atom list to the list
AtomList &Append(const AtomList &a) { return Append(a.Count(),a.Atoms()); }
//! Prepend an atom to the list
- AtomList &Prepend(const t_atom &a);
- //! Prepend an atom list to the list
- AtomList &Prepend(int argc,const t_atom *argv = NULL);
+ AtomList &Prepend(const t_atom &a) { return Prepend(1,&a); }
//! Prepend an atom list to the list
AtomList &Prepend(const AtomList &a) { return Prepend(a.Count(),a.Atoms()); }
@@ -615,7 +637,7 @@ public:
bool Print(char *buffer,int buflen) const { return flext::PrintList(Count(),Atoms(),buffer,buflen); }
protected:
- virtual void Alloc(int sz);
+ virtual void Alloc(int sz,int keepix = -1,int keeplen = -1,int keepto = 0);
virtual void Free();
int cnt;
@@ -628,7 +650,7 @@ public:
protected:
AtomListStaticBase(int pc,t_atom *dt): precnt(pc),predata(dt) {}
virtual ~AtomListStaticBase();
- virtual void Alloc(int sz);
+ virtual void Alloc(int sz,int keepix = -1,int keeplen = -1,int keepto = 0);
virtual void Free();
const int precnt;
@@ -1195,12 +1217,12 @@ protected:
// gcc doesn't like these to be included into the flext class (even if static)
-inline bool operator ==(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) == 0; }
-inline bool operator !=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) != 0; }
-inline bool operator <(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) < 0; }
-inline bool operator <=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) <= 0; }
-inline bool operator >(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) > 0; }
-inline bool operator >=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) >= 0; }
+inline bool operator ==(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) == 0; }
+inline bool operator !=(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) != 0; }
+inline bool operator <(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) < 0; }
+inline bool operator <=(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) <= 0; }
+inline bool operator >(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) > 0; }
+inline bool operator >=(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) >= 0; }
//! @} // FLEXT_SUPPORT