From f688c9de1efee2e09fbb9b39a715853b23fadcb3 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Fri, 17 Dec 2004 05:01:18 +0000 Subject: global system lock functions fixed a thread sensitive spot fix for _long_ attribute dialogs build system for flext-based externals typo fixed in attribute editor atom outlet functions svn path=/trunk/; revision=2394 --- .../grill/flext/build/config-win-max-msvc.def | 22 +++++++ .../grill/flext/build/config-win-max-msvc.txt | 22 +++++++ externals/grill/flext/build/config-win-pd-msvc.def | 20 +++++++ externals/grill/flext/build/config-win-pd-msvc.txt | 20 +++++++ externals/grill/flext/build/make-win-gen-msvc.inc | 67 ++++++++++++++++++++++ externals/grill/flext/build/make-win-max-msvc.inc | 35 +++++++++++ externals/grill/flext/build/make-win-msvc.inc | 22 +++++++ externals/grill/flext/build/make-win-pd-msvc.inc | 34 +++++++++++ externals/grill/flext/changes.txt | 3 + externals/grill/flext/config-max-msvc.txt | 2 +- externals/grill/flext/config-pd-msvc.txt | 8 +-- externals/grill/flext/flext.vcproj | 20 ++++--- externals/grill/flext/make-inc.max-msvc | 4 +- externals/grill/flext/make-inc.pd-msvc | 4 +- externals/grill/flext/source/flclass.h | 10 ++++ externals/grill/flext/source/flout.cpp | 24 ++++++++ externals/grill/flext/source/flqueue.cpp | 41 ++++++++++++- externals/grill/flext/source/flstdc.h | 1 + externals/grill/flext/source/flsupport.h | 29 +++++++++- 19 files changed, 365 insertions(+), 23 deletions(-) create mode 100644 externals/grill/flext/build/config-win-max-msvc.def create mode 100644 externals/grill/flext/build/config-win-max-msvc.txt create mode 100644 externals/grill/flext/build/config-win-pd-msvc.def create mode 100644 externals/grill/flext/build/config-win-pd-msvc.txt create mode 100644 externals/grill/flext/build/make-win-gen-msvc.inc create mode 100644 externals/grill/flext/build/make-win-max-msvc.inc create mode 100644 externals/grill/flext/build/make-win-msvc.inc create mode 100644 externals/grill/flext/build/make-win-pd-msvc.inc diff --git a/externals/grill/flext/build/config-win-max-msvc.def b/externals/grill/flext/build/config-win-max-msvc.def new file mode 100644 index 00000000..c1192ad4 --- /dev/null +++ b/externals/grill/flext/build/config-win-max-msvc.def @@ -0,0 +1,22 @@ +# where are the Max/MSP SDK header files? +# you should have the latest version! +MAXSDKPATH="c:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support" + +# where do the flext libraries reside? +FLEXTPATH="%CommonProgramFiles%\Cycling '74\flext" + +# where is MS VC++? +# (need not be defined if the build is started with the compiler environment set) +# MSVCPATH="c:\programme\prog\microsoft visual studio\VC98" + +# where should the external be built? +# (path for temporary files) +OUTPATH=max-msvc + +# where should the external be installed? +# (leave blank to omit installation) +INSTPATH="%CommonProgramFiles%\Cycling '74\externals\flext" + +# some user-definable flags +# (check if they match your system!) +UFLAGS=/G6 /Ox /arch:SSE diff --git a/externals/grill/flext/build/config-win-max-msvc.txt b/externals/grill/flext/build/config-win-max-msvc.txt new file mode 100644 index 00000000..c1192ad4 --- /dev/null +++ b/externals/grill/flext/build/config-win-max-msvc.txt @@ -0,0 +1,22 @@ +# where are the Max/MSP SDK header files? +# you should have the latest version! +MAXSDKPATH="c:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support" + +# where do the flext libraries reside? +FLEXTPATH="%CommonProgramFiles%\Cycling '74\flext" + +# where is MS VC++? +# (need not be defined if the build is started with the compiler environment set) +# MSVCPATH="c:\programme\prog\microsoft visual studio\VC98" + +# where should the external be built? +# (path for temporary files) +OUTPATH=max-msvc + +# where should the external be installed? +# (leave blank to omit installation) +INSTPATH="%CommonProgramFiles%\Cycling '74\externals\flext" + +# some user-definable flags +# (check if they match your system!) +UFLAGS=/G6 /Ox /arch:SSE diff --git a/externals/grill/flext/build/config-win-pd-msvc.def b/externals/grill/flext/build/config-win-pd-msvc.def new file mode 100644 index 00000000..bdce5879 --- /dev/null +++ b/externals/grill/flext/build/config-win-pd-msvc.def @@ -0,0 +1,20 @@ +# where is PD? +PDPATH=c:\programme\audio\pd + +# where do the flext libraries reside? +FLEXTPATH=$(PDPATH)\flext + +# where is MS VC++? +# (not necessary if the build is run with the compiler environment) +# MSVCPATH=C:\Programme\Microsoft Visual Studio .NET 2003\Vc7 + +# where should the external be built? +OUTPATH=pd-msvc + +# where should the external be installed? +# (leave blank to omit installation) +INSTPATH=$(PDPATH)\extra + +# user defined compiler flags +# (check if they match your system!) +UFLAGS=/G6 /Ox /arch:SSE diff --git a/externals/grill/flext/build/config-win-pd-msvc.txt b/externals/grill/flext/build/config-win-pd-msvc.txt new file mode 100644 index 00000000..bdce5879 --- /dev/null +++ b/externals/grill/flext/build/config-win-pd-msvc.txt @@ -0,0 +1,20 @@ +# where is PD? +PDPATH=c:\programme\audio\pd + +# where do the flext libraries reside? +FLEXTPATH=$(PDPATH)\flext + +# where is MS VC++? +# (not necessary if the build is run with the compiler environment) +# MSVCPATH=C:\Programme\Microsoft Visual Studio .NET 2003\Vc7 + +# where should the external be built? +OUTPATH=pd-msvc + +# where should the external be installed? +# (leave blank to omit installation) +INSTPATH=$(PDPATH)\extra + +# user defined compiler flags +# (check if they match your system!) +UFLAGS=/G6 /Ox /arch:SSE diff --git a/externals/grill/flext/build/make-win-gen-msvc.inc b/externals/grill/flext/build/make-win-gen-msvc.inc new file mode 100644 index 00000000..0538f63e --- /dev/null +++ b/externals/grill/flext/build/make-win-gen-msvc.inc @@ -0,0 +1,67 @@ +INCPATH=$(INCPATH) /I$(FLEXTPATH) +LIBPATH=$(LIBPATH) /LIBPATH:$(FLEXTPATH) + +!ifdef MSVCPATH +INCPATH=$(INCPATH) /I$(MSVCPATH)\include +LIBPATH=$(LIBPATH) /LIBPATH:$(MSVCPATH)\lib +!endif + +# add user flags +CFLAGS=$(UFLAGS) + +# for VC7 - exception handling +CFLAGS=$(CFLAGS) /EHsc + +############################################## + +# use multithreaded static libraries +!ifdef _DEBUG +CFLAGS=$(CFLAGS) /DMTd +!else +CFLAGS=$(CFLAGS) /DMT +!endif + +!ifdef FLEXT_SHARED +# --- shared --- +DEFS=$(DEFS) /DFLEXT_SHARED + +!elseifdef FLEXT_THREADED +# --- static multi-threaded --- +DEFS=$(DEFS) /DFLEXT_THREADS + +!else +# --- static single-threaded --- + +!endif + +############################################## + +all: $(OUTPATH) $(OUTPATH)\$(NAME).$(EXT) + +# remove build +clean: + -del /q $(OUTPATH) > nul + -rmdir $(OUTPATH) > nul + +OBJS= $(SRCS:.c=.obj) +OBJS= $(OBJS:.objpp=.obj) + +$(OUTPATH): + -mkdir $(OUTPATH) > nul + +{$(SRCDIR)}.cpp{}.obj: + cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)\$@ + +{$(SRCDIR)}.c{}.obj: + cl /c /LD $(CFLAGS) $(DEFS) $(INCPATH) $** /Fo$(OUTPATH)\$@ + +$(OUTPATH)\$(NAME).$(EXT): $(OBJS) + cd $(OUTPATH) + link /DLL $(LDFLAGS) /out:$(NAME).$(EXT) /INCREMENTAL:NO $** $(LIBS) $(LIBPATH) + @-del *.exp + @-del *.lib + cd .. +!ifdef INSTPATH + @-if not exist $(INSTPATH) mkdir $(INSTPATH) + copy $@ $(INSTPATH) > nul +!endif diff --git a/externals/grill/flext/build/make-win-max-msvc.inc b/externals/grill/flext/build/make-win-max-msvc.inc new file mode 100644 index 00000000..eb03a828 --- /dev/null +++ b/externals/grill/flext/build/make-win-max-msvc.inc @@ -0,0 +1,35 @@ +DEFS=$(DEFS) /DFLEXT_SYS=1 +CFLAGS=$(CFLAGS) /Zp2 + +INCPATH=$(INCPATH) /I$(MAXSDKPATH)\max-includes /I$(MAXSDKPATH)\msp-includes +LIBPATH=$(LIBPATH) /LIBPATH:$(MAXSDKPATH)\max-includes /LIBPATH:$(MAXSDKPATH)\msp-includes + +# these are both in MAXSDKPATH +LIBS=$(LIBS) maxapi.lib maxaudio.lib + +EXT=mxe + +######################################### + +!ifdef FLEXT_SHARED +# --- shared --- + +!elseifdef FLEXT_THREADED +# --- static multi-threaded --- + +!ifdef _DEBUG +LIBS=$(LIBS) flext_td-maxwin.lib +!else +LIBS=$(LIBS) flext_t-maxwin.lib +!endif + +!else +# --- static single-threaded --- + +!ifdef _DEBUG +LIBS=$(LIBS) flext_d-maxwin.lib +!else +LIBS=$(LIBS) flext-maxwin.lib +!endif + +!endif diff --git a/externals/grill/flext/build/make-win-msvc.inc b/externals/grill/flext/build/make-win-msvc.inc new file mode 100644 index 00000000..56b4deee --- /dev/null +++ b/externals/grill/flext/build/make-win-msvc.inc @@ -0,0 +1,22 @@ +!ifdef $(MAX) +# Max/MSP +!include config-pd-msvc.txt +!include makefile-msvc.txt +!include ..\flext\build\make-win-max-msvc.inc + +!elseifdef $(PD) +# PD +!include config-pd-msvc.txt +!include makefile-msvc.txt +!include ..\flext\build\make-win-pd-msvc.inc + +!else +!error Platform not supported +!endif + +# all the source files from the package +!include make-files.txt + +# now build +!include ..\flext\build\make-win-gen-msvc.inc + diff --git a/externals/grill/flext/build/make-win-pd-msvc.inc b/externals/grill/flext/build/make-win-pd-msvc.inc new file mode 100644 index 00000000..41cbfd20 --- /dev/null +++ b/externals/grill/flext/build/make-win-pd-msvc.inc @@ -0,0 +1,34 @@ +DEFS=$(DEFS) /DFLEXT_SYS=2 + +INCPATH=$(INCPATH) /I$(PDPATH)\src +LIBPATH=$(LIBPATH) /LIBPATH:$(PDPATH)\bin + +# these are both in PDPATH +LIBS=$(LIBS) pd.lib pthreadVC.lib + +EXT=dll + +######################################### + +!ifdef FLEXT_SHARED +# --- shared --- + +!elseifdef FLEXT_THREADED +# --- static multi-threaded --- + +!ifdef _DEBUG +LIBS=$(LIBS) flext_td-pdwin.lib +!else +LIBS=$(LIBS) flext_t-pdwin.lib +!endif + +!else +# --- static single-threaded --- + +!ifdef _DEBUG +LIBS=$(LIBS) flext_d-pdwin.lib +!else +LIBS=$(LIBS) flext-pdwin.lib +!endif + +!endif diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index e31d9add..e073de04 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -21,6 +21,9 @@ Version history: - show saveable attributes on object select - fix for long attribute dialogs - dropped support for Max UI objects +- added global system locking +- added general atom outlet functions To{Sys,Out,Queue}Atom +- added build system for flext-based externals 0.4.7: - added flext::GetBool (just because flext::GetInt has been there for a while) diff --git a/externals/grill/flext/config-max-msvc.txt b/externals/grill/flext/config-max-msvc.txt index 88fceca8..a1d62c63 100644 --- a/externals/grill/flext/config-max-msvc.txt +++ b/externals/grill/flext/config-max-msvc.txt @@ -3,7 +3,7 @@ # # where is the Max SDK? -MAXSDKPATH="F:\prog\audio\maxmspsdk_win\4.5 headers\c74support" +MAXSDKPATH="C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support" # where is MS VC++? # (should be commented out when called from the Visual Studio Command prompt) diff --git a/externals/grill/flext/config-pd-msvc.txt b/externals/grill/flext/config-pd-msvc.txt index 23ce4083..fdbe841c 100644 --- a/externals/grill/flext/config-pd-msvc.txt +++ b/externals/grill/flext/config-pd-msvc.txt @@ -1,5 +1,5 @@ # flext - C++ layer for Max/MSP and pd (pure data) externals -# Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) +# Copyright (c) 2001-2004 Thomas Grill (gr@grrrr.org) # # where is PD? @@ -7,7 +7,7 @@ PDPATH=c:\programme\audio\pd # where is the pthreads package? # (comment out if you use the standard pd package where pthreads are included) -# PTHREADS=F:\prog\packs\pthreads +# PTHREADS=c:\data\prog\packs\pthreads # where is MS VC++? # (should be commented out when called from the Visual Studio Command prompt) @@ -16,12 +16,12 @@ PDPATH=c:\programme\audio\pd # where is the SndObj directory? # headers are searched in SNDOBJ/include, the sndobj.lib in SNDOBJ/lib # (leave blank or comment out to disable SndObj support) -SNDOBJ=f:\prog\audio\sndobj +SNDOBJ=c:\data\prog\audio\sndobj # where is the STK include directory? # headers are searched in STK/include, the stk.lib in STK/lib # (leave blank or comment out to disable STK support) -STK=f:\prog\audio\stk +STK=c:\data\prog\audio\stk # where should flext libraries be built? # object files will be placed in subfolders diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj index 7a1938ea..c4426b2d 100644 --- a/externals/grill/flext/flext.vcproj +++ b/externals/grill/flext/flext.vcproj @@ -121,7 +121,7 @@ + Name="PD Threads Debug|Win32" + ExcludedFromBuild="TRUE"> + Name="PD Threads Release|Win32" + ExcludedFromBuild="TRUE"> + Name="PD Threads Debug|Win32" + ExcludedFromBuild="TRUE"> + Name="PD Threads Release|Win32" + ExcludedFromBuild="TRUE"> (sym_list),argc,(t_atom *)argv); CRITOFF(); } } void flext_base::ToSysAnything(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(); } } +void flext_base::ToSysAtom(int n,const t_atom &at) const +{ + outlet *o = GetOut(n); + if(o) { + CRITON(); + if(IsSymbol(at)) + outlet_symbol((t_outlet *)o,const_cast(GetSymbol(at))); + else if(IsFloat(at)) + outlet_float((t_outlet *)o,GetFloat(at)); +#if FLEXT_SYS == FLEXT_SYS_MAX + else if(IsInt(at)) + outlet_flint((t_outlet *)o,GetInt(at)); +#endif +#if FLEXT_SYS == FLEXT_SYS_PD + else if(IsPointer(at)) + outlet_pointer((t_outlet *)o,GetPointer(at)); +#endif + else + error("Atom type not supported"); + CRITOFF(); + } +} + #elif FLEXT_SYS == FLEXT_SYS_JMAX void flext_base::ToSysBang(int n) const { fts_outlet_bang((fts_object *)thisHdr(),n); } @@ -52,6 +75,7 @@ void flext_base::ToOutBang(int n) const { if(CHKTHR()) ToSysBang(n); else ToQueu void flext_base::ToOutFloat(int n,float f) const { if(CHKTHR()) ToSysFloat(n,f); else ToQueueFloat(n,f); } void flext_base::ToOutInt(int n,int f) const { if(CHKTHR()) ToSysInt(n,f); else ToQueueInt(n,f); } void flext_base::ToOutSymbol(int n,const t_symbol *s) const { if(CHKTHR()) ToSysSymbol(n,s); else ToQueueSymbol(n,s); } +void flext_base::ToOutAtom(int n,const t_atom &at) const { if(CHKTHR()) ToSysAtom(n,at); else ToQueueAtom(n,at); } void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysList(n,argc,argv); else ToQueueList(n,argc,argv); } void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysAnything(n,s,argc,argv); else ToQueueAnything(n,s,argc,argv); } diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 41b201d7..9277887b 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -32,7 +32,11 @@ flext::thrid_t flext::thrmsgid = 0; class qmsg { public: - void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) { th = t,out = o,sym = s,argc = ac,argv = av; } + void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) + { + th = t; out = o; + sym = s,argc = ac,argv = av; + } // \note PD sys lock must already be held by caller void Send() const @@ -98,10 +102,11 @@ public: { t_atom *at = GetAtoms(1); SetInt(*at,dt); + const t_symbol *sym; #if FLEXT_SYS == FLEXT_SYS_PD - const t_symbol *sym = sym_float; + sym = sym_float; #elif FLEXT_SYS == FLEXT_SYS_MAX - const t_symbol *sym = sym_int; + sym = sym_int; #else #error Not implemented! #endif @@ -115,6 +120,30 @@ public: Set(th,o,sym_symbol,1,at); } + void Push(flext_base *th,int o,const t_atom &a) + { + t_atom *at = GetAtoms(1); + *at = a; + const t_symbol *sym; + if(IsSymbol(a)) + sym = sym_symbol; + else if(IsFloat(a)) + sym = sym_float; +#if FLEXT_SYS == FLEXT_SYS_MAX + else if(IsInt(a)) + sym = sym_int; +#endif +#if FLEXT_SYS == FLEXT_SYS_PD + else if(IsPointer(a)) + sym = sym_pointer; +#endif + else { + error("atom type not supported"); + return; + } + Set(th,o,sym,1,at); + } + void Push(flext_base *th,int o,int argc,const t_atom *argv) { t_atom *at = GetAtoms(argc); @@ -312,6 +341,12 @@ void flext_base::ToQueueSymbol(int o,const t_symbol *s) const Trigger(); } +void flext_base::ToQueueAtom(int o,const t_atom &at) const +{ + queue.Push(const_cast(this),o,at); + Trigger(); +} + void flext_base::ToQueueList(int o,int argc,const t_atom *argv) const { queue.Push(const_cast(this),o,argc,argv); diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index 0bc70cd3..0a63111e 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -118,6 +118,7 @@ extern "C" { #include "ext.h" #include "ext_user.h" +#include "ext_critical.h" #include "z_dsp.h" } // extern "C" diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index be64b1e2..31b64f2a 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -437,11 +437,11 @@ public: //! Check whether the atom can be a pointer static bool CanbePointer(const t_atom &a) { return IsPointer(a); } //! Access the pointer value (without type check) - static void *GetPointer(const t_atom &a) { return a.a_w.w_gpointer; } + static t_gpointer *GetPointer(const t_atom &a) { return a.a_w.w_gpointer; } //! Check for a pointer and get its value - static void *GetAPointer(const t_atom &a,void *def = NULL) { return IsPointer(a)?GetPointer(a):def; } + static t_gpointer *GetAPointer(const t_atom &a,t_gpointer *def = NULL) { return IsPointer(a)?GetPointer(a):def; } //! Set the atom to represent a pointer - static void SetPointer(t_atom &a,void *p) { a.a_type = A_POINTER; a.a_w.w_gpointer = (t_gpointer *)p; } + static void SetPointer(t_atom &a,t_gpointer *p) { a.a_type = A_POINTER; a.a_w.w_gpointer = (t_gpointer *)p; } #elif FLEXT_SYS == FLEXT_SYS_MAX //! Check for a float and get its value @@ -645,6 +645,29 @@ public: // --- thread stuff ----------------------------------------------- + /*! \defgroup FLEXT_S_LOCK Global system locking + @{ + */ + +#if FLEXT_SYS == FLEXT_SYS_PD + #if PD_MINOR_VERSION >= 38 || (PD_MINOR_VERSION >= 37 && defined(PD_DEVEL_VERSION)) + static void Lock() { sys_lock(); } + static void Unlock() { sys_unlock(); } + #else + // no system locking for old PD versions + static void Lock() {} + static void Unlock() {} + #endif +#elif FLEXT_SYS == FLEXT_SYS_MAX + // Max 4.2 upwards! + static void Lock() { critical_enter(0); } + static void Unlock() { critical_exit(0); } +#else +#error +#endif + +//! @} FLEXT_S_LOCK + #ifdef FLEXT_THREADS /*! \defgroup FLEXT_S_THREAD Flext thread handling @{ -- cgit v1.2.1