aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext/source')
-rwxr-xr-xexternals/grill/flext/source/flmsg.cpp2
-rwxr-xr-xexternals/grill/flext/source/flprefix.h12
-rw-r--r--externals/grill/flext/source/flsupport.cpp26
-rw-r--r--externals/grill/flext/source/flsupport.h90
4 files changed, 117 insertions, 13 deletions
diff --git a/externals/grill/flext/source/flmsg.cpp b/externals/grill/flext/source/flmsg.cpp
index 3041ea0b..95f9790a 100755
--- a/externals/grill/flext/source/flmsg.cpp
+++ b/externals/grill/flext/source/flmsg.cpp
@@ -47,7 +47,7 @@ bool flext_base::CallMeth(const methitem &m,int argc,const t_atom *argv)
}
#if FLEXT_SYS == FLEXT_SYS_PD
case a_pointer: {
- if(IsPointer(argv[ix])) aargs[ix].pt = GetPointer(argv[ix]);
+ if(IsPointer(argv[ix])) aargs[ix].pt = (t_gpointer *)GetPointer(argv[ix]);
else ok = false;
break;
}
diff --git a/externals/grill/flext/source/flprefix.h b/externals/grill/flext/source/flprefix.h
index fc9846a9..c6e0a267 100755
--- a/externals/grill/flext/source/flprefix.h
+++ b/externals/grill/flext/source/flprefix.h
@@ -36,6 +36,15 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define FLEXT_SYS FLEXT_SYS_PD
#endif
+#ifndef FLEXT_SYS_JMAX
+ #define FLEXT_SYS_JMAX 3
+#else
+ // already defined
+ #undef FLEXT_SYS_JMAX
+ #define FLEXT_SYS_JMAX 3
+ #define FLEXT_SYS FLEXT_SYS_JMAX
+#endif
+
// --- definitions for FLEXT_OS ----------------------
#define FLEXT_OS_UNKNOWN 0
#define FLEXT_OS_WIN 1
@@ -78,8 +87,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// Definition of supported real-time systems
#if FLEXT_SYS == FLEXT_SYS_MAX
#elif FLEXT_SYS == FLEXT_SYS_PD
+#elif FLEXT_SYS == FLEXT_SYS_JMAX
#else
- #error "System must be defined by either FLEXT_SYS_MAX or FLEXT_SYS_PD"
+ #error "System must be defined by either FLEXT_SYS_MAX, FLEXT_SYS_PD or FLEXT_SYS_JMAX"
#endif
// Definition of OS/CPU
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index ec3b5ef7..f8717d02 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -57,7 +57,11 @@ void flext::Setup()
void *flext::operator new(size_t bytes)
{
bytes += sizeof(size_t);
- char *blk = (char *)getbytes(bytes);
+#if FLEXT_SYS == FLEXT_SYS_JMAX
+ char *blk = (char *)::fts_malloc(bytes);
+#else
+ char *blk = (char *)::getbytes(bytes);
+#endif
*(size_t *)blk = bytes;
return blk+sizeof(size_t);
}
@@ -66,7 +70,11 @@ void flext::operator delete(void *blk)
{
char *ori = (char *)blk-sizeof(size_t);
size_t bytes = *(size_t *)ori;
- freebytes(ori,bytes);
+#if FLEXT_SYS == FLEXT_SYS_JMAX
+ ::fts_free(ori);
+#else
+ ::freebytes(ori,bytes);
+#endif
}
void *flext::NewAligned(size_t bytes,int bitalign)
@@ -74,7 +82,11 @@ void *flext::NewAligned(size_t bytes,int bitalign)
const size_t ovh = sizeof(size_t)+sizeof(char *);
const unsigned long alignovh = bitalign/8-1;
bytes += ovh+alignovh;
- char *blk = (char *)getbytes(bytes);
+#if FLEXT_SYS == FLEXT_SYS_JMAX
+ char *blk = (char *)::fts_malloc(bytes);
+#else
+ char *blk = (char *)::getbytes(bytes);
+#endif
char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh);
*(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk;
*(size_t *)(ablk-sizeof(size_t)) = bytes;
@@ -85,11 +97,17 @@ void flext::FreeAligned(void *blk)
{
char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *));
size_t bytes = *(size_t *)((char *)blk-sizeof(size_t));
- freebytes(ori,bytes);
+
+#if FLEXT_SYS == FLEXT_SYS_JMAX
+ ::fts_free(ori);
+#else
+ ::freebytes(ori,bytes);
+#endif
}
// ------------------------------------------
+//! \todo there is probably also a shortcut for Max and jMax
void flext::GetAString(const t_atom &a,char *buf,int szbuf)
{
#if FLEXT_SYS == FLEXT_SYS_PD
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index 0c0c62c9..fd3992f8 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -33,6 +33,18 @@ class FLEXT_SHARE flext {
*/
public:
+// --- types -------------------------------------------------------
+
+#if FLEXT_SYS == FLEXT_SYS_JMAX
+ typedef fts_symbol_t t_symbol;
+ typedef fts_atom_t t_atom;
+ typedef fts_class_t t_class;
+#else
+// typedef t_symbol t_symbol;
+// typedef t_atom t_atom;
+// typedef t_class t_class;
+#endif
+
// --- memory -------------------------------------------------------
/*! \defgroup FLEXT_S_MEMORY Memory allocation functions
@@ -202,21 +214,39 @@ public:
static const t_symbol *sym_signal;
#endif
+#if FLEXT_SYS == FLEXT_SYS_JMAX
//! Make a symbol from a string
- static const t_symbol *MakeSymbol(const char *s) { return gensym(const_cast<char *>(s)); }
-
+ static const t_symbol *MakeSymbol(const char *s) { return ::fts_new_symbol(s); }
+ //! Get symbol string
+ static const char *GetString(const t_symbol *s); // ** TODO **
+#else
+ //! Make a symbol from a string
+ static const t_symbol *MakeSymbol(const char *s) { return ::gensym(const_cast<char *>(s)); }
//! Get symbol string
static const char *GetString(const t_symbol *s) { return s->s_name; }
+#endif
//! Check for symbol and get string
static const char *GetAString(const t_symbol *s,const char *def = "") { return s?GetString(s):def; }
// --- atom stuff ----------------------------------------
//! Set atom from another atom
- static int GetType(const t_atom &a) { return a.a_type; }
+ static void SetAtom(t_atom &a,const t_atom &b) { CopyAtom(&a,&b); }
+#if FLEXT_SYS == FLEXT_SYS_JMAX
//! Set atom from another atom
- static void SetAtom(t_atom &a,const t_atom &b) { CopyAtom(&a,&b); }
+ static int GetType(const t_atom &a) // ** TODO **
+
+ //! Check whether the atom is nothing
+ static bool IsNothing(const t_atom &a) // ** TODO **
+ //! Set the atom to represent nothing
+ static void SetNothing(t_atom &a) // ** TODO **
+
+ //! Check whether the atom is a float
+ static bool IsFloat(const t_atom &a) // ** TODO **
+#else
+ //! Set atom from another atom
+ static int GetType(const t_atom &a) { return a.a_type; }
//! Check whether the atom is nothing
static bool IsNothing(const t_atom &a) { return a.a_type == A_NULL; }
@@ -225,8 +255,20 @@ public:
//! Check whether the atom is a float
static bool IsFloat(const t_atom &a) { return a.a_type == A_FLOAT; }
+#endif
+
//! Check whether the atom can be represented as a float
static bool CanbeFloat(const t_atom &a) { return IsFloat(a) || IsInt(a); }
+
+#if FLEXT_SYS == FLEXT_SYS_JMAX
+ //! Access the float value (without type check)
+ static float GetFloat(const t_atom &a); // ** TODO **
+ //! Set the atom to represent a float
+ static void SetFloat(t_atom &a,float v) // ** TODO **
+
+ //! Check whether the atom is a symbol
+ static bool IsSymbol(const t_atom &a) // ** TODO **
+#else
//! Access the float value (without type check)
static float GetFloat(const t_atom &a) { return a.a_w.w_float; }
//! Set the atom to represent a float
@@ -234,16 +276,25 @@ public:
//! Check whether the atom is a symbol
static bool IsSymbol(const t_atom &a) { return a.a_type == A_SYMBOL; }
+#endif
+
#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
static void SetSymbol(t_atom &a,const t_symbol *s) { a.a_type = A_SYMBOL; a.a_w.w_symbol = const_cast<t_symbol *>(s); }
-#else
+#elif FLEXT_SYS == FLEXT_SYS_MAX
//! Access the symbol value (without type check)
static t_symbol *GetSymbol(const t_atom &a) { return a.a_w.w_sym; }
//! Set the atom to represent a symbol
static void SetSymbol(t_atom &a,const t_symbol *s) { a.a_type = A_SYMBOL; a.a_w.w_sym = const_cast<t_symbol *>(s); }
+#elif FLEXT_SYS == FLEXT_SYS_JMAX
+ //! Access the symbol value (without type check)
+ static t_symbol *GetSymbol(const t_atom &a); // ** TODO **
+ //! Set the atom to represent a symbol
+ static void SetSymbol(t_atom &a,const t_symbol *s) { ::fts_set_symbol(&a,s); }
+#else
+#error
#endif
//! Check for a symbol and get its value
static t_symbol *GetASymbol(const t_atom &a,t_symbol *def = NULL) { return IsSymbol(a)?GetSymbol(a):def; } // NULL or empty symbol?
@@ -285,7 +336,7 @@ public:
//! Check whether the atom can be a pointer
static bool CanbePointer(const t_atom &a) { return IsPointer(a); }
//! Access the pointer value (without type check)
- static t_gpointer *GetPointer(const t_atom &a) { return a.a_w.w_gpointer; }
+ static void *GetPointer(const t_atom &a) { return a.a_w.w_gpointer; }
//! Check for a pointer and get its value
static void *GetAPointer(const t_atom &a,void *def = NULL) { return IsPointer(a)?GetPointer(a):def; }
//! Set the atom to represent a pointer
@@ -308,12 +359,37 @@ public:
static bool IsPointer(const t_atom &) { return false; }
//! Check whether the atom can be a pointer
static bool CanbePointer(const t_atom &a) { return IsInt(a); }
+ //! Access the pointer value (without type check)
+ static void *GetPointer(const t_atom &a) { return NULL; }
//! Check for a pointer and get its value
static void *GetAPointer(const t_atom &a,void *def = NULL) { return IsInt(a)?(void *)GetInt(a):def; }
//! Set the atom to represent a pointer
static void SetPointer(t_atom &a,void *p) { SetInt(a,(int)p); }
+#elif FLEXT_SYS == FLEXT_SYS_JMAX
+ //! Check for a float and get its value
+ static float GetAFloat(const t_atom &a,float def = 0) { return IsFloat(a)?GetFloat(a):(IsInt(a)?GetInt(a):def); }
+
+ //! Check whether the atom is an int
+ static bool IsInt(const t_atom &a); // ** TODO **
+ //! Access the integer value (without type check)
+ static int GetInt(const t_atom &a); // ** TODO **
+ //! Check for an integer and get its value
+ static int GetAInt(const t_atom &a,int def = 0) { return IsInt(a)?GetInt(a):(IsFloat(a)?(int)GetFloat(a):def); }
+ //! Set the atom to represent an integer
+ static void SetInt(t_atom &a,int v) { ::fts_set_long(&a,v); }
+
+ //! Check whether the atom strictly is a pointer
+ static bool IsPointer(const t_atom &); // ** TODO **
+ //! Check whether the atom can be a pointer
+ static bool CanbePointer(const t_atom &a) { return IsPointer(a); }
+ //! Access the pointer value (without type check)
+ static void *GetPointer(const t_atom &a) { return ::fts_get_ptr(&a,NULL); }
+ //! Check for a pointer and get its value
+ static void *GetAPointer(const t_atom &a,void *def = NULL) { return ::fts_get_ptr(&a,def); }
+ //! Set the atom to represent a pointer
+ static void SetPointer(t_atom &a,void *p) { ::fts_set_ptr(&a,p); }
#else
-#error
+#error "Platform not supported"
#endif
// --- atom list stuff -------------------------------------------