diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2007-01-20 14:27:22 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2007-01-20 14:27:22 +0000 |
commit | 6efe6563a57bc3f946deaecff67653f9d21ea99d (patch) | |
tree | b8b333e445065d03fa18a9d2f5c1588f8eeae162 /externals/grill/py | |
parent | da93c2de9bcc91555e5cbf8255d811818d8beca8 (diff) |
fixed rich comparison method in Symbol class
fix for OSX
small cosmetic fixes
enable compiled-only scripts (without .py)
small changes for numpy support
fix for numpy headers on OS X
fix for numpy
added xcode 2.4 project
added pyext._list and pyext._tuple to convert input lists to Python sequence objects
fix numpy et al
enable module packages (module/__init__.py[co]), now also for Max
svn path=/trunk/; revision=7370
Diffstat (limited to 'externals/grill/py')
-rw-r--r-- | externals/grill/py/build/gnumake-lnx-gcc.inc | 9 | ||||
-rw-r--r-- | externals/grill/py/build/gnumake-mac-gcc.inc | 8 | ||||
-rw-r--r-- | externals/grill/py/build/gnumake-win-cygwin.inc | 7 | ||||
-rw-r--r-- | externals/grill/py/build/nmake-win-msvc.inc | 8 | ||||
-rwxr-xr-x | externals/grill/py/maxmsp/py-objectmappings.txt | 2 | ||||
-rw-r--r-- | externals/grill/py/py.vcproj | 4 | ||||
-rw-r--r-- | externals/grill/py/py.xcodeproj/project.pbxproj | 626 | ||||
-rw-r--r-- | externals/grill/py/source/pybuffer.cpp | 1584 | ||||
-rw-r--r-- | externals/grill/py/source/pysymbol.cpp | 48 |
9 files changed, 1478 insertions, 818 deletions
diff --git a/externals/grill/py/build/gnumake-lnx-gcc.inc b/externals/grill/py/build/gnumake-lnx-gcc.inc index ff0a8bfa..483bb514 100644 --- a/externals/grill/py/build/gnumake-lnx-gcc.inc +++ b/externals/grill/py/build/gnumake-lnx-gcc.inc @@ -4,4 +4,11 @@ LIBS += -lpython$(PYTHONVERSION) ifdef PY_NUMARRAY DEFS += -DPY_NUMARRAY -endif
\ No newline at end of file +endif +ifdef PY_NUMPY +DEFS += -DPY_NUMPY +endif +ifdef PY_NUMERIC +DEFS += -DPY_NUMERIC +endif + diff --git a/externals/grill/py/build/gnumake-mac-gcc.inc b/externals/grill/py/build/gnumake-mac-gcc.inc index c7268557..c7080d47 100644 --- a/externals/grill/py/build/gnumake-mac-gcc.inc +++ b/externals/grill/py/build/gnumake-mac-gcc.inc @@ -4,3 +4,11 @@ LIBS += -framework Python ifdef PY_NUMARRAY DEFS += -DPY_NUMARRAY endif +ifdef PY_NUMPY +DEFS += -DPY_NUMPY +INCPATH += -I/Library/Python/2.3/site-packages/numpy/core/include +endif +ifdef PY_NUMERIC +DEFS += -DPY_NUMERIC +endif + diff --git a/externals/grill/py/build/gnumake-win-cygwin.inc b/externals/grill/py/build/gnumake-win-cygwin.inc index 70cfca17..102c2ecd 100644 --- a/externals/grill/py/build/gnumake-win-cygwin.inc +++ b/externals/grill/py/build/gnumake-win-cygwin.inc @@ -6,3 +6,10 @@ LIBS += -lpython$(PYTHONVER) -lshell32 ifdef PY_NUMARRAY DEFS += -DPY_NUMARRAY endif +ifdef PY_NUMPY +DEFS += -DPY_NUMPY +endif +ifdef PY_NUMERIC +DEFS += -DPY_NUMERIC +endif + diff --git a/externals/grill/py/build/nmake-win-msvc.inc b/externals/grill/py/build/nmake-win-msvc.inc index 0d4fa162..0820daf9 100644 --- a/externals/grill/py/build/nmake-win-msvc.inc +++ b/externals/grill/py/build/nmake-win-msvc.inc @@ -6,3 +6,11 @@ LIBS=$(LIBS) shell32.lib !ifdef PY_NUMARRAY DEFS = $(DEFS) /DPY_NUMARRAY !endif +!ifdef PY_NUMPY +INCPATH=$(INCPATH) /I$(PYTHONPATH)\Lib\site-packages\numpy\core\include +DEFS = $(DEFS) /DPY_NUMPY +!endif +!ifdef PY_NUMERIC +DEFS = $(DEFS) /DPY_NUMERIC +!endif + diff --git a/externals/grill/py/maxmsp/py-objectmappings.txt b/externals/grill/py/maxmsp/py-objectmappings.txt index 70b84768..cb0e4db3 100755 --- a/externals/grill/py/maxmsp/py-objectmappings.txt +++ b/externals/grill/py/maxmsp/py-objectmappings.txt @@ -8,6 +8,7 @@ max objectfile pyext~ py; max objectfile pyext.~ py;
max objectfile pyx~ py;
max objectfile pyx.~ py;
+max objectfile pym py;
max oblist python py;
max oblist python py.;
@@ -15,3 +16,4 @@ max oblist python pyext; max oblist python pyext.;
max oblist python pyext~;
max oblist python pyext.~;
+max oblist python pym;
diff --git a/externals/grill/py/py.vcproj b/externals/grill/py/py.vcproj index 021edc52..74c3954c 100644 --- a/externals/grill/py/py.vcproj +++ b/externals/grill/py/py.vcproj @@ -85,8 +85,8 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="C:\data\prog\packs\pthreads\include;"c:\data\pd\pd-cvs\src";..\flext\source;c:\programme\prog\Python24\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2;FLEXT_THREADS;PY_NUMARRAY;xFLEXT_USECMEM" + AdditionalIncludeDirectories="C:\data\prog\packs\pthreads\include;"c:\data\pd\pd-cvs\src";..\flext\source;C:\Programme\prog\Python24\include;"C:\Programme\prog\Python24\Lib\site-packages\numpy\core\include"" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2;FLEXT_THREADS;xPY_NUMPY;xFLEXT_USECMEM" BasicRuntimeChecks="3" RuntimeLibrary="1" RuntimeTypeInfo="TRUE" diff --git a/externals/grill/py/py.xcodeproj/project.pbxproj b/externals/grill/py/py.xcodeproj/project.pbxproj new file mode 100644 index 00000000..c46e16e1 --- /dev/null +++ b/externals/grill/py/py.xcodeproj/project.pbxproj @@ -0,0 +1,626 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + E90043870887A302008AEAFC /* pyatom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90043820887A302008AEAFC /* pyatom.cpp */; }; + E90043880887A302008AEAFC /* pyatom.h in Headers */ = {isa = PBXBuildFile; fileRef = E90043830887A302008AEAFC /* pyatom.h */; }; + E90043890887A302008AEAFC /* pybase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90043840887A302008AEAFC /* pybase.cpp */; }; + E900438A0887A302008AEAFC /* pybase.h in Headers */ = {isa = PBXBuildFile; fileRef = E90043850887A302008AEAFC /* pybase.h */; }; + E900438B0887A302008AEAFC /* pymeth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90043860887A302008AEAFC /* pymeth.cpp */; }; + E903AC8E09D32D03004755CA /* pybundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E903AC8C09D32D03004755CA /* pybundle.cpp */; }; + E903AC8F09D32D03004755CA /* pybundle.h in Resources */ = {isa = PBXBuildFile; fileRef = E903AC8D09D32D03004755CA /* pybundle.h */; }; + E903AC9009D32D03004755CA /* pybundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E903AC8C09D32D03004755CA /* pybundle.cpp */; }; + E903AC9109D32D03004755CA /* pybundle.h in Headers */ = {isa = PBXBuildFile; fileRef = E903AC8D09D32D03004755CA /* pybundle.h */; }; + E90E52E908092581001341AC /* main.h in Headers */ = {isa = PBXBuildFile; fileRef = E90E51DE08091989001341AC /* main.h */; }; + E90E52EA08092581001341AC /* pybuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = E90E51E308091989001341AC /* pybuffer.h */; }; + E90E52EB08092581001341AC /* pyext.h in Headers */ = {isa = PBXBuildFile; fileRef = E90E51E608091989001341AC /* pyext.h */; }; + E90E52EC08092581001341AC /* pyprefix.h in Headers */ = {isa = PBXBuildFile; fileRef = E90E51E708091989001341AC /* pyprefix.h */; }; + E90E52ED08092581001341AC /* pysymbol.h in Headers */ = {isa = PBXBuildFile; fileRef = E90E51E908091989001341AC /* pysymbol.h */; }; + E90E52EE0809258A001341AC /* bound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DB08091989001341AC /* bound.cpp */; }; + E90E52EF0809258A001341AC /* clmeth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DC08091989001341AC /* clmeth.cpp */; }; + E90E52F00809258A001341AC /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DD08091989001341AC /* main.cpp */; }; + E90E52F10809258A001341AC /* modmeth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DF08091989001341AC /* modmeth.cpp */; }; + E90E52F20809258A001341AC /* py.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E008091989001341AC /* py.cpp */; }; + E90E52F30809258A001341AC /* pyargs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E108091989001341AC /* pyargs.cpp */; }; + E90E52F40809258A001341AC /* pybuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E208091989001341AC /* pybuffer.cpp */; }; + E90E52F50809258A001341AC /* pydsp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E408091989001341AC /* pydsp.cpp */; }; + E90E52F60809258A001341AC /* pyext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E508091989001341AC /* pyext.cpp */; }; + E90E52F70809258A001341AC /* pysymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E808091989001341AC /* pysymbol.cpp */; }; + E90E52F80809258A001341AC /* register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51EA08091989001341AC /* register.cpp */; }; + E90E535B08092593001341AC /* Python.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E90E51FB080919EC001341AC /* Python.framework */; }; + E90E535D08092593001341AC /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E90E521108091CA5001341AC /* ApplicationServices.framework */; }; + E90E535E08092593001341AC /* vecLib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E90E52D208091F79001341AC /* vecLib.framework */; }; + E926B6D8089F76D90034D534 /* pyatom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90043820887A302008AEAFC /* pyatom.cpp */; }; + E926B6D9089F76D90034D534 /* pyatom.h in Sources */ = {isa = PBXBuildFile; fileRef = E90043830887A302008AEAFC /* pyatom.h */; }; + E926B6DA089F76D90034D534 /* pybase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90043840887A302008AEAFC /* pybase.cpp */; }; + E926B6DB089F76D90034D534 /* pybase.h in Sources */ = {isa = PBXBuildFile; fileRef = E90043850887A302008AEAFC /* pybase.h */; }; + E926B6DC089F76D90034D534 /* pymeth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90043860887A302008AEAFC /* pymeth.cpp */; }; + E926B6DD089F76D90034D534 /* bound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DB08091989001341AC /* bound.cpp */; }; + E926B6DE089F76D90034D534 /* clmeth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DC08091989001341AC /* clmeth.cpp */; }; + E926B6DF089F76D90034D534 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DD08091989001341AC /* main.cpp */; }; + E926B6E0089F76D90034D534 /* main.h in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DE08091989001341AC /* main.h */; }; + E926B6E1089F76D90034D534 /* modmeth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51DF08091989001341AC /* modmeth.cpp */; }; + E926B6E2089F76D90034D534 /* py.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E008091989001341AC /* py.cpp */; }; + E926B6E3089F76D90034D534 /* pyargs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E108091989001341AC /* pyargs.cpp */; }; + E926B6E4089F76D90034D534 /* pybuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E208091989001341AC /* pybuffer.cpp */; }; + E926B6E5089F76D90034D534 /* pybuffer.h in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E308091989001341AC /* pybuffer.h */; }; + E926B6E6089F76D90034D534 /* pydsp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E408091989001341AC /* pydsp.cpp */; }; + E926B6E7089F76D90034D534 /* pyext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E508091989001341AC /* pyext.cpp */; }; + E926B6E8089F76D90034D534 /* pyext.h in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E608091989001341AC /* pyext.h */; }; + E926B6E9089F76D90034D534 /* pyprefix.h in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E708091989001341AC /* pyprefix.h */; }; + E926B6EA089F76D90034D534 /* pysymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E808091989001341AC /* pysymbol.cpp */; }; + E926B6EB089F76D90034D534 /* pysymbol.h in Sources */ = {isa = PBXBuildFile; fileRef = E90E51E908091989001341AC /* pysymbol.h */; }; + E926B6EC089F76D90034D534 /* register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E90E51EA08091989001341AC /* register.cpp */; }; + E926B6F4089F77B20034D534 /* vecLib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E90E52D208091F79001341AC /* vecLib.framework */; }; + E926B7B6089F77B90034D534 /* Python.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E90E51FB080919EC001341AC /* Python.framework */; }; + E926B818089F782F0034D534 /* MaxAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E926B817089F782F0034D534 /* MaxAPI.framework */; }; + E926B81A089F78400034D534 /* MaxAudioAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E926B819089F78400034D534 /* MaxAudioAPI.framework */; }; + E926B833089F7CB50034D534 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E90E521108091CA5001341AC /* ApplicationServices.framework */; }; + E9D6763108FC619F0039A6F6 /* libflext-pd_d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E9D6762F08FC61860039A6F6 /* libflext-pd_d.dylib */; }; + E9D6763208FC619F0039A6F6 /* libflext-pd.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E9D6763008FC61860039A6F6 /* libflext-pd.dylib */; }; + E9D6763308FC61A40039A6F6 /* libflext-max_d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E9D6762D08FC61860039A6F6 /* libflext-max_d.dylib */; }; + E9D6763408FC61A40039A6F6 /* libflext-max.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E9D6762E08FC61860039A6F6 /* libflext-max.dylib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + E90043820887A302008AEAFC /* pyatom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pyatom.cpp; path = source/pyatom.cpp; sourceTree = "<group>"; }; + E90043830887A302008AEAFC /* pyatom.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pyatom.h; path = source/pyatom.h; sourceTree = "<group>"; }; + E90043840887A302008AEAFC /* pybase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pybase.cpp; path = source/pybase.cpp; sourceTree = "<group>"; }; + E90043850887A302008AEAFC /* pybase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pybase.h; path = source/pybase.h; sourceTree = "<group>"; }; + E90043860887A302008AEAFC /* pymeth.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pymeth.cpp; path = source/pymeth.cpp; sourceTree = "<group>"; }; + E903AC8C09D32D03004755CA /* pybundle.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pybundle.cpp; path = source/pybundle.cpp; sourceTree = "<group>"; }; + E903AC8D09D32D03004755CA /* pybundle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pybundle.h; path = source/pybundle.h; sourceTree = "<group>"; }; + E90E51DB08091989001341AC /* bound.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = bound.cpp; path = source/bound.cpp; sourceTree = "<group>"; }; + E90E51DC08091989001341AC /* clmeth.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = clmeth.cpp; path = source/clmeth.cpp; sourceTree = "<group>"; }; + E90E51DD08091989001341AC /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = source/main.cpp; sourceTree = "<group>"; }; + E90E51DE08091989001341AC /* main.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = main.h; path = source/main.h; sourceTree = "<group>"; }; + E90E51DF08091989001341AC /* modmeth.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = modmeth.cpp; path = source/modmeth.cpp; sourceTree = "<group>"; }; + E90E51E008091989001341AC /* py.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = py.cpp; path = source/py.cpp; sourceTree = "<group>"; }; + E90E51E108091989001341AC /* pyargs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pyargs.cpp; path = source/pyargs.cpp; sourceTree = "<group>"; }; + E90E51E208091989001341AC /* pybuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pybuffer.cpp; path = source/pybuffer.cpp; sourceTree = "<group>"; }; + E90E51E308091989001341AC /* pybuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pybuffer.h; path = source/pybuffer.h; sourceTree = "<group>"; }; + E90E51E408091989001341AC /* pydsp.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pydsp.cpp; path = source/pydsp.cpp; sourceTree = "<group>"; }; + E90E51E508091989001341AC /* pyext.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pyext.cpp; path = source/pyext.cpp; sourceTree = "<group>"; }; + E90E51E608091989001341AC /* pyext.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pyext.h; path = source/pyext.h; sourceTree = "<group>"; }; + E90E51E708091989001341AC /* pyprefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pyprefix.h; path = source/pyprefix.h; sourceTree = "<group>"; }; + E90E51E808091989001341AC /* pysymbol.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = pysymbol.cpp; path = source/pysymbol.cpp; sourceTree = "<group>"; }; + E90E51E908091989001341AC /* pysymbol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pysymbol.h; path = source/pysymbol.h; sourceTree = "<group>"; }; + E90E51EA08091989001341AC /* register.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = register.cpp; path = source/register.cpp; sourceTree = "<group>"; }; + E90E51FB080919EC001341AC /* Python.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Python.framework; path = /System/Library/Frameworks/Python.framework; sourceTree = "<absolute>"; }; + E90E521108091CA5001341AC /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; }; + E90E52D208091F79001341AC /* vecLib.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = vecLib.framework; path = /System/Library/Frameworks/vecLib.framework; sourceTree = "<absolute>"; }; + E90E52E608092505001341AC /* py.pd_darwin */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = py.pd_darwin; sourceTree = BUILT_PRODUCTS_DIR; }; + E926B6D3089F75950034D534 /* py.mxo */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = py.mxo; sourceTree = BUILT_PRODUCTS_DIR; }; + E926B6D4089F75950034D534 /* py-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "py-Info.plist"; path = "/Users/thomas/Develop/pdmax/py/py-Info.plist"; sourceTree = "<absolute>"; }; + E926B817089F782F0034D534 /* MaxAPI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MaxAPI.framework; path = /Library/Frameworks/MaxAPI.framework; sourceTree = "<absolute>"; }; + E926B819089F78400034D534 /* MaxAudioAPI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MaxAudioAPI.framework; path = /Library/Frameworks/MaxAudioAPI.framework; sourceTree = "<absolute>"; }; + E9D6762D08FC61860039A6F6 /* libflext-max_d.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libflext-max_d.dylib"; path = "/usr/local/lib/libflext-max_d.dylib"; sourceTree = "<absolute>"; }; + E9D6762E08FC61860039A6F6 /* libflext-max.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libflext-max.dylib"; path = "/usr/local/lib/libflext-max.dylib"; sourceTree = "<absolute>"; }; + E9D6762F08FC61860039A6F6 /* libflext-pd_d.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libflext-pd_d.dylib"; path = "/usr/local/lib/libflext-pd_d.dylib"; sourceTree = "<absolute>"; }; + E9D6763008FC61860039A6F6 /* libflext-pd.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libflext-pd.dylib"; path = "/usr/local/lib/libflext-pd.dylib"; sourceTree = "<absolute>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E90E52E408092505001341AC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E9D6763108FC619F0039A6F6 /* libflext-pd_d.dylib in Frameworks */, + E9D6763208FC619F0039A6F6 /* libflext-pd.dylib in Frameworks */, + E90E535B08092593001341AC /* Python.framework in Frameworks */, + E90E535D08092593001341AC /* ApplicationServices.framework in Frameworks */, + E90E535E08092593001341AC /* vecLib.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E926B6D1089F75950034D534 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E9D6763308FC61A40039A6F6 /* libflext-max_d.dylib in Frameworks */, + E9D6763408FC61A40039A6F6 /* libflext-max.dylib in Frameworks */, + E926B833089F7CB50034D534 /* ApplicationServices.framework in Frameworks */, + E926B7B6089F77B90034D534 /* Python.framework in Frameworks */, + E926B6F4089F77B20034D534 /* vecLib.framework in Frameworks */, + E926B818089F782F0034D534 /* MaxAPI.framework in Frameworks */, + E926B81A089F78400034D534 /* MaxAudioAPI.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* py */ = { + isa = PBXGroup; + children = ( + 08FB77ADFE841716C02AAC07 /* Source */, + 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */, + 19C28FB4FE9D528D11CA2CBB /* Products */, + E926B6D4089F75950034D534 /* py-Info.plist */, + ); + name = py; + sourceTree = "<group>"; + }; + 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + E9D6762D08FC61860039A6F6 /* libflext-max_d.dylib */, + E9D6762E08FC61860039A6F6 /* libflext-max.dylib */, + E9D6762F08FC61860039A6F6 /* libflext-pd_d.dylib */, + E9D6763008FC61860039A6F6 /* libflext-pd.dylib */, + E926B819089F78400034D534 /* MaxAudioAPI.framework */, + E926B817089F782F0034D534 /* MaxAPI.framework */, + E90E52D208091F79001341AC /* vecLib.framework */, + E90E521108091CA5001341AC /* ApplicationServices.framework */, + E90E51FB080919EC001341AC /* Python.framework */, + ); + name = "External Frameworks and Libraries"; + sourceTree = "<group>"; + }; + 08FB77ADFE841716C02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + E903AC8C09D32D03004755CA /* pybundle.cpp */, + E903AC8D09D32D03004755CA /* pybundle.h */, + E90043820887A302008AEAFC /* pyatom.cpp */, + E90043830887A302008AEAFC /* pyatom.h */, + E90043840887A302008AEAFC /* pybase.cpp */, + E90043850887A302008AEAFC /* pybase.h */, + E90043860887A302008AEAFC /* pymeth.cpp */, + E90E51DB08091989001341AC /* bound.cpp */, + E90E51DC08091989001341AC /* clmeth.cpp */, + E90E51DD08091989001341AC /* main.cpp */, + E90E51DE08091989001341AC /* main.h */, + E90E51DF08091989001341AC /* modmeth.cpp */, + E90E51E008091989001341AC /* py.cpp */, + E90E51E108091989001341AC /* pyargs.cpp */, + E90E51E208091989001341AC /* pybuffer.cpp */, + E90E51E308091989001341AC /* pybuffer.h */, + E90E51E408091989001341AC /* pydsp.cpp */, + E90E51E508091989001341AC /* pyext.cpp */, + E90E51E608091989001341AC /* pyext.h */, + E90E51E708091989001341AC /* pyprefix.h */, + E90E51E808091989001341AC /* pysymbol.cpp */, + E90E51E908091989001341AC /* pysymbol.h */, + E90E51EA08091989001341AC /* register.cpp */, + ); + name = Source; + sourceTree = "<group>"; + }; + 19C28FB4FE9D528D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + E90E52E608092505001341AC /* py.pd_darwin */, + E926B6D3089F75950034D534 /* py.mxo */, + ); + name = Products; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + E90E52E208092505001341AC /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + E90E52E908092581001341AC /* main.h in Headers */, + E90E52EA08092581001341AC /* pybuffer.h in Headers */, + E90E52EB08092581001341AC /* pyext.h in Headers */, + E90E52EC08092581001341AC /* pyprefix.h in Headers */, + E90E52ED08092581001341AC /* pysymbol.h in Headers */, + E90043880887A302008AEAFC /* pyatom.h in Headers */, + E900438A0887A302008AEAFC /* pybase.h in Headers */, + E903AC9109D32D03004755CA /* pybundle.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + E90E52E508092505001341AC /* py.pd_darwin */ = { + isa = PBXNativeTarget; + buildConfigurationList = E93C2D850A5DB6E70023B566 /* Build configuration list for PBXNativeTarget "py.pd_darwin" */; + buildPhases = ( + E90E52E208092505001341AC /* Headers */, + E90E52E308092505001341AC /* Sources */, + E90E52E408092505001341AC /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = py.pd_darwin; + productName = py; + productReference = E90E52E608092505001341AC /* py.pd_darwin */; + productType = "com.apple.product-type.library.dynamic"; + }; + E926B6D2089F75950034D534 /* py */ = { + isa = PBXNativeTarget; + buildConfigurationList = E93C2D890A5DB6E70023B566 /* Build configuration list for PBXNativeTarget "py" */; + buildPhases = ( + E926B6CF089F75950034D534 /* Resources */, + E926B6D0089F75950034D534 /* Sources */, + E926B6D1089F75950034D534 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = py; + productName = py; + productReference = E926B6D3089F75950034D534 /* py.mxo */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = E93C2D8D0A5DB6E70023B566 /* Build configuration list for PBXProject "py" */; + hasScannedForEncodings = 1; + mainGroup = 089C166AFE841209C02AAC07 /* py */; + projectDirPath = ""; + targets = ( + E90E52E508092505001341AC /* py.pd_darwin */, + E926B6D2089F75950034D534 /* py */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + E926B6CF089F75950034D534 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E903AC8F09D32D03004755CA /* pybundle.h in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + E90E52E308092505001341AC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E90E52EE0809258A001341AC /* bound.cpp in Sources */, + E90E52EF0809258A001341AC /* clmeth.cpp in Sources */, + E90E52F00809258A001341AC /* main.cpp in Sources */, + E90E52F10809258A001341AC /* modmeth.cpp in Sources */, + E90E52F20809258A001341AC /* py.cpp in Sources */, + E90E52F30809258A001341AC /* pyargs.cpp in Sources */, + E90E52F40809258A001341AC /* pybuffer.cpp in Sources */, + E90E52F50809258A001341AC /* pydsp.cpp in Sources */, + E90E52F60809258A001341AC /* pyext.cpp in Sources */, + E90E52F70809258A001341AC /* pysymbol.cpp in Sources */, + E90E52F80809258A001341AC /* register.cpp in Sources */, + E90043870887A302008AEAFC /* pyatom.cpp in Sources */, + E90043890887A302008AEAFC /* pybase.cpp in Sources */, + E900438B0887A302008AEAFC /* pymeth.cpp in Sources */, + E903AC9009D32D03004755CA /* pybundle.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E926B6D0089F75950034D534 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E926B6D8089F76D90034D534 /* pyatom.cpp in Sources */, + E926B6D9089F76D90034D534 /* pyatom.h in Sources */, + E926B6DA089F76D90034D534 /* pybase.cpp in Sources */, + E926B6DB089F76D90034D534 /* pybase.h in Sources */, + E926B6DC089F76D90034D534 /* pymeth.cpp in Sources */, + E926B6DD089F76D90034D534 /* bound.cpp in Sources */, + E926B6DE089F76D90034D534 /* clmeth.cpp in Sources */, + E926B6DF089F76D90034D534 /* main.cpp in Sources */, + E926B6E0089F76D90034D534 /* main.h in Sources */, + E926B6E1089F76D90034D534 /* modmeth.cpp in Sources */, + E926B6E2089F76D90034D534 /* py.cpp in Sources */, + E926B6E3089F76D90034D534 /* pyargs.cpp in Sources */, + E926B6E4089F76D90034D534 /* pybuffer.cpp in Sources */, + E926B6E5089F76D90034D534 /* pybuffer.h in Sources */, + E926B6E6089F76D90034D534 /* pydsp.cpp in Sources */, + E926B6E7089F76D90034D534 /* pyext.cpp in Sources */, + E926B6E8089F76D90034D534 /* pyext.h in Sources */, + E926B6E9089F76D90034D534 /* pyprefix.h in Sources */, + E926B6EA089F76D90034D534 /* pysymbol.cpp in Sources */, + E926B6EB089F76D90034D534 /* pysymbol.h in Sources */, + E926B6EC089F76D90034D534 /* register.cpp in Sources */, + E903AC8E09D32D03004755CA /* pybundle.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + E93C2D860A5DB6E70023B566 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + DEBUGGING_SYMBOLS = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + EXECUTABLE_EXTENSION = pd_darwin; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_MODEL_CPU = G4; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = source/pyprefix.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "FLEXT_SYS=2", + FLEXT_DEBUG, + FLEXT_THREADS, + ); + HEADER_SEARCH_PATHS = ( + "$(flext)/source", + "$(PD-devel)/src", + ); + INSTALL_PATH = "$(PDApp)/extra"; + LIBRARY_SEARCH_PATHS = "$(flext)/build"; + LIBRARY_STYLE = STATIC; + MACH_O_TYPE = staticlib; + OPTIMIZATION_CFLAGS = "-O0"; + OTHER_CFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = py; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + ZERO_LINK = YES; + }; + name = Development; + }; + E93C2D870A5DB6E70023B566 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + EXECUTABLE_EXTENSION = pd_darwin; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_CPU = G4; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = source/pyprefix.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "FLEXT_SYS=2", + FLEXT_SHARED, + ); + HEADER_SEARCH_PATHS = ( + "$(flext)/source", + "$(PD-devel)/src", + ); + INSTALL_PATH = "$(PDApp)/extra"; + LIBRARY_SEARCH_PATHS = "$(flext)/build"; + LIBRARY_STYLE = DYNAMIC; + MACH_O_TYPE = mh_dylib; + OTHER_CFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = py; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + ZERO_LINK = NO; + }; + name = Deployment; + }; + E93C2D880A5DB6E70023B566 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + EXECUTABLE_EXTENSION = pd_darwin; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_MODEL_CPU = G4; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = source/pyprefix.h; + GCC_PREPROCESSOR_DEFINITIONS = "FLEXT_SYS=2"; + HEADER_SEARCH_PATHS = ( + "$(flext)/source", + "$(PD-devel)/src", + ); + INSTALL_PATH = "$(PDApp)/extra"; + LIBRARY_SEARCH_PATHS = "$(flext)/build"; + LIBRARY_STYLE = DYNAMIC; + MACH_O_TYPE = mh_dylib; + OTHER_CFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = py; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + }; + name = Default; + }; + E93C2D8A0A5DB6E70023B566 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + DEBUGGING_SYMBOLS = YES; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = source/pyprefix.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "FLEXT_SYS=1", + FLEXT_DEBUG, + FLEXT_THREADS, + ); + GENERATE_PKGINFO_FILE = YES; + HEADER_SEARCH_PATHS = ( + "$(flext)/source", + "$(MaxSDK)/max-includes", + "$(MaxSDK)/msp-includes", + ); + INFOPLIST_FILE = "py-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(MaxSDK)/max-includes", + "$(MaxSDK)/msp-includes", + ); + LIBRARY_STYLE = STATIC; + OPTIMIZATION_CFLAGS = "-O0"; + OTHER_CFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = py; + SECTORDER_FLAGS = ""; + SKIP_INSTALL = YES; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = mxo; + ZERO_LINK = YES; + }; + name = Development; + }; + E93C2D8B0A5DB6E70023B566 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = source/pyprefix.h; + GCC_PREPROCESSOR_DEFINITIONS = ( + "FLEXT_SYS=1", + FLEXT_SHARED, + ); + GENERATE_PKGINFO_FILE = YES; + HEADER_SEARCH_PATHS = ( + "$(flext)/source", + "$(MaxSDK)/max-includes", + "$(MaxSDK)/msp-includes", + ); + INFOPLIST_FILE = "py-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(MaxSDK)/max-includes", + "$(MaxSDK)/msp-includes", + ); + OTHER_CFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = py; + SECTORDER_FLAGS = ""; + SKIP_INSTALL = YES; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = mxo; + ZERO_LINK = NO; + }; + name = Deployment; + }; + E93C2D8C0A5DB6E70023B566 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = source/pyprefix.h; + GCC_PREPROCESSOR_DEFINITIONS = "FLEXT_SYS=1"; + GENERATE_PKGINFO_FILE = YES; + HEADER_SEARCH_PATHS = ( + "$(flext)/source", + "$(MaxSDK)/max-includes", + "$(MaxSDK)/msp-includes", + ); + INFOPLIST_FILE = "py-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(MaxSDK)/max-includes", + "$(MaxSDK)/msp-includes", + ); + OTHER_CFLAGS = ""; + OTHER_REZFLAGS = ""; + PRODUCT_NAME = py; + SECTORDER_FLAGS = ""; + SKIP_INSTALL = YES; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = mxo; + }; + name = Default; + }; + E93C2D8E0A5DB6E70023B566 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = PY_NUMERIC; + }; + name = Development; + }; + E93C2D8F0A5DB6E70023B566 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = PY_NUMERIC; + }; + name = Deployment; + }; + E93C2D900A5DB6E70023B566 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = PY_NUMPY; + }; + name = Default; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + E93C2D850A5DB6E70023B566 /* Build configuration list for PBXNativeTarget "py.pd_darwin" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E93C2D860A5DB6E70023B566 /* Development */, + E93C2D870A5DB6E70023B566 /* Deployment */, + E93C2D880A5DB6E70023B566 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; + E93C2D890A5DB6E70023B566 /* Build configuration list for PBXNativeTarget "py" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E93C2D8A0A5DB6E70023B566 /* Development */, + E93C2D8B0A5DB6E70023B566 /* Deployment */, + E93C2D8C0A5DB6E70023B566 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; + E93C2D8D0A5DB6E70023B566 /* Build configuration list for PBXProject "py" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E93C2D8E0A5DB6E70023B566 /* Development */, + E93C2D8F0A5DB6E70023B566 /* Deployment */, + E93C2D900A5DB6E70023B566 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/externals/grill/py/source/pybuffer.cpp b/externals/grill/py/source/pybuffer.cpp index 15b64c6d..c375aa63 100644 --- a/externals/grill/py/source/pybuffer.cpp +++ b/externals/grill/py/source/pybuffer.cpp @@ -1,791 +1,793 @@ -/*
-
-py/pyext - python script object for PD and Max/MSP
-
-Copyright (c)2002-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-
-*/
-
-#include "pybase.h"
-
-#undef PY_ARRAYS
-
-
-#if defined(PY_NUMERIC) || defined(PY_NUMPY)
- #define PY_ARRAYS 1
-#elif defined(PY_NUMARRAY)
- #define PY_ARRAYS 1
- #define NA
-#endif
-
-#ifdef PY_ARRAYS
-
-#ifdef NA
- #if FLEXT_OS == FLEXT_OS_MAC
- #include <Python/numarray/libnumarray.h>
- #else
- #include <numarray/libnumarray.h>
- #endif
-
-static NumarrayType numtype = tAny;
-inline bool arrsupport() { return numtype != tAny; }
-
-#else
- #if FLEXT_OS == FLEXT_OS_MAC
- #include <Python/numarray/arrayobject.h>
- #else
- #include <numarray/arrayobject.h>
- #endif
-
-static PyArray_TYPES numtype = PyArray_NOTYPE;
-inline bool arrsupport() { return numtype != PyArray_NOTYPE; }
-#endif
-#endif
-
-
-PyObject *pybase::py_arraysupport(PyObject *self,PyObject *args)
-{
- PyObject *ret;
-#ifdef PY_ARRAYS
- ret = Py_True;
-#else
- ret = Py_False;
-#endif
- Py_INCREF(ret);
- return ret;
-}
-
-
-// PD defines a T_OBJECT symbol
-#undef T_OBJECT
-
-#if FLEXT_OS == FLEXT_OS_MAC
-#include "Python/bufferobject.h"
-#include "Python/structmember.h"
-#else
-#include "bufferobject.h"
-#include "structmember.h"
-#endif
-
-static PyObject *buffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- pySamplebuffer *self = (pySamplebuffer *)pySamplebuffer_Type.tp_alloc(&pySamplebuffer_Type, 0);
- self->sym = NULL;
- self->buf = NULL;
- self->dirty = false;
- return (PyObject *)self;
-}
-
-static void buffer_dealloc(PyObject *obj)
-{
- pySamplebuffer *self = (pySamplebuffer *)obj;
-
- if(self->buf) {
- self->buf->Unlock(self->lock);
- if(self->dirty) self->buf->Dirty(true);
- delete self->buf;
- }
-
- obj->ob_type->tp_free(obj);
-}
-
-static int buffer_init(PyObject *obj, PyObject *args, PyObject *kwds)
-{
- FLEXT_ASSERT(pySamplebuffer_Check(obj));
-
- PyObject *arg = PySequence_GetItem(args,0); // new reference
- if(!arg) return -1;
-
- int ret = 0;
-
- pySamplebuffer *self = (pySamplebuffer *)obj;
- FLEXT_ASSERT(!self->sym && !self->buf);
-
- if(pySymbol_Check(arg))
- self->sym = pySymbol_AS_SYMBOL(arg);
- else if(PyString_Check(arg))
- self->sym = flext::MakeSymbol(PyString_AS_STRING(arg));
- else
- ret = -1;
- Py_DECREF(arg);
-
- if(self->sym) {
- flext::buffer *b = new flext::buffer(self->sym);
- if(b->Ok() && b->Valid())
- self->lock = (self->buf = b)->Lock();
- else
- delete b;
- }
-
- return ret;
-}
-
-static PyObject *buffer_repr(PyObject *self)
-{
- FLEXT_ASSERT(pySamplebuffer_Check(self));
- return (PyObject *)PyString_FromFormat("<Samplebuffer %s>",pySamplebuffer_AS_STRING(self));
-}
-
-static long buffer_hash(PyObject *self)
-{
- FLEXT_ASSERT(pySamplebuffer_Check(self));
- return (long)(((pySamplebuffer *)self)->buf);
-}
-
-static PyObject *buffer_getsymbol(pySamplebuffer* self,void *closure)
-{
- if(self->sym)
- return pySymbol_FromSymbol(self->sym);
- else {
- Py_INCREF(Py_None);
- return Py_None;
- }
-}
-
-static PyGetSetDef buffer_getseters[] = {
- {"symbol",(getter)buffer_getsymbol, NULL, NULL},
- {NULL} /* Sentinel */
-};
-
-static PyObject *buffer_dirty(PyObject *obj)
-{
- ((pySamplebuffer *)obj)->dirty = true;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *buffer_resize(PyObject *obj,PyObject *args,PyObject *kwds)
-{
- flext::buffer *b = ((pySamplebuffer *)obj)->buf;
- if(b) {
- int frames,keep = 1,zero = 1;
- static char *kwlist[] = {"frames", "keep", "zero", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, kwds, "i|ii", kwlist, &frames, &keep, &zero))
- return NULL;
-
- b->Frames(frames,keep != 0,zero != 0);
-
- Py_INCREF(obj);
- return obj;
- }
- else {
- PyErr_SetString(PyExc_RuntimeError,"Invalid buffer");
- return NULL;
- }
-}
-
-static PyMethodDef buffer_methods[] = {
- {"dirty", (PyCFunction)buffer_dirty,METH_NOARGS,"Mark buffer as dirty"},
- {"resize", (PyCFunction)buffer_resize,METH_VARARGS|METH_KEYWORDS,"Resize buffer"},
- {NULL} /* Sentinel */
-};
-
-
-
-// support the buffer protocol
-static int buffer_readbuffer(PyObject *obj, int segment, void **ptrptr)
-{
- flext::buffer *b = ((pySamplebuffer *)obj)->buf;
- ptrptr[0] = b->Data();
- return b->Channels()*b->Frames()*sizeof(t_sample);
-}
-
-static int buffer_writebuffer(PyObject *obj, int segment, void **ptrptr)
-{
- flext::buffer *b = ((pySamplebuffer *)obj)->buf;
- ptrptr[0] = b->Data();
- return b->Channels()*b->Frames()*sizeof(t_sample);
-}
-
-static int buffer_segcount(PyObject *obj, int *lenp)
-{
- flext::buffer *b = ((pySamplebuffer *)obj)->buf;
- if(lenp) lenp[0] = b->Channels()*b->Frames()*sizeof(t_sample);
- return 1;
-}
-
-static int buffer_charbuffer(PyObject *obj, int segment, const char **ptrptr)
-{
- flext::buffer *b = ((pySamplebuffer *)obj)->buf;
- ptrptr[0] = (char *)b->Data();
- return b->Channels()*b->Frames()*sizeof(t_sample);
-}
-
-static PyBufferProcs buffer_as_buffer = {
- buffer_readbuffer,
- buffer_writebuffer,
- buffer_segcount,
- buffer_charbuffer
-};
-
-static int buffer_length(pySamplebuffer *self)
-{
- return self->buf?self->buf->Frames():0;
-}
-
-static PyObject *buffer_item(pySamplebuffer *self, int i)
-{
- PyObject *ret;
- if(self->buf) {
- if (i < 0 || i >= self->buf->Frames()) {
- PyErr_SetString(PyExc_IndexError,"Index out of range");
- ret = NULL;
- }
- else {
- if(self->buf->Channels() == 1)
- ret = PyFloat_FromDouble(self->buf->Data()[i]);
- else {
- PyErr_SetString(PyExc_NotImplementedError,"Multiple channels not implemented yet");
- ret = NULL;
- }
- }
- }
- else {
- Py_INCREF(Py_None);
- ret = Py_None;
- }
- return ret;
-}
-
-PyObject *arrayfrombuffer(PyObject *buf,int c,int n)
-{
-#ifdef PY_ARRAYS
- if(arrsupport()) {
- PyObject *arr;
- int shape[2];
- shape[0] = n;
- shape[1] = c;
-#ifdef NA
- arr = (PyObject *)NA_NewAllFromBuffer(c == 1?1:2,shape,numtype,buf,0,0,NA_ByteOrder(),1,1);
-#else
- void *data;
- int len;
- int err = PyObject_AsWriteBuffer(buf,&data,&len);
- if(!err) {
- FLEXT_ASSERT(len <= n*c*sizeof(t_sample));
- Py_INCREF(buf);
- arr = PyArray_FromDimsAndData(c == 1?1:2,shape,numtype,(char *)data);
- }
- else {
- // exception string is already set
- arr = NULL;
- }
-#endif
- return arr;
- }
- else
-#endif
- return NULL;
-}
-
-static PyObject *buffer_slice(pySamplebuffer *self,int ilow = 0,int ihigh = 1<<(sizeof(int)*8-2))
-{
- PyObject *ret;
-#ifdef PY_ARRAYS
- if(arrsupport()) {
- if(self->buf) {
- const int n = self->buf->Frames();
- const int c = self->buf->Channels();
- if(ilow < 0) ilow += n;
- if(ilow >= n) ilow = n-1;
- if(ihigh < 0) ihigh += n;
- if(ihigh > n) ihigh = n;
-
- PyObject *nobj = arrayfrombuffer((PyObject *)self,c,n);
- if(ilow != 0 || ihigh != n) {
- ret = PySequence_GetSlice(nobj,ilow,ihigh);
- Py_DECREF(nobj);
- }
- else
- ret = nobj;
- }
- else {
- Py_INCREF(Py_None);
- ret = Py_None;
- }
- }
- else
-#endif
- {
- PyErr_SetString(PyExc_RuntimeError,"No numarray support");
- ret = NULL;
- }
- return ret;
-}
-
-static int buffer_ass_item(pySamplebuffer *self,int i,PyObject *v)
-{
- int ret;
- if(self->buf) {
- if (i < 0 || i >= self->buf->Frames()) {
- PyErr_Format(PyExc_IndexError,"Index out of range");
- ret = -1;
- }
- else {
- if(self->buf->Channels() == 1) {
- self->buf->Data()[i] = (t_sample)PyFloat_AsDouble(v);
- if(PyErr_Occurred()) {
- // cast to double failed
- PyErr_SetString(PyExc_TypeError,"Value must be a numarray");
- ret = -1;
- }
- else {
- self->dirty = true;
- ret = 0;
- }
- }
- else {
- PyErr_SetString(PyExc_NotImplementedError,"Multiple channels not implemented yet");
- ret = -1;
- }
- }
- }
- else
- ret = -1;
- return ret;
-}
-
-static int buffer_ass_slice(pySamplebuffer *self,int ilow,int ihigh,PyObject *value)
-{
- int ret;
-#ifdef PY_ARRAYS
- if(arrsupport()) {
- if(!value) {
- PyErr_SetString(PyExc_TypeError,"Object doesn't support item deletion");
- ret = -1;
- }
- else if(self->buf) {
- const int n = self->buf->Frames();
- const int c = self->buf->Channels();
- if(ilow < 0) ilow += n;
- if(ilow >= n) ilow = n-1;
- if(ihigh < 0) ihigh += n;
- if(ihigh > n) ihigh = n;
-
-#ifdef NA
- PyArrayObject *out = NA_InputArray(value,numtype,NUM_C_ARRAY);
-#else
- PyArrayObject *out = (PyArrayObject *)PyArray_ContiguousFromObject(value,numtype,0,0);
-#endif
- if(!out) {
- PyErr_SetString(PyExc_TypeError,"Assigned object must be a numarray");
- ret = -1;
- }
- else if(out->nd != 1) {
- PyErr_SetString(PyExc_NotImplementedError,"Multiple dimensions not supported yet");
- ret = -1;
- }
- else {
- int dlen = ihigh-ilow;
- int slen = out->dimensions[0];
-#ifdef NA
- flext::CopySamples(self->buf->Data()+ilow,(t_sample *)NA_OFFSETDATA(out),slen < dlen?slen:dlen);
-#else
- flext::CopySamples(self->buf->Data()+ilow,(t_sample *)out->data,slen < dlen?slen:dlen);
-#endif
- self->dirty = true;
- ret = 0;
- }
-
- Py_XDECREF(out);
- }
- else {
- PyErr_SetString(PyExc_ValueError,"Buffer is not assigned");
- ret = -1;
- }
- }
- else
-#endif
- {
- PyErr_SetString(PyExc_RuntimeError,"No numarray support");
- ret = -1;
- }
- return ret;
-}
-
-static PyObject *buffer_concat(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PySequence_Concat(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_repeat(pySamplebuffer *self,int rep)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PySequence_Repeat(nobj,rep);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-
-static PySequenceMethods buffer_as_seq = {
- (inquiry)buffer_length, /* inquiry sq_length; __len__ */
- (binaryfunc)buffer_concat, /* __add__ */
- (intargfunc)buffer_repeat, /* __mul__ */
- (intargfunc)buffer_item, /* intargfunc sq_item; __getitem__ */
- (intintargfunc)buffer_slice, /* intintargfunc sq_slice; __getslice__ */
- (intobjargproc)buffer_ass_item, /* intobjargproc sq_ass_item; __setitem__ */
- (intintobjargproc)buffer_ass_slice, /* intintobjargproc sq_ass_slice; __setslice__ */
-};
-
-static PyObject *buffer_iter(PyObject *obj)
-{
- pySamplebuffer *self = (pySamplebuffer *)obj;
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *it = PyObject_GetIter(nobj);
- Py_DECREF(nobj);
- return it;
- }
- else
- return NULL;
-}
-
-
-static PyObject *buffer_add(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Add(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_subtract(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Subtract(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_multiply(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Multiply(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_divide(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Divide(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_remainder(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Remainder(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_divmod(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Divmod(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_power(pySamplebuffer *self,PyObject *op1,PyObject *op2)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Power(nobj,op1,op2);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_negative(pySamplebuffer *self)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Negative(nobj);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_pos(pySamplebuffer *self)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Positive(nobj);
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_absolute(pySamplebuffer *self)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_Absolute(nobj);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static int buffer_coerce(pySamplebuffer **pm, PyObject **pw)
-{
- if(pySamplebuffer_Check(*pw)) {
- Py_INCREF(*pm);
- Py_INCREF(*pw);
- return 0;
- }
- else
- return 1;
-}
-
-static PyObject *buffer_inplace_add(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_InPlaceAdd(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_inplace_subtract(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_InPlaceSubtract(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_inplace_multiply(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_InPlaceMultiply(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_inplace_divide(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_InPlaceDivide(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_inplace_remainder(pySamplebuffer *self,PyObject *op)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_InPlaceRemainder(nobj,op);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-static PyObject *buffer_inplace_power(pySamplebuffer *self,PyObject *op1,PyObject *op2)
-{
- PyObject *nobj = buffer_slice(self);
- if(nobj) {
- PyObject *ret = PyNumber_InPlacePower(nobj,op1,op2);
- if(ret == nobj) self->dirty = true;
- Py_DECREF(nobj);
- return ret;
- }
- else
- return NULL;
-}
-
-
-
-static PyNumberMethods buffer_as_number = {
- (binaryfunc)buffer_add, /*nb_add*/
- (binaryfunc)buffer_subtract, /*nb_subtract*/
- (binaryfunc)buffer_multiply, /*nb_multiply*/
- (binaryfunc)buffer_divide, /*nb_divide*/
- (binaryfunc)buffer_remainder, /*nb_remainder*/
- (binaryfunc)buffer_divmod, /*nb_divmod*/
- (ternaryfunc)buffer_power, /*nb_power*/
- (unaryfunc)buffer_negative,
- (unaryfunc)buffer_pos, /*nb_pos*/
- (unaryfunc)buffer_absolute, /* (unaryfunc)buffer_abs, */
- 0, //(inquiry)buffer_nonzero, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- (coercion)buffer_coerce, /*nb_coerce*/
- 0, /*nb_int*/
- 0, /*nb_long*/
- 0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)buffer_inplace_add, /* nb_inplace_add */
- (binaryfunc)buffer_inplace_subtract, /* nb_inplace_subtract */
- (binaryfunc)buffer_inplace_multiply, /* nb_inplace_multiply */
- (binaryfunc)buffer_inplace_divide, /* nb_inplace_divide */
- (binaryfunc)buffer_inplace_remainder, /* nb_inplace_remainder */
- (ternaryfunc)buffer_inplace_power, /* nb_inplace_power */
- 0, /* nb_inplace_lshift */
- 0, /* nb_inplace_rshift */
- 0, /* nb_inplace_and */
- 0, /* nb_inplace_xor */
- 0, /* nb_inplace_or */
-// buffer_floor_div, /* nb_floor_divide */
-// buffer_div, /* nb_true_divide */
-// buffer_inplace_floor_div, /* nb_inplace_floor_divide */
-// buffer_inplace_div, /* nb_inplace_true_divide */
-};
-
-PyTypeObject pySamplebuffer_Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Buffer", /*tp_name*/
- sizeof(pySamplebuffer), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- buffer_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- buffer_repr, /*tp_repr*/
- &buffer_as_number, /*tp_as_number*/
- &buffer_as_seq, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- buffer_hash, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &buffer_as_buffer, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT /*| Py_TPFLAGS_BASETYPE*/, /*tp_flags*/
- "Samplebuffer objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0 /*buffer_richcompare*/, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- buffer_iter, /* tp_iter */
- 0, /* tp_iternext */
- buffer_methods, /* tp_methods */
- 0, /* tp_members */
- buffer_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- buffer_init, /* tp_init */
- 0, /* tp_alloc */
- buffer_new, /* tp_new */
-};
-
-void initsamplebuffer()
-{
- PyErr_Clear();
-
-#ifdef PY_ARRAYS
-#ifdef NA
- import_libnumarray();
-#else
- import_array();
-#endif
- if(PyErr_Occurred())
- // catch import error
- PyErr_Clear();
- else {
- // numarray support ok
-#ifdef NA
- numtype = sizeof(t_sample) == 4?tFloat32:tFloat64;
-#else
- numtype = sizeof(t_sample) == 4?PyArray_FLOAT:PyArray_DOUBLE;
-#endif
- post("");
- post("Python array support enabled");
- }
-#endif
-
- if(PyType_Ready(&pySamplebuffer_Type) < 0)
- FLEXT_ASSERT(false);
- else
- Py_INCREF(&pySamplebuffer_Type);
-}
+/* + +py/pyext - python script object for PD and Max/MSP + +Copyright (c)2002-2006 Thomas Grill (gr@grrrr.org) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pybase.h" + +#undef PY_ARRAYS + + +#if defined(PY_NUMERIC) || defined(PY_NUMPY) || defined(PY_NUMARRAY) + #define PY_ARRAYS 1 +#endif + +#ifdef PY_ARRAYS + +#ifdef PY_NUMARRAY +# if FLEXT_OS == FLEXT_OS_MAC +# include <Python/numarray/libnumarray.h> +# else +# include <numarray/libnumarray.h> +# endif + +static NumarrayType numtype = tAny; +inline bool arrsupport() { return numtype != tAny; } + +#else +# if defined(PY_NUMPY) +# include <numpy/arrayobject.h> +# else +# if FLEXT_OS == FLEXT_OS_MAC +# include <Python/numarray/arrayobject.h> +# else +# include <numarray/arrayobject.h> +# endif +# endif + + static PyArray_TYPES numtype = PyArray_NOTYPE; + inline bool arrsupport() { return numtype != PyArray_NOTYPE; } +#endif +#endif + + +PyObject *pybase::py_arraysupport(PyObject *self,PyObject *args) +{ + PyObject *ret; +#ifdef PY_ARRAYS + ret = Py_True; +#else + ret = Py_False; +#endif + Py_INCREF(ret); + return ret; +} + + +// PD defines a T_OBJECT symbol +#undef T_OBJECT + +#if FLEXT_OS == FLEXT_OS_MAC +#include "Python/bufferobject.h" +#include "Python/structmember.h" +#else +#include "bufferobject.h" +#include "structmember.h" +#endif + +static PyObject *buffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + pySamplebuffer *self = (pySamplebuffer *)pySamplebuffer_Type.tp_alloc(&pySamplebuffer_Type, 0); + self->sym = NULL; + self->buf = NULL; + self->dirty = false; + return (PyObject *)self; +} + +static void buffer_dealloc(PyObject *obj) +{ + pySamplebuffer *self = (pySamplebuffer *)obj; + + if(self->buf) { + self->buf->Unlock(self->lock); + if(self->dirty) self->buf->Dirty(true); + delete self->buf; + } + + obj->ob_type->tp_free(obj); +} + +static int buffer_init(PyObject *obj, PyObject *args, PyObject *kwds) +{ + FLEXT_ASSERT(pySamplebuffer_Check(obj)); + + PyObject *arg = PySequence_GetItem(args,0); // new reference + if(!arg) return -1; + + int ret = 0; + + pySamplebuffer *self = (pySamplebuffer *)obj; + FLEXT_ASSERT(!self->sym && !self->buf); + + if(pySymbol_Check(arg)) + self->sym = pySymbol_AS_SYMBOL(arg); + else if(PyString_Check(arg)) + self->sym = flext::MakeSymbol(PyString_AS_STRING(arg)); + else + ret = -1; + Py_DECREF(arg); + + if(self->sym) { + flext::buffer *b = new flext::buffer(self->sym); + if(b->Ok() && b->Valid()) + self->lock = (self->buf = b)->Lock(); + else + delete b; + } + + return ret; +} + +static PyObject *buffer_repr(PyObject *self) +{ + FLEXT_ASSERT(pySamplebuffer_Check(self)); + return (PyObject *)PyString_FromFormat("<Samplebuffer %s>",pySamplebuffer_AS_STRING(self)); +} + +static long buffer_hash(PyObject *self) +{ + FLEXT_ASSERT(pySamplebuffer_Check(self)); + return (long)(((pySamplebuffer *)self)->buf); +} + +static PyObject *buffer_getsymbol(pySamplebuffer* self,void *closure) +{ + if(self->sym) + return pySymbol_FromSymbol(self->sym); + else { + Py_INCREF(Py_None); + return Py_None; + } +} + +static PyGetSetDef buffer_getseters[] = { + {"symbol",(getter)buffer_getsymbol, NULL, NULL}, + {NULL} /* Sentinel */ +}; + +static PyObject *buffer_dirty(PyObject *obj) +{ + ((pySamplebuffer *)obj)->dirty = true; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *buffer_resize(PyObject *obj,PyObject *args,PyObject *kwds) +{ + flext::buffer *b = ((pySamplebuffer *)obj)->buf; + if(b) { + int frames,keep = 1,zero = 1; + static char *kwlist[] = {"frames", "keep", "zero", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, kwds, "i|ii", kwlist, &frames, &keep, &zero)) + return NULL; + + b->Frames(frames,keep != 0,zero != 0); + + Py_INCREF(obj); + return obj; + } + else { + PyErr_SetString(PyExc_RuntimeError,"Invalid buffer"); + return NULL; + } +} + +static PyMethodDef buffer_methods[] = { + {"dirty", (PyCFunction)buffer_dirty,METH_NOARGS,"Mark buffer as dirty"}, + {"resize", (PyCFunction)buffer_resize,METH_VARARGS|METH_KEYWORDS,"Resize buffer"}, + {NULL} /* Sentinel */ +}; + + + +// support the buffer protocol +static int buffer_readbuffer(PyObject *obj, int segment, void **ptrptr) +{ + flext::buffer *b = ((pySamplebuffer *)obj)->buf; + ptrptr[0] = b->Data(); + return b->Channels()*b->Frames()*sizeof(t_sample); +} + +static int buffer_writebuffer(PyObject *obj, int segment, void **ptrptr) +{ + flext::buffer *b = ((pySamplebuffer *)obj)->buf; + ptrptr[0] = b->Data(); + return b->Channels()*b->Frames()*sizeof(t_sample); +} + +static int buffer_segcount(PyObject *obj, int *lenp) +{ + flext::buffer *b = ((pySamplebuffer *)obj)->buf; + if(lenp) lenp[0] = b->Channels()*b->Frames()*sizeof(t_sample); + return 1; +} + +static int buffer_charbuffer(PyObject *obj, int segment, const char **ptrptr) +{ + flext::buffer *b = ((pySamplebuffer *)obj)->buf; + ptrptr[0] = (char *)b->Data(); + return b->Channels()*b->Frames()*sizeof(t_sample); +} + +static PyBufferProcs buffer_as_buffer = { + buffer_readbuffer, + buffer_writebuffer, + buffer_segcount, + buffer_charbuffer +}; + +static int buffer_length(pySamplebuffer *self) +{ + return self->buf?self->buf->Frames():0; +} + +static PyObject *buffer_item(pySamplebuffer *self, int i) +{ + PyObject *ret; + if(self->buf) { + if (i < 0 || i >= self->buf->Frames()) { + PyErr_SetString(PyExc_IndexError,"Index out of range"); + ret = NULL; + } + else { + if(self->buf->Channels() == 1) + ret = PyFloat_FromDouble(self->buf->Data()[i]); + else { + PyErr_SetString(PyExc_NotImplementedError,"Multiple channels not implemented yet"); + ret = NULL; + } + } + } + else { + Py_INCREF(Py_None); + ret = Py_None; + } + return ret; +} + +PyObject *arrayfrombuffer(PyObject *buf,int c,int n) +{ +#ifdef PY_ARRAYS + if(arrsupport()) { + PyObject *arr; + int shape[2]; + shape[0] = n; + shape[1] = c; +#ifdef PY_NUMARRAY + arr = (PyObject *)NA_NewAllFromBuffer(c == 1?1:2,shape,numtype,buf,0,0,NA_ByteOrder(),1,1); +#else + void *data; + int len; + int err = PyObject_AsWriteBuffer(buf,&data,&len); + if(!err) { + FLEXT_ASSERT(len <= n*c*sizeof(t_sample)); + Py_INCREF(buf); + // \todo change to new API! + arr = PyArray_FromDimsAndData(c == 1?1:2,shape,numtype,(char *)data); + } + else { + // exception string is already set + arr = NULL; + } +#endif + return arr; + } + else +#endif + return NULL; +} + +static PyObject *buffer_slice(pySamplebuffer *self,int ilow = 0,int ihigh = 1<<(sizeof(int)*8-2)) +{ + PyObject *ret; +#ifdef PY_ARRAYS + if(arrsupport()) { + if(self->buf) { + const int n = self->buf->Frames(); + const int c = self->buf->Channels(); + if(ilow < 0) ilow += n; + if(ilow >= n) ilow = n-1; + if(ihigh < 0) ihigh += n; + if(ihigh > n) ihigh = n; + + PyObject *nobj = arrayfrombuffer((PyObject *)self,c,n); + if(ilow != 0 || ihigh != n) { + ret = PySequence_GetSlice(nobj,ilow,ihigh); + Py_DECREF(nobj); + } + else + ret = nobj; + } + else { + Py_INCREF(Py_None); + ret = Py_None; + } + } + else +#endif + { + PyErr_SetString(PyExc_RuntimeError,"No numarray support"); + ret = NULL; + } + return ret; +} + +static int buffer_ass_item(pySamplebuffer *self,int i,PyObject *v) +{ + int ret; + if(self->buf) { + if (i < 0 || i >= self->buf->Frames()) { + PyErr_Format(PyExc_IndexError,"Index out of range"); + ret = -1; + } + else { + if(self->buf->Channels() == 1) { + self->buf->Data()[i] = (t_sample)PyFloat_AsDouble(v); + if(PyErr_Occurred()) { + // cast to double failed + PyErr_SetString(PyExc_TypeError,"Value must be a numarray"); + ret = -1; + } + else { + self->dirty = true; + ret = 0; + } + } + else { + PyErr_SetString(PyExc_NotImplementedError,"Multiple channels not implemented yet"); + ret = -1; + } + } + } + else + ret = -1; + return ret; +} + +static int buffer_ass_slice(pySamplebuffer *self,int ilow,int ihigh,PyObject *value) +{ + int ret; +#ifdef PY_ARRAYS + if(arrsupport()) { + if(!value) { + PyErr_SetString(PyExc_TypeError,"Object doesn't support item deletion"); + ret = -1; + } + else if(self->buf) { + const int n = self->buf->Frames(); + const int c = self->buf->Channels(); + if(ilow < 0) ilow += n; + if(ilow >= n) ilow = n-1; + if(ihigh < 0) ihigh += n; + if(ihigh > n) ihigh = n; + +#ifdef PY_NUMARRAY + PyArrayObject *out = NA_InputArray(value,numtype,NUM_C_ARRAY); +#else + PyArrayObject *out = (PyArrayObject *)PyArray_ContiguousFromObject(value,numtype,0,0); +#endif + if(!out) { + PyErr_SetString(PyExc_TypeError,"Assigned object must be a numarray"); + ret = -1; + } + else if(out->nd != 1) { + PyErr_SetString(PyExc_NotImplementedError,"Multiple dimensions not supported yet"); + ret = -1; + } + else { + int dlen = ihigh-ilow; + int slen = out->dimensions[0]; +#ifdef PY_NUMARRAY + flext::CopySamples(self->buf->Data()+ilow,(t_sample *)NA_OFFSETDATA(out),slen < dlen?slen:dlen); +#else + flext::CopySamples(self->buf->Data()+ilow,(t_sample *)out->data,slen < dlen?slen:dlen); +#endif + self->dirty = true; + ret = 0; + } + + Py_XDECREF(out); + } + else { + PyErr_SetString(PyExc_ValueError,"Buffer is not assigned"); + ret = -1; + } + } + else +#endif + { + PyErr_SetString(PyExc_RuntimeError,"No numarray support"); + ret = -1; + } + return ret; +} + +static PyObject *buffer_concat(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PySequence_Concat(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_repeat(pySamplebuffer *self,int rep) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PySequence_Repeat(nobj,rep); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + + +static PySequenceMethods buffer_as_seq = { + (inquiry)buffer_length, /* inquiry sq_length; __len__ */ + (binaryfunc)buffer_concat, /* __add__ */ + (intargfunc)buffer_repeat, /* __mul__ */ + (intargfunc)buffer_item, /* intargfunc sq_item; __getitem__ */ + (intintargfunc)buffer_slice, /* intintargfunc sq_slice; __getslice__ */ + (intobjargproc)buffer_ass_item, /* intobjargproc sq_ass_item; __setitem__ */ + (intintobjargproc)buffer_ass_slice, /* intintobjargproc sq_ass_slice; __setslice__ */ +}; + +static PyObject *buffer_iter(PyObject *obj) +{ + pySamplebuffer *self = (pySamplebuffer *)obj; + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *it = PyObject_GetIter(nobj); + Py_DECREF(nobj); + return it; + } + else + return NULL; +} + + +static PyObject *buffer_add(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Add(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_subtract(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Subtract(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_multiply(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Multiply(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_divide(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Divide(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_remainder(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Remainder(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_divmod(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Divmod(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_power(pySamplebuffer *self,PyObject *op1,PyObject *op2) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Power(nobj,op1,op2); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_negative(pySamplebuffer *self) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Negative(nobj); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_pos(pySamplebuffer *self) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Positive(nobj); + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_absolute(pySamplebuffer *self) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_Absolute(nobj); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static int buffer_coerce(pySamplebuffer **pm, PyObject **pw) +{ + if(pySamplebuffer_Check(*pw)) { + Py_INCREF(*pm); + Py_INCREF(*pw); + return 0; + } + else + return 1; +} + +static PyObject *buffer_inplace_add(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_InPlaceAdd(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_inplace_subtract(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_InPlaceSubtract(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_inplace_multiply(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_InPlaceMultiply(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_inplace_divide(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_InPlaceDivide(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_inplace_remainder(pySamplebuffer *self,PyObject *op) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_InPlaceRemainder(nobj,op); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + +static PyObject *buffer_inplace_power(pySamplebuffer *self,PyObject *op1,PyObject *op2) +{ + PyObject *nobj = buffer_slice(self); + if(nobj) { + PyObject *ret = PyNumber_InPlacePower(nobj,op1,op2); + if(ret == nobj) self->dirty = true; + Py_DECREF(nobj); + return ret; + } + else + return NULL; +} + + + +static PyNumberMethods buffer_as_number = { + (binaryfunc)buffer_add, /*nb_add*/ + (binaryfunc)buffer_subtract, /*nb_subtract*/ + (binaryfunc)buffer_multiply, /*nb_multiply*/ + (binaryfunc)buffer_divide, /*nb_divide*/ + (binaryfunc)buffer_remainder, /*nb_remainder*/ + (binaryfunc)buffer_divmod, /*nb_divmod*/ + (ternaryfunc)buffer_power, /*nb_power*/ + (unaryfunc)buffer_negative, + (unaryfunc)buffer_pos, /*nb_pos*/ + (unaryfunc)buffer_absolute, /* (unaryfunc)buffer_abs, */ + 0, //(inquiry)buffer_nonzero, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)buffer_coerce, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + (binaryfunc)buffer_inplace_add, /* nb_inplace_add */ + (binaryfunc)buffer_inplace_subtract, /* nb_inplace_subtract */ + (binaryfunc)buffer_inplace_multiply, /* nb_inplace_multiply */ + (binaryfunc)buffer_inplace_divide, /* nb_inplace_divide */ + (binaryfunc)buffer_inplace_remainder, /* nb_inplace_remainder */ + (ternaryfunc)buffer_inplace_power, /* nb_inplace_power */ + 0, /* nb_inplace_lshift */ + 0, /* nb_inplace_rshift */ + 0, /* nb_inplace_and */ + 0, /* nb_inplace_xor */ + 0, /* nb_inplace_or */ +// buffer_floor_div, /* nb_floor_divide */ +// buffer_div, /* nb_true_divide */ +// buffer_inplace_floor_div, /* nb_inplace_floor_divide */ +// buffer_inplace_div, /* nb_inplace_true_divide */ +}; + +PyTypeObject pySamplebuffer_Type = { + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "Buffer", /*tp_name*/ + sizeof(pySamplebuffer), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + buffer_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + buffer_repr, /*tp_repr*/ + &buffer_as_number, /*tp_as_number*/ + &buffer_as_seq, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + buffer_hash, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &buffer_as_buffer, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT /*| Py_TPFLAGS_BASETYPE*/, /*tp_flags*/ + "Samplebuffer objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0 /*buffer_richcompare*/, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + buffer_iter, /* tp_iter */ + 0, /* tp_iternext */ + buffer_methods, /* tp_methods */ + 0, /* tp_members */ + buffer_getseters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + buffer_init, /* tp_init */ + 0, /* tp_alloc */ + buffer_new, /* tp_new */ +}; + +void initsamplebuffer() +{ + PyErr_Clear(); + +#ifdef PY_ARRAYS +#ifdef PY_NUMARRAY + import_libnumarray(); +#else + import_array(); +#endif + if(PyErr_Occurred()) + // catch import error + PyErr_Clear(); + else { + // numarray support ok +#ifdef PY_NUMARRAY + numtype = sizeof(t_sample) == 4?tFloat32:tFloat64; +#else + numtype = sizeof(t_sample) == 4?PyArray_FLOAT:PyArray_DOUBLE; +#endif + post(""); + post("Python array support enabled"); + } +#endif + + if(PyType_Ready(&pySamplebuffer_Type) < 0) + FLEXT_ASSERT(false); + else + Py_INCREF(&pySamplebuffer_Type); +} diff --git a/externals/grill/py/source/pysymbol.cpp b/externals/grill/py/source/pysymbol.cpp index b5c5b127..2f023469 100644 --- a/externals/grill/py/source/pysymbol.cpp +++ b/externals/grill/py/source/pysymbol.cpp @@ -73,8 +73,8 @@ static PyObject *symbol_richcompare(PyObject *a,PyObject *b,int cmp) }
return PyBool_FromLong(ret);
}
- Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
}
static long symbol_hash(PyObject *self)
@@ -219,9 +219,9 @@ pySymbol *pySymbol_int; void initsymbol()
{
if(PyType_Ready(&pySymbol_Type) < 0)
- FLEXT_ASSERT(false);
- else
- Py_INCREF(&pySymbol_Type);
+ return;
+
+ Py_INCREF(&pySymbol_Type);
// initialize predefined objects
pySymbol__ = symbol_newsym(flext::sym__);
@@ -233,22 +233,22 @@ void initsymbol() }
-PyObject *pySymbol_FromSymbol(const t_symbol *sym) -{ - pySymbol *op; - if(sym == flext::sym__) - Py_INCREF(op = pySymbol__); - else if(sym == flext::sym_bang) - Py_INCREF(op = pySymbol_bang); - else if(sym == flext::sym_list) - Py_INCREF(op = pySymbol_list); - else if(sym == flext::sym_symbol) - Py_INCREF(op = pySymbol_symbol); - else if(sym == flext::sym_float) - Py_INCREF(op = pySymbol_float); - else if(sym == flext::sym_int) - Py_INCREF(op = pySymbol_int); - else - op = symbol_newsym(sym); - return (PyObject *)op; -} +PyObject *pySymbol_FromSymbol(const t_symbol *sym)
+{
+ pySymbol *op;
+ if(sym == flext::sym__)
+ Py_INCREF(op = pySymbol__);
+ else if(sym == flext::sym_bang)
+ Py_INCREF(op = pySymbol_bang);
+ else if(sym == flext::sym_list)
+ Py_INCREF(op = pySymbol_list);
+ else if(sym == flext::sym_symbol)
+ Py_INCREF(op = pySymbol_symbol);
+ else if(sym == flext::sym_float)
+ Py_INCREF(op = pySymbol_float);
+ else if(sym == flext::sym_int)
+ Py_INCREF(op = pySymbol_int);
+ else
+ op = symbol_newsym(sym);
+ return (PyObject *)op;
+}
|