From b00be027fe91e9ae5a19f53b6c1fd0245b4d4bae Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 15 Jan 2003 04:37:19 +0000 Subject: "" svn path=/trunk/; revision=339 --- externals/grill/flext/source/flatom.cpp | 4 +- externals/grill/flext/source/flatom_pr.cpp | 24 ++---- externals/grill/flext/source/flattr.cpp | 6 +- externals/grill/flext/source/flbase.h | 110 +++++++++++++++++-------- externals/grill/flext/source/flbuf.cpp | 10 ++- externals/grill/flext/source/flclass.h | 115 ++++++++++++++++---------- externals/grill/flext/source/fldsp.cpp | 122 ++++++++++++++++++++++------ externals/grill/flext/source/fldsp.h | 28 ++++++- externals/grill/flext/source/flext.cpp | 28 ++++++- externals/grill/flext/source/flinternal.h | 3 + externals/grill/flext/source/fllib.cpp | 50 +++++++++--- externals/grill/flext/source/flout.cpp | 125 +++++++++++++++++++++++++---- externals/grill/flext/source/flproxy.cpp | 18 ++++- externals/grill/flext/source/flqueue.cpp | 44 +++++----- externals/grill/flext/source/flstdc.h | 42 +++++++++- externals/grill/flext/source/flsupport.cpp | 21 +++-- externals/grill/flext/source/flsupport.h | 56 +++++++------ 17 files changed, 591 insertions(+), 215 deletions(-) (limited to 'externals/grill/flext/source') diff --git a/externals/grill/flext/source/flatom.cpp b/externals/grill/flext/source/flatom.cpp index 9f905d7b..0e7eb544 100644 --- a/externals/grill/flext/source/flatom.cpp +++ b/externals/grill/flext/source/flatom.cpp @@ -53,10 +53,12 @@ flext::AtomList &flext::AtomList::Set(int argc,const t_atom *argv,int offs,bool } - +#if FLEXT_SYS != FLEXT_SYS_JMAX +// not for jmax as long as t_symbol * == char * flext::AtomAnything::AtomAnything(const t_symbol *h,int argc,const t_atom *argv): AtomList(argc,argv),hdr(h?h:MakeSymbol("")) {} +#endif flext::AtomAnything::AtomAnything(const char *h,int argc,const t_atom *argv): AtomList(argc,argv),hdr(MakeSymbol(h)) diff --git a/externals/grill/flext/source/flatom_pr.cpp b/externals/grill/flext/source/flatom_pr.cpp index d6f030b5..7eeada93 100644 --- a/externals/grill/flext/source/flatom_pr.cpp +++ b/externals/grill/flext/source/flatom_pr.cpp @@ -26,35 +26,25 @@ WARRANTIES, see the file, "license.txt," in this distribution. void flext::PrintAtom(const t_atom &a,char *buf) { - switch(a.a_type) { - case A_NULL: - break; - case A_FLOAT: + if(IsFloat(a)) { #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; -#if FLEXT_SYS == FLEXT_SYS_MAX - case A_LONG: + } + else if(IsInt(a)) STD::sprintf(buf,"%i",GetInt(a)); - break; -#endif -#if FLEXT_SYS == FLEXT_SYS_PD - case A_POINTER: + else if(IsPointer(a)) STD::sprintf(buf,"%p",GetPointer(a)); - break; -#endif - case A_SYMBOL: + else if(IsSymbol(a)) strcpy(buf,GetString(a)); - break; + else if(IsNothing(a)) {} #ifdef FLEXT_DEBUG - default: + else ERRINTERNAL(); #endif - } } bool flext::ScanAtom(t_atom &a,const char *buf) diff --git a/externals/grill/flext/source/flattr.cpp b/externals/grill/flext/source/flattr.cpp index ffb6b6fd..f55fe0ee 100644 --- a/externals/grill/flext/source/flattr.cpp +++ b/externals/grill/flext/source/flattr.cpp @@ -141,10 +141,10 @@ bool flext_base::InitAttrib(int argc,const t_atom *argv) bool flext_base::ListAttrib() { - if(outattr) { + if(procattr) { AtomList la; int c = ListAttr(la); - ToOutAnything(outattr,MakeSymbol("attributes"),c,la.Atoms()); + ToOutAnything(GetOutAttr(),MakeSymbol("attributes"),c,la.Atoms()); return true; } else @@ -274,7 +274,7 @@ bool flext_base::GetAttrib(attritem *a) default: ERRINTERNAL(); } - ToOutAnything(outattr,a->tag,la.Count(),la.Atoms()); + ToOutAnything(GetOutAttr(),a->tag,la.Count(),la.Atoms()); } else post("%s - attribute %s has no set method",thisName(),GetString(a->tag)); diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index ea682077..d72466c5 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -146,20 +146,25 @@ class FLEXT_SHARE flext_obj: const t_symbol *thisNameSym() const { return m_name; } -#if FLEXT_SYS == FLEXT_SYS_PD //! Get the class pointer +#if FLEXT_SYS == FLEXT_SYS_PD t_class *thisClass() const { return (t_class *)((t_object *)(x_obj))->te_g.g_pd; } +#elif FLEXT_SYS == FLEXT_SYS_MAX + t_class *thisClass() const { return (t_class *)(((t_tinyobject *)x_obj)->t_messlist-1); } +#elif FLEXT_SYS == FLEXT_SYS_JMAX + t_class *thisClass() const { return fts_object_get_class((fts_object_t *)thisHdr()); } +#else +#error +#endif +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_JMAX //! Typedef for unique class identifier typedef t_class *t_classid; //! Get unique id for object class t_classid thisClassId() const { return thisClass(); } //! Get class pointer from class id static t_class *getClass(t_classid c) { return c; } -#elif FLEXT_SYS == FLEXT_SYS_MAX - //! Get the class pointer - t_class *thisClass() const { return (t_class *)(((t_tinyobject *)x_obj)->t_messlist-1); } - +#else //! Typedef for unique class identifier typedef void *t_classid; //! Get unique id for object class (for Max/MSP library object share the same (t_class *)!) @@ -239,9 +244,13 @@ class FLEXT_SHARE flext_obj: // Definitions for library objects static void lib_init(const char *name,void setupfun(),bool attr); static void obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),flext_obj *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...); +#if FLEXT_SYS == FLEXT_SYS_JMAX + static void obj_new(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); + static void obj_free(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); +#else static flext_hdr *obj_new(const t_symbol *s,int argc,t_atom *argv); static void obj_free(flext_hdr *o); - +#endif //! @} FLEXT_O_INTERNAL //! @} FLEXT_OBJCLASS @@ -306,10 +315,15 @@ static void __setup__(t_classid classid) \ protected: \ static inline NEW_CLASS *thisObject(void *c) { return FLEXT_CAST(((flext_hdr *)c)->data); } - // generate name of dsp/non-dsp setup function -#define FLEXT_STPF_0(NAME) NAME##_setup -#define FLEXT_STPF_1(NAME) NAME##_tilde_setup +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + #define FLEXT_STPF_0(NAME) NAME##_setup + #define FLEXT_STPF_1(NAME) NAME##_tilde_setup +#else + #define FLEXT_STPF_0(NAME) NAME##_config + #define FLEXT_STPF_1(NAME) signal_##NAME##_config +#endif + #define FLEXT_STPF_(DSP) FLEXT_STPF_##DSP #define FLEXT_STPF(NAME,DSP) FLEXT_STPF_(DSP)(NAME) @@ -322,13 +336,19 @@ static inline NEW_CLASS *thisObject(void *c) { return FLEXT_CAST((( // these can be used in library setup functions // to register the individual objects in the library -#define REAL_SETUP_0(cl) \ -extern void cl##_setup(); \ -cl##_setup() - -#define REAL_SETUP_1(cl) \ -extern void cl##_tilde_setup(); \ -cl##_tilde_setup() +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + #define REAL_SETUP_0(cl) \ + extern void cl##_setup(); cl##_setup() + + #define REAL_SETUP_1(cl) \ + extern void cl##_tilde_setup(); cl##_tilde_setup() +#else + #define REAL_SETUP_0(cl) \ + extern void cl##_config(); cl##_config() + + #define REAL_SETUP_1(cl) \ + extern void signal_##cl##_config(); signal_##cl##_config() +#endif #define REAL_SETUP(cl,DSP) REAL_SETUP_##DSP(cl) @@ -338,6 +358,10 @@ cl##_tilde_setup() #define REAL_LIB_SETUP(NAME,SETUPFUN) extern "C" FLEXT_EXT void NAME##_setup() { flext_obj::lib_init(#NAME,SETUPFUN,FLEXT_ATTRIBUTES); } #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; } +#elif FLEXT_SYS == FLEXT_SYS_JMAX +#define REAL_LIB_SETUP(NAME,SETUPFUN) \ +static void __##NAME##_initfun() { flext_obj::lib_init(#NAME,SETUPFUN,FLEXT_ATTRIBUTES); } \ +fts_module_t __##NAME##_module = {#NAME,#NAME,__##NAME##_initfun,0,0}; #else #error #endif @@ -350,12 +374,12 @@ cl##_tilde_setup() #define FLEXT_EXP_1 #define FLEXT_EXP(LIB) FLEXT_EXP_##LIB -#if FLEXT_SYS == FLEXT_SYS_PD +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_JMAX #define FLEXT_OBJ_SETUP_0(NEW_CLASS,DSP) #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 +#error not implemented #endif #define FLEXT_OBJ_SETUP_1(NEW_CLASS,DSP) @@ -368,29 +392,49 @@ cl##_tilde_setup() // These definitions are used below // ---------------------------------------- +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + // maybe that's not necessary + #define FLEXTTPN_NULL A_NULL + #if FLEXT_SYS == FLEXT_SYS_PD + #define FLEXTTPN_PTR A_POINTER + #else + #define FLEXTTPN_INT A_INT + #endif + #define FLEXTTPN_FLOAT A_FLOAT + #define FLEXTTPN_SYM A_SYMBOL + #define FLEXTTPN_VAR A_GIMME +#else + #define FLEXTTPN_NULL 0 + #define FLEXTTPN_PTR 1 + #define FLEXTTPN_INT 2 + #define FLEXTTPN_FLOAT 3 + #define FLEXTTPN_SYM 4 + #define FLEXTTPN_VAR 5 +#endif + // Shortcuts for PD/Max type arguments -#define FLEXTTYPE_void A_NULL +#define FLEXTTYPE_void FLEXTTPN_NULL #define CALLBTYPE_void void -#define FLEXTTYPE_float A_FLOAT +#define FLEXTTYPE_float FLEXTTPN_FLOAT #define CALLBTYPE_float float -#define FLEXTTYPE_t_float A_FLOAT +#define FLEXTTYPE_t_float FLEXTTPN_FLOAT #define CALLBTYPE_t_float t_float #if FLEXT_SYS == FLEXT_SYS_PD -#define FLEXTTYPE_int A_FLOAT +#define FLEXTTYPE_int FLEXTTPN_FLOAT #define CALLBTYPE_int float -#elif FLEXT_SYS == FLEXT_SYS_MAX -#define FLEXTTYPE_int A_INT +#elif FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_JMAX +#define FLEXTTYPE_int FLEXTTPN_INT #define CALLBTYPE_int int #else #error #endif -#define FLEXTTYPE_t_symptr A_SYMBOL +#define FLEXTTYPE_t_symptr FLEXTTPN_SYM #define CALLBTYPE_t_symptr t_symptr -#define FLEXTTYPE_t_symtype A_SYMBOL +#define FLEXTTYPE_t_symtype FLEXTTPN_SYM #define CALLBTYPE_t_symtype t_symptr -#define FLEXTTYPE_t_ptrtype A_POINTER +#define FLEXTTYPE_t_ptrtype FLEXTTPN_PTR #define CALLBTYPE_t_ptrtype t_ptrtype #define FLEXTTP(TP) FLEXTTYPE_ ## TP @@ -411,7 +455,7 @@ flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \ } \ FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \ { \ - flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,&NEW_CLASS::__free__,A_NULL); \ + flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,&NEW_CLASS::__free__,FLEXTTPN_NULL); \ } \ FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) @@ -422,7 +466,7 @@ flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \ } \ FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \ { \ - flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,&NEW_CLASS::__free__,A_GIMME,A_NULL); \ + flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,&NEW_CLASS::__free__,FLEXTTPN_VAR,FLEXTTPN_NULL); \ } \ FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) @@ -433,7 +477,7 @@ flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \ } \ FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \ { \ - flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),A_NULL); \ + flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTPN_NULL); \ } \ FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) @@ -444,7 +488,7 @@ flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \ } \ FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \ { \ - flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTP(TYPE2),A_NULL); \ + flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTP(TYPE2),FLEXTTPN_NULL); \ } \ FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) @@ -455,7 +499,7 @@ flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \ } \ FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \ { \ - flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTP(TYPE2),FLEXTTP(TYPE3),A_NULL); \ + flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTP(TYPE2),FLEXTTP(TYPE3),FLEXTTPN_NULL); \ } \ FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) @@ -466,7 +510,7 @@ flext_obj *NEW_CLASS::__init__(int argc,t_atom *argv) \ } \ FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \ { \ - flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTP(TYPE2),FLEXTTP(TYPE3),FLEXTTP(TYPE4),A_NULL); \ + flext_obj::obj_add(LIB,DSP,FLEXT_ATTRIBUTES,#NEW_CLASS,NAME,NEW_CLASS::__setup__,NEW_CLASS::__init__,NEW_CLASS::__free__,FLEXTTP(TYPE1),FLEXTTP(TYPE2),FLEXTTP(TYPE3),FLEXTTP(TYPE4),FLEXTTPN_NULL); \ } \ FLEXT_OBJ_SETUP(NEW_CLASS,DSP,LIB) diff --git a/externals/grill/flext/source/flbuf.cpp b/externals/grill/flext/source/flbuf.cpp index 7a2a21b6..4b4da40a 100644 --- a/externals/grill/flext/source/flbuf.cpp +++ b/externals/grill/flext/source/flbuf.cpp @@ -14,6 +14,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flext.h" +#if FLEXT_SYS != FLEXT_SYS_JMAX + #if FLEXT_SYS == FLEXT_SYS_MAX #include "flmspbuffer.h" // include inofficial buffer.h #endif @@ -58,7 +60,7 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly) chns = 0; } - if(s && *s->s_name) sym = s; + if(s && *GetString(s)) sym = s; if(!sym) { if(valid) ret = -1; @@ -110,7 +112,7 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly) if(valid) ret = -1; } #else -#error +#error not implemented #endif } @@ -152,7 +154,7 @@ bool flext::buffer::Update() return false; } #else -#error +#error not implemented #endif } @@ -263,3 +265,5 @@ void flext::buffer::cb_tick(buffer *b) } #endif + +#endif // Jmax diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index 33c125f0..bfae95c6 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -183,16 +183,22 @@ public: //! Get number of signal outlets int CntOutSig() const { return outsigs; } - class outlet; - //! Retrieve currently processed message tag (NULL if no message processing) const t_symbol *thisTag() const { return curtag; } - //! Get pointer to outlet (not in the constructor!) - outlet *GetOut(int ix) const { return (outlets && ix < outcnt)?outlets[ix]:NULL; } +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + class outlet; - //! Get pointer to attribute outlet - outlet *GetOutAttr() const { return outattr; } + //! Get pointer to outlet (not in the constructor!) + outlet *GetOut(int ix) const { +#ifdef FLEXT_DEBUG + return (outlets && ix < (procattr?outcnt+1:outcnt))?outlets[ix]:NULL; +#else + return outlets[ix]; +#endif + } +#endif + int GetOutAttr() const { return procattr?CntOut():0; } //! @} FLEXT_C_IO_MISC @@ -203,40 +209,40 @@ public: // output messages //! Output bang (to appointed outlet) - void ToOutBang(outlet *o) const; +// void ToOutBang(outlet *o) const; //! Output bang (index n starts with 0) - void ToOutBang(int n) const { outlet *o = GetOut(n); if(o) ToOutBang(o); } + void ToOutBang(int n) const; // { outlet *o = GetOut(n); if(o) ToOutBang(o); } //! Output float (to appointed outlet) - void ToOutFloat(outlet *o,float f) const; +// void ToOutFloat(outlet *o,float f) const; //! Output float (index n starts with 0) - void ToOutFloat(int n,float f) const { outlet *o = GetOut(n); if(o) ToOutFloat(o,f); } + void ToOutFloat(int n,float f) const; // { outlet *o = GetOut(n); if(o) ToOutFloat(o,f); } //! Output integer (to appointed outlet) - void ToOutInt(outlet *o,int f) const; +// void ToOutInt(outlet *o,int f) const; //! Output integer (index n starts with 0) - void ToOutInt(int n,int f) const { outlet *o = GetOut(n); if(o) ToOutInt(o,f); } + void ToOutInt(int n,int f) const; // { outlet *o = GetOut(n); if(o) ToOutInt(o,f); } //! Output symbol (to appointed outlet) - void ToOutSymbol(outlet *o,const t_symbol *s) const; +// void ToOutSymbol(outlet *o,const t_symbol *s) const; //! Output symbol (index n starts with 0) - void ToOutSymbol(int n,const t_symbol *s) const { outlet *o = GetOut(n); if(o) ToOutSymbol(o,s); } + void ToOutSymbol(int n,const t_symbol *s) const; // { outlet *o = GetOut(n); if(o) ToOutSymbol(o,s); } //! Output string aka symbol (to appointed outlet) - void ToOutString(outlet *o,const char *s) const { ToOutSymbol(o,MakeSymbol(s)); } +// void ToOutString(outlet *o,const char *s) const { ToOutSymbol(o,MakeSymbol(s)); } //! Output string aka symbol (index n starts with 0) - void ToOutString(int n,const char *s) const { outlet *o = GetOut(n); if(o) ToOutString(o,s); } + void ToOutString(int n,const char *s) const { ToOutSymbol(n,MakeSymbol(s)); } //! Output list (to appointed outlet) - void ToOutList(outlet *o,int argc,const t_atom *argv) const; +// void ToOutList(outlet *o,int argc,const t_atom *argv) const; //! Output list (index n starts with 0) - void ToOutList(int n,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) ToOutList(o,argc,argv); } + void ToOutList(int n,int argc,const t_atom *argv) const; // { outlet *o = GetOut(n); if(o) ToOutList(o,argc,argv); } //! Output list (index n starts with 0) void ToOutList(int n,const AtomList &list) const { ToOutList(n,list.Count(),list.Atoms()); } //! Output anything (to appointed outlet) void ToOutAnything(outlet *o,const t_symbol *s,int argc,const t_atom *argv) const; //! Output anything (index n starts with 0) - void ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) ToOutAnything(o,const_cast(s),argc,argv); } + void ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const; // { outlet *o = GetOut(n); if(o) ToOutAnything(o,const_cast(s),argc,argv); } //! Output anything (index n starts with 0) void ToOutAnything(int n,const AtomAnything &any) const { ToOutAnything(n,any.Header(),any.Count(),any.Atoms()); } @@ -247,44 +253,44 @@ public: */ //! Output bang (to appointed outlet) - void ToQueueBang(outlet *o) const; +// void ToQueueBang(outlet *o) const; //! Output bang (index n starts with 0) - void ToQueueBang(int n) const { outlet *o = GetOut(n); if(o) ToQueueBang(o); } + void ToQueueBang(int n) const; // { outlet *o = GetOut(n); if(o) ToQueueBang(o); } //! Output float (to appointed outlet) - void ToQueueFloat(outlet *o,float f) const; +// void ToQueueFloat(outlet *o,float f) const; //! Output float (index n starts with 0) - void ToQueueFloat(int n,float f) const { outlet *o = GetOut(n); if(o) ToQueueFloat(o,f); } + void ToQueueFloat(int n,float f) const; // { outlet *o = GetOut(n); if(o) ToQueueFloat(o,f); } //! Output integer (to appointed outlet) - void ToQueueInt(outlet *o,int f) const; +// void ToQueueInt(outlet *o,int f) const; //! Output integer (index n starts with 0) - void ToQueueInt(int n,int f) const { outlet *o = GetOut(n); if(o) ToQueueInt(o,f); } + void ToQueueInt(int n,int f) const; // { outlet *o = GetOut(n); if(o) ToQueueInt(o,f); } //! Output symbol (to appointed outlet) - void ToQueueSymbol(outlet *o,const t_symbol *s) const; +// void ToQueueSymbol(outlet *o,const t_symbol *s) const; //! Output symbol (index n starts with 0) - void ToQueueSymbol(int n,const t_symbol *s) const { outlet *o = GetOut(n); if(o) ToQueueSymbol(o,s); } + void ToQueueSymbol(int n,const t_symbol *s) const; // { outlet *o = GetOut(n); if(o) ToQueueSymbol(o,s); } //! Output string aka symbol (to appointed outlet) - void ToQueueString(outlet *o,const char *s) const { ToQueueSymbol(o,MakeSymbol(s)); } +// void ToQueueString(outlet *o,const char *s) const { ToQueueSymbol(o,MakeSymbol(s)); } //! Output string aka symbol (to appointed outlet) - void ToQueueString(int n,const char *s) const { ToQueueSymbol(n,MakeSymbol(s)); } + void ToQueueString(int n,const char *s) const; // { ToQueueSymbol(n,MakeSymbol(s)); } //! Output list (to appointed outlet) - void ToQueueList(outlet *o,int argc,const t_atom *argv) const; +// void ToQueueList(outlet *o,int argc,const t_atom *argv) const; //! Output list (to appointed outlet) - void ToQueueList(outlet *o,const AtomList &list) const { ToQueueList(o,list.Count(),list.Atoms()); } +// void ToQueueList(outlet *o,const AtomList &list) const { ToQueueList(o,list.Count(),list.Atoms()); } //! Output list (index n starts with 0) - void ToQueueList(int n,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) ToQueueList(o,argc,argv); } + void ToQueueList(int n,int argc,const t_atom *argv) const; // { outlet *o = GetOut(n); if(o) ToQueueList(o,argc,argv); } //! Output list (index n starts with 0) void ToQueueList(int n,const AtomList &list) const { ToQueueList(n,list.Count(),list.Atoms()); } //! Output anything (to appointed outlet) - void ToQueueAnything(outlet *o,const t_symbol *s,int argc,const t_atom *argv) const; +// void ToQueueAnything(outlet *o,const t_symbol *s,int argc,const t_atom *argv) const; //! Output anything (to appointed outlet) - void ToQueueAnything(outlet *o,const AtomAnything &any) const { ToQueueAnything(o,any.Header(),any.Count(),any.Atoms()); } +// void ToQueueAnything(outlet *o,const AtomAnything &any) const { ToQueueAnything(o,any.Header(),any.Count(),any.Atoms()); } //! Output anything (index n starts with 0) - void ToQueueAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) ToQueueAnything(o,s,argc,argv); } + void ToQueueAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const; // { outlet *o = GetOut(n); if(o) ToQueueAnything(o,s,argc,argv); } //! Output anything (index n starts with 0) void ToQueueAnything(int n,const AtomAnything &any) const { ToQueueAnything(n,any.Header(),any.Count(),any.Atoms()); } @@ -324,7 +330,7 @@ public: void AddMethod(int inlet,bool (*m)(flext_base *,float &,float &,float &)) { AddMethod(ThMeths(),inlet,"list",(methfun)m,a_float,a_float,a_float,a_null); } // list of 3 floats #if FLEXT_SYS == FLEXT_SYS_PD void AddMethod(int inlet,bool (*m)(flext_base *,int &)) { AddMethod(ThMeths(),inlet,"float",(methfun)m,a_int,a_null); } // single float -#elif FLEXT_SYS == FLEXT_SYS_MAX +#elif FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_JMAX void AddMethod(int inlet,bool (*m)(flext_base *,int &)) { AddMethod(ThMeths(),inlet,"int",(methfun)m,a_int,a_null); } // single float #else #error @@ -361,9 +367,9 @@ public: static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,float &,float &)) { AddMethod(ClMeths(c),inlet,"list",(methfun)m,a_float,a_float,a_null); } // list of 2 floats static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,float &,float &,float &)) { AddMethod(ClMeths(c),inlet,"list",(methfun)m,a_float,a_float,a_float,a_null); } // list of 3 floats #if FLEXT_SYS == FLEXT_SYS_PD - static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,int &)) { AddMethod(ClMeths(c),inlet,"float",(methfun)m,a_int,a_null); } // single float -#elif FLEXT_SYS == FLEXT_SYS_MAX - static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,int &)) { AddMethod(ClMeths(c),inlet,"int",(methfun)m,a_int,a_null); } // single float + static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,int &)) { AddMethod(ClMeths(c),inlet,"float",(methfun)m,a_int,a_null); } // single integer +#elif FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_JMAX + static void AddMethod(t_classid c,int inlet,bool (*m)(flext_base *,int &)) { AddMethod(ClMeths(c),inlet,"int",(methfun)m,a_int,a_null); } // single integer #else #error #endif @@ -392,16 +398,24 @@ public: bool Bind(const t_symbol *s) { pd_bind(&thisHdr()->ob_pd,const_cast(s)); return true; } //! Unbind object from a symbol bool Unbind(const t_symbol *s) { pd_unbind(&thisHdr()->ob_pd,const_cast(s)); return true; } -#else +#elif FLEXT_SYS == FLEXT_SYS_MAX //! Bind object to a symbol bool Bind(const t_symbol *s) { if(s->s_thing) return false; else { const_cast(s)->s_thing = (t_object *)thisHdr(); return true; } } //! Unbind object from a symbol bool Unbind(const t_symbol *s) { if(s->s_thing != (t_object *)thisHdr()) return false; else { const_cast(s)->s_thing = NULL; return true; } } #endif + +#if FLEXT_SYS == FLEXT_SYS_JMAX + //! Bind object to a symbol (as string) + bool Bind(const char *c); // ** TODO ** + //! Unbind object from a symbol (as string) + bool Unbind(const char *c); // ** TODO ** +#else //! Bind object to a symbol (as string) bool Bind(const char *c) { return Bind(MakeSymbol(c)); } //! Unbind object from a symbol (as string) bool Unbind(const char *c) { return Unbind(MakeSymbol(c)); } +#endif /* // Low level @@ -619,8 +633,10 @@ private: xlet *inlist,*outlist; const t_symbol *curtag; int incnt,outcnt,insigs,outsigs; - outlet **outlets,*outattr; bool distmsgs; +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + outlet **outlets; +#endif void AddXlet(xlet::type tp,int mult,const char *desc,xlet *&root); void DescXlet(int ix,const char *desc,xlet *&root); @@ -673,8 +689,12 @@ private: class qmsg; qmsg *qhead,*qtail; +#if FLEXT_SYS == FLEXT_SYS_JMAX + static void QTick(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); +#else t_qelem *qclk; static void QTick(flext_base *th); +#endif void Queue(qmsg *m); #ifdef FLEXT_THREADS ThrMutex qmutex; @@ -711,9 +731,9 @@ 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 + +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX static void cb_px_anything(t_class *c,const t_symbol *s,int argc,t_atom *argv); static void cb_px_ft1(t_class *c,float f); @@ -727,6 +747,9 @@ private: static void cb_px_ft9(t_class *c,float f); px_object **inlets; +#elif FLEXT_SYS == FLEXT_SYS_JMAX + static void jmax_proxy(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); +#endif static void SetProxies(t_class *c); @@ -735,9 +758,13 @@ private: // callback functions +#if FLEXT_SYS == FLEXT_SYS_JMAX + static void cb_help(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); +#else static void cb_help(t_class *c); - static void cb_loadbang(t_class *c); +#endif + #if FLEXT_SYS == FLEXT_SYS_MAX char **indesc,**outdesc; diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp index 7f845074..13eab25d 100644 --- a/externals/grill/flext/source/fldsp.cpp +++ b/externals/grill/flext/source/fldsp.cpp @@ -20,6 +20,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. // === flext_dsp ============================================== +#if FLEXT_SYS == FLEXT_SYS_JMAX +const t_symbol *flext_dsp::dspsym = MakeSymbol("__flext_dspfun__"); +#endif + void flext_dsp::Setup(t_classid id) { t_class *c = getClass(id); @@ -27,27 +31,35 @@ void flext_dsp::Setup(t_classid id) #if FLEXT_SYS == FLEXT_SYS_MAX // dsp_initclass(); dsp_initboxclass(); -#endif - -#if FLEXT_SYS == FLEXT_SYS_PD - CLASS_MAINSIGNALIN(c,flext_hdr,defsig); -#endif - add_dsp(c,cb_dsp); -#if FLEXT_SYS != FLEXT_SYS_MAX +#elif FLEXT_SYS == FLEXT_SYS_PD + CLASS_MAINSIGNALIN(c,flext_hdr,defsig); // float messages going into the left inlet are converted to signal + add_dsp(c,cb_dsp); add_method1(c,cb_enable,"enable",A_FLOAT); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + fts_dsp_declare_function(dspsym,dspmeth); + fts_class_message_varargs(c, fts_s_put, cb_dsp); + fts_class_message_varargs(c, MakeSymbol("enable"), cb_enable); #endif } flext_dsp::flext_dsp(): +#if FLEXT_SYS == FLEXT_SYS_JMAX + srate(fts_dsp_get_sample_rate()), // should we set it? + blksz(fts_dsp_get_tick_size()), +#else srate(sys_getsr()), // should we set it? blksz(sys_getblksize()), +#endif #if FLEXT_SYS == FLEXT_SYS_PD chnsin(sys_get_inchannels()), chnsout(sys_get_outchannels()), #elif FLEXT_SYS == FLEXT_SYS_MAX chnsin(sys_getch()), chnsout(sys_getch()), +#elif FLEXT_SYS == FLEXT_SYS_JMAX + #pragma message("not implemented") + chnsin(0),chnsout(0), #else #error #endif @@ -55,16 +67,27 @@ flext_dsp::flext_dsp(): dspon(true), #endif invecs(NULL),outvecs(NULL) -{} +{ +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_dsp_object_init(thisHdr()); +#endif +} flext_dsp::~flext_dsp() { +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_dsp_object_delete(thisHdr()); +#endif if(invecs) delete[] invecs; if(outvecs) delete[] outvecs; } - +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_dsp::dspmeth(fts_word_t *w) +{ +} +#else t_int *flext_dsp::dspmeth(t_int *w) { flext_dsp *obj = (flext_dsp *)w[1]; @@ -76,30 +99,35 @@ t_int *flext_dsp::dspmeth(t_int *w) obj->m_signal((int)w[2],obj->invecs,obj->outvecs); return w+3; } +#endif -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 *outs) -{ - for(int i = 0; i < CntOutSig(); ++i) - memset(outs[i],0,n*sizeof(*outs[i])); -} - +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_dsp::cb_dsp(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at) +#else void flext_dsp::cb_dsp(t_class *c,t_signal **sp) +#endif { flext_dsp *obj = thisObject(c); if(obj->CntInSig()+obj->CntOutSig() == 0) return; // store current dsp parameters +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_dsp_descr_t *dsp = (fts_dsp_descr_t *)fts_get_pointer(at+0); + obj->srate = fts_dsp_get_input_srate(dsp,0); + obj->blksz = fts_dsp_get_input_size(dsp,0); // is this guaranteed to be the same as sys_getblksize() ? +#else obj->srate = sp[0]->s_sr; obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ? +#endif #if FLEXT_SYS == FLEXT_SYS_PD obj->chnsin = sys_get_inchannels(); obj->chnsout = sys_get_outchannels(); #elif FLEXT_SYS == FLEXT_SYS_MAX obj->chnsin = obj->chnsout = sys_getch(); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + #pragma message ("How to query the channels?") #else #error #endif @@ -107,22 +135,70 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp) // store in and out signal vectors int i,in = obj->CntInSig(),out = obj->CntOutSig(); if(obj->invecs) delete[] obj->invecs; - obj->invecs = new t_sample *[in]; - for(i = 0; i < in; ++i) obj->invecs[i] = sp[i]->s_vec; + obj->invecs = new t_signalvec[in]; + for(i = 0; i < in; ++i) + obj->invecs[i] = +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_dsp_get_input_name(dsp,i); +#else + sp[i]->s_vec; +#endif if(obj->outvecs) delete[] obj->outvecs; - obj->outvecs = new t_sample *[out]; - for(i = 0; i < out; ++i) obj->outvecs[i] = sp[in+i]->s_vec; + obj->outvecs = new t_signalvec[out]; + for(i = 0; i < out; ++i) + obj->outvecs[i] = +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_dsp_get_output_name(dsp,i); +#else + sp[in+i]->s_vec; +#endif // with the following call derived classes can do their eventual DSP setup - obj->m_dsp(sp[0]->s_n,obj->invecs,obj->outvecs); + obj->m_dsp(obj->blksz,obj->invecs,obj->outvecs); // set the DSP function - dsp_add((t_dspmethod)dspmeth,2,obj,sp[0]->s_n); +#if FLEXT_SYS == FLEXT_SYS_JMAX + fts_atom_t args[2]; + fts_set_pointer(args+0,obj); + fts_set_int(args+1,obj->blksz); + fts_dsp_add_function(dspsym,2,args); +#else + dsp_add((t_dspmethod)dspmeth,2,obj,obj->blksz); +#endif +} + +/* +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_dsp::cb_dsp_init(fts_object_t *c, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at) +{ + fts_dsp_add_object(c); +} + +void flext_dsp::cb_dsp_delete(fts_object_t *c, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at) +{ + fts_dsp_remove_object(c); +} +#endif +*/ + +void flext_dsp::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec 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(outs[i],0,n*sizeof(*outs[i])); } #if FLEXT_SYS != FLEXT_SYS_MAX + +#if FLEXT_SYS == FLEXT_SYS_PD void flext_dsp::cb_enable(t_class *c,t_float on) { thisObject(c)->m_enable(on != 0); } +#elif FLEXT_SYS == FLEXT_SYS_JMAX +void flext_dsp::cb_enable(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at) +{ thisObject(c)->m_enable(fts_get_int(at+0) != 0); } +#endif + 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 b0cb7f01..80631531 100644 --- a/externals/grill/flext/source/fldsp.h +++ b/externals/grill/flext/source/fldsp.h @@ -57,8 +57,14 @@ public: */ int ChannelsOut() const { return chnsout; } -//! @} + //! typedef describing a signal vector +#if FLEXT_SYS == FLEXT_SYS_JMAX + typedef fts_symbol_t t_signalvec; +#else + typedef t_sample *t_signalvec; +#endif +//! @} // --- inheritable virtual methods -------------------------------- @@ -73,7 +79,7 @@ public: \param insigs: array of input vectors (get number with function CntInSig()) \param outsigs: array of output vectors (get number with function CntOutSig()) */ - virtual void m_dsp(int n,t_sample *const *insigs,t_sample *const *outsigs); + virtual void m_dsp(int n,t_signalvec const *insigs,t_signalvec const *outsigs); /*! \brief Called with every signal vector - here you do the dsp calculation @@ -141,16 +147,32 @@ private: // callback functions +#if FLEXT_SYS == FLEXT_SYS_JMAX + static void cb_dsp(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); +// static void cb_dsp_init(fts_object_t *o, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at); +// static void cb_dsp_delete(fts_object_t *o, int winlet, fts_symbol_t *s, int ac, const fts_atom_t *at); +#else static void cb_dsp(t_class *c,t_signal **s); +#endif + #if FLEXT_SYS != FLEXT_SYS_MAX +#if FLEXT_SYS == FLEXT_SYS_JMAX + static void cb_enable(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); +#else static void cb_enable(t_class *c,t_float on); +#endif bool dspon; #endif // dsp stuff +#if FLEXT_SYS == FLEXT_SYS_JMAX + static void dspmeth(fts_word_t *); + static const t_symbol *dspsym; +#else static t_int *dspmeth(t_int *w); - t_sample **invecs,**outvecs; +#endif + t_signalvec *invecs,*outvecs; }; #endif diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp index baf33c42..c2cd59c4 100644 --- a/externals/grill/flext/source/flext.cpp +++ b/externals/grill/flext/source/flext.cpp @@ -25,9 +25,10 @@ flext_base::flext_base(): curtag(NULL), incnt(0),outcnt(0), insigs(0),outsigs(0), - outlets(NULL),outattr(NULL), - distmsgs(false), - inlets(NULL) + distmsgs(false) +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + ,outlets(NULL),inlets(NULL) +#endif #if FLEXT_SYS == FLEXT_SYS_MAX ,indesc(NULL),outdesc(NULL) #endif @@ -48,7 +49,9 @@ flext_base::flext_base(): // message queue ticker qhead = qtail = NULL; +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX qclk = (t_qelem *)(qelem_new(this,(t_method)QTick)); +#endif } flext_base::~flext_base() @@ -58,8 +61,14 @@ flext_base::~flext_base() #endif // send remaining pending messages and destroy queue ticker +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX while(qhead) QTick(this); qelem_free((t_qelem *)qclk); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + while(qhead) QTick((fts_object_t *)thisHdr(),0,NULL,0,NULL); + // this is dangerous because there may be other timers on this object! + fts_timebase_remove_object(fts_get_timebase(), (fts_object_t *)thisHdr()); +#endif // delete message lists if(methhead) delete methhead; @@ -68,6 +77,8 @@ flext_base::~flext_base() // destroy inlets and outlets and their proxy objects if(inlist) delete inlist; if(outlist) delete outlist; + +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX if(outlets) delete[] outlets; if(inlets) { @@ -82,6 +93,7 @@ flext_base::~flext_base() } delete[] inlets; } +#endif #if FLEXT_SYS == FLEXT_SYS_MAX if(indesc) { @@ -139,11 +151,16 @@ void flext_base::Setup(t_classid id) { t_class *c = getClass(id); +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX add_method(c,cb_help,"help"); add_loadbang(c,cb_loadbang); #if FLEXT_SYS == FLEXT_SYS_MAX add_assist(c,cb_assist); #endif +#else + fts_class_message_varargs(c,MakeSymbol("help"),cb_help); + #pragma message ("no implementation of loadbang or assist") +#endif if(process_attributes) AddMethod(id,0,"getattributes",(methfun)cb_ListAttrib); @@ -156,9 +173,12 @@ void flext_base::Setup(t_classid id) #endif } +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_base::cb_help(fts_object_t *c,int, fts_symbol_t, int, const fts_atom_t *) { thisObject(c)->m_help(); } +#else void flext_base::cb_help(t_class *c) { thisObject(c)->m_help(); } - void flext_base::cb_loadbang(t_class *c) { thisObject(c)->m_loadbang(); } +#endif void flext_base::m_help() { diff --git a/externals/grill/flext/source/flinternal.h b/externals/grill/flext/source/flinternal.h index 016a0bd7..af88cbca 100644 --- a/externals/grill/flext/source/flinternal.h +++ b/externals/grill/flext/source/flinternal.h @@ -112,6 +112,9 @@ typedef t_perfroutine t_dspmethod; #define CRITON() short state = lockout_set(1) #define CRITOFF() lockout_set(state) +#elif FLEXT_SYS == FLEXT_SYS_JMAX + + #endif diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp index 2d3aaa4c..998cbae3 100755 --- a/externals/grill/flext/source/fllib.cpp +++ b/externals/grill/flext/source/fllib.cpp @@ -78,7 +78,7 @@ static const char *extract(const char *name,int ix = 0) //! Check if object's name ends with a tilde -static bool chktilde(const char *objname) +bool flext::chktilde(const char *objname) { // int stplen = strlen(setupfun); bool tilde = true; //!strncmp(setupfun,"_tilde",6); @@ -202,6 +202,13 @@ void flext_obj::lib_init(const char *name,void setupfun(),bool attr) setupfun(); } +#if FLEXT_SYS == FLEXT_SYS_JMAX +static void jmax_class_inst(t_class *cl) +{ + fts_class_init(cl, sizeof(flext_hdr),flext_obj::obj_new,flext_obj::obj_free); +} +#endif + void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),flext_obj *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...) { // get first possible object name @@ -235,6 +242,8 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha // attention: in Max/MSP the *cl variable is not initialized after that call. // just the address is stored, the initialization then occurs with the first object instance! } +#elif FLEXT_SYS == FLEXT_SYS_JMAX + *cl = fts_class_install(nsym, jmax_class_inst); #else #error #endif @@ -248,7 +257,7 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha // post("ADDCLASS %p -> LIBOBJ %p -> %p",*cl,lo,lo->clss); // parse the argument type list and store it with the object - if(argtp1 == A_GIMME) + if(argtp1 == FLEXTTPN_VAR) lo->argc = -1; else { int argtp,i; @@ -256,7 +265,7 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha // parse a first time and count only va_start(marker,argtp1); - for(argtp = argtp1; argtp != A_NULL; ++lo->argc) argtp = (int)va_arg(marker,int); + for(argtp = argtp1; argtp != FLEXTTPN_NULL; ++lo->argc) argtp = (int)va_arg(marker,int); va_end(marker); lo->argv = new int[lo->argc]; @@ -271,7 +280,7 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha } // get unique class id -#if FLEXT_SYS == FLEXT_SYS_PD +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_JMAX t_classid clid = lo->clss; #else // in Max/MSP the t_class *value can't be used because it's possible that's it's not yet set!! @@ -299,6 +308,8 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha // 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(c)); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + if(ix > 0) fts_class_alias(lo->clss,l->name); #else #error #endif @@ -311,9 +322,15 @@ void flext_obj::obj_add(bool lib,bool dsp,bool attr,const char *idname,const cha typedef flext_obj *(*libfun)(int,t_atom *); +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_obj::obj_new(fts_object_t *o, int, fts_symbol_t s, int _argc_, const fts_atom_t *argv) +{ + flext_hdr *obj = (flext_hdr *)o; +#else flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) { flext_hdr *obj = NULL; +#endif libname *l = libname::Find(s); if(l) { bool ok = true; @@ -333,19 +350,19 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) if(argc == lo->argc) { for(int i = 0; /*ok &&*/ i < lo->argc; ++i) { switch(lo->argv[i]) { -#if FLEXT_SYS == FLEXT_SYS_MAX - case A_INT: +#if FLEXT_SYS != FLEXT_SYS_PD + case FLEXTTPN_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])); else ok = false; break; #endif - case A_FLOAT: + case FLEXTTPN_FLOAT: if(flext::IsInt(argv[i])) flext::SetFloat(args[i],(float)flext::GetInt(argv[i])); else if(flext::IsFloat(argv[i])) args[i] = argv[i]; else ok = false; break; - case A_SYMBOL: + case FLEXTTPN_SYM: if(flext::IsSymbol(argv[i])) args[i] = argv[i]; else ok = false; break; @@ -353,10 +370,10 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) } if(!ok) - post("%s: Creation arguments do not match",s->s_name); + post("%s: Creation arguments do not match",GetString(s)); } else { - error("%s: %s creation arguments",s->s_name,argc < lo->argc?"Not enough":"Too many"); + error("%s: %s creation arguments",GetString(s),argc < lo->argc?"Not enough":"Too many"); ok = false; } } @@ -370,6 +387,8 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) #elif FLEXT_SYS == FLEXT_SYS_MAX clid = lo; obj = (flext_hdr *)::newobject(lo->clss); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + clid = lo->clss; #else #error #endif @@ -384,7 +403,7 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) // for interpreted arguments obj->data = lo->newfun(lo->argc,args); else - obj->data = lo->newfun(argc,argv); + obj->data = lo->newfun(argc,(t_atom *)argv); flext_obj::m_holder = NULL; flext_obj::m_holdname = NULL; @@ -426,11 +445,18 @@ flext_hdr *flext_obj::obj_new(const t_symbol *s,int _argc_,t_atom *argv) error("Class %s not found in library!",s->s_name); #endif +#if FLEXT_SYS != FLEXT_SYS_JMAX return obj; +#endif } -void flext_obj::obj_free(flext_hdr *hdr) +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_obj::obj_free(fts_object_t *h, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at) +#else +void flext_obj::obj_free(flext_hdr *h) +#endif { + flext_hdr *hdr = (flext_hdr *)h; const t_symbol *name = hdr->data->thisNameSym(); libname *l = libname::Find(name); diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index f8fb1fe1..c745924c 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -16,22 +16,43 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flinternal.h" #include +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + +#ifndef FLEXT_THREADS +void flext_base::ToOutBang(int n) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_bang((t_outlet *)o); CRITOFF(); } } +void flext_base::ToOutFloat(int n,float f) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_float((t_outlet *)o,f); CRITOFF(); } } +void flext_base::ToOutInt(int n,int f) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_flint((t_outlet *)o,f); CRITOFF(); } } +void flext_base::ToOutSymbol(int n,const t_symbol *s) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_symbol((t_outlet *)o,const_cast(s)); CRITOFF(); } } +void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_list((t_outlet *)o,const_cast(sym_list),argc,(t_atom *)argv); CRITOFF(); } } +void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_anything((t_outlet *)o,const_cast(s),argc,(t_atom *)argv); CRITOFF(); } } +#else +void flext_base::ToOutBang(int n) const { if(IsSystemThread()) { outlet *o = GetOut(n); if(o) { CRITON(); outlet_bang((t_outlet *)o); CRITOFF(); } } else ToQueueBang(n); } +void flext_base::ToOutFloat(int n,float f) const { if(IsSystemThread()) { outlet *o = GetOut(n); if(o) { CRITON(); outlet_float((t_outlet *)o,f); CRITOFF(); } } else ToQueueFloat(n,f); } +void flext_base::ToOutInt(int n,int f) const { if(IsSystemThread()) { outlet *o = GetOut(n); if(o) { CRITON(); outlet_flint((t_outlet *)o,f); CRITOFF(); } } else ToQueueInt(n,f); } +void flext_base::ToOutSymbol(int n,const t_symbol *s) const { if(IsSystemThread()) { outlet *o = GetOut(n); if(o) { CRITON(); outlet_symbol((t_outlet *)o,const_cast(s)); CRITOFF(); } } else ToQueueSymbol(n,s); } +void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { if(IsSystemThread()) { outlet *o = GetOut(n); if(o) { CRITON(); outlet_list((t_outlet *)o,const_cast(sym_list),argc,(t_atom *)argv); CRITOFF(); } } else ToQueueList(n,argc,(t_atom *)argv); } +void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(IsSystemThread()) { outlet *o = GetOut(n); if(o) { CRITON(); outlet_anything((t_outlet *)o,const_cast(s),argc,(t_atom *)argv); CRITOFF(); } } else ToQueueAnything(n,s,argc,(t_atom *)argv); } +#endif + +#elif FLEXT_SYS == FLEXT_SYS_JMAX + #ifndef FLEXT_THREADS -void flext_base::ToOutBang(outlet *o) const { CRITON(); outlet_bang((t_outlet *)o); CRITOFF(); } -void flext_base::ToOutFloat(outlet *o,float f) const { CRITON(); outlet_float((t_outlet *)o,f); CRITOFF(); } -void flext_base::ToOutInt(outlet *o,int f) const { CRITON(); outlet_flint((t_outlet *)o,f); CRITOFF(); } -void flext_base::ToOutSymbol(outlet *o,const t_symbol *s) const { CRITON(); outlet_symbol((t_outlet *)o,const_cast(s)); CRITOFF(); } -void flext_base::ToOutList(outlet *o,int argc,const t_atom *argv) const { CRITON(); outlet_list((t_outlet *)o,gensym("list"),argc,(t_atom *)argv); CRITOFF(); } -void flext_base::ToOutAnything(outlet *o,const t_symbol *s,int argc,const t_atom *argv) const { CRITON(); outlet_anything((t_outlet *)o,const_cast(s),argc,(t_atom *)argv); CRITOFF(); } +void flext_base::ToOutBang(int n) const { fts_outlet_bang((fts_object *)thisHdr(),n); } +void flext_base::ToOutFloat(int n,float f) const { fts_outlet_float((fts_object *)thisHdr(),n,f); } +void flext_base::ToOutInt(int n,int f) const { fts_outlet_int((fts_object *)thisHdr(),n,f); } +void flext_base::ToOutSymbol(int n,const t_symbol *s) const { fts_outlet_symbol((fts_object *)thisHdr(),n,s); } +void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { fts_outlet_send((fts_object *)thisHdr(),n,sym_list,argc,(t_atom *)argv); } +void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { fts_outlet_send((fts_object *)thisHdr(),n,const_cast(s),argc,(t_atom *)argv); } #else -void flext_base::ToOutBang(outlet *o) const { if(IsSystemThread()) { CRITON(); outlet_bang((t_outlet *)o); CRITOFF(); } else ToQueueBang(o); } -void flext_base::ToOutFloat(outlet *o,float f) const { if(IsSystemThread()) { CRITON(); outlet_float((t_outlet *)o,f); CRITOFF(); } else ToQueueFloat(o,f); } -void flext_base::ToOutInt(outlet *o,int f) const { if(IsSystemThread()) { CRITON(); outlet_flint((t_outlet *)o,f); CRITOFF(); } else ToQueueInt(o,f); } -void flext_base::ToOutSymbol(outlet *o,const t_symbol *s) const { if(IsSystemThread()) { CRITON(); outlet_symbol((t_outlet *)o,const_cast(s)); CRITOFF(); } else ToQueueSymbol(o,s); } -void flext_base::ToOutList(outlet *o,int argc,const t_atom *argv) const { if(IsSystemThread()) { CRITON(); outlet_list((t_outlet *)o,gensym("list"),argc,(t_atom *)argv); CRITOFF(); } else ToQueueList(o,argc,(t_atom *)argv); } -void flext_base::ToOutAnything(outlet *o,const t_symbol *s,int argc,const t_atom *argv) const { if(IsSystemThread()) { CRITON(); outlet_anything((t_outlet *)o,const_cast(s),argc,(t_atom *)argv); CRITOFF(); } else ToQueueAnything(o,s,argc,(t_atom *)argv); } +void flext_base::ToOutBang(int n) const { if(IsSystemThread()) fts_outlet_bang((fts_object *)thisHdr(),n); else ToQueueBang(n); } +void flext_base::ToOutFloat(int n,float f) const { if(IsSystemThread()) fts_outlet_float((fts_object *)thisHdr(),n,f); else ToQueueFloat(n,f); } +void flext_base::ToOutInt(int n,int f) const { if(IsSystemThread()) fts_outlet_int((fts_object *)thisHdr(),n,f); else ToQueueInt(n,f); } +void flext_base::ToOutSymbol(int n,const t_symbol *s) const { if(IsSystemThread()) fts_outlet_symbol((fts_object *)thisHdr(),n,s); else ToQueueSymbol(n,s); } +void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { if(IsSystemThread()) fts_outlet_send((fts_object *)thisHdr(),n,sym_list,argc,(t_atom *)argv); else ToQueueList(n,argc,(t_atom *)argv); } +void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(IsSystemThread()) fts_outlet_send((fts_object *)thisHdr(),n,const_cast(s),argc,(t_atom *)argv); else ToQueueAnything(n,s,argc,(t_atom *)argv); } #endif +#endif bool flext_base::InitInlets() { @@ -68,8 +89,10 @@ bool flext_base::InitInlets() delete inlist; inlist = NULL; +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX inlets = new px_object *[incnt]; for(i = 0; i < incnt; ++i) inlets[i] = NULL; +#endif // type info is now in list array #if FLEXT_SYS == FLEXT_SYS_PD @@ -195,6 +218,43 @@ bool flext_base::InitInlets() // dsp_setup(thisHdr(),insigs); // signal inlets dsp_setupbox(thisHdr(),insigs); // signal inlets } +#elif FLEXT_SYS == FLEXT_SYS_JMAX + { + t_class *cl = thisClass(); + int cnt = 0; + for(int ix = 0; ix < incnt; ++ix,++cnt) { + switch(list[ix]) { + case xlet::tp_float: + case xlet::tp_int: +// fts_class_inlet_number(cl, ix, jmax_proxy); + break; + case xlet::tp_sym: +// fts_class_inlet_symbol(cl, ix, jmax_proxy); + break; + case xlet::tp_sig: + if(compatibility && list[ix-1] != xlet::tp_sig) { + post("%s: All signal inlets must be left-aligned in compatibility mode",thisName()); + ok = false; + } + else { + if(!insigs) fts_dsp_declare_inlet(cl,0); + ++insigs; + } + // no break -> let a signal inlet also accept any messages + case xlet::tp_list: + case xlet::tp_any: +// fts_class_inlet_varargs(cl,ix, jmax_proxy); + break; + default: + error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]); + ok = false; + } + } + + incnt = cnt; + + fts_object_set_inlets_number((fts_object_t *)thisHdr(), incnt); + } #else #error #endif @@ -217,8 +277,9 @@ bool flext_base::InitOutlets() #if FLEXT_SYS == FLEXT_SYS_MAX // for Max/MSP the rightmost outlet has to be created first + outlet *attrtmp = NULL; if(procattr) - outattr = (outlet *)newout_anything(&x_obj->obj); + attrtmp = (outlet *)newout_anything(thisHdr()); #endif if(outlist) { @@ -249,7 +310,8 @@ bool flext_base::InitOutlets() delete outlist; outlist = NULL; - outlets = new outlet *[outcnt]; +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX + outlets = new outlet *[outcnt+(procattr?1:0)]; // type info is now in list array #if FLEXT_SYS == FLEXT_SYS_PD @@ -284,17 +346,50 @@ bool flext_base::InitOutlets() default: ERRINTERNAL(); ok = false; +#endif + } + } +#elif FLEXT_SYS == FLEXT_SYS_JMAX + t_class *cl = thisClass(); + for(int ix = 0; ix < outcnt; ++ix) { + switch(list[ix]) { + case xlet::tp_float: + case xlet::tp_int: +// fts_class_outlet_number(cl, ix); + break; + case xlet::tp_sym: +// fts_class_outlet_symbol(cl, ix); + break; + case xlet::tp_list: + case xlet::tp_any: +// fts_class_outlet_anything(cl, ix); + break; + case xlet::tp_sig: + if(!outsigs) fts_dsp_declare_outlet(cl,0); + ++outsigs; + break; +#ifdef FLEXT_DEBUG + default: + ERRINTERNAL(); + ok = false; #endif } } + fts_object_set_outlets_number((fts_object_t *)thisHdr(), outcnt); +#endif + delete[] list; } if(procattr) { + // attribute dump outlet is the last one + outlets[outcnt] = #if FLEXT_SYS == FLEXT_SYS_PD // attribute dump outlet is the last one - outattr = (outlet *)newout_anything(&x_obj->obj); + (outlet *)newout_anything(&x_obj->obj); +#elif FLEXT_SYS == FLEXT_SYS_MAX + attrtmp; #endif } diff --git a/externals/grill/flext/source/flproxy.cpp b/externals/grill/flext/source/flproxy.cpp index 185700a5..75bbc897 100755 --- a/externals/grill/flext/source/flproxy.cpp +++ b/externals/grill/flext/source/flproxy.cpp @@ -84,10 +84,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) -#else -#error // Other system #endif +#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX DEF_IN_FT(1) DEF_IN_FT(2) @@ -99,7 +98,6 @@ DEF_IN_FT(7) DEF_IN_FT(8) DEF_IN_FT(9) - void flext_base::SetProxies(t_class *c) { // proxy for extra inlets @@ -129,4 +127,18 @@ void flext_base::SetProxies(t_class *c) ADD_IN_FT(9); } +#elif FLEXT_SYS == FLEXT_SYS_JMAX +void flext_base::jmax_proxy(fts_object_t *c, int winlet, fts_symbol_t s, int argc, const fts_atom_t *argv) +{ + flext_base *o = thisObject(c); + o->m_methodmain(winlet,s,argc,argv); +} + +void flext_base::SetProxies(t_class *c) +{ + fts_class_set_default_handler(c, jmax_proxy); +} + +#endif + diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 8c3be318..13cada78 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -25,14 +25,14 @@ public: void Clear(); - void SetBang(outlet *o) { Clear(); out = o; tp = tp_bang; } - void SetFloat(outlet *o,float f) { Clear(); out = o; tp = tp_float; _float = f; } - void SetInt(outlet *o,int i) { Clear(); out = o; tp = tp_int; _int = i; } - void SetSymbol(outlet *o,const t_symbol *s) { Clear(); out = o; tp = tp_sym; _sym = s; } - void SetList(outlet *o,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_list; _list.argc = argc,_list.argv = CopyList(argc,argv); } - void SetAny(outlet *o,const t_symbol *s,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_any; _any.s = s,_any.argc = argc,_any.argv = CopyList(argc,argv); } - - outlet *out; + void SetBang(int o) { Clear(); out = o; tp = tp_bang; } + void SetFloat(int o,float f) { Clear(); out = o; tp = tp_float; _float = f; } + void SetInt(int o,int i) { Clear(); out = o; tp = tp_int; _int = i; } + void SetSymbol(int o,const t_symbol *s) { Clear(); out = o; tp = tp_sym; _sym = s; } + void SetList(int o,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_list; _list.argc = argc,_list.argv = CopyList(argc,argv); } + void SetAny(int o,const t_symbol *s,int argc,const t_atom *argv) { Clear(); out = o; tp = tp_any; _any.s = s,_any.argc = argc,_any.argv = CopyList(argc,argv); } + + int out; enum { tp_none,tp_bang,tp_float,tp_int,tp_sym,tp_list,tp_any } tp; union { float _float; @@ -56,8 +56,14 @@ void flext_base::qmsg::Clear() tp = tp_none; } +#if FLEXT_SYS == FLEXT_SYS_JMAX +void flext_base::QTick(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at) +{ + flext_base *th = thisObject(c); +#else void flext_base::QTick(flext_base *th) { +#endif // post("qtick"); #if defined(FLEXT_THREADS) && defined(FLEXT_DEBUG) if(!th->IsSystemThread()) { @@ -73,8 +79,6 @@ void flext_base::QTick(flext_base *th) qmsg *m = th->qhead; if(!m) break; - CRITON(); - switch(m->tp) { case qmsg::tp_bang: th->ToOutBang(m->out); break; case qmsg::tp_float: th->ToOutFloat(m->out,m->_float); break; @@ -87,8 +91,6 @@ void flext_base::QTick(flext_base *th) #endif } - CRITOFF(); - th->qhead = m->nxt; if(!th->qhead) th->qtail = NULL; m->nxt = NULL; @@ -117,48 +119,50 @@ void flext_base::Queue(qmsg *m) clock_delay(qclk,0); #elif FLEXT_SYS == FLEXT_SYS_MAX qelem_set(qclk); +#elif FLEXT_SYS == FLEXT_SYS_JMAX + // this is dangerous because there may be other timers on this object! + fts_timebase_add_call(fts_get_timebase(), (fts_object_t *)thisHdr(), QTick, NULL, 0); #else -#error +#error #endif - } -void flext_base::ToQueueBang(outlet *o) const +void flext_base::ToQueueBang(int o) const { qmsg *m = new qmsg(); m->SetBang(o); const_cast(*this).Queue(m); } -void flext_base::ToQueueFloat(outlet *o,float f) const +void flext_base::ToQueueFloat(int o,float f) const { qmsg *m = new qmsg; m->SetFloat(o,f); const_cast(*this).Queue(m); } -void flext_base::ToQueueInt(outlet *o,int f) const +void flext_base::ToQueueInt(int o,int f) const { qmsg *m = new qmsg; m->SetInt(o,f); const_cast(*this).Queue(m); } -void flext_base::ToQueueSymbol(outlet *o,const t_symbol *s) const +void flext_base::ToQueueSymbol(int o,const t_symbol *s) const { qmsg *m = new qmsg; m->SetSymbol(o,s); const_cast(*this).Queue(m); } -void flext_base::ToQueueList(outlet *o,int argc,const t_atom *argv) const +void flext_base::ToQueueList(int o,int argc,const t_atom *argv) const { qmsg *m = new qmsg; m->SetList(o,argc,argv); const_cast(*this).Queue(m); } -void flext_base::ToQueueAnything(outlet *o,const t_symbol *s,int argc,const t_atom *argv) const +void flext_base::ToQueueAnything(int o,const t_symbol *s,int argc,const t_atom *argv) const { qmsg *m = new qmsg; m->SetAny(o,s,argc,argv); diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index aedcdf83..e36ec4e4 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -54,7 +54,6 @@ typedef t_object t_sigobj; typedef t_gpointer *t_ptrtype; typedef t_float t_flint; -typedef t_symbol *t_symptr; typedef t_symbol *t_symtype; typedef t_class **t_thing; @@ -97,7 +96,6 @@ typedef t_pxbox t_sigobj; // that's the all-in-one object type of Max/MSP (not typedef t_patcher t_canvas; typedef t_int t_flint; -typedef t_symbol *t_symptr; typedef t_symbol *t_symtype; typedef t_object *t_thing; @@ -124,8 +122,46 @@ typedef void t_binbuf; #define A_SYMBOL A_SYM #endif -#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 diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp index ecc39153..3c6ab8f3 100644 --- a/externals/grill/flext/source/flsupport.cpp +++ b/externals/grill/flext/source/flsupport.cpp @@ -18,10 +18,13 @@ 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_anything = 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 @@ -43,8 +46,14 @@ void flext::Setup() 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 -#error #endif } @@ -69,10 +78,10 @@ void *flext::operator new(size_t bytes) void flext::operator delete(void *blk) { char *ori = (char *)blk-sizeof(size_t); - size_t bytes = *(size_t *)ori; #if FLEXT_SYS == FLEXT_SYS_JMAX - ::fts_free(ori); + fts_free(ori); #else + size_t bytes = *(size_t *)ori; ::freebytes(ori,bytes); #endif } @@ -96,11 +105,11 @@ void *flext::NewAligned(size_t bytes,int bitalign) 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)); #if FLEXT_SYS == FLEXT_SYS_JMAX - ::fts_free(ori); + fts_free(ori); #else + size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); ::freebytes(ori,bytes); #endif } diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 56c43bc6..3f771ea0 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -33,16 +33,13 @@ class FLEXT_SHARE flext { */ public: -// --- types ------------------------------------------------------- +// --- console output ----------------------------------------------- #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; + //! post message to console + static void post(const char *s,...); + //! post error message to console + static void error(const char *s,...); #endif // --- memory ------------------------------------------------------- @@ -76,6 +73,9 @@ public: @{ */ +// not for Jmax at the moment +#if FLEXT_SYS != FLEXT_SYS_JMAX + //! Class for platform independent buffer handling class FLEXT_SHARE buffer { @@ -112,7 +112,7 @@ public: t_symbol *Symbol() const { return const_cast(sym); } //! Get literal name of buffer - const char *Name() const { return sym?sym->s_name:""; } + const char *Name() const { return sym?GetString(sym):""; } /*! \brief Get pointer to buffer, channel and frame count. \remark Channels are interleaved @@ -144,6 +144,8 @@ public: #endif }; +#endif // jmax + //! @} FLEXT_S_BUFFER // --- utilities -------------------------------------------------- @@ -235,15 +237,15 @@ public: #if FLEXT_SYS == FLEXT_SYS_JMAX //! Set atom from another atom - static int GetType(const t_atom &a) // ** TODO ** + static int GetType(const t_atom &a); // ** TODO ** //! Check whether the atom is nothing - static bool IsNothing(const t_atom &a) // ** TODO ** + static bool IsNothing(const t_atom &a) { return fts_is_a(&a,fts_void_class); } //! Set the atom to represent nothing - static void SetNothing(t_atom &a) // ** TODO ** + static void SetNothing(t_atom &a) { fts_set_void(&a); } //! Check whether the atom is a float - static bool IsFloat(const t_atom &a) // ** TODO ** + static bool IsFloat(const t_atom &a) { return fts_is_a(&a,fts_float_class); } #else //! Set atom from another atom static int GetType(const t_atom &a) { return a.a_type; } @@ -262,12 +264,12 @@ public: #if FLEXT_SYS == FLEXT_SYS_JMAX //! Access the float value (without type check) - static float GetFloat(const t_atom &a); // ** TODO ** + static float GetFloat(const t_atom &a) { return fts_get_float(&a); } //! Set the atom to represent a float - static void SetFloat(t_atom &a,float v) // ** TODO ** + static void SetFloat(t_atom &a,float v) { fts_set_float(&a,v); } //! Check whether the atom is a symbol - static bool IsSymbol(const t_atom &a) // ** TODO ** + static bool IsSymbol(const t_atom &a) { return fts_is_a(&a,fts_symbol_class); } #else //! Access the float value (without type check) static float GetFloat(const t_atom &a) { return a.a_w.w_float; } @@ -292,7 +294,7 @@ public: //! 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); } + static void SetSymbol(t_atom &a,const t_symbol *s) { fts_set_symbol(&a,s); } #else #error #endif @@ -306,7 +308,7 @@ public: //! Check for a string and get its value static void GetAString(const t_atom &a,char *buf,int szbuf); //! Set the atom to represent a string - static void SetString(t_atom &a,const char *c) { SetSymbol(a,gensym(const_cast(c))); } + static void SetString(t_atom &a,const char *c) { SetSymbol(a,MakeSymbol(c)); } //! Check whether the atom can be represented as an integer static bool CanbeInt(const t_atom &a) { return IsFloat(a) || IsInt(a); } @@ -370,24 +372,24 @@ public: 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 ** + static bool IsInt(const t_atom &a) { return fts_is_a(&a,fts_int_class); } //! Access the integer value (without type check) - static int GetInt(const t_atom &a); // ** TODO ** + static int GetInt(const t_atom &a) { return fts_get_int(&a); } //! 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); } + static void SetInt(t_atom &a,int v) { fts_set_int(&a,v); } //! Check whether the atom strictly is a pointer - static bool IsPointer(const t_atom &); // ** TODO ** + static bool IsPointer(const t_atom &a) { return fts_is_a(&a,fts_pointer_class); } //! 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); } + static void *GetPointer(const t_atom &a) { return fts_get_pointer(&a); } //! Check for a pointer and get its value - static void *GetAPointer(const t_atom &a,void *def = NULL) { return ::fts_get_ptr(&a,def); } + static void *GetAPointer(const t_atom &a,void *def = NULL) { return IsPointer(a)?GetPointer(a):def; } //! Set the atom to represent a pointer - static void SetPointer(t_atom &a,void *p) { ::fts_set_ptr(&a,p); } + static void SetPointer(t_atom &a,void *p) { fts_set_pointer(&a,p); } #else #error "Platform not supported" #endif @@ -459,8 +461,10 @@ public: public AtomList { public: +#if FLEXT_SYS != FLEXT_SYS_JMAX //! Construct anything AtomAnything(const t_symbol *h = NULL,int argc = 0,const t_atom *argv = NULL); +#endif //! Construct anything AtomAnything(const char *h,int argc = 0,const t_atom *argv = NULL); //! Construct anything @@ -803,6 +807,8 @@ protected: friend class flext_obj; #endif static void Setup(); + + static bool chktilde(const char *objname); }; #endif -- cgit v1.2.1