aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-12-05 05:36:32 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-12-05 05:36:32 +0000
commit60ee6bb60b11bbfbccf56f335c9c6213e6daa79d (patch)
tree99b0c72c60aeba5d1a0489aae9edd16f371d965c /externals/grill/flext/source
parentbbd9d289d152f6ef085dec680f0b1611c29f0e32 (diff)
""
svn path=/trunk/; revision=278
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r--externals/grill/flext/source/flatom.cpp7
-rw-r--r--externals/grill/flext/source/flatom_pr.cpp10
-rw-r--r--externals/grill/flext/source/flattr.cpp2
-rw-r--r--externals/grill/flext/source/flbase.cpp10
-rw-r--r--externals/grill/flext/source/flbase.h35
-rw-r--r--externals/grill/flext/source/flbuf.cpp44
-rw-r--r--externals/grill/flext/source/flclass.h30
-rwxr-xr-xexternals/grill/flext/source/flcwmax-x-thr.h1
-rw-r--r--externals/grill/flext/source/flcwmax.h22
-rw-r--r--externals/grill/flext/source/fldsp.cpp32
-rw-r--r--externals/grill/flext/source/fldsp.h8
-rw-r--r--externals/grill/flext/source/flext.cpp101
-rw-r--r--externals/grill/flext/source/flext.h9
-rw-r--r--externals/grill/flext/source/flinternal.h7
-rwxr-xr-xexternals/grill/flext/source/fllib.cpp59
-rwxr-xr-xexternals/grill/flext/source/flmspbuffer.h2
-rw-r--r--externals/grill/flext/source/flout.cpp28
-rwxr-xr-xexternals/grill/flext/source/flprefix.h159
-rw-r--r--externals/grill/flext/source/flsndobj.cpp3
-rw-r--r--externals/grill/flext/source/flsndobj.h8
-rw-r--r--externals/grill/flext/source/flstdc.h98
-rw-r--r--externals/grill/flext/source/flsupport.cpp12
-rw-r--r--externals/grill/flext/source/flsupport.h17
-rw-r--r--externals/grill/flext/source/flthr.cpp40
-rw-r--r--externals/grill/flext/source/flutil.cpp32
-rwxr-xr-xexternals/grill/flext/source/flxlet.cpp4
26 files changed, 434 insertions, 346 deletions
diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp
index b7ba4524..0efb79f4 100644
--- a/externals/grill/flext/source/flatom.cpp
+++ b/externals/grill/flext/source/flatom.cpp
@@ -14,6 +14,13 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
+t_atom *flext::CopyList(int argc,const t_atom *argv)
+{
+ int i;
+ t_atom *dst = new t_atom[argc];
+ for(i = 0; i < argc; ++i) CopyAtom(dst+i,argv+i);
+ return dst;
+}
flext::AtomList::AtomList(int argc,const t_atom *argv):
cnt(0),lst(NULL)
diff --git a/externals/grill/flext/source/flatom_pr.cpp b/externals/grill/flext/source/flatom_pr.cpp
index 808f0543..44b43bbf 100644
--- a/externals/grill/flext/source/flatom_pr.cpp
+++ b/externals/grill/flext/source/flatom_pr.cpp
@@ -30,19 +30,19 @@ void flext::PrintAtom(const t_atom &a,char *buf)
case A_NULL:
break;
case A_FLOAT:
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
if(a.a_w.w_float == (int)a.a_w.w_float)
STD::sprintf(buf,"%i",(int)GetFloat(a));
else
#endif
STD::sprintf(buf,"%f",GetFloat(a));
break;
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
case A_LONG:
STD::sprintf(buf,"%i",GetInt(a));
break;
#endif
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
case A_POINTER:
STD::sprintf(buf,"%x",GetPointer(a));
break;
@@ -50,7 +50,7 @@ void flext::PrintAtom(const t_atom &a,char *buf)
case A_SYMBOL:
strcpy(buf,GetString(a));
break;
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
default:
ERRINTERNAL();
#endif
@@ -76,7 +76,7 @@ bool flext::ScanAtom(t_atom &a,const char *buf)
switch(s) {
case 0: // integer
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
SetInt(a,atol(tmp));
break;
#endif
diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp
index 2739ae11..44dc0d28 100644
--- a/externals/grill/flext/source/flattr.cpp
+++ b/externals/grill/flext/source/flattr.cpp
@@ -15,7 +15,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include <string.h>
-#ifdef MAXMSP
+#ifdef __MWERKS__
#define STD std
#else
#define STD
diff --git a/externals/grill/flext/source/flbase.cpp b/externals/grill/flext/source/flbase.cpp
index 5a2e5f0a..b321fbf1 100644
--- a/externals/grill/flext/source/flbase.cpp
+++ b/externals/grill/flext/source/flbase.cpp
@@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
\remark This is all derived from GEM by Mark Danks
*/
-#include "flbase.h"
+#include "flext.h"
#include "flinternal.h"
#include <string.h>
@@ -41,9 +41,9 @@ flext_obj :: flext_obj()
, procattr(m_holdattr)
, init_ok(true)
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
m_canvas = canvas_getcurrent();
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
m_canvas = (t_patcher *)gensym("#P")->s_thing;
x_obj->curinlet = 0;
#endif
@@ -58,7 +58,7 @@ flext_obj :: ~flext_obj() {}
void flext_obj::DefineHelp(t_class *c,const char *ref,const char *dir,bool addtilde)
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
char tmp[256];
if(dir) {
strcpy(tmp,dir);
@@ -70,7 +70,7 @@ void flext_obj::DefineHelp(t_class *c,const char *ref,const char *dir,bool addti
strcpy(tmp,ref);
::class_sethelpsymbol(c,gensym(const_cast<char *>(tmp)));
#else
- // no solution for MaxMSP yet
+ // no solution for Max/MSP yet
#endif
}
diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h
index cf973a41..0c8e8e7e 100644
--- a/externals/grill/flext/source/flbase.h
+++ b/externals/grill/flext/source/flbase.h
@@ -44,13 +44,13 @@ struct FLEXT_EXT flext_hdr
*/
t_sigobj obj;
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
//! PD only: float signal holder for pd
float defsig;
#endif
-#if defined(MAXMSP)
- //! MaxMSP only: current inlet used by proxy objects
+#if FLEXT_SYS == FLEXT_SYS_MAX
+ //! Max/MSP only: current inlet used by proxy objects
long curinlet;
#endif
@@ -142,10 +142,10 @@ class flext_obj:
//! Get the class name (as a symbol)
const t_symbol *thisNameSym() const { return m_name; }
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
//! Get the class pointer
t_class *thisClass() { return (t_class *)((t_object *)(x_obj))->te_g.g_pd; }
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
//! Get the class pointer
t_class *thisClass() { return (t_class *)(((t_tinyobject *)x_obj)->t_messlist-1); }
#endif
@@ -159,7 +159,7 @@ class flext_obj:
*/
/*! Overloaded new memory allocation method
- \warning MaxMSP (or MacOS) allows only 16K in overdrive mode!
+ \warning Max/MSP (or MacOS) allows only 16K in overdrive mode!
*/
void *operator new(size_t bytes);
//! Overloaded delete method
@@ -276,6 +276,10 @@ class flext_obj:
#define FLEXT_ATTRIBUTES \
\
0
+
+
+#elif FLEXT_ATTRIBUTES != 0 && FLEXT_ATTRIBUTES != 1
+#error "FLEXT_ATTRIBUTES must be 0 or 1"
#endif
// ----------------------------------------
@@ -337,10 +341,12 @@ cl##_tilde_setup()
// specify that to define the library itself
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
#define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT void NAME##_setup() { flext_obj::lib_init(#NAME,SETUPFUN,FLEXT_ATTRIBUTES); }
-#else // MAXMSP
+#elif FLEXT_SYS == FLEXT_SYS_MAX
#define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT int main() { flext_obj::lib_init(#NAME,SETUPFUN,FLEXT_ATTRIBUTES); return 0; }
+#else
+#error
#endif
@@ -351,11 +357,14 @@ cl##_tilde_setup()
#define FLEXT_EXP_1
#define FLEXT_EXP(LIB) FLEXT_EXP_##LIB
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
#define FLEXT_OBJ_SETUP_0(NEW_CLASS,DSP)
-#else // MAXMSP
+#elif FLEXT_SYS == FLEXT_SYS_MAX
#define FLEXT_OBJ_SETUP_0(NEW_CLASS,DSP) extern "C" FLEXT_EXT int main() { FLEXT_STPF(NEW_CLASS,DSP)(); return 0; }
+#else
+#error
#endif
+
#define FLEXT_OBJ_SETUP_1(NEW_CLASS,DSP)
#define FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) FLEXT_OBJ_SETUP_##LIB(NEW_CLASS,DSP)
@@ -374,12 +383,14 @@ cl##_tilde_setup()
#define FLEXTTYPE_t_float A_FLOAT
#define CALLBTYPE_t_float t_float
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
#define FLEXTTYPE_int A_FLOAT
#define CALLBTYPE_int float
-#else
+#elif FLEXT_SYS == FLEXT_SYS_MAX
#define FLEXTTYPE_int A_INT
#define CALLBTYPE_int int
+#else
+#error
#endif
#define FLEXTTYPE_t_symptr A_SYMBOL
diff --git a/externals/grill/flext/source/flbuf.cpp b/externals/grill/flext/source/flbuf.cpp
index dc5704c0..91ac8ce6 100644
--- a/externals/grill/flext/source/flbuf.cpp
+++ b/externals/grill/flext/source/flbuf.cpp
@@ -14,11 +14,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
#include "flmspbuffer.h" // include inofficial buffer.h
#endif
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
#define DIRTY_INTERVAL 0 // buffer dirty check in msec
#endif
@@ -28,7 +28,7 @@ flext::buffer::buffer(const t_symbol *bn,bool delayed):
sym(NULL),data(NULL),
chns(0),frames(0)
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
arr = NULL;
interval = DIRTY_INTERVAL;
isdirty = false;
@@ -41,7 +41,7 @@ flext::buffer::buffer(const t_symbol *bn,bool delayed):
flext::buffer::~buffer()
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
clock_free(tick);
#endif
}
@@ -64,7 +64,7 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly)
if(valid) ret = -1;
}
else if(!nameonly) {
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
int frames1;
t_sample *data1;
@@ -88,7 +88,7 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly)
if(data != data1) { data = data1; if(!ret) ret = 1; }
chns = 1;
}
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
if(sym->s_thing) {
const _buffer *p = (const _buffer *)sym->s_thing;
@@ -97,7 +97,7 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly)
if(valid) ret = -1;
}
else {
-#ifdef DEBUG
+#ifdef FLEXT_DEBUG
post("%s: buffer object '%s' - valid:%i samples:%i channels:%i frames:%i",thisName(),bufname->s_name,p->b_valid,p->b_frames,p->b_nchans,p->b_frames);
#endif
if(data != p->b_samples) { data = p->b_samples; if(!ret) ret = 1; }
@@ -109,6 +109,8 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly)
error("buffer: symbol '%s' not defined", sym->s_name);
if(valid) ret = -1;
}
+#else
+#error
#endif
}
@@ -119,7 +121,7 @@ bool flext::buffer::Update()
{
if(!Ok()) return false;
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
int frames1;
t_sample *data1;
if(!garray_getfloatarray(arr, &frames1, &data1)) {
@@ -135,7 +137,7 @@ bool flext::buffer::Update()
}
else
return false;
-#else // MAXMSP
+#elif FLEXT_SYS == FLEXT_SYS_MAX
if(!sym->s_thing)
return false;
else {
@@ -149,15 +151,17 @@ bool flext::buffer::Update()
else
return false;
}
+#else
+#error
#endif
}
void flext::buffer::Frames(int fr,bool keep)
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
::garray_resize(arr,(float)fr);
Update();
-#else
+#elif FLEXT_SYS == FLEXT_SYS_MAX
t_sample *tmp = NULL;
int sz = frames;
if(fr < sz) sz = fr;
@@ -187,11 +191,13 @@ void flext::buffer::Frames(int fr,bool keep)
BlockMoveData(tmp,data,sizeof(t_sample)*sz);
delete[] tmp;
}
+#else
+#error
#endif
}
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
void flext::buffer::SetRefrIntv(float intv)
{
interval = intv;
@@ -200,15 +206,17 @@ void flext::buffer::SetRefrIntv(float intv)
ticking = false;
}
}
-#else
+#elif FLEXT_SYS == FLEXT_SYS_MAX
void flext::buffer::SetRefrIntv(float) {}
+#else
+#error
#endif
void flext::buffer::Dirty(bool force)
{
if(sym) {
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
if((!ticking) && (interval || force)) {
ticking = true;
cb_tick(this); // immediately redraw
@@ -217,7 +225,7 @@ void flext::buffer::Dirty(bool force)
if(force) clock_delay(tick,0);
isdirty = true;
}
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
if(sym->s_thing) {
_buffer *p = (_buffer *)sym->s_thing;
@@ -231,15 +239,17 @@ void flext::buffer::Dirty(bool force)
else {
error("buffer: symbol '%s' not defined",sym->s_name);
}
+#else
+#error
#endif
}
}
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
void flext::buffer::cb_tick(buffer *b)
{
if(b->arr) garray_redraw(b->arr);
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
else error("buffer: array is NULL");
#endif
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index 8c14e6b8..12efeb82 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -79,7 +79,7 @@ public:
//! called on patcher load (not on mere object creation!)
virtual void m_loadbang() {}
- //! quickhelp for inlets/outlets (gets called in MaxMSP only)
+ //! quickhelp for inlets/outlets (gets called in Max/MSP only)
virtual void m_assist(long /*msg*/,long /*arg*/,char * /*s*/) {}
/*! \brief Called for every incoming message.
@@ -87,12 +87,12 @@ public:
\return True if a handler was found and called
\todo Once, there should be a const modifier for argv
*/
- virtual bool m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv);
+ virtual bool m_methodmain(int inlet,const t_symbol *s,int argc,const t_atom *argv);
/*! \brief Called for every unhandled message (by m_methodmain)
\todo Once, there should be a const modifier for argv
*/
- virtual bool m_method_(int inlet,const t_symbol *s,int argc,t_atom *argv);
+ virtual bool m_method_(int inlet,const t_symbol *s,int argc,const t_atom *argv);
//! @} FLEXT_C_VIRTUAL
@@ -325,10 +325,12 @@ public:
void AddMethod(int inlet,bool (*m)(flext_base *,float &)) { AddMethod(inlet,"float",(methfun)m,a_float,a_null); } // single float
void AddMethod(int inlet,bool (*m)(flext_base *,float &,float &)) { AddMethod(inlet,"list",(methfun)m,a_float,a_float,a_null); } // list of 2 floats
void AddMethod(int inlet,bool (*m)(flext_base *,float &,float &,float &)) { AddMethod(inlet,"list",(methfun)m,a_float,a_float,a_float,a_null); } // list of 3 floats
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
void AddMethod(int inlet,bool (*m)(flext_base *,int &)) { AddMethod(inlet,"float",(methfun)m,a_int,a_null); } // single float
-#else
+#elif FLEXT_SYS == FLEXT_SYS_MAX
void AddMethod(int inlet,bool (*m)(flext_base *,int &)) { AddMethod(inlet,"int",(methfun)m,a_int,a_null); } // single float
+#else
+#error
#endif
void AddMethod(int inlet,bool (*m)(flext_base *,int &,int &)) { AddMethod(inlet,"list",(methfun)m,a_int,a_int,a_null); } // list of 2 floats
void AddMethod(int inlet,bool (*m)(flext_base *,int &,int &,int &)) { AddMethod(inlet,"list",(methfun)m,a_int,a_int,a_int,a_null); } // list of 3 floats
@@ -341,7 +343,7 @@ public:
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,float &)) { AddMethod(inlet,tag,(methfun)m,a_float,a_null); } // method+float
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,int &)) { AddMethod(inlet,tag,(methfun)m,a_int,a_null); } // method+int
- //! Set MaxMSP style of distributing list elements over (message) inlets
+ //! Set Max/MSP style of distributing list elements over (message) inlets
void SetDist(bool d = true) { distmsgs = d; }
//! @} FLEXT_C_ADDMETHOD
@@ -353,7 +355,7 @@ public:
@{
*/
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
//! Bind object to a symbol
bool Bind(const t_symbol *s) { pd_bind(&thisHdr()->ob_pd,const_cast<t_symbol *>(s)); return true; }
//! Unbind object from a symbol
@@ -616,9 +618,9 @@ private:
float ft;
int it;
t_symbol *st;
- #ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
t_gpointer *pt;
- #endif
+#endif
void *vt;
};
@@ -665,7 +667,7 @@ private:
class qmsg;
qmsg *qhead,*qtail;
t_qelem *qclk;
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
t_clock *yclk;
static void YTick(flext_base *th);
#endif
@@ -673,11 +675,11 @@ private:
static void QTick(flext_base *th);
void Queue(qmsg *m);
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
// proxy object (for additional inlets) stuff
struct px_object;
friend struct px_object;
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
typedef object px_object;
static void cb_px_float(t_class *c,float f);
static void cb_px_int(t_class *c,int v);
@@ -692,6 +694,8 @@ private:
static void cb_px_in7(t_class *c,int v);
static void cb_px_in8(t_class *c,int v);
static void cb_px_in9(t_class *c,int v);
+#else
+#error
#endif
static void cb_px_anything(t_class *c,const t_symbol *s,int argc,t_atom *argv);
@@ -712,7 +716,7 @@ private:
static void cb_help(t_class *c);
static void cb_loadbang(t_class *c);
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
static void cb_assist(t_class *c,void *b,long msg,long arg,char *s);
#endif
};
diff --git a/externals/grill/flext/source/flcwmax-x-thr.h b/externals/grill/flext/source/flcwmax-x-thr.h
index a5f105a2..205dbd1f 100755
--- a/externals/grill/flext/source/flcwmax-x-thr.h
+++ b/externals/grill/flext/source/flcwmax-x-thr.h
@@ -14,7 +14,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define _FLEXT_CW_MAX_X_THR_H
#define FLEXT_THREADS
-#define _POSIX_THREADS
/*
old CodeWarrior version (<= 6) don't have sigset_t defined which
diff --git a/externals/grill/flext/source/flcwmax.h b/externals/grill/flext/source/flcwmax.h
index 184803ff..d637d0cc 100644
--- a/externals/grill/flext/source/flcwmax.h
+++ b/externals/grill/flext/source/flcwmax.h
@@ -16,33 +16,17 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef __MWERKS__
#error "This header file is for CodeWarrior only."
#endif
+
+#define FLEXT_SYS 1
#ifndef _CW_NOPRECOMP
#include <MacHeaders.h>
#endif
#if __option(sym) || !__option(opt_dead_code)
- #define _DEBUG
-#endif
-
-#ifdef MAXMSP
- #pragma message("#define MAXMSP is deprecated, use #define FLEXT_SYS_MAX instead")
-#else
- #define FLEXT_SYS_MAX
- // this is deprecated (but still necessary)
- #define MAXMSP
+ #define FLEXT_DEBUG
#endif
-#if __POWERPC__
- #define FLEXT_PLATFORM_MAC
-#elif __INTEL__
- #define FLEXT_PLATFORM_WIN
- // this is necessary for Cycling headers when compiling for Windows
- #define WIN_VERSION 1
-#else
- #error "Target platform not supported."
-#endif
-
/* #define _LOG */
#endif
diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp
index d1079286..f5a5d94e 100644
--- a/externals/grill/flext/source/fldsp.cpp
+++ b/externals/grill/flext/source/fldsp.cpp
@@ -22,31 +22,31 @@ WARRANTIES, see the file, "license.txt," in this distribution.
void flext_dsp::Setup(t_class *c)
{
-#ifdef PD
-// CLASS_MAINSIGNALIN(c,flext_hdr,defsig);
-#elif defined(MAXMSP)
+#if FLEXT_SYS == FLEXT_SYS_MAX
// dsp_initclass();
dsp_initboxclass();
#endif
add_dsp(c,cb_dsp);
-#ifndef MAXMSP
- add_method1(c,cb_enable,"enable",A_FLINT);
+#if FLEXT_SYS != FLEXT_SYS_MAX
+ add_method1(c,cb_enable,"enable",A_FLOAT);
#endif
}
flext_dsp::flext_dsp():
-#ifndef MAXMSP
+#if FLEXT_SYS != FLEXT_SYS_MAX
dspon(true),
#endif
srate(sys_getsr()), // should we set it?
blksz(sys_getblksize()),
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
chnsin(sys_get_inchannels()),
chnsout(sys_get_outchannels()),
-#else // MAXMSP
+#elif FLEXT_SYS == FLEXT_SYS_MAX
chnsin(sys_getch()),
chnsout(sys_getch()),
+#else
+#error
#endif
invecs(NULL),outvecs(NULL)
{}
@@ -62,7 +62,7 @@ flext_dsp::~flext_dsp()
t_int *flext_dsp::dspmeth(t_int *w)
{
flext_dsp *obj = (flext_dsp *)w[1];
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
if(!obj->thisHdr()->z_disabled)
#else
if(obj->dspon)
@@ -73,10 +73,10 @@ t_int *flext_dsp::dspmeth(t_int *w)
void flext_dsp::m_dsp(int /*n*/,t_sample *const * /*insigs*/,t_sample *const * /*outsigs*/) {}
-void flext_dsp::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outsigs)
+void flext_dsp::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs)
{
for(int i = 0; i < CntOutSig(); ++i)
- memset(outsigs[i],0,n*sizeof(*outsigs[i]));
+ memset(outs[i],0,n*sizeof(*outs[i]));
}
void flext_dsp::cb_dsp(t_class *c,t_signal **sp)
@@ -89,11 +89,13 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp)
obj->srate = sp[0]->s_sr;
obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ?
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
obj->chnsin = sys_get_inchannels();
obj->chnsout = sys_get_outchannels();
-#else // MAXMSP
+#elif FLEXT_SYS == FLEXT_SYS_MAX
obj->chnsin = obj->chnsout = sys_getch();
+#else
+#error
#endif
// store in and out signal vectors
@@ -113,8 +115,8 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp)
dsp_add((t_dspmethod)dspmeth,2,obj,sp[0]->s_n);
}
-#ifndef MAXMSP
-void flext_dsp::cb_enable(t_class *c,t_flint on) { thisObject(c)->m_enable(on != 0); }
+#if FLEXT_SYS != FLEXT_SYS_MAX
+void flext_dsp::cb_enable(t_class *c,t_float on) { thisObject(c)->m_enable(on != 0); }
void flext_dsp::m_enable(bool en) { dspon = en; }
#endif
diff --git a/externals/grill/flext/source/fldsp.h b/externals/grill/flext/source/fldsp.h
index 56959c72..b1fbe23d 100644
--- a/externals/grill/flext/source/fldsp.h
+++ b/externals/grill/flext/source/fldsp.h
@@ -83,9 +83,9 @@ public:
*/
virtual void m_signal(int n,t_sample *const *insigs,t_sample *const *outsigs);
-#ifndef MAXMSP
+#if FLEXT_SYS != FLEXT_SYS_MAX
/*! \brief called with "enable" message: pauses/resumes dsp
- \note PD only - implicitely defined in MaxMSP
+ \note PD only - implicitely defined in Max/MSP
*/
virtual void m_enable(bool on);
#endif
@@ -132,8 +132,8 @@ private:
// callback functions
static void cb_dsp(t_class *c,t_signal **s);
-#ifndef MAXMSP
- static void cb_enable(t_class *c,t_flint on);
+#if FLEXT_SYS != FLEXT_SYS_MAX
+ static void cb_enable(t_class *c,t_float on);
bool dspon;
#endif
diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp
index 85f3da6e..dedf7c49 100644
--- a/externals/grill/flext/source/flext.cpp
+++ b/externals/grill/flext/source/flext.cpp
@@ -20,7 +20,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// === proxy class for flext_base ============================
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
static t_class *px_class;
@@ -54,7 +54,7 @@ void flext_base::cb_px_ft ## IX(t_class *c,float v) { \
#define ADD_IN_FT(IX) \
add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT)
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
void flext_base::cb_px_anything(t_class *c,const t_symbol *s,int argc,t_atom *argv)
{
@@ -97,7 +97,9 @@ void flext_base::cb_px_ft ## IX(t_class *c,float v) { long &ci = ((flext_hdr *)t
add_method1(c,cb_px_in ## IX,"in" #IX,A_INT); \
add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT)
-#endif // MAXMSP
+#else
+#error // Other system
+#endif
DEF_IN_FT(1)
@@ -135,7 +137,7 @@ flext_base::flext_base():
#endif
qhead = qtail = NULL;
qclk = (t_qelem *)(qelem_new(this,(t_method)QTick));
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
yclk = (t_clock *)(clock_new(this,(t_method)YTick));
#endif
@@ -149,7 +151,7 @@ flext_base::~flext_base()
shouldexit = true;
for(int wi = 0; thrhead && wi < 100; ++wi) Sleep(0.01f);
-#ifdef _POSIX_THREADS
+//#ifdef _POSIX_THREADS
qmutex.Lock(); // Lock message queue
tlmutex.Lock();
// timeout -> hard termination
@@ -161,16 +163,16 @@ flext_base::~flext_base()
}
tlmutex.Unlock();
qmutex.Unlock();
-#else
-#pragma message ("No tread cancelling")
-#endif
+//#else
+//#pragma message ("No tread cancelling")
+//#endif
#endif
// send remaining pending messages
while(qhead) QTick(this);
qelem_free((t_qelem *)qclk);
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
clock_free((object *)yclk);
#endif
@@ -181,16 +183,16 @@ flext_base::~flext_base()
if(inlets) {
for(int ix = 0; ix < incnt; ++ix)
if(inlets[ix]) {
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
pd_free(&inlets[ix]->obj.ob_pd);
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
freeobject((object *)inlets[ix]);
#endif
}
delete[] inlets;
}
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
// if(insigs) dsp_free(thisHdr());
if(insigs) dsp_freebox(thisHdr());
#endif
@@ -203,30 +205,13 @@ flext_base::~flext_base()
after the constructor has been processed. It creates the inlets and outlets.
\note You can override it in your own class, but be sure to call it,
\note otherwise no inlets/outlets will be created
- \remark Creation of inlets/outlets can't be done upon declaration, as MaxMSP needs creation
+ \remark Creation of inlets/outlets can't be done upon declaration, as Max/MSP needs creation
\remark in reverse.
*/
bool flext_base::Init()
{
-// if(!flext_obj::Init()) return false;
-
bool ok = true;
-/*
- if(inlets) {
- for(int ix = 0; ix < incnt; ++ix)
- if(inlets[ix]) {
-#ifdef PD
- pd_free(&inlets[ix]->obj.ob_pd);
-#elif defined(MAXMSP)
- freeobject(inlets[ix]);
-#endif
- }
- delete[] inlets;
- inlets = NULL;
- }
-*/
-
// ----------------------------------
// create inlets
// ----------------------------------
@@ -246,7 +231,7 @@ bool flext_base::Init()
for(i = 0; i < incnt; ++i) inlets[i] = NULL;
// type info is now in list array
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
{
int cnt = 0;
@@ -317,7 +302,7 @@ bool flext_base::Init()
incnt = cnt;
}
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
{
int ix,cnt;
// count leftmost signal inlets
@@ -370,6 +355,8 @@ bool flext_base::Init()
// dsp_setup(thisHdr(),insigs); // signal inlets
dsp_setupbox(thisHdr(),insigs); // signal inlets
}
+#else
+#error
#endif
delete[] list;
@@ -384,8 +371,8 @@ bool flext_base::Init()
outcnt = outsigs = 0;
-#ifdef MAXMSP
- // for MAXMSP the rightmost outlet has to be created first
+#if FLEXT_SYS == FLEXT_SYS_MAX
+ // for Max/MSP the rightmost outlet has to be created first
if(procattr)
outattr = (outlet *)newout_anything(&x_obj->obj);
#endif
@@ -405,10 +392,12 @@ bool flext_base::Init()
outlets = new outlet *[outcnt];
// type info is now in list array
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
for(int ix = 0; ix < outcnt; ++ix)
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
for(int ix = outcnt-1; ix >= 0; --ix)
+#else
+#error
#endif
{
switch(list[ix]) {
@@ -431,7 +420,7 @@ bool flext_base::Init()
case xlet::tp_any:
outlets[ix] = (outlet *)newout_anything(&x_obj->obj);
break;
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
default:
ERRINTERNAL();
ok = false;
@@ -443,7 +432,7 @@ bool flext_base::Init()
}
if(procattr) {
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
// attribute dump outlet is the last one
outattr = (outlet *)newout_anything(&x_obj->obj);
#endif
@@ -464,21 +453,23 @@ void flext_base::Setup(t_class *c)
{
add_method(c,cb_help,"help");
add_loadbang(c,cb_loadbang);
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
add_assist(c,cb_assist);
#endif
// proxy for extra inlets
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
add_anything(c,cb_px_anything); // for leftmost inlet
px_class = class_new(gensym("flext_base proxy"),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL);
add_anything(px_class,px_object::px_method); // for other inlets
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
add_bang(c,cb_px_bang);
add_method1(c,cb_px_int,"int",A_INT);
add_method1(c,cb_px_float,"float",A_FLOAT);
add_methodG(c,cb_px_anything,"list");
add_anything(c,cb_px_anything);
+#else
+#error
#endif
// setup non-leftmost ints and floats
@@ -496,7 +487,7 @@ void flext_base::Setup(t_class *c)
void flext_base::cb_help(t_class *c) { thisObject(c)->m_help(); }
void flext_base::cb_loadbang(t_class *c) { thisObject(c)->m_loadbang(); }
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
void flext_base::cb_assist(t_class *c,void * /*b*/,long msg,long arg,char *s) { thisObject(c)->m_assist(msg,arg,s); }
#endif
@@ -509,7 +500,7 @@ void flext_base::m_help()
/*! \brief All the message processing
The messages of all the inlets go here and are promoted to the registered callback functions
*/
-bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
+bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,const t_atom *argv)
{
static bool trap = false;
bool ret = false;
@@ -524,10 +515,10 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
LOG4("found method tag %s: inlet=%i, symbol=%s, argc=%i",m->tag->s_name,inlet,s->s_name,argc);
if(m->argc == 1 && m->args[0] == a_list) {
- ret = ((methfun_V)m->fun)(this,argc,argv);
+ ret = ((methfun_V)m->fun)(this,argc,const_cast<t_atom *>(argv));
}
else if(m->argc == 1 && m->args[0] == a_any) {
- ret = ((methfun_A)m->fun)(this,s,argc,argv);
+ ret = ((methfun_A)m->fun)(this,s,argc,const_cast<t_atom *>(argv));
}
else if(argc == m->argc) {
int ix;
@@ -558,7 +549,7 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
if(ok) LOG2("symbol arg %i = %s",ix,GetString(aargs[ix].st));
break;
}
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
case a_pointer: {
if(IsPointer(argv[ix])) aargs[ix].pt = GetPointer(argv[ix]);
else ok = false;
@@ -594,11 +585,11 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
// any
LOG4("found any method for %s: inlet=%i, symbol=%s, argc=%i",m->tag->s_name,inlet,s->s_name,argc);
- ret = ((methfun_A)m->fun)(this,s,argc,argv);
+ ret = ((methfun_A)m->fun)(this,s,argc,const_cast<t_atom *>(argv));
}
}
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
// If float message is not explicitly handled: try int handler instead
if(!ret && argc == 1 && s == sym_float && !trap) {
t_atom fl;
@@ -620,14 +611,14 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
// If float or int message is not explicitly handled: try list handler instead
if(!ret && !trap && argc == 1 && (s == sym_float
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
|| s == sym_int
#endif
)) {
t_atom list;
if(s == sym_float)
SetFloat(list,GetFloat(argv[0]));
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
else if(s == sym_int)
SetInt(list,GetInt(argv[0]));
#endif
@@ -655,7 +646,7 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
if(IsFloat(argv[i])) sym = sym_float;
else if(IsInt(argv[i])) sym = sym_int;
else if(IsSymbol(argv[i])) sym = sym_symbol;
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
else if(IsPointer(argv[i])) sym = sym_pointer; // can pointer atoms occur here?
#endif
if(sym) {
@@ -675,9 +666,9 @@ bool flext_base::m_methodmain(int inlet,const t_symbol *s,int argc,t_atom *argv)
return ret; // true if appropriate handler was found and called
}
-bool flext_base::m_method_(int inlet,const t_symbol *s,int argc,t_atom *argv)
+bool flext_base::m_method_(int inlet,const t_symbol *s,int argc,const t_atom *argv)
{
-//#ifdef _DEBUG
+//#ifdef FLEXT_DEBUG
post("%s: message unhandled - inlet:%i args:%i symbol:%s",thisName(),inlet,argc,s?s->s_name:"");
//#endif
return false;
@@ -763,12 +754,12 @@ void flext_base::AddMethod(int inlet,const char *tag,methfun fun,metharg tp,...)
va_start(marker,tp);
metharg a = tp;
for(int ix = 0; ix < argc; ++ix) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
if(a == a_list && ix > 0) {
ERRINTERNAL();
}
#endif
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
if(a == a_pointer && flext_base::compatibility) {
post("Pointer arguments are not allowed in compatibility mode");
}
diff --git a/externals/grill/flext/source/flext.h b/externals/grill/flext/source/flext.h
index 4933c91d..1e72daa5 100644
--- a/externals/grill/flext/source/flext.h
+++ b/externals/grill/flext/source/flext.h
@@ -30,14 +30,17 @@ WARRANTIES, see the file, "license.txt," in this distribution.
//! @}
+
+// determine System/OS/CPU
+#include "flprefix.h"
+
#ifdef FLEXT_THREADS
extern "C" {
-#include <pthread.h>
-#include <sched.h>
+ #include <pthread.h>
+ #include <sched.h>
}
#endif
-
// include all the flext interface definitions
#include "fldefs.h"
diff --git a/externals/grill/flext/source/flinternal.h b/externals/grill/flext/source/flinternal.h
index 6df1129c..09b8cbd1 100644
--- a/externals/grill/flext/source/flinternal.h
+++ b/externals/grill/flext/source/flinternal.h
@@ -12,7 +12,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
\brief Definitions for internal flext usage
\internal
- Here, a few shortcuts for common MaxMSP or PD library calls and type definitions
+ Here, a few shortcuts for common Max/MSP or PD library calls and type definitions
are declared
*/
@@ -22,7 +22,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flstdc.h"
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
#define object_new(clss) pd_new(clss)
#define object_free(obj) pd_free(&(obj).ob_pd)
@@ -62,7 +62,8 @@ typedef t_perfroutine t_dspmethod;
#define qelem_set clock_set
#define qelem_unset clock_unset
-#elif defined(MAXMSP)
+
+#elif FLEXT_SYS == FLEXT_SYS_MAX
/*
typedef void _inlet;
diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp
index 3328ac9b..2f4e8e59 100755
--- a/externals/grill/flext/source/fllib.cpp
+++ b/externals/grill/flext/source/fllib.cpp
@@ -19,11 +19,16 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define ALIASDEL ','
#define ALIASSLASHES ":/\\"
-#ifdef MAXMSP
+#if FLEXT_OS == FLEXT_OS_MACOS
#define ALIASSLASH ':'
-#elif defined(NT)
- #define ALIASSLASH '/'
+#elif FLEXT_OS == FLEXT_OS_WIN
+ #if FLEXT_SYS == FLEXT_SYS_PD
+ #define ALIASSLASH '/'
+ #else
+ #error "Undefined"
+ #endif
#else
+ // default to "/"
#define ALIASSLASH '/'
#endif
@@ -146,16 +151,16 @@ libname *libname::find(const t_symbol *s) {
return l;
}
-// for MAXMSP, the library is represented by a special object (class) registered at startup
+// for Max/MSP, the library is represented by a special object (class) registered at startup
// all objects in the library are clones of that library object - they share the same class
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
static t_class *lib_class = NULL;
static const t_symbol *lib_name = NULL;
#endif
void flext_obj::lib_init(const char *name,void setupfun(),bool attr)
{
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
lib_name = MakeSymbol(name);
::setup(
(t_messlist **)&lib_class,
@@ -171,7 +176,7 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha
// get first possible object name
const t_symbol *nsym = MakeSymbol(extract(names));
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
if(dsp) chktilde(GetString(nsym));
#endif
@@ -179,24 +184,26 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha
// set dynamic class pointer
t_class **cl =
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
lib?&lib_class:
#endif
new t_class *;
// register object class
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
*cl = ::class_new(
(t_symbol *)nsym,
(t_newmethod)obj_new,(t_method)obj_free,
sizeof(flext_hdr),0,A_GIMME,A_NULL);
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
if(!lib) {
::setup(
(t_messlist **)cl,
(t_newmethod)obj_new,(t_method)obj_free,
sizeof(flext_hdr),NULL,A_GIMME,A_NULL);
}
+#else
+#error
#endif
// make new dynamic object
@@ -241,15 +248,17 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha
libname *l = new libname(MakeSymbol(c),lo);
libname::add(l);
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
if(ix > 0)
// in PD the first name is already registered with class creation
::class_addcreator((t_newmethod)obj_new,(t_symbol *)l->name,A_GIMME,A_NULL);
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
if(ix > 0 || lib)
- // in MaxMSP the first alias gets its name from the name of the object file,
+ // in Max/MSP the first alias gets its name from the name of the object file,
// unless it is a library (then the name can be different)
::alias(const_cast<char *>(c));
+#else
+#error
#endif
}
@@ -275,14 +284,14 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
}
if(lo->argc >= 0) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
if(lo->argc > FLEXT_MAXNEWARGS) { ERRINTERNAL(); ok = false; }
#endif
if(argc == lo->argc) {
for(int i = 0; /*ok &&*/ i < lo->argc; ++i) {
switch(lo->argv[i]) {
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
case A_INT:
if(flext::IsInt(argv[i])) args[i] = argv[i];
else if(flext::IsFloat(argv[i])) flext::SetInt(args[i],(int)flext::GetFloat(argv[i]));
@@ -311,10 +320,12 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
}
if(ok) {
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
obj = (flext_hdr *)::pd_new(lo->clss);
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
obj = (flext_hdr *)::newobject(lo->clss);
+#else
+#error
#endif
flext_obj::m_holder = obj;
flext_obj::m_holdname = l->name;
@@ -331,7 +342,7 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
flext_obj::m_holdname = NULL;
flext_obj::m_holdattr = false;
- bool ok = obj->data &&
+ ok = obj->data &&
// check constructor exit flag
obj->data->InitOk();
@@ -354,10 +365,10 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv)
}
}
}
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
else
-#ifdef MAXMSP
- // in MaxMSP an object with the name of the library exists, even if not explicitely declared!
+#if FLEXT_SYS == FLEXT_SYS_MAX
+ // in Max/MSP an object with the name of the library exists, even if not explicitely declared!
if(s != lib_name)
#endif
error("Class %s not found in library!",s->s_name);
@@ -378,10 +389,10 @@ void flext_obj::obj_free(flext_hdr *hdr)
// now call object destructor and deallocate
l->obj->freefun(hdr);
}
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
else
-#ifdef MAXMSP
- // in MaxMSP an object with the name of the library exists, even if not explicitely declared!
+#if FLEXT_SYS == FLEXT_SYS_MAX
+ // in Max/MSP an object with the name of the library exists, even if not explicitely declared!
if(name != lib_name)
#endif
error("Class %s not found in library!",name);
diff --git a/externals/grill/flext/source/flmspbuffer.h b/externals/grill/flext/source/flmspbuffer.h
index 4a8ffe69..9a18499d 100755
--- a/externals/grill/flext/source/flmspbuffer.h
+++ b/externals/grill/flext/source/flmspbuffer.h
@@ -16,7 +16,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
The latter is not easily found so i included the original file buffer.h with flext
*/
-#if defined(MAXMSP) && !defined(__FLEXT_MSPBUFFER_H)
+#if (FLEXT_SYS == FLEXT_SYS_MAX) && !defined(__FLEXT_MSPBUFFER_H)
#define __FLEXT_MSPBUFFER_H
enum {
diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp
index db225bd5..16a6ea29 100644
--- a/externals/grill/flext/source/flout.cpp
+++ b/externals/grill/flext/source/flout.cpp
@@ -16,7 +16,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flinternal.h"
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
#define CRITON() short state = lockout_set(1)
#define CRITOFF() lockout_set(state)
#else
@@ -92,7 +92,7 @@ void flext_base::qmsg::Add(qmsg *o)
}
*/
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
void flext_base::YTick(flext_base *th)
{
clock_delay(th->yclk,0);
@@ -105,20 +105,21 @@ void flext_base::YTick(flext_base *th)
void flext_base::QTick(flext_base *th)
{
-#ifdef DEBUG
+#ifdef FLEXT_THREADS
+
+#ifdef FLEXT_DEBUG
if(!th->IsSystemThread()) {
error("flext - Queue tick called by wrong thread!");
return;
}
#endif
-#ifdef FLEXT_THREADS
th->qmutex.Lock();
#endif
while(th->qhead) {
qmsg *m = th->qhead;
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
short state = lockout_set(1);
#endif
@@ -129,12 +130,12 @@ void flext_base::QTick(flext_base *th)
case qmsg::tp_sym: th->ToOutSymbol(m->out,m->_sym); break;
case qmsg::tp_list: th->ToOutList(m->out,m->_list.argc,m->_list.argv); break;
case qmsg::tp_any: th->ToOutAnything(m->out,m->_any.s,m->_any.argc,m->_any.argv); break;
-#ifdef DEBUG
+#ifdef FLEXT_DEBUG
default: ERRINTERNAL();
#endif
}
-#ifdef MAXMSP
+#if FLEXT_SYS == FLEXT_SYS_MAX
lockout_set(state);
#endif
@@ -156,15 +157,16 @@ void flext_base::Queue(qmsg *m)
if(qtail) qtail->nxt = m;
else qhead = m;
qtail = m;
-#ifdef FLEXT_THREADS
- qmutex.Unlock();
-#endif
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
clock_delay(qclk,0);
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
clock_delay(yclk,0);
#else
- #error "To implement!"
+#error
+#endif
+
+#ifdef FLEXT_THREADS
+ qmutex.Unlock();
#endif
}
diff --git a/externals/grill/flext/source/flprefix.h b/externals/grill/flext/source/flprefix.h
index 973a6966..34debe69 100755
--- a/externals/grill/flext/source/flprefix.h
+++ b/externals/grill/flext/source/flprefix.h
@@ -23,32 +23,36 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// definitions for FLEXT_OS
#define FLEXT_OS_UNKNOWN 0
#define FLEXT_OS_WIN 1
-#define FLEXT_OS_MACOS9 2
-#define FLEXT_OS_MACOSX 3
-#define FLEXT_OS_LINUX 4
-#define FLEXT_OS_IRIX 5
+#define FLEXT_OS_MACOS 2
+#define FLEXT_OS_LINUX 3
+#define FLEXT_OS_IRIX 4
// definitions for FLEXT_CPU
#define FLEXT_CPU_UNKNOWN 0
#define FLEXT_CPU_INTEL 1
#define FLEXT_CPU_PPC 2
#define FLEXT_CPU_MIPS 3
+#define FLEXT_CPU_ALPHA 4
+
// Old definitions
#if defined(MAXMSP)
#define FLEXT_SYS FLEXT_SYS_MAX
- #undef MAXMSP
+// #undef MAXMSP
#elif defined(PD)
#define FLEXT_SYS FLEXT_SYS_PD
- #undef PD
- #undef NT
+// #undef PD
+// #undef NT
+#endif
+
+#if defined(_DEBUG)
+ #define FLEXT_DEBUG
#endif
// Definition of supported real-time systems
#if FLEXT_SYS == FLEXT_SYS_MAX
#elif FLEXT_SYS == FLEXT_SYS_PD
- #define PD
#else
#error "System must be defined by either FLEXT_SYS_MAX or FLEXT_SYS_PD"
#endif
@@ -57,47 +61,156 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#if defined(_MSC_VER)
// Microsoft C++
+ #ifndef FLEXT_CPU
+ #if defined(_M_IX86)
+ #define FLEXT_CPU FLEXT_CPU_INTEL
+ #elif defined(_M_PPC)
+ #define FLEXT_CPU FLEXT_CPU_PPC
+ #elif defined(_M_MRX000)
+ #define FLEXT_CPU FLEXT_CPU_MIPS
+ #elif defined(_M_ALPHA)
+ #define FLEXT_CPU FLEXT_CPU_ALPHA
+ #else
+ #define FLEXT_CPU FLEXT_CPU_UNKNOWN
+ #endif
+ #endif
+
+ #ifndef FLEXT_OS
+ #if defined(_WIN32)
+ #define FLEXT_OS FLEXT_OS_WIN
+ #else
+ #define FLEXT_OS FLEXT_OS_UNKNOWN
+ #endif
+ #endif
+
+#elif defined(__BORLANDC__)
+ // Borland C++
+
+ #ifndef FLEXT_CPU
+ #define FLEXT_CPU FLEXT_CPU_INTEL
+ #endif
+ #ifndef FLEXT_OS
+ #define FLEXT_OS FLEXT_OS_WIN
+ #endif
+
#elif defined(__MWERKS__)
// Metrowerks CodeWarrior
- #if defined(__INTEL__)
- #define FLEXT_CPU FLEXT_CPU_INTEL
- #elif defined(__POWERPC__)
- #define FLEXT_CPU FLEXT_CPU_PPC
- #elif defined(__MIPS__)
- #define FLEXT_CPU FLEXT_CPU_MIPS
- #elif defined(__POWERPC__)
- #define FLEXT_CPU FLEXT_CPU_UNKNOWN
+ #ifndef FLEXT_CPU
+ #if defined(__INTEL__)
+ #define FLEXT_CPU FLEXT_CPU_INTEL
+ #elif defined(__POWERPC__)
+ #define FLEXT_CPU FLEXT_CPU_PPC
+ #elif defined(__MIPS__)
+ #define FLEXT_CPU FLEXT_CPU_MIPS
+ #else
+ #define FLEXT_CPU FLEXT_CPU_UNKNOWN
+ #endif
+ #endif
+
+ #ifndef FLEXT_OS
+ #if defined(macintosh)
+ #define FLEXT_OS FLEXT_OS_MACOS
+ #elif defined(__INTEL__)
+ // assume Windows
+ #define FLEXT_OS FLEXT_OS_WIN
+ #else
+ #define FLEXT_OS FLEXT_OS_UNKNOWN
+ #endif
#endif
#elif defined(__GNUG__)
// GNU C++
+ #ifndef FLEXT_CPU
+ #if defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__)
+ #define FLEXT_CPU FLEXT_CPU_INTEL
+ #elif defined(__POWERPC__)
+ #define FLEXT_CPU FLEXT_CPU_PPC
+ #elif defined(__MIPS__)
+ #define FLEXT_CPU FLEXT_CPU_MIPS
+ #else
+ #define FLEXT_CPU FLEXT_CPU_UNKNOWN
+ #endif
+ #endif
+
+ #ifndef FLEXT_OS
+ #if defined(linux) || defined(__linux__)
+ #define FLEXT_OS FLEXT_OS_LINUX
+ #elif defined(__CYGWIN__) || defined(__CYGWIN32__)
+ #define FLEXT_OS FLEXT_OS_WIN
+ #elif defined(__APPLE__) && defined(__MACH__)
+ #define FLEXT_OS FLEXT_OS_MACOS
+ // how about IRIX??
+ #else
+ #define FLEXT_OS FLEXT_OS_UNKNOWN
+ #endif
+ #endif
+
+#elif defined(__MRC__) && defined(MPW_CPLUS)
+ // Apple MPW MrCpp
+ #if __MRC__ < 0x500
+ #error Apple MPW MrCpp v.5.0.0 or better compiler required
+ #endif
+
+ #ifndef FLEXT_CPU
+ #if defined(__POWERPC__)
+ #define FLEXT_CPU FLEXT_CPU_PPC
+ #else
+ #define FLEXT_CPU FLEXT_CPU_UNKNOWN
+ #endif
+ #endif
+
+ #ifndef FLEXT_OS
+ #if defined(macintosh)
+ #define FLEXT_OS FLEXT_OS_MACOS
+ #else
+ #define FLEXT_OS FLEXT_OS_UNKNOWN
+ #endif
+ #endif
+
#endif
#if FLEXT_OS == FLEXT_OS_WIN
+// #pragma message("Compiling for Windows")
+
#if FLEXT_SYS == FLEXT_SYS_MAX
- #define WIN_VERSION 1
+// #define WIN_VERSION 1
#elif FLEXT_SYS == FLEXT_SYS_PD
- #define NT
+// #define PD
+// #define NT
#endif
#elif FLEXT_OS == FLEXT_OS_LINUX
- #if FLEXT_SYS == FLEXT_SYS_MAX
+// #pragma message("Compiling for Linux")
+
+ #if FLEXT_SYS == FLEXT_SYS_PD
+// #define PD
+ #else
#error "Flext SYS/OS combination unknown"
#endif
#elif FLEXT_OS == FLEXT_OS_IRIX
- #if FLEXT_SYS == FLEXT_SYS_MAX
+// #pragma message("Compiling for Irix")
+
+ #if FLEXT_SYS == FLEXT_SYS_PD
+// #define PD
+ #else
#error "Flext SYS/OS combination unknown"
#endif
-#elif FLEXT_OS == FLEXT_OS_MACOS9
+#elif FLEXT_OS == FLEXT_OS_MACOS
+// #pragma message("Compiling for MacOS")
+
#if FLEXT_SYS == FLEXT_SYS_PD
- #error "Flext SYS/OS combination unknown"
+// #define PD
#endif
-#elif FLEXT_OS == FLEXT_OS_MACOSX
#else
#error "Operating system could not be determined"
#endif
+#if FLEXT_SYS == FLEXT_SYS_MAX
+// #pragma message("Compiling for Max/MSP")
+#elif FLEXT_SYS == FLEXT_SYS_PD
+// #pragma message("Compiling for PD")
+#endif
#endif
diff --git a/externals/grill/flext/source/flsndobj.cpp b/externals/grill/flext/source/flsndobj.cpp
index 1965b86b..e377b4a7 100644
--- a/externals/grill/flext/source/flsndobj.cpp
+++ b/externals/grill/flext/source/flsndobj.cpp
@@ -1,6 +1,6 @@
+#include "flext.h"
#include "flsndobj.h"
-//namespace flext {
flext_sndobj::flext_sndobj():
inobjs(0),outobjs(0),
@@ -103,5 +103,4 @@ short flext_sndobj::Outlet::Write()
else return 0;
}
-//} // namespace flext
diff --git a/externals/grill/flext/source/flsndobj.h b/externals/grill/flext/source/flsndobj.h
index f68054ed..30099404 100644
--- a/externals/grill/flext/source/flsndobj.h
+++ b/externals/grill/flext/source/flsndobj.h
@@ -10,9 +10,13 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define FLEXT_SNDOBJ
#include "flext.h"
+
+#ifndef FLEXT_THREADS
+#define NOPTHREAD
+#endif
#include <SndObj/AudioDefs.h>
+#undef NOPTHREAD
-//namespace flext {
class flext_sndobj:
public flext_dsp
@@ -78,6 +82,4 @@ private:
int blsz;
};
-//} // namespace flext
-
#endif
diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h
index 4031dda1..bf0ddd23 100644
--- a/externals/grill/flext/source/flstdc.h
+++ b/externals/grill/flext/source/flstdc.h
@@ -9,7 +9,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
/*! \file flstdc.h
- \brief Definitions to unite MaxMSP and PD notions
+ \brief Definitions to unite Max/MSP and PD notions
This file contains a few definitions to unite a few of the notions that
once drifted apart in Max and PD. It is not elegant but helps.
@@ -18,49 +18,36 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef __FLEXT_STDC_H
#define __FLEXT_STDC_H
-// Be sure that one target is defined
-#if !defined(PD) && !defined(MAXMSP)
-#error Either PD or MAXMSP must be defined
-#endif
-
-// Do some compiler checking
-#if defined(__MRC__) && __MRC__ < 0x500
-#error Apple MPW MrCpp v.5.0.0 or better compiler required
-#endif
-
-
// PD stuff
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
/* PD definitions start here */
#ifdef _MSC_VER
-#pragma warning (push)
-#pragma warning (disable:4091)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
+ #pragma warning (push)
+ #pragma warning (disable:4091 4005)
#endif
-// Include the relevant PD header files
-#ifdef _DEBUG
-#include <m_imp.h> // for easier debugging
-#else
-#include <m_pd.h>
+#if FLEXT_OS == FLEXT_OS_WIN
+#define NT
#endif
-#ifdef __cplusplus
+extern "C" {
+ // Include the relevant PD header files
+ #ifdef FLEXT_DEBUG
+ #include <m_imp.h> // for easier debugging
+ #else
+ #include <m_pd.h>
+ #endif
}
-#endif
#ifdef _MSC_VER
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
#ifdef cabs
-#undef cabs // this is defined in m_pd.h (clashes with math.h)
+#undef cabs // this is defined in m_pd.h (clashes with math.h in MacOSX)
#endif
typedef t_object t_sigobj;
@@ -77,37 +64,36 @@ typedef t_clock t_qelem;
#define A_FLINT A_FLOAT
#define A_DEFFLINT A_DEFFLOAT
-// MAX stuff
-#elif defined(MAXMSP)
-/* MaxMSP definitions start here */
+#elif FLEXT_SYS == FLEXT_SYS_MAX
-#ifndef __MRC__
-#define powerc
-#endif
-#define __MOTO__ 0
+/* Max/MSP definitions start here */
-// Include the relevant MaxMSP header files
+// Include the relevant Max/MSP header files
-#include <MacTypes.h>
+#if FLEXT_OS == FLEXT_OS_MACOS
+ #ifndef __MRC__
+ #define powerc
+ #endif
+ #define __MOTO__ 0
+
+ #include <MacTypes.h>
+#elif FLEXT_OS == FLEXT_OS_WIN
+ #define WIN_VERSION 1
+#endif
extern "C"
{
-
-#include "ext.h"
-/*
-#include "ext_prefix.h"
-#include "ext_mess.h"
-#include "ext_proto.h"
-*/
-//#include "ext_strings.h" // clashes with MPW
-#include "ext_user.h"
-#include "z_dsp.h"
-//#include "z_atom.h"
+ #include "ext.h"
+ #include "ext_user.h"
+ #include "z_dsp.h"
}
-typedef t_pxbox t_sigobj; // that's the all-in-one object type of MaxMSP (not very memory-efficent, i guess)
+#undef WIN_VERSION
+
+
+typedef t_pxbox t_sigobj; // that's the all-in-one object type of Max/MSP (not very memory-efficent, i guess)
typedef t_patcher t_canvas;
typedef t_int t_flint;
@@ -128,7 +114,6 @@ typedef void t_binbuf;
#define clock_free(tick) freeobject((object *)tick)
#define A_NULL A_NOTHING
-//#define A_FLINT A_INT
#define A_DEFFLINT A_DEFLONG
#ifndef A_INT
@@ -165,7 +150,7 @@ typedef void t_binbuf;
#endif
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
#define ASSERT(b) ((void)(!(b)?(error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__),0):0))
#else
#define ASSERT(b) ((void)0)
@@ -176,15 +161,10 @@ typedef void t_binbuf;
/* Set the right calling convention (and exporting) for the OS */
-#if defined(NT)
-#define FLEXT_EXT __declspec(dllexport)
+#ifdef _MSC_VER
+ #define FLEXT_EXT __declspec(dllexport)
#else // other OS's
-#define FLEXT_EXT
+ #define FLEXT_EXT
#endif
#endif
-
-
-
-
-
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index 854fe871..85ebae79 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -12,7 +12,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
\brief flext support functions and classes.
*/
-#include "flsupport.h"
+#include "flext.h"
const t_symbol *flext::sym_float = NULL;
const t_symbol *flext::sym_symbol = NULL;
@@ -22,13 +22,13 @@ const t_symbol *flext::sym_anything = NULL;
const t_symbol *flext::sym_pointer = NULL;
const t_symbol *flext::sym_int = NULL;
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
const t_symbol *flext::sym_signal = NULL;
#endif
void flext::Setup()
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
sym_anything = &s_anything;
sym_pointer = &s_pointer;
sym_float = &s_float;
@@ -36,19 +36,21 @@ void flext::Setup()
sym_bang = &s_bang;
sym_list = &s_list;
sym_signal = &s_signal;
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
sym_int = gensym("int");
sym_float = gensym("float");
sym_symbol = gensym("symbol");
sym_bang = gensym("bang");
sym_list = gensym("list");
sym_anything = gensym("anything");
+#else
+#error
#endif
}
void flext::GetAString(const t_atom &a,char *buf,int szbuf)
{
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
atom_string(const_cast<t_atom *>(&a),buf,szbuf);
#else
if(IsSymbol(a)) sprintf(buf,GetString(a));
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index 022aaae9..08036ff5 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -17,10 +17,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flstdc.h"
-#ifdef FLEXT_THREADS
-#include <pthread.h>
-#endif
-
class FLEXT_EXT flext {
/*! \defgroup FLEXT_SUPPORT Flext support class
@@ -90,7 +86,7 @@ public:
const t_symbol *sym;
t_sample *data;
int chns,frames;
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
t_garray *arr;
float interval;
bool isdirty,ticking;
@@ -155,8 +151,7 @@ public:
*/
static const t_symbol *sym_pointer;
-#ifdef PD
-
+#if FLEXT_SYS == FLEXT_SYS_PD
/*! \brief Symbol constant for "signal"
\note PD only
*/
@@ -195,7 +190,7 @@ public:
//! Check whether the atom is a symbol
static bool IsSymbol(const t_atom &a) { return a.a_type == A_SYMBOL; }
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
//! Access the symbol value (without type check)
static t_symbol *GetSymbol(const t_atom &a) { return a.a_w.w_symbol; }
//! Set the atom to represent a symbol
@@ -228,7 +223,7 @@ public:
//! Check for an boolean and get its value
static bool GetABool(const t_atom &a) { return GetAInt(a) != 0; }
-#ifdef PD
+#if FLEXT_SYS == FLEXT_SYS_PD
//! Check for a float and get its value
static float GetAFloat(const t_atom &a) { return IsFloat(a)?GetFloat(a):0; }
@@ -252,7 +247,7 @@ public:
//! Set the atom to represent a pointer
static void SetPointer(t_atom &a,void *p) { a.a_type = A_POINTER; a.a_w.w_gpointer = (t_gpointer *)p; }
-#elif defined(MAXMSP)
+#elif FLEXT_SYS == FLEXT_SYS_MAX
//! Check for a float and get its value
static float GetAFloat(const t_atom &a) { return IsFloat(a)?GetFloat(a):(IsInt(a)?GetInt(a):0); }
@@ -273,6 +268,8 @@ public:
static void *GetAPointer(const t_atom &a) { return IsInt(a)?(void *)GetInt(a):NULL; }
//! Set the atom to represent a pointer
static void SetPointer(t_atom &a,void *p) { SetInt(a,(int)p); }
+#else
+#error
#endif
// --- atom list stuff -------------------------------------------
diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp
index 2a3ad3df..f23eb38f 100644
--- a/externals/grill/flext/source/flthr.cpp
+++ b/externals/grill/flext/source/flthr.cpp
@@ -12,25 +12,22 @@ WARRANTIES, see the file, "license.txt," in this distribution.
\brief Implementation of the flext thread functionality.
*/
-#ifdef FLEXT_THREADS
-
#include "flext.h"
#include "flinternal.h"
-#ifdef MAXMSP
-#define SCHEDTICK 1
-#endif
+#ifdef FLEXT_THREADS
-#ifdef NT
+#if FLEXT_OS == FLEXT_OS_WIN
#include <windows.h>
#endif
+
#include <errno.h>
bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *methname)
{
static bool init = false;
static pthread_attr_t attr;
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
if(!p) {
ERRINTERNAL();
return false;
@@ -55,8 +52,6 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me
pthread_setschedparam(id,policy,&parm);
}
-// post("Create thread");
-
pthread_t thrid;
int ret = pthread_create (&thrid,&attr,(void *(*)(void *))meth,p);
@@ -65,7 +60,7 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me
pthread_setschedparam(id,policy,&parm);
if(ret) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
error((char *)(ret == EAGAIN?"%s - Unsufficient resources to launch thread!":"%s - Could not launch method!"),methname);
#endif
error((char *)("%s - Could not launch method!"),methname);
@@ -73,14 +68,8 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me
delete p;
return false;
}
- else {
-#ifdef MAXMSP
- sched_yield();
-#endif
-// post("Create thread: OK");
-
+ else
return true;
- }
}
bool flext_base::PushThread()
@@ -96,7 +85,7 @@ bool flext_base::PushThread()
thrtail = nt;
{
-#ifdef NT
+#if FLEXT_OS == FLEXT_OS_WIN
// set detached thread to lower priority class
DWORD err;
HANDLE thr = GetCurrentThread();
@@ -128,9 +117,6 @@ bool flext_base::PushThread()
tlmutex.Unlock();
-#ifdef MAXMSP
- clock_delay(yclk,0);
-#endif
return true;
}
@@ -157,7 +143,7 @@ void flext_base::PopThread()
delete ti;
}
else {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
post("%s - INTERNAL ERROR: Thread not found!",thisName());
#endif
}
@@ -175,7 +161,7 @@ bool flext_base::ChangePriority(int dp,thrid_t id)
sched_param parm;
int policy;
if(pthread_getschedparam(id,&policy,&parm) < 0) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
post("flext - failed to get parms");
#endif
return false;
@@ -183,7 +169,7 @@ bool flext_base::ChangePriority(int dp,thrid_t id)
else {
parm.sched_priority += dp;
if(pthread_setschedparam(id,policy,&parm) < 0) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
post("flext - failed to change priority");
#endif
return false;
@@ -198,7 +184,7 @@ int flext_base::GetPriority(thrid_t id)
sched_param parm;
int policy;
if(pthread_getschedparam(id,&policy,&parm) < 0) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
post("flext - failed to get parms");
#endif
return -1;
@@ -212,7 +198,7 @@ bool flext_base::SetPriority(int p,thrid_t id)
sched_param parm;
int policy;
if(pthread_getschedparam(id,&policy,&parm) < 0) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
post("flext - failed to get parms");
#endif
return false;
@@ -220,7 +206,7 @@ bool flext_base::SetPriority(int p,thrid_t id)
else {
parm.sched_priority = p;
if(pthread_setschedparam(id,policy,&parm) < 0) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
post("flext - failed to change priority");
#endif
return false;
diff --git a/externals/grill/flext/source/flutil.cpp b/externals/grill/flext/source/flutil.cpp
index 5307b820..2a65aaf6 100644
--- a/externals/grill/flext/source/flutil.cpp
+++ b/externals/grill/flext/source/flutil.cpp
@@ -15,34 +15,18 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flext.h"
#include <string.h>
-#ifdef NT
+#if FLEXT_OS == FLEXT_OS_WIN
#include <windows.h>
-#endif
-
-#ifdef MAXMSP
+#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || defined(__GNUC__)
+#include <unistd.h>
+#elif FLEXT_OS == FLEXT_OS_MACOS
#include <Timer.h>
#include <Threads.h>
#endif
-#ifdef unix
-#include <unistd.h>
-#endif
-
-t_atom *flext::CopyList(int argc,const t_atom *argv)
-{
- int i;
- t_atom *dst = new t_atom[argc];
- for(i = 0; i < argc; ++i) CopyAtom(dst+i,argv+i);
- return dst;
-}
-
void flext::CopyMem(void *dst,const void *src,int bytes)
{
-#ifdef macintosh
- BlockMoveData(src,dst,bytes);
-#else
memcpy(dst,src,bytes);
-#endif
}
void flext::ZeroMem(void *dst,int bytes)
@@ -52,9 +36,11 @@ void flext::ZeroMem(void *dst,int bytes)
void flext::Sleep(float s)
{
-#ifdef NT
+#if FLEXT_OS == FLEXT_OS_WIN
::Sleep((long)(s*1000));
-#elif defined(MAXMSP)
+#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || defined(__GNUC__)
+ usleep((long)(s*1000000));
+#elif FLEXT_OS == FLEXT_OS_MACOS
UnsignedWide tick;
Microseconds(&tick);
double target = tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo+s*1.e6;
@@ -64,6 +50,6 @@ void flext::Sleep(float s)
YieldToAnyThread(); // should we really yield?
}
#else
- usleep((long)(s*1000000));
+#error
#endif
}
diff --git a/externals/grill/flext/source/flxlet.cpp b/externals/grill/flext/source/flxlet.cpp
index 881769da..c360daf3 100755
--- a/externals/grill/flext/source/flxlet.cpp
+++ b/externals/grill/flext/source/flxlet.cpp
@@ -17,7 +17,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <string.h>
#include <stdarg.h>
-//namespace flext {
flext_base::xlet::xlet(type t,const char *d):
tp(t),nxt(NULL)
@@ -60,7 +59,7 @@ unsigned long flext_base::XletCode(xlet::type tp,...)
int cnt = 0;
xlet::type *args = NULL,arg = tp;
for(; arg; ++cnt) {
-#ifdef _DEBUG
+#ifdef FLEXT_DEBUG
if(cnt > 9) {
error("%s - Too many in/outlets defined - truncated to 9",thisName());
break;
@@ -85,4 +84,3 @@ void flext_base::AddOutlets(unsigned long code)
for(; code; code /= 10) AddOutlet((xlet::type)(code%10));
}
-//} // namespace flext