From 0300ab2189742d254bd95c147a1779a60dac298f Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 25 Feb 2003 04:32:10 +0000 Subject: "" svn path=/trunk/; revision=428 --- externals/grill/flext/examples/source/henon.cpp | 1 + externals/grill/flext/source/flext.cpp | 2 +- externals/grill/flext/source/flmsg.cpp | 12 +- externals/grill/flext/source/flstdc.h | 424 ++++++++++++------------ externals/grill/flext/source/flsupport.cpp | 317 +++++++++--------- 5 files changed, 380 insertions(+), 376 deletions(-) (limited to 'externals/grill/flext') diff --git a/externals/grill/flext/examples/source/henon.cpp b/externals/grill/flext/examples/source/henon.cpp index 39d446eb..e48b9555 100644 --- a/externals/grill/flext/examples/source/henon.cpp +++ b/externals/grill/flext/examples/source/henon.cpp @@ -91,6 +91,7 @@ void henon::Setup(t_classid c) FLEXT_CADDBANG(c,0,m_bang); FLEXT_CADDMETHOD_(c,0,"reset",m_reset); + // methods for non-left inlets FLEXT_CADDMETHOD(c,1,m_alpha); FLEXT_CADDMETHOD(c,2,m_beta); diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp index c2cd59c4..e1a11179 100644 --- a/externals/grill/flext/source/flext.cpp +++ b/externals/grill/flext/source/flext.cpp @@ -33,7 +33,7 @@ flext_base::flext_base(): ,indesc(NULL),outdesc(NULL) #endif { - LOG1("%s - flext logging is on",thisName()); + FLEXT_LOG1("%s - flext logging is on",thisName()); t_classid clid = thisClassId(); clmethhead = ClMeths(clid); diff --git a/externals/grill/flext/source/flmsg.cpp b/externals/grill/flext/source/flmsg.cpp index 95f9790a..c558a270 100755 --- a/externals/grill/flext/source/flmsg.cpp +++ b/externals/grill/flext/source/flmsg.cpp @@ -27,7 +27,7 @@ bool flext_base::CallMeth(const methitem &m,int argc,const t_atom *argv) else if(IsInt(argv[ix])) aargs[ix].ft = (float)GetInt(argv[ix]); else ok = false; - if(ok) LOG2("int arg %i = %f",ix,aargs[ix].ft); + if(ok) FLEXT_LOG2("int arg %i = %f",ix,aargs[ix].ft); break; } case a_int: { @@ -35,14 +35,14 @@ bool flext_base::CallMeth(const methitem &m,int argc,const t_atom *argv) else if(IsInt(argv[ix])) aargs[ix].it = GetInt(argv[ix]); else ok = false; - if(ok) LOG2("float arg %i = %i",ix,aargs[ix].it); + if(ok) FLEXT_LOG2("float arg %i = %i",ix,aargs[ix].it); break; } case a_symbol: { if(IsSymbol(argv[ix])) aargs[ix].st = GetSymbol(argv[ix]); else ok = false; - if(ok) LOG2("symbol arg %i = %s",ix,GetString(aargs[ix].st)); + if(ok) FLEXT_LOG2("symbol arg %i = %s",ix,GetString(aargs[ix].st)); break; } #if FLEXT_SYS == FLEXT_SYS_PD @@ -76,7 +76,7 @@ bool flext_base::TryMethTag(const methitem *m,int inlet,const t_symbol *t,int ar { do { if(m->inlet == inlet && m->tag == t) { - LOG3("found method tag %s: inlet=%i, argc=%i",GetString(m->tag),m->inlet,argc); + FLEXT_LOG3("found method tag %s: inlet=%i, argc=%i",GetString(m->tag),m->inlet,argc); if(m->attr) { // attributes are treated differently @@ -107,7 +107,7 @@ bool flext_base::TryMethSym(const methitem *m,int inlet,const t_symbol *t,const { do { if(!m->IsAttr() && m->inlet == inlet && m->tag == t) { - LOG3("found symbol method for %s: inlet=%i, symbol=%s",GetString(m->tag),m->inlet,GetString(s)); + FLEXT_LOG3("found symbol method for %s: inlet=%i, symbol=%s",GetString(m->tag),m->inlet,GetString(s)); t_any sym; sym.st = const_cast(s); if(((methfun_1)m->fun)(this,sym)) return true; @@ -120,7 +120,7 @@ bool flext_base::TryMethAny(const methitem *m,int inlet,const t_symbol *t,const { do { if(!m->IsAttr() && m->inlet == inlet && m->tag == t) { - LOG4("found any method for %s: inlet=%i, symbol=%s, argc=%i",GetString(m->tag),m->inlet,GetString(s),argc); + FLEXT_LOG4("found any method for %s: inlet=%i, symbol=%s, argc=%i",GetString(m->tag),m->inlet,GetString(s),argc); if(((methfun_A)m->fun)(this,s,argc,const_cast(argv))) return true; } diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index 44d2dc03..e6a75a9e 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -1,212 +1,212 @@ -/* - -flext - C++ layer for Max/MSP and pd (pure data) externals - -Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) -For information on usage and redistribution, and for a DISCLAIMER OF ALL -WARRANTIES, see the file, "license.txt," in this distribution. - -*/ - -/*! \file flstdc.h - \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. -*/ - -#ifndef __FLEXT_STDC_H -#define __FLEXT_STDC_H - -// PD stuff - -#if FLEXT_SYS == FLEXT_SYS_PD - -/* PD definitions start here */ - -#ifdef _MSC_VER - #pragma warning (push) - #pragma warning (disable:4091 4005) -#endif - -#if FLEXT_OS == FLEXT_OS_WIN && !defined(NT) -#define NT -#endif - -extern "C" { - // Include the relevant PD header files - #ifdef FLEXT_DEBUG - #include // for easier debugging - #else - #include - #endif -} - -#ifdef _MSC_VER - #pragma warning (pop) -#endif - -#ifdef cabs -#undef cabs // this is defined in m_pd.h (clashes with math.h in MacOSX) -#endif - -typedef t_object t_sigobj; -typedef t_gpointer *t_ptrtype; - -typedef t_float t_flint; -typedef t_symbol *t_symtype; -typedef t_class **t_thing; - -typedef t_clock t_qelem; - -#define A_NOTHING A_NULL -#define A_FLINT A_FLOAT -#define A_DEFFLINT A_DEFFLOAT - - -#elif FLEXT_SYS == FLEXT_SYS_MAX - -/* Max/MSP definitions start here */ - - -// Include the relevant Max/MSP header files - -#if FLEXT_OS == FLEXT_OS_MAC - #ifndef __MRC__ - #define powerc - #endif - #define __MOTO__ 0 - - #include -#elif FLEXT_OS == FLEXT_OS_WIN - #define WIN_VERSION 1 -#endif - -extern "C" -{ - #include "ext.h" - #include "ext_user.h" - #include "z_dsp.h" -} - -#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; -typedef t_symbol *t_symtype; -typedef t_object *t_thing; - -typedef qelem t_qelem; - -typedef method t_method; -typedef method t_newmethod; -typedef int t_atomtype; - -typedef struct clock t_clock; -typedef void t_binbuf; - -#undef clock_free -#define clock_free(tick) freeobject((object *)tick) - -#define A_NULL A_NOTHING -#define A_DEFFLINT A_DEFLONG - -#ifndef A_INT -#define A_INT A_LONG -#endif - -#ifndef A_SYMBOL -#define A_SYMBOL A_SYM -#endif - - -#elif FLEXT_SYS == FLEXT_SYS_JMAX - -extern "C" { - // Wow, the jMax developers made excessive use of C++ reserved words - // good hit! - #define typeid c_typeid_ - #define template c_template_ - #define this c_this_ - #define class c_class_ - - #include - - // undefine them again - #undef typeid - #undef template - #undef this - #undef class -} - -typedef fts_dsp_object t_sigobj; -typedef void t_canvas; // decide type later on - -typedef char t_symbol; -typedef fts_atom_t t_atom; -typedef fts_class_t t_class; -typedef float t_sample; // is there no sample type in jMax? - -typedef fts_timebase_entry_t t_clock; -typedef fts_timebase_entry_t t_qelem; - -#endif // FLEXT_SYS - - -// general definitions - -typedef t_symbol *t_symptr; - - -// ------------------------- - -#ifdef _LOG - -/* If _LOG is defined implement logging */ -#define LOG(s) post(s) -#define LOG1(s,v1) post(s,v1) -#define LOG2(s,v1,v2) post(s,v1,v2) -#define LOG3(s,v1,v2,v3) post(s,v1,v2,v3) -#define LOG4(s,v1,v2,v3,v4) post(s,v1,v2,v3,v4) -#define LOG5(s,v1,v2,v3,v4,v5) post(s,v1,v2,v3,v4,v5) - - -#else - -/* If _LOG is not defined avoid logging */ -#define LOG(s) ((void)0) -#define LOG1(s,v1) ((void)0) -#define LOG2(s,v1,v2) ((void)0) -#define LOG3(s,v1,v2,v3) ((void)0) -#define LOG4(s,v1,v2,v3,v4) ((void)0) -#define LOG5(s,v1,v2,v3,v4,v5) ((void)0) - -#endif - -#ifdef FLEXT_DEBUG -#define FLEXT_ASSERT(b) ((void)(!(b)?(error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__),0):0)) -#else -#define FLEXT_ASSERT(b) ((void)0) -#endif - -#define ERRINTERNAL() error("flext: Internal error in file " __FILE__ ", line %i - please report",(int)__LINE__) - - -/* Set the right calling convention (and exporting) for the OS */ - -#ifdef _MSC_VER - #ifdef FLEXT_SHARED - #define FLEXT_SHARE __declspec(dllexport) - #else - #define FLEXT_SHARE - #endif - #define FLEXT_EXT __declspec(dllexport) -#else // other OS's - #define FLEXT_SHARE - #define FLEXT_EXT -#endif - -#endif +/* + +flext - C++ layer for Max/MSP and pd (pure data) externals + +Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +/*! \file flstdc.h + \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. +*/ + +#ifndef __FLEXT_STDC_H +#define __FLEXT_STDC_H + +// PD stuff + +#if FLEXT_SYS == FLEXT_SYS_PD + +/* PD definitions start here */ + +#ifdef _MSC_VER + #pragma warning (push) + #pragma warning (disable:4091 4005) +#endif + +#if FLEXT_OS == FLEXT_OS_WIN && !defined(NT) +#define NT +#endif + +extern "C" { + // Include the relevant PD header files + #ifdef FLEXT_DEBUG + #include // for easier debugging + #else + #include + #endif +} + +#ifdef _MSC_VER + #pragma warning (pop) +#endif + +#ifdef cabs +#undef cabs // this is defined in m_pd.h (clashes with math.h in MacOSX) +#endif + +typedef t_object t_sigobj; +typedef t_gpointer *t_ptrtype; + +typedef t_float t_flint; +typedef t_symbol *t_symtype; +typedef t_class **t_thing; + +typedef t_clock t_qelem; + +#define A_NOTHING A_NULL +#define A_FLINT A_FLOAT +#define A_DEFFLINT A_DEFFLOAT + + +#elif FLEXT_SYS == FLEXT_SYS_MAX + +/* Max/MSP definitions start here */ + + +// Include the relevant Max/MSP header files + +#if FLEXT_OS == FLEXT_OS_MAC + #ifndef __MRC__ + #define powerc + #endif + #define __MOTO__ 0 + + #include +#elif FLEXT_OS == FLEXT_OS_WIN + #define WIN_VERSION 1 +#endif + +extern "C" +{ + #include "ext.h" + #include "ext_user.h" + #include "z_dsp.h" +} + +#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; +typedef t_symbol *t_symtype; +typedef t_object *t_thing; + +typedef qelem t_qelem; + +typedef method t_method; +typedef method t_newmethod; +typedef int t_atomtype; + +typedef struct clock t_clock; +typedef void t_binbuf; + +#undef clock_free +#define clock_free(tick) freeobject((object *)tick) + +#define A_NULL A_NOTHING +#define A_DEFFLINT A_DEFLONG + +#ifndef A_INT +#define A_INT A_LONG +#endif + +#ifndef A_SYMBOL +#define A_SYMBOL A_SYM +#endif + + +#elif FLEXT_SYS == FLEXT_SYS_JMAX + +extern "C" { + // Wow, the jMax developers made excessive use of C++ reserved words + // good hit! + #define typeid c_typeid_ + #define template c_template_ + #define this c_this_ + #define class c_class_ + + #include + + // undefine them again + #undef typeid + #undef template + #undef this + #undef class +} + +typedef fts_dsp_object t_sigobj; +typedef void t_canvas; // decide type later on + +typedef char t_symbol; +typedef fts_atom_t t_atom; +typedef fts_class_t t_class; +typedef float t_sample; // is there no sample type in jMax? + +typedef fts_timebase_entry_t t_clock; +typedef fts_timebase_entry_t t_qelem; + +#endif // FLEXT_SYS + + +// general definitions + +typedef t_symbol *t_symptr; + + +// ------------------------- + +#ifdef FLEXT_LOGGING + +/* If _LOG is defined implement logging */ +#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) + + +#else + +/* If _LOG is not defined avoid logging */ +#define FLEXT_LOG(s) ((void)0) +#define FLEXT_LOG1(s,v1) ((void)0) +#define FLEXT_LOG2(s,v1,v2) ((void)0) +#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) + +#endif + +#ifdef FLEXT_DEBUG +#define FLEXT_ASSERT(b) ((void)(!(b)?(error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__),0):0)) +#else +#define FLEXT_ASSERT(b) ((void)0) +#endif + +#define ERRINTERNAL() error("flext: Internal error in file " __FILE__ ", line %i - please report",(int)__LINE__) + + +/* Set the right calling convention (and exporting) for the OS */ + +#ifdef _MSC_VER + #ifdef FLEXT_SHARED + #define FLEXT_SHARE __declspec(dllexport) + #else + #define FLEXT_SHARE + #endif + #define FLEXT_EXT __declspec(dllexport) +#else // other OS's + #define FLEXT_SHARE + #define FLEXT_EXT +#endif + +#endif diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp index 115e0ee6..d56028d8 100644 --- a/externals/grill/flext/source/flsupport.cpp +++ b/externals/grill/flext/source/flsupport.cpp @@ -1,157 +1,160 @@ -/* - -flext - C++ layer for Max/MSP and pd (pure data) externals - -Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) -For information on usage and redistribution, and for a DISCLAIMER OF ALL -WARRANTIES, see the file, "license.txt," in this distribution. - -*/ - -/*! \file flsupport.cpp - \brief flext support functions and classes. -*/ - -#include "flext.h" - -const t_symbol *flext::sym_float = NULL; -const t_symbol *flext::sym_symbol = NULL; -const t_symbol *flext::sym_bang = NULL; -const t_symbol *flext::sym_list = NULL; -const t_symbol *flext::sym_pointer = NULL; -const t_symbol *flext::sym_int = NULL; - -#if FLEXT_SYS != FLEXT_SYS_JMAX -const t_symbol *flext::sym_anything = NULL; -#endif - -#if FLEXT_SYS == FLEXT_SYS_PD -const t_symbol *flext::sym_signal = NULL; -#endif - -void flext::Setup() -{ -#if FLEXT_SYS == FLEXT_SYS_PD - sym_anything = &s_anything; - sym_pointer = &s_pointer; - sym_float = &s_float; - sym_symbol = &s_symbol; - sym_bang = &s_bang; - sym_list = &s_list; - sym_signal = &s_signal; -#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"); -#elif FLEXT_SYS == FLEXT_SYS_JMAX - sym_int = fts_s_int; - sym_float = fts_s_float; - sym_symbol = fts_s_symbol; - sym_bang = fts_s_bang; - sym_list = fts_s_list; - sym_pointer = fts_s_pointer; -#else -#endif -} - - -///////////////////////////////////////////////////////// -// overloaded new/delete memory allocation methods -// -///////////////////////////////////////////////////////// - -void *flext::operator new(size_t bytes) -{ - bytes += sizeof(size_t); -#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); -} - -void flext::operator delete(void *blk) -{ - char *ori = (char *)blk-sizeof(size_t); -#if FLEXT_SYS == FLEXT_SYS_JMAX - fts_free(ori); -#else - size_t bytes = *(size_t *)ori; - ::freebytes(ori,bytes); -#endif -} - -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; -#if FLEXT_SYS == FLEXT_SYS_JMAX - char *blk = (char *)::fts_malloc(bytes); -#else - char *blk = (char *)::getbytes(bytes); -#endif - char *ablk = reinterpret_cast((reinterpret_cast(blk)+ovh+alignovh) & ~alignovh); - *(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk; - *(size_t *)(ablk-sizeof(size_t)) = bytes; - return ablk; -} - -void flext::FreeAligned(void *blk) -{ - char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *)); - -#if FLEXT_SYS == FLEXT_SYS_JMAX - fts_free(ori); -#else - size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); - ::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 - atom_string(const_cast(&a),buf,szbuf); -#else - if(IsSymbol(a)) snprintf(buf,szbuf,GetString(a)); - else if(IsFloat(a)) snprintf(buf,szbuf,"%f",GetFloat(a)); - else if(IsInt(a)) snprintf(buf,szbuf,"%i",GetInt(a)); - else strncpy(buf,"",szbuf); -#endif -} - -unsigned long flext::AtomHash(const t_atom &a) -{ -#if FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_PD - return ((unsigned long)a.a_type<<28)^*(unsigned long *)&a.a_w; -#else -#error Not implemented -#endif -} - -unsigned int flext::FoldBits(unsigned long h,int bits) -{ - if(!bits) return 0; - const int hmax = (1<>i)&hmax; - return ret; -} - -int flext::Int2Bits(unsigned long n) -{ - int b; - for(b = 0; n; ++b) n >>= 1; - return b; -} - +/* + +flext - C++ layer for Max/MSP and pd (pure data) externals + +Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +/*! \file flsupport.cpp + \brief flext support functions and classes. +*/ + +#include "flext.h" + +const t_symbol *flext::sym_float = NULL; +const t_symbol *flext::sym_symbol = NULL; +const t_symbol *flext::sym_bang = NULL; +const t_symbol *flext::sym_list = NULL; +const t_symbol *flext::sym_pointer = NULL; +const t_symbol *flext::sym_int = NULL; + +#if FLEXT_SYS != FLEXT_SYS_JMAX +const t_symbol *flext::sym_anything = NULL; +#endif + +#if FLEXT_SYS == FLEXT_SYS_PD +const t_symbol *flext::sym_signal = NULL; +#endif + +void flext::Setup() +{ +#if FLEXT_SYS == FLEXT_SYS_PD + sym_anything = &s_anything; + sym_pointer = &s_pointer; + sym_float = &s_float; + sym_symbol = &s_symbol; + sym_bang = &s_bang; + sym_list = &s_list; + sym_signal = &s_signal; +#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"); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + sym_int = fts_s_int; + sym_float = fts_s_float; + sym_symbol = fts_s_symbol; + sym_bang = fts_s_bang; + sym_list = fts_s_list; + sym_pointer = fts_s_pointer; +#else +#endif +} + + +///////////////////////////////////////////////////////// +// overloaded new/delete memory allocation methods +// +///////////////////////////////////////////////////////// + +void *flext::operator new(size_t bytes) +{ + bytes += sizeof(size_t); +#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); +} + +void flext::operator delete(void *blk) +{ + char *ori = (char *)blk-sizeof(size_t); +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_free(ori); +#else + size_t bytes = *(size_t *)ori; + ::freebytes(ori,bytes); +#endif +} + +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; +#if FLEXT_SYS == FLEXT_SYS_JMAX + char *blk = (char *)::fts_malloc(bytes); +#else + char *blk = (char *)::getbytes(bytes); +#endif + char *ablk = reinterpret_cast((reinterpret_cast(blk)+ovh+alignovh) & ~alignovh); + *(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk; + *(size_t *)(ablk-sizeof(size_t)) = bytes; + return ablk; +} + +void flext::FreeAligned(void *blk) +{ + char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *)); + +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_free(ori); +#else + size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); + ::freebytes(ori,bytes); +#endif +} + +// ------------------------------------------ + +/*! \todo there is probably also a shortcut for Max and jMax + \todo size checking +*/ +void flext::GetAString(const t_atom &a,char *buf,int szbuf) +{ +#if FLEXT_SYS == FLEXT_SYS_PD + atom_string(const_cast(&a),buf,szbuf); +#else + // no checking for size here + if(IsSymbol(a)) sprintf(tmp,GetString(a)); + else if(IsFloat(a)) sprintf(tmp,"%f",GetFloat(a)); + else if(IsInt(a)) sprintf(tmp,"%i",GetInt(a)); + else *buf = 0; +#endif +} + +unsigned long flext::AtomHash(const t_atom &a) +{ +#if FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_PD + return ((unsigned long)a.a_type<<28)^*(unsigned long *)&a.a_w; +#else +#error Not implemented +#endif +} + +unsigned int flext::FoldBits(unsigned long h,int bits) +{ + if(!bits) return 0; + const int hmax = (1<>i)&hmax; + return ret; +} + +int flext::Int2Bits(unsigned long n) +{ + int b; + for(b = 0; n; ++b) n >>= 1; + return b; +} + -- cgit v1.2.1