From e4991ce586558b0ff3a06b7c0c4022d2083c4d01 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 15 Apr 2003 02:41:04 +0000 Subject: "" svn path=/trunk/; revision=562 --- externals/grill/dyn/build-pd-linux.sh | 2 +- externals/grill/dyn/config-pd-linux.txt | 3 +- externals/grill/dyn/pd/dyn~.pd | 4 +- externals/grill/dyn/src/main.cpp | 8 +-- externals/grill/flext/flext.cw | Bin 506677 -> 509213 bytes externals/grill/flext/flext.doxy | 2 +- externals/grill/flext/flext.dsp | 4 ++ externals/grill/flext/make-files.txt | 4 +- externals/grill/flext/readme.txt | 6 +- externals/grill/flext/source/flbase.h | 5 ++ externals/grill/flext/source/flbind.cpp | 95 +++++++++++++++++++++++++++ externals/grill/flext/source/flclass.h | 47 +++++++++---- externals/grill/flext/source/flcwmax-thr.h | 6 +- externals/grill/flext/source/flcwmax-x-thr.h | 6 +- externals/grill/flext/source/flcwmax-x.h | 6 +- externals/grill/flext/source/flcwmax.h | 6 +- externals/grill/flext/source/fldefs.h | 22 +++++++ externals/grill/flext/source/flext.cpp | 2 + externals/grill/flext/source/flinternal.h | 14 ++-- externals/grill/flext/source/flitem.cpp | 43 ++++++++++++ externals/grill/flext/source/fllib.cpp | 31 ++++++++- externals/grill/flext/source/flmeth.cpp | 3 +- externals/grill/flext/source/flout.cpp | 6 +- externals/grill/flext/source/flproxy.cpp | 3 +- externals/grill/flext/source/flsupport.h | 44 ++++++------- externals/grill/flext/source/flthr.cpp | 1 + externals/grill/flext/source/fltimer.cpp | 8 +-- externals/grill/py/make-files.txt | 6 ++ externals/grill/py/makefile.pd-bcc | 7 +- externals/grill/py/makefile.pd-darwin | 11 ++-- externals/grill/py/makefile.pd-linux | 9 ++- externals/grill/py/makefile.pd-msvc | 14 ++-- externals/grill/vasp/config-pd-cygwin.txt | 2 +- externals/grill/vasp/make-files.txt | 2 + externals/grill/vasp/makefile.pd-cygwin | 1 - externals/grill/vasp/makefile.pd-darwin | 1 - externals/grill/vasp/makefile.pd-linux | 5 +- externals/grill/vasp/makefile.pd-msvc | 4 +- externals/grill/xsample/xsample.cw | Bin 213671 -> 213671 bytes 39 files changed, 338 insertions(+), 105 deletions(-) create mode 100644 externals/grill/flext/source/flbind.cpp create mode 100644 externals/grill/py/make-files.txt diff --git a/externals/grill/dyn/build-pd-linux.sh b/externals/grill/dyn/build-pd-linux.sh index 413650f7..421cb6e1 100644 --- a/externals/grill/dyn/build-pd-linux.sh +++ b/externals/grill/dyn/build-pd-linux.sh @@ -4,7 +4,7 @@ make -f makefile.pd-linux && { - if [ $INSTPATH != "" ]; then + if [ ${INSTPATH} != "" ]; then echo Now install as root su -c "make -f makefile.pd-linux install" fi diff --git a/externals/grill/dyn/config-pd-linux.txt b/externals/grill/dyn/config-pd-linux.txt index ded839c1..9afaa255 100644 --- a/externals/grill/dyn/config-pd-linux.txt +++ b/externals/grill/dyn/config-pd-linux.txt @@ -10,8 +10,9 @@ # where are the PD source files? # (the normal header file doesn't work as g_canvas.h is not there) +# please note that currently the development branch (e.g devel_0_36) is needed # -PDPATH=/usr/src/pd-0.36-0/src +PDPATH=/home/thomas/prog/pd-devel/src # where do the flext libraries reside? FLEXTPATH=/usr/local/lib/pd/flext diff --git a/externals/grill/dyn/pd/dyn~.pd b/externals/grill/dyn/pd/dyn~.pd index c13f5296..f65c7052 100644 --- a/externals/grill/dyn/pd/dyn~.pd +++ b/externals/grill/dyn/pd/dyn~.pd @@ -1,4 +1,4 @@ -#N canvas 195 68 749 575 12; +#N canvas 195 68 751 577 12; #N canvas 218 20 570 669 examples 0; #X floatatom 153 276 5 0 0 0 - - -; #X floatatom 110 353 5 0 0 0 - - -; @@ -66,7 +66,7 @@ conn 1 a 1 \, conn a 0 b 0 \, conn 2 b 1 \, conn b 0 0; #X obj 54 468 dyn~ 0 1 0 2; #X text 156 467 dyn sig/msg inlets sig/msg outlets; #X msg 165 421 vis \$1; -#X obj 129 421 tgl 20 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +#X obj 129 421 tgl 20 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1; #X text 222 417 make patch visible/invisible; #X msg 129 323 dis x 2 y 3; diff --git a/externals/grill/dyn/src/main.cpp b/externals/grill/dyn/src/main.cpp index cdf37504..f60e9587 100644 --- a/externals/grill/dyn/src/main.cpp +++ b/externals/grill/dyn/src/main.cpp @@ -17,7 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #error You need at least flext version 0.4.2 #endif -#define DYN_VERSION "0.0.3" +#define DYN_VERSION "0.0.4" #if FLEXT_SYS != FLEXT_SYS_PD @@ -456,11 +456,11 @@ t_gobj *dyn::New(const t_symbol *kind,int _argc_,const t_atom *_argv_,bool add) // send loadbang (if it is an abstraction) if(pd_class(&newest->g_pd) == canvas_class) { - // loadbang the abstraction - pd_vmess((t_pd *)newest,gensym("loadbang"),""); - // hide the sub-canvas pd_vmess((t_pd *)newest,gensym("vis"),"i",0); + + // loadbang the abstraction + pd_vmess((t_pd *)newest,gensym("loadbang"),""); } // restart dsp - that's necessary because ToCanvas is called manually diff --git a/externals/grill/flext/flext.cw b/externals/grill/flext/flext.cw index 0afabe2e..a2b07ec1 100644 Binary files a/externals/grill/flext/flext.cw and b/externals/grill/flext/flext.cw differ diff --git a/externals/grill/flext/flext.doxy b/externals/grill/flext/flext.doxy index 433f3b4d..d2632d0f 100644 --- a/externals/grill/flext/flext.doxy +++ b/externals/grill/flext/flext.doxy @@ -4,7 +4,7 @@ # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = flext -PROJECT_NUMBER = "version 0.4.2" +PROJECT_NUMBER = "version 0.4.3" OUTPUT_DIRECTORY = f:/prog/max/flext/doc/ OUTPUT_LANGUAGE = English EXTRACT_ALL = NO diff --git a/externals/grill/flext/flext.dsp b/externals/grill/flext/flext.dsp index de8c2b13..de0d40b7 100644 --- a/externals/grill/flext/flext.dsp +++ b/externals/grill/flext/flext.dsp @@ -273,6 +273,10 @@ SOURCE=.\source\flattr.cpp # End Source File # Begin Source File +SOURCE=.\source\flbind.cpp +# End Source File +# Begin Source File + SOURCE=.\source\flitem.cpp # End Source File # Begin Source File diff --git a/externals/grill/flext/make-files.txt b/externals/grill/flext/make-files.txt index 42720544..3702966d 100644 --- a/externals/grill/flext/make-files.txt +++ b/externals/grill/flext/make-files.txt @@ -1,8 +1,10 @@ SRCS=flbase.cpp flext.cpp flbuf.cpp fldsp.cpp fllib.cpp flxlet.cpp flattr.cpp flsupport.cpp \ flutil.cpp flatom.cpp flatom_pr.cpp flthr.cpp fltimer.cpp flsimd.cpp flout.cpp \ flatom_app.cpp flatom_part.cpp flitem.cpp flmeth.cpp flmsg.cpp \ -flproxy.cpp flqueue.cpp +flproxy.cpp flqueue.cpp flbind.cpp + HDRS=flprefix.h flstdc.h flbase.h flclass.h fldefs.h flext.h flsupport.h fldsp.h flinternal.h + SRCS_SNDOBJ=flsndobj.cpp HDRS_SNDOBJ=flsndobj.h SRCS_STK=flstk.cpp diff --git a/externals/grill/flext/readme.txt b/externals/grill/flext/readme.txt index 9afb459d..32d783d5 100644 --- a/externals/grill/flext/readme.txt +++ b/externals/grill/flext/readme.txt @@ -124,6 +124,9 @@ Version history: - fixed bug for Max/MSP buffer resize with preservation of contents - fixed bug with thread initialization (caused PD@OSX to crash on startup) - flext::setup is only run once now +- fixed creation bug with objects that have attributes but no outlets +- added FLEXT_BINDMETHOD,FLEXT_UNBINDMETHOD to bind a method to a symbol +- fixed bug with hard thread termination (of incooperative threads) 0.4.2: - started port for jMax @@ -356,11 +359,8 @@ tests: features: -- abstraction for clock functions - manage running threads individually (stop, isrunning?, priority etc.) -premature thoughts: -- GUI objects diff --git a/externals/grill/flext/source/flbase.h b/externals/grill/flext/source/flbase.h index 97e5f2b6..18ba2ca1 100644 --- a/externals/grill/flext/source/flbase.h +++ b/externals/grill/flext/source/flbase.h @@ -218,6 +218,10 @@ class FLEXT_SHARE flext_obj: //! Flag for successful object construction bool init_ok; + // --- proxy stuff for symbol-bound methods ---- + + static void SetupBindProxy(); + public: //! Creation callback @@ -251,6 +255,7 @@ class FLEXT_SHARE flext_obj: 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 diff --git a/externals/grill/flext/source/flbind.cpp b/externals/grill/flext/source/flbind.cpp new file mode 100644 index 00000000..3eee25ae --- /dev/null +++ b/externals/grill/flext/source/flbind.cpp @@ -0,0 +1,95 @@ +/* + +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 flbind.cpp + \brief Functionality for symbol-bound methods. +*/ + +#include "flext.h" +#include "flinternal.h" + + +t_class *flext_base::pxbnd_class = NULL; + +flext_base::binditem::binditem(int in,const t_symbol *sym,bool (*f)(flext_base *,t_symbol *s,int,t_atom *),pxbnd_object *p): + item(sym,0,NULL),fun(f),px(p) +{} + + +bool flext_base::BindMethod(const t_symbol *sym,bool (*fun)(flext_base *,t_symbol *s,int,t_atom *)) +{ + if(!bindhead) + bindhead = new itemarr; + else { + // Search for symbol + if(bindhead->Find(sym,0)) { + post("%s - Symbol already bound",thisName()); + return false; + } + } + + FLEXT_ASSERT(pxbnd_class); + + pxbnd_object *px = (pxbnd_object *)object_new(pxbnd_class); + + if(px) { + binditem *mi = new binditem(0,sym,fun,px); + bindhead->Add(mi); + + px->init(this,mi); + +#if FLEXT_SYS == FLEXT_SYS_PD + pd_bind(&px->obj.ob_pd,const_cast(sym)); +#elif FLEXT_SYS == FLEXT_SYS_MAX + if(!sym->s_thing) + const_cast(sym)->s_thing = (t_object *)px; + else + error("%s - Symbol is already bound",thisName()); +#else +# pragma warning("Not implemented") +#endif + } + else + error("%s - Symbol proxy could not be created",thisName()); + + return true; +} + + +bool flext_base::UnbindMethod(const t_symbol *sym) +{ + item *it = bindhead?bindhead->Find(sym,0):NULL; + if(it) { + bool ok = bindhead->Remove(it); + if(ok) { + pxbnd_object *px = ((binditem *)it)->px; +#if FLEXT_SYS == FLEXT_SYS_PD + pd_unbind(&px->obj.ob_pd,const_cast(sym)); +#elif FLEXT_SYS == FLEXT_SYS_MAX + if(sym->s_thing == (t_object *)px) + const_cast(sym)->s_thing = NULL; + else + error("%s - Binding not found",thisName()); +#else +# pragma warning("Not implemented") +#endif + object_free(&px->obj); + delete it; + } + return ok; + } + else + return true; +} + +void flext_base::pxbnd_object::px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv) +{ + c->item->fun(c->base,(t_symbol *)s,argc,(t_atom *)argv); +} diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index 17385370..67926266 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -411,16 +411,8 @@ public: bool Unbind(const char *c) { return Unbind(MakeSymbol(c)); } #endif -/* - // Low level - - //! Bind object to a symbol - static void DoUnbind(t_symbol *s,flext_obj *o); - //! Unbind object from a symbol - static void DoBind(const t_symbol *s,flext_obj *o); - //! Get bound object of a symbol - static t_class **GetBound(const t_symbol *s) { return (t_class **)s->s_thing; } -*/ + bool BindMethod(const t_symbol *s,bool (*m)(flext_base *,t_symbol *s,int,t_atom *)); + bool UnbindMethod(const t_symbol *s); //! @} FLEXT_C_BIND @@ -555,6 +547,7 @@ protected: ~itemarr(); void Add(item *it); + bool Remove(item *it); item *Find(const t_symbol *tag,int inlet = 0) const; void Finalize(); @@ -606,6 +599,21 @@ protected: methfun fun; }; +private: + class pxbnd_object; +public: + + //! \brief This represents an item of the method list + class binditem: + public item { + public: + binditem(int inlet,const t_symbol *sym,bool (*f)(flext_base *,t_symbol *s,int,t_atom *),pxbnd_object *px); + ~binditem(); + + bool (*fun)(flext_base *,t_symbol *s,int,t_atom *); + pxbnd_object *px; + }; + //! @} FLEXT_CLASS itemarr *ThMeths() { return methhead; } @@ -657,6 +665,7 @@ private: static itemarr *GetClassArr(t_classid,int ix); itemarr *methhead,*clmethhead; + itemarr *bindhead; bool CallMeth(const methitem &m,int argc,const t_atom *argv); bool FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *argv); @@ -709,7 +718,6 @@ private: static void px_method(px_object *c,const t_symbol *s,int argc,t_atom *argv); }; - friend struct px_object; #elif FLEXT_SYS == FLEXT_SYS_MAX typedef object px_object; static void cb_px_float(t_class *c,float f); @@ -745,6 +753,23 @@ private: static void jmax_proxy(fts_object_t *c, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at); #endif + // --------- symbol-bound proxy + + static t_class *pxbnd_class; + + class pxbnd_object // no virtual table! + { + public: + t_object obj; // MUST reside at memory offset 0 + flext_base *base; + binditem *item; + + void init(flext_base *b,binditem *it) { base = b; item = it; } + static void px_method(pxbnd_object *c,const t_symbol *s,int argc,t_atom *argv); + }; + + // --------- + static void SetProxies(t_class *c); bool InitInlets(); diff --git a/externals/grill/flext/source/flcwmax-thr.h b/externals/grill/flext/source/flcwmax-thr.h index 9b3f3096..b3ef6edb 100755 --- a/externals/grill/flext/source/flcwmax-thr.h +++ b/externals/grill/flext/source/flcwmax-thr.h @@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -// This is the prefix file for CodeWarrior projects - threaded version - +/*! \file flcwmax-thr.h + \brief Prefix file for CodeWarrior projects - OS 9 threaded version. +*/ + #ifndef _FLEXT_CW_MAX_THR_H #define _FLEXT_CW_MAX_THR_H diff --git a/externals/grill/flext/source/flcwmax-x-thr.h b/externals/grill/flext/source/flcwmax-x-thr.h index 13fcbfd3..0d2d8b3d 100755 --- a/externals/grill/flext/source/flcwmax-x-thr.h +++ b/externals/grill/flext/source/flcwmax-x-thr.h @@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -// This is the prefix file for CodeWarrior projects - threaded version - +/*! \file flcwmax-x-thr.h + \brief Prefix file for CodeWarrior projects - OS X threaded version. +*/ + #ifndef _FLEXT_CW_MAX_X_THR_H #define _FLEXT_CW_MAX_X_THR_H diff --git a/externals/grill/flext/source/flcwmax-x.h b/externals/grill/flext/source/flcwmax-x.h index 6af4fb4d..bffff8d3 100755 --- a/externals/grill/flext/source/flcwmax-x.h +++ b/externals/grill/flext/source/flcwmax-x.h @@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -/* This is the prefix file for CodeWarrior projects - OS X version */ - +/*! \file flcwmax-x.h + \brief Prefix file for CodeWarrior projects - OS X version. +*/ + #ifndef _FLEXT_CW_MAX_X_H #define _FLEXT_CW_MAX_X_H diff --git a/externals/grill/flext/source/flcwmax.h b/externals/grill/flext/source/flcwmax.h index fea603ca..87653e3b 100644 --- a/externals/grill/flext/source/flcwmax.h +++ b/externals/grill/flext/source/flcwmax.h @@ -8,8 +8,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -/* This is the prefix file for CodeWarrior projects */ - +/*! \file flcwmax.h + \brief Prefix file for CodeWarrior projects - OS 9 version. +*/ + #ifndef _FLEXT_CW_MAX_H #define _FLEXT_CW_MAX_H diff --git a/externals/grill/flext/source/fldefs.h b/externals/grill/flext/source/fldefs.h index da6d995c..98461d56 100644 --- a/externals/grill/flext/source/fldefs.h +++ b/externals/grill/flext/source/fldefs.h @@ -875,6 +875,28 @@ FLEXT_ADDMETHOD_3(IX,M_TAG,M_FUN,int,int,int) //! @} FLEXT_D_ADDMETHOD + +/*! \defgroup FLEXT_D_BINDMETHOD Call flext methods manually + @{ +*/ + +/*! \brief Bind a handler for a method with an anything argument to a symbol +*/ +#define FLEXT_BINDMETHOD(SYM,M_FUN) \ +\ +BindMethod(SYM,FLEXT_CALL_PRE(M_FUN)) + +/*! \brief Unbind any handler for a method from a symbol +*/ +#define FLEXT_UNBINDMETHOD(SYM) \ +\ +UnbindMethod(SYM) + + +//! @} FLEXT_D_BINDMETHOD + + + /*! \defgroup FLEXT_D_CALLMETHOD Call flext methods manually @{ */ diff --git a/externals/grill/flext/source/flext.cpp b/externals/grill/flext/source/flext.cpp index a5ee5a59..23d02893 100644 --- a/externals/grill/flext/source/flext.cpp +++ b/externals/grill/flext/source/flext.cpp @@ -38,6 +38,7 @@ flext_base::flext_base(): t_classid clid = thisClassId(); clmethhead = ClMeths(clid); methhead = new itemarr; + bindhead = NULL; if(procattr) { // initialize when attribute processing is enabled @@ -78,6 +79,7 @@ flext_base::~flext_base() // delete message lists if(methhead) delete methhead; + if(bindhead) delete bindhead; if(attrhead) delete attrhead; // destroy inlets and outlets and their proxy objects diff --git a/externals/grill/flext/source/flinternal.h b/externals/grill/flext/source/flinternal.h index af88cbca..c8cdcf2a 100644 --- a/externals/grill/flext/source/flinternal.h +++ b/externals/grill/flext/source/flinternal.h @@ -25,7 +25,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #if FLEXT_SYS == FLEXT_SYS_PD #define object_new(clss) pd_new(clss) -#define object_free(obj) pd_free(&(obj).ob_pd) +#define object_free(obj) pd_free(&(obj)->ob_pd) @@ -68,16 +68,11 @@ typedef t_perfroutine t_dspmethod; #elif FLEXT_SYS == FLEXT_SYS_MAX -/* -typedef void _inlet; -typedef _inlet t_inlet; -*/ - typedef void t_outlet; -//typedef _outlet t_outlet; -#define object_new(clss) pd_new(clss) -#define object_free(obj) freeobject((object *)obj) + +#define object_new(clss) newobject(clss) +#define object_free(obj) freeobject((object *)(obj)) #define add_dsp(clss,meth) addmess((method)meth,"dsp",A_CANT,A_NOTHING) #define add_bang(clss,meth) addbang((method)meth) @@ -112,6 +107,7 @@ typedef t_perfroutine t_dspmethod; #define CRITON() short state = lockout_set(1) #define CRITOFF() lockout_set(state) + #elif FLEXT_SYS == FLEXT_SYS_JMAX diff --git a/externals/grill/flext/source/flitem.cpp b/externals/grill/flext/source/flitem.cpp index 1e5a26a6..7af91fea 100755 --- a/externals/grill/flext/source/flitem.cpp +++ b/externals/grill/flext/source/flitem.cpp @@ -68,6 +68,49 @@ void flext_base::itemarr::Add(item *it) } } +bool flext_base::itemarr::Remove(item *it) +{ + if(Ready()) { + // retrieve array index + int ix = Hash(it->tag,it->inlet,bits); + + // remove from array slot + if(arr[ix]) { + item *a1 = NULL,*a = arr[ix]; + while(a && a != it) a1 = a,a = a->nxt; + if(a) { // found (a == it) + if(a1) a1->nxt = it->nxt; + else arr[ix] = it->nxt; + it->nxt = NULL; + return true; + } + else + return false; + } + else + return false; + } + else { + // remove from list + if(!arr[0]) + return false; + else { + item *a1 = NULL,*a = arr[0]; + while(a && a != it) a1 = a,a = a->nxt; + if(a) { // found (a == it) + if(a1) a1->nxt = it->nxt; + else arr[0] = it->nxt; + if(!it->nxt) arr[1] = a1; + it->nxt = NULL; + --cnt; + return true; + } + else + return false; + } + } +} + void flext_base::itemarr::Finalize() { if(!Ready()) diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp index 281bad58..438f8bd0 100755 --- a/externals/grill/flext/source/fllib.cpp +++ b/externals/grill/flext/source/fllib.cpp @@ -8,9 +8,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. */ -// Code for handling of object creation functions +/*! \file fllib.cpp + \brief Code for handling of object (and library) creation functions. +*/ #include "flext.h" +#include "flinternal.h" #include #include @@ -189,10 +192,33 @@ flext_obj::t_classid flext_obj::thisClassId() const { return libname::Find(thisN t_class *flext_obj::getClass(t_classid id) { return reinterpret_cast(id)->clss; } #endif +/*! \brief Set up the proxy class for symbol-bound methods + \note This has to take place before the main class is set up because + \note Max does not know which class is the current one afterwards (when methods are added) +*/ +void flext_obj::SetupBindProxy() +{ + // already initialized? + if(!flext_base::pxbnd_class) { +#if FLEXT_SYS == FLEXT_SYS_PD + flext_base::pxbnd_class = class_new(gensym("flext_base bind proxy"),NULL,NULL,sizeof(flext_base::pxbnd_object),CLASS_PD|CLASS_NOINLET, A_NULL); + add_anything(flext_base::pxbnd_class,flext_base::pxbnd_object::px_method); // for symbol-bound methods +#elif FLEXT_SYS == FLEXT_SYS_MAX + ::setup((t_messlist **)&flext_base::pxbnd_class,NULL,NULL,sizeof(flext_base::pxbnd_object),NULL,A_NULL); + add_anything(flext_base::pxbnd_class,flext_base::pxbnd_object::px_method); // for symbol-bound methods +#else +#pragma warning("Not implemented!") +#endif + } +} + + void flext_obj::lib_init(const char *name,void setupfun(),bool attr) { flext::Setup(); + SetupBindProxy(); + #if FLEXT_SYS == FLEXT_SYS_MAX lib_name = MakeSymbol(name); ::setup( @@ -213,6 +239,9 @@ static void jmax_class_inst(t_class *cl) 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,...) { + // set up bind proxy + SetupBindProxy(); + // get first possible object name const t_symbol *nsym = MakeSymbol(extract(names)); diff --git a/externals/grill/flext/source/flmeth.cpp b/externals/grill/flext/source/flmeth.cpp index acdd10b2..5e6a86b4 100755 --- a/externals/grill/flext/source/flmeth.cpp +++ b/externals/grill/flext/source/flmeth.cpp @@ -15,6 +15,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flext.h" #include #include +#include "flinternal.h" flext_base::methitem::methitem(int in,const t_symbol *tg,attritem *conn): item(tg,in,conn), @@ -34,6 +35,7 @@ void flext_base::methitem::SetArgs(methfun _fun,int _argc,metharg *_args) argc = _argc,args = _args; } + void flext_base::AddMethodDef(int inlet,const char *tag) { methhead->Add(new methitem(inlet,tag?MakeSymbol(tag):NULL)); @@ -85,4 +87,3 @@ void flext_base::AddMethod(itemarr *ma,int inlet,const char *tag,methfun fun,met ma->Add(mi); } - diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index 75da3023..c32f710f 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -64,7 +64,8 @@ bool flext_base::InitInlets() incnt = insigs = 0; - if(inlist) { + // digest inlist + { xlet *xi; incnt = 0; for(xi = inlist; xi; xi = xi->nxt) ++incnt; @@ -282,7 +283,8 @@ bool flext_base::InitOutlets() attrtmp = (outlet *)newout_anything(thisHdr()); #endif - if(outlist) { + // digest outlist + { xlet *xi; // count outlets diff --git a/externals/grill/flext/source/flproxy.cpp b/externals/grill/flext/source/flproxy.cpp index 75bbc897..2edcd4c9 100755 --- a/externals/grill/flext/source/flproxy.cpp +++ b/externals/grill/flext/source/flproxy.cpp @@ -105,6 +105,7 @@ void flext_base::SetProxies(t_class *c) add_anything(c,cb_px_anything); // for leftmost inlet px_class = class_new(gensym("flext_base proxy"),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL); add_anything(px_class,px_object::px_method); // for other inlets + #elif FLEXT_SYS == FLEXT_SYS_MAX add_bang(c,cb_px_bang); add_method1(c,cb_px_int,"int",A_INT); @@ -112,7 +113,7 @@ void flext_base::SetProxies(t_class *c) add_methodG(c,cb_px_anything,"list"); add_anything(c,cb_px_anything); #else -#error +#error Not implemented! #endif // setup non-leftmost ints and floats diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index a40ef6cf..867e2859 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -701,7 +701,7 @@ public: //! Lock thread mutex bool Lock() { return pthread_mutex_lock(&mutex) == 0; } - /*! \brief Wait to lock thread mutex + /*! \brief Wait to lock thread mutex. \todo Implement! */ bool WaitForLock(double tm) { return pthread_mutex_lock(&mutex) == 0; } @@ -759,7 +759,7 @@ public: return ret; } - /*! \brief Wait for condition (for a certain time) + /*! \brief Wait for condition (for a certain time). \param ftime Wait time in seconds \ret 0 = signalled, 1 = timed out \remark Depending on the implementation ftime may not be fractional. @@ -808,7 +808,7 @@ public: //! Wait for condition bool Wait() { return MPWaitForEvent(ev,NULL,kDurationForever) == noErr; } - /*! \brief Wait for condition (for a certain time) + /*! \brief Wait for condition (for a certain time). \param time Wait time in seconds */ bool TimedWait(double tm) { return MPWaitForEvent(ev,NULL,tm*kDurationMicrosecond*1.e6) == noErr; } @@ -824,19 +824,19 @@ public: #error "Not implemented" #endif - /*! \brief Add current thread to list of active threads + /*! \brief Add current thread to list of active threads. \return true on success \internal */ static bool PushThread(); - /*! \brief Remove current thread from list of active threads + /*! \brief Remove current thread from list of active threads. \internal */ static void PopThread(); - /*! \brief Launch a thread - \remark thr_params *p may be NULL if not needed + /*! \brief Launch a thread. + \remark thr_params *p may be NULL if not needed. */ static bool LaunchThread(void (*meth)(thr_params *p),thr_params *p = NULL); @@ -855,28 +855,28 @@ public: \remark Since this clock can be synchronized to an external clock (or e.g. the audio card) \remark it may differ from the clock of the operating system */ - /*! \brief Get time since real-time system startup + /*! \brief Get time since real-time system startup. \note This is not the time of the operating system but of the real-time system. \note It depends on the time source the system is synchronized to. */ static double GetTime(); - /*! \brief Get time granularity of the GetTime function + /*! \brief Get time granularity of the GetTime function. \note This can be zero if not determined. */ static double GetTimeGrain(); - /*! \brief Get operating system time since flext startup + /*! \brief Get operating system time since flext startup. */ static double GetOSTime(); - /*! \brief Sleep for an amount of time - \remark The OS clock is used for that - \note Clearly in a real-time system this should only be used in a detached thread + /*! \brief Sleep for an amount of time. + \remark The OS clock is used for that. + \note Clearly in a real-time system this should only be used in a detached thread. */ static void Sleep(double s); - /*! \brief Class encapsulating a timer with callback functionality + /*! \brief Class encapsulating a timer with callback functionality. This class can either be used with FLEXT_ADDTIMER or used as a base class with an overloaded virtual Work function. */ class FLEXT_SHARE Timer @@ -885,23 +885,23 @@ public: Timer(bool queued = false); virtual ~Timer(); - //! Set timer callback function + //! Set timer callback function. void SetCallback(void (*cb)(void *data)) { clss = NULL,cback = cb; } - //! Set timer callback function (with class pointer) + //! Set timer callback function (with class pointer). void SetCallback(flext_base &th,bool (*cb)(flext_base *th,void *data)) { clss = &th,cback = (void (*)(void *))cb; } - //! Clear timer + //! Clear timer. bool Reset(); - //! Trigger a one shot at an absolute time + //! Trigger a one shot at an absolute time. bool At(double tm,void *data = NULL,bool dopast = true); - //! Trigger a one shot interval + //! Trigger a one shot interval. bool Delay(double tm,void *data = NULL); - //! Trigger a periodic interval + //! Trigger a periodic interval. bool Periodic(double tm,void *data = NULL); - //! Trigger immediately + //! Trigger immediately. bool Now(void *data = NULL) { return Delay(0,data); } - //! Worker function, called on every timer event + //! Worker function, called on every timer event. virtual void Work(); protected: diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp index df8fb1a1..7f9564d5 100644 --- a/externals/grill/flext/source/flthr.cpp +++ b/externals/grill/flext/source/flthr.cpp @@ -300,6 +300,7 @@ bool flext_base::StopThreads() t = tn; } else t = t->nxt; + thrhead = NULL; tlmutex.Unlock(); qmutex.Unlock(); diff --git a/externals/grill/flext/source/fltimer.cpp b/externals/grill/flext/source/fltimer.cpp index 9b69de2b..6767c186 100755 --- a/externals/grill/flext/source/fltimer.cpp +++ b/externals/grill/flext/source/fltimer.cpp @@ -216,8 +216,8 @@ bool flext::Timer::Periodic(double tm,void *data) return true; } -/*! \brief Callback function for system clock - \todo Make periodic events scheduled as such +/*! \brief Callback function for system clock. + \todo Make periodic events scheduled as such. */ void flext::Timer::callback(Timer *tmr) { @@ -244,12 +244,12 @@ void flext::Timer::callback(Timer *tmr) } #if FLEXT_SYS == FLEXT_SYS_MAX -/*! \brief Callback function for low priority clock (for queued messages) +/*! \brief Callback function for low priority clock (for queued messages). */ void flext::Timer::queuefun(Timer *tmr) { tmr->Work(); } #endif -/*! \brief Virtual worker function - by default it calls the user callback function +/*! \brief Virtual worker function - by default it calls the user callback function. \remark The respective callback parameter format is chosen depending on whether clss is defined or not. */ void flext::Timer::Work() diff --git a/externals/grill/py/make-files.txt b/externals/grill/py/make-files.txt new file mode 100644 index 00000000..dec24613 --- /dev/null +++ b/externals/grill/py/make-files.txt @@ -0,0 +1,6 @@ +# all the source files from the package +SRCDIR=source + +SRCS= main.cpp py.cpp pyext.cpp modmeth.cpp clmeth.cpp register.cpp pyargs.cpp bound.cpp + +HDRS= main.h pyext.h diff --git a/externals/grill/py/makefile.pd-bcc b/externals/grill/py/makefile.pd-bcc index e94abdf4..9141ffb8 100644 --- a/externals/grill/py/makefile.pd-bcc +++ b/externals/grill/py/makefile.pd-bcc @@ -23,7 +23,7 @@ LIBPATH=-L$(BCCPATH)\lib -L$(PDPATH)\lib LIBS=cw32.lib import32.lib C0D32.OBJ # compiler definitions and flags -DEFS=-DPD -DNT +DEFS=-DFLEXT_SYS=2 CFLAGS=-6 -O2 -OS -ff -tWD @@ -31,8 +31,7 @@ CFLAGS=-6 -O2 -OS -ff -tWD # ---------------------------------------------- # all the source files from the package -SRCS= main.cpp py.cpp pyext.cpp modmeth.cpp clmeth.cpp register.cpp pyargs.cpp bound.cpp -HDRS= main.h pyext.h +!include make-files.txt # default target all: $(OUTPATH)\$(NAME).dll @@ -55,7 +54,7 @@ OBJS= $(SRCS:.cpp=.obj) #$(SRCS): $(HDRS) # -touch $< -{source}.cpp.obj: +{$(SRCDIR)}.cpp.obj: bcc32 -c $(CFLAGS) $(DEFS) $(INCPATH) -n$(OUTPATH) $< $(OUTPATH): diff --git a/externals/grill/py/makefile.pd-darwin b/externals/grill/py/makefile.pd-darwin index 1351d834..ec0eeeba 100755 --- a/externals/grill/py/makefile.pd-darwin +++ b/externals/grill/py/makefile.pd-darwin @@ -17,7 +17,7 @@ FLEXTLIB=${FLEXTPATH}/flext_t.a # compiler+linker stuff INCLUDES=${PDPATH} ${FLEXTPATH} ${PYTHONINCLUDE} LIBPATH= ${PYTHONLIB} -FLAGS=-DPD -Dunix -DMACOSX -DFLEXT_THREADS +FLAGS=-DFLEXT_SYS=2 -DFLEXT_THREADS CFLAGS=-O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes # -maltivec #CFLAGS=-g LIBS=m python${PYTHONVER} @@ -29,25 +29,22 @@ LDFLAGS=-bundle -bundle_loader ${PD} NAME=py # all the source files from the package -SRCS=main.cpp py.cpp pyext.cpp bound.cpp clmeth.cpp modmeth.cpp pyargs.cpp register.cpp -HDRS=main.h pyext.h +include make-files.txt -DIR=source - TARGET=$(TARGDIR)/$(NAME).pd_darwin MAKEFILE=makefile.pd-darwin # default target all: $(TARGDIR) $(TARGET) -$(patsubst %,$(DIR)/%,$(SRCS)): $(patsubst %,$(DIR)/%,$(HDRS)) $(FLEXTLIB) $(MAKEFILE) $(CONFIG) +$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTLIB) $(MAKEFILE) $(CONFIG) touch $@ $(TARGDIR): mkdir $(TARGDIR) -$(TARGDIR)/%.o : $(DIR)/%.cpp +$(TARGDIR)/%.o : $(SRCDIR)/%.cpp $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES)) $< -o $@ $(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) diff --git a/externals/grill/py/makefile.pd-linux b/externals/grill/py/makefile.pd-linux index af2b58d2..0c90892f 100644 --- a/externals/grill/py/makefile.pd-linux +++ b/externals/grill/py/makefile.pd-linux @@ -17,7 +17,7 @@ FLEXTLIB=$(FLEXTPATH)/flext_t.a # compiler+linker stuff INCLUDES=$(PDPATH) $(PYTHONINCLUDE) LIBPATH=$(PYTHONLIB) -FLAGS=-DPD -DFLEXT_THREADS +FLAGS=-DFLEXT_SYS=2 -DFLEXT_THREADS CFLAGS=-O6 -mcpu=pentiumpro #CFLAGS=-g LIBS=m util python$(PYTHONVER) @@ -30,21 +30,20 @@ LIBS=m util python$(PYTHONVER) NAME=py # all the source files from the package -SRCS=main.cpp py.cpp pyext.cpp bound.cpp clmeth.cpp modmeth.cpp pyargs.cpp register.cpp -HDRS=main.h pyext.h +include make-files.txt TARGET=$(TARGDIR)/$(NAME).pd_linux # default target all: $(TARGDIR) $(TARGET) -$(patsubst %,source/%,$(SRCS)): $(patsubst %,source/%,$(HDRS)) $(FLEXTLIB) $(CONFIG) +$(patsubst %,$(SRCDIR)/%,$(SRCS)): $(patsubst %,$(SRCDIR)/%,$(HDRS)) $(FLEXTLIB) $(CONFIG) touch $@ $(TARGDIR): mkdir $(TARGDIR) -$(TARGDIR)/%.o : source/%.cpp +$(TARGDIR)/%.o : $(SRCDIR)/%.cpp $(CXX) -c $(CFLAGS) $(FLAGS) $(patsubst %,-I%,$(INCLUDES) $(FLEXTPATH)) $< -o $@ $(TARGET) : $(patsubst %.cpp,$(TARGDIR)/%.o,$(SRCS)) $(FLEXTLIB) diff --git a/externals/grill/py/makefile.pd-msvc b/externals/grill/py/makefile.pd-msvc index 921a7a8d..46f569a3 100644 --- a/externals/grill/py/makefile.pd-msvc +++ b/externals/grill/py/makefile.pd-msvc @@ -15,21 +15,17 @@ LIBPATH=/LIBPATH:"$(MSVCPATH)\lib" /LIBPATH:"$(PDPATH)\bin" /LIBPATH:"$(FLEXTPAT LIBS=pd.lib pthreadVC.lib flext_t-pdwin.lib $(PYTHONLIB) # compiler definitions and flags -DEFS=/DPD /DNT /DFLEXT_THREADS +DEFS=/DFLEXT_SYS=2 /DFLEXT_THREADS CFLAGS=/GR- /GX- /GD /G6 /Ox /MT # the rest can stay untouched # ---------------------------------------------- -# all the source files from the package -SRCS= main.cpp py.cpp pyext.cpp modmeth.cpp clmeth.cpp register.cpp pyargs.cpp bound.cpp -HDRS= main.h pyext.h - -# ----------------------------------------------- - NAME=py -DIR=source + +# all the source files from the package +!include make-files.txt all: $(OUTPATH) $(OUTPATH)\$(NAME).dll @@ -43,7 +39,7 @@ OBJS= $(SRCS:.cpp=.obj) $(OUTPATH): -mkdir $(OUTPATH) > nul -{$(DIR)}.cpp{}.obj: +{$(SRCDIR)}.cpp{}.obj: cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)\$@ $(OUTPATH)\$(NAME).dll: $(OBJS) diff --git a/externals/grill/vasp/config-pd-cygwin.txt b/externals/grill/vasp/config-pd-cygwin.txt index d9932ada..06dd61aa 100644 --- a/externals/grill/vasp/config-pd-cygwin.txt +++ b/externals/grill/vasp/config-pd-cygwin.txt @@ -16,7 +16,7 @@ PDINC=${PD}/src # where do the flext libraries reside? FLEXTPATH=${PD}/flext -# where should flext libraries be built? +# where should VASP be built? TARGDIR=./pd-cygwin # where should VASP be installed? diff --git a/externals/grill/vasp/make-files.txt b/externals/grill/vasp/make-files.txt index 50ecb538..abedf02b 100644 --- a/externals/grill/vasp/make-files.txt +++ b/externals/grill/vasp/make-files.txt @@ -1,4 +1,6 @@ # all the source files from the package +SRCDIR=source + SRCS= \ arg.cpp mixfft.cpp obj_part.cpp obj_split.cpp opparam.cpp ops_cplx.cpp ops_gen.cpp ops_trnsc.cpp util.cpp \ buflib.cpp obj_chns.cpp obj_peaks.cpp obj_sync.cpp ops_arith.cpp ops_dft.cpp ops_qminmax.cpp ops_wnd.cpp vasp.cpp \ diff --git a/externals/grill/vasp/makefile.pd-cygwin b/externals/grill/vasp/makefile.pd-cygwin index 454c3167..0f408436 100644 --- a/externals/grill/vasp/makefile.pd-cygwin +++ b/externals/grill/vasp/makefile.pd-cygwin @@ -28,7 +28,6 @@ LIBS=m # ---------------------------------------------- NAME=vasp -SRCDIR=source include make-files.txt diff --git a/externals/grill/vasp/makefile.pd-darwin b/externals/grill/vasp/makefile.pd-darwin index 7d9eeb8a..89ee3f47 100755 --- a/externals/grill/vasp/makefile.pd-darwin +++ b/externals/grill/vasp/makefile.pd-darwin @@ -29,7 +29,6 @@ FRAMEWORKS=Carbon # ---------------------------------------------- NAME=vasp -SRCDIR=source include make-files.txt diff --git a/externals/grill/vasp/makefile.pd-linux b/externals/grill/vasp/makefile.pd-linux index 3bb424c0..4caa0097 100644 --- a/externals/grill/vasp/makefile.pd-linux +++ b/externals/grill/vasp/makefile.pd-linux @@ -9,7 +9,9 @@ # to install help, do "make -f makefile.pd-linux install-help" # -include config-pd-linux.txt +CONFIG=config-pd-linux.txt + +include ${CONFIG} FLEXTLIB=$(FLEXTPATH)/flext_t.a @@ -27,7 +29,6 @@ LIBS=m # ---------------------------------------------- NAME=vasp -SRCDIR=source include make-files.txt diff --git a/externals/grill/vasp/makefile.pd-msvc b/externals/grill/vasp/makefile.pd-msvc index 9f55ea1a..1ab086f8 100644 --- a/externals/grill/vasp/makefile.pd-msvc +++ b/externals/grill/vasp/makefile.pd-msvc @@ -24,8 +24,6 @@ CFLAGS=/GR /GX- /GD /G6 /Ox /MT NAME=vasp -DIR=source - !include make-files.txt @@ -43,7 +41,7 @@ $(OUTPATH): # bad tricks here... the obj's are phantom files... no real make -{$(DIR)}.cpp.obj: +{$(SRCDIR)}.cpp.obj: cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)\$@ $(OUTPATH)\$(NAME).dll: $(OBJS) diff --git a/externals/grill/xsample/xsample.cw b/externals/grill/xsample/xsample.cw index efe28b36..3f58cdee 100755 Binary files a/externals/grill/xsample/xsample.cw and b/externals/grill/xsample/xsample.cw differ -- cgit v1.2.1