diff options
Diffstat (limited to 'externals/grill')
21 files changed, 137 insertions, 91 deletions
diff --git a/externals/grill/py/build/gnumake-lnx-gcc.inc b/externals/grill/py/build/gnumake-lnx-gcc.inc index f12ec62e..bdb375f1 100644 --- a/externals/grill/py/build/gnumake-lnx-gcc.inc +++ b/externals/grill/py/build/gnumake-lnx-gcc.inc @@ -1,2 +1,3 @@ +DEFS += -DPY_EXPORTS INCPATH += -I$(PYTHONPREFIX)/include/python$(PYTHONVERSION) LIBS += -lpython$(PYTHONVERSION) diff --git a/externals/grill/py/build/gnumake-mac-gcc.inc b/externals/grill/py/build/gnumake-mac-gcc.inc index 0e510dec..16e9df6f 100644 --- a/externals/grill/py/build/gnumake-mac-gcc.inc +++ b/externals/grill/py/build/gnumake-mac-gcc.inc @@ -1,4 +1,3 @@ -# - -LIBS += -framework Python
+DEFS += -DPY_EXPORTS +LIBS += -framework Python diff --git a/externals/grill/py/build/nmake-win-msvc.inc b/externals/grill/py/build/nmake-win-msvc.inc index 8748d223..373f98a7 100644 --- a/externals/grill/py/build/nmake-win-msvc.inc +++ b/externals/grill/py/build/nmake-win-msvc.inc @@ -1,2 +1,3 @@ +DEFS = $(DEFS) /DPY_EXPORTS INCPATH=/I$(PYTHONPATH)\include LIBPATH=/LIBPATH:$(PYTHONPATH)\libs diff --git a/externals/grill/py/pd/attr-1.pd b/externals/grill/py/pd/attr-1.pd index bf797c70..56875379 100644 --- a/externals/grill/py/pd/attr-1.pd +++ b/externals/grill/py/pd/attr-1.pd @@ -1,28 +1,30 @@ -#N canvas 114 127 693 451 12;
+#N canvas 114 127 697 455 12;
#X obj 224 397 pyext simple ex3;
#X obj 392 398 print A;
-#X msg 252 207 get tmp;
-#X msg 369 237 get _inlets;
-#X msg 253 231 set tmp 3;
-#X msg 368 261 set _inlets 4;
+#X msg 362 247 get tmp;
+#X msg 396 320 get _inlets;
+#X msg 395 344 set _inlets 4;
#X msg 18 206 dir;
#X msg 15 312 getattributes;
#X msg 15 336 getmethods;
#X msg 18 234 dir+;
#X text 15 75 This demonstrates the usage of attributes. See the simple.py
file.;
-#X text 252 188 access a class variable;
-#X text 368 218 try to get/set internal stuff;
-#X text 479 261 (NOT allowed!);
-#X text 16 288 get attributes and methods;
+#X text 260 212 access a class variable;
+#X text 395 301 try to get/set internal stuff;
+#X text 506 347 (NOT allowed!);
+#X text 14 288 get attributes and methods;
#X text 51 205 Python module dict;
#X text 59 235 Python class dict;
#X text 17 128 All attribute-related methods dump eventual output to
the attribute outlet (which is the right-most one);
#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 235 32 http://www.parasitaere-kapazitaeten.net;
-#X text 235 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 235 32 http://grrrr.org/ext;
+#X msg 260 248 set tmp \$1;
+#X obj 259 230 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+10 -262144 -1 -1 0 256;
#X connect 0 1 1 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
@@ -31,4 +33,5 @@ the attribute outlet (which is the right-most one); #X connect 6 0 0 0;
#X connect 7 0 0 0;
#X connect 8 0 0 0;
-#X connect 9 0 0 0;
+#X connect 20 0 0 0;
+#X connect 21 0 20 0;
diff --git a/externals/grill/py/pd/script-1.pd b/externals/grill/py/pd/script-1.pd index 39e3b27b..b748857d 100644 --- a/externals/grill/py/pd/script-1.pd +++ b/externals/grill/py/pd/script-1.pd @@ -1,4 +1,4 @@ -#N canvas 297 17 684 526 12;
+#N canvas 297 17 688 530 12;
#X obj 39 278 print;
#X obj 345 251 print;
#X msg 499 149 freakhole;
@@ -33,8 +33,10 @@ file.; #X msg 58 160 dir+;
#X obj 16 13 cnv 15 630 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 235 32 http://www.parasitaere-kapazitaeten.net;
-#X text 235 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 235 32 http://grrrr.org/ext;
+#X msg 509 178 a b c;
+#X text 556 181 too many args;
#X connect 2 0 25 1;
#X connect 3 0 21 1;
#X connect 4 0 21 1;
@@ -56,3 +58,4 @@ file.; #X connect 25 0 1 0;
#X connect 26 0 21 0;
#X connect 28 0 21 0;
+#X connect 32 0 25 1;
diff --git a/externals/grill/py/pd/sendrecv-1.pd b/externals/grill/py/pd/sendrecv-1.pd index ca399705..02ac052a 100644 --- a/externals/grill/py/pd/sendrecv-1.pd +++ b/externals/grill/py/pd/sendrecv-1.pd @@ -1,4 +1,4 @@ -#N canvas 145 126 650 325 12;
+#N canvas 145 126 654 329 12;
#X msg 125 81 reload mi ma;
#X floatatom 48 238 5 0 0 0 - - -;
#X floatatom 297 239 5 0 0 0 - - -;
@@ -17,10 +17,10 @@ #X text 292 219 or here;
#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 213 32 http://www.parasitaere-kapazitaeten.net;
-#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill;
#X msg 202 128 bind;
#X msg 249 129 unbind;
+#X text 213 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 213 32 http://grrrr.org/ext;
#X connect 0 0 13 0;
#X connect 1 0 7 0;
#X connect 2 0 3 0;
@@ -29,5 +29,5 @@ #X connect 10 0 13 0;
#X connect 11 0 13 0;
#X connect 12 0 13 0;
-#X connect 19 0 13 1;
-#X connect 20 0 13 1;
+#X connect 17 0 13 1;
+#X connect 18 0 13 1;
diff --git a/externals/grill/py/pd/sendrecv-2.pd b/externals/grill/py/pd/sendrecv-2.pd index a257d5e8..77a6a466 100644 --- a/externals/grill/py/pd/sendrecv-2.pd +++ b/externals/grill/py/pd/sendrecv-2.pd @@ -1,4 +1,4 @@ -#N canvas 133 322 643 185 12;
+#N canvas 133 322 647 189 12;
#X obj 152 98 pyext sendrecv ex2 huha;
#X floatatom 152 128 5 0 0 0 - - -;
#X floatatom 33 96 5 0 0 0 - - -;
@@ -6,7 +6,7 @@ #X text 20 77 scroll here;
#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 213 32 http://www.parasitaere-kapazitaeten.net;
-#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 213 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 213 32 http://grrrr.org/ext;
#X connect 0 0 1 0;
#X connect 2 0 3 0;
diff --git a/externals/grill/py/pd/sendrecv-3.pd b/externals/grill/py/pd/sendrecv-3.pd index 037895fb..f1847f6a 100644 --- a/externals/grill/py/pd/sendrecv-3.pd +++ b/externals/grill/py/pd/sendrecv-3.pd @@ -1,9 +1,9 @@ -#N canvas 294 237 640 319 12;
-#X obj 410 265 pyext sendrecv ex3;
+#N canvas 294 237 644 323 12;
+#X obj 410 265 pyext sendrecv ex3 @detach 1;
#X obj 564 262 bng 25 250 50 0 empty ugh empty 0 -6 0 8 -258699 -1
-1;
#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 213 32 http://www.parasitaere-kapazitaeten.net;
-#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 213 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 213 32 http://grrrr.org/ext;
#X connect 1 0 0 1;
diff --git a/externals/grill/py/pd/simple-1.pd b/externals/grill/py/pd/simple-1.pd index f4b10cae..d34d43b5 100644 --- a/externals/grill/py/pd/simple-1.pd +++ b/externals/grill/py/pd/simple-1.pd @@ -1,4 +1,4 @@ -#N canvas 156 192 662 389 12;
+#N canvas 156 192 670 397 12;
#X obj 53 123 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X floatatom 52 155 5 0 0 0 - - -;
@@ -23,8 +23,8 @@ file.; #X msg 106 325 doc+;
#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 213 32 http://www.parasitaere-kapazitaeten.net;
-#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 213 32 http://grrrr.org/ext;
+#X text 213 16 Python script objects \, (C)2003-2005 Thomas Grill;
#X connect 0 0 9 1;
#X connect 1 0 9 1;
#X connect 3 0 9 1;
diff --git a/externals/grill/py/pd/simple-2.pd b/externals/grill/py/pd/simple-2.pd index 31680d87..1845b032 100644 --- a/externals/grill/py/pd/simple-2.pd +++ b/externals/grill/py/pd/simple-2.pd @@ -1,4 +1,4 @@ -#N canvas 95 223 650 390 12;
+#N canvas 95 223 654 394 12;
#X floatatom 202 113 5 0 0 0 - - -;
#X text 338 286 watch the console output!;
#X msg 20 115 help;
@@ -21,8 +21,8 @@ file.; so _anything_ is called!;
#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 213 32 http://www.parasitaere-kapazitaeten.net;
-#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 213 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 213 32 http://grrrr.org/ext;
#X connect 0 0 8 1;
#X connect 2 0 8 0;
#X connect 4 0 8 0;
diff --git a/externals/grill/py/pd/simple-3.pd b/externals/grill/py/pd/simple-3.pd index 9cdb3f1b..ceebbcf3 100644 --- a/externals/grill/py/pd/simple-3.pd +++ b/externals/grill/py/pd/simple-3.pd @@ -1,4 +1,4 @@ -#N canvas 136 275 649 361 12;
+#N canvas 136 275 653 365 12;
#X msg 73 266 help;
#X text 17 80 This demonstrates message handling. See the simple.py
file.;
@@ -17,8 +17,8 @@ file.; #X text 410 140 sets argument;
#X obj 16 13 cnv 15 600 40 empty empty py/pyext 10 22 0 24 -260818
-1 0;
-#X text 213 32 http://www.parasitaere-kapazitaeten.net;
-#X text 213 16 Python script objects \, (C)2003-2004 Thomas Grill;
+#X text 213 16 Python script objects \, (C)2003-2005 Thomas Grill;
+#X text 213 32 http://grrrr.org/ext;
#X connect 0 0 7 0;
#X connect 2 0 7 0;
#X connect 3 0 7 0;
diff --git a/externals/grill/py/pd/tcltk.pd b/externals/grill/py/pd/tcltk.pd index c1c3b246..368544e6 100644 --- a/externals/grill/py/pd/tcltk.pd +++ b/externals/grill/py/pd/tcltk.pd @@ -1,9 +1,7 @@ -#N canvas 156 192 610 329 12;
+#N canvas 156 192 614 333 12;
#X obj 328 118 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
-1;
#X msg 94 128 help;
-#X text 16 15 py/pyext - Python script objects \, (C)2002 Thomas Grill
-;
#X msg 139 127 doc;
#X text 14 49 This demonstrates a tcl/tk dialog. See the tcltk.py file.
;
@@ -12,7 +10,9 @@ notice clicks. This Tk window is NOT called over a net socket \, like PD is;
#X obj 206 169 pyext tcltk myapp;
#X obj 206 200 print tcltk;
-#X connect 0 0 6 1;
-#X connect 1 0 6 0;
-#X connect 3 0 6 0;
-#X connect 6 0 7 0;
+#X text 16 15 py/pyext - Python script objects \, (C)2002-2005 Thomas
+Grill;
+#X connect 0 0 5 1;
+#X connect 1 0 5 0;
+#X connect 2 0 5 0;
+#X connect 5 0 6 0;
diff --git a/externals/grill/py/py.vcproj b/externals/grill/py/py.vcproj index 38bfb17d..50640b5b 100644 --- a/externals/grill/py/py.vcproj +++ b/externals/grill/py/py.vcproj @@ -22,7 +22,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="c:\programme\audio\pd\src;f:\prog\max\flext\source;C:\Programme\prog\Python23\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2" BasicRuntimeChecks="3" RuntimeLibrary="5" RuntimeTypeInfo="TRUE" @@ -86,7 +86,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""c:\data\prog\pd\pd-cvs\src";c:\data\pdmax\flext\source;"C:\data\prog\packs\Python-2.4\include";"C:\data\prog\packs\Python-2.4\PC"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_THREADS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2;FLEXT_THREADS" BasicRuntimeChecks="3" RuntimeLibrary="1" RuntimeTypeInfo="TRUE" @@ -152,7 +152,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="c:\programme\audio\pd\src;c:\data\pdmax\flext\source;C:\Programme\prog\Python24\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_THREADS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2;FLEXT_THREADS" StringPooling="TRUE" RuntimeLibrary="0" EnableFunctionLevelLinking="TRUE" @@ -217,7 +217,7 @@ Optimization="2" InlineFunctionExpansion="1" AdditionalIncludeDirectories="c:\programme\audio\pd\src;f:\prog\max\flext\source;C:\Programme\prog\Python23\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2" StringPooling="TRUE" RuntimeLibrary="4" EnableFunctionLevelLinking="TRUE" @@ -277,8 +277,8 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories=""c:\data\prog\pd\pd-cvs\src";c:\data\prog\packs\pthreads;c:\data\prog\max\flext\source;"C:\data\prog\packs\Python-2.4\include"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_SHARED" + AdditionalIncludeDirectories=""c:\data\prog\pd\pd-cvs\src";c:\data\prog\packs\pthreads;..\flext\source;"C:\data\prog\packs\Python-2.4\include";"C:\data\prog\packs\Python-2.4\PC"" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2;FLEXT_SHARED" BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="TRUE" @@ -292,11 +292,11 @@ Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" - AdditionalDependencies="flext_ld.lib pd.lib pthreadVC.lib" + AdditionalDependencies="pd.lib pthreadVC.lib" OutputFile="$(outdir)/py.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="f:\prog\max\flext\pd-msvc;"f:\prog\pd\pd-cvs/bin";f:\prog\packs\pthreads;"f:\prog\packs\Python-2.3.4\PCbuild"" + AdditionalLibraryDirectories=""c:\data\prog\pd\pd-cvs/bin";c:\data\prog\packs\pthreads;"c:\data\prog\packs\Python-2.4\PCbuild"" GenerateDebugInformation="TRUE" ProgramDatabaseFile="$(outdir)/py.pdb" ImportLibrary="$(outdir)/py.lib" @@ -346,7 +346,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="3" AdditionalIncludeDirectories=""c:\data\prog\pd\pd-cvs\src";c:\data\prog\packs\pthreads;..\flext\source;C:\Programme\prog\Python24\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_SHARED" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=2;FLEXT_SHARED" StringPooling="TRUE" RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" @@ -359,7 +359,7 @@ Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" - AdditionalDependencies="flext_l.lib pd.lib pthreadVC.lib" + AdditionalDependencies="pd.lib pthreadVC.lib" OutputFile="$(outdir)\py.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" @@ -408,7 +408,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""F:\prog\audio\MaxWinSDK\c74support\msp-includes";"F:\prog\audio\MaxWinSDK\c74support\max-includes";f:\prog\packs\pthreads;f:\prog\max\flext\source;C:\Programme\prog\Python23\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=1;FLEXT_SHARED" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=1;FLEXT_SHARED" BasicRuntimeChecks="3" RuntimeLibrary="3" StructMemberAlignment="2" @@ -473,7 +473,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support\msp-includes";"C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support\max-includes";..\flext\source;C:\Programme\prog\Python24\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=1;FLEXT_THREADS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=1;FLEXT_THREADS" BasicRuntimeChecks="3" RuntimeLibrary="1" StructMemberAlignment="2" @@ -542,7 +542,7 @@ GlobalOptimizations="FALSE" FavorSizeOrSpeed="1" AdditionalIncludeDirectories=""C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support\msp-includes";"C:\data\prog\audio\maxmspsdk_win\4.5 headers\c74support\max-includes";..\flext\source;C:\Programme\prog\Python24\include" - PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;FLEXT_SYS=1;FLEXT_THREADS" + PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;PY_EXPORTS;FLEXT_SYS=1;FLEXT_THREADS" BasicRuntimeChecks="3" RuntimeLibrary="0" StructMemberAlignment="2" diff --git a/externals/grill/py/scripts/pak.py b/externals/grill/py/scripts/pak.py index 17841630..6394570d 100644 --- a/externals/grill/py/scripts/pak.py +++ b/externals/grill/py/scripts/pak.py @@ -8,7 +8,7 @@ class pak(pyext._class): # initialize list self.lst = [0 for x in range(n)] - def _anything_(self,n,args): - # args should be type-checked! - self.lst[n-1] = args + def _anything_(self,n,arg): + # arg should be type-checked! + self.lst[n-1] = arg self._outlet(1,self.lst) diff --git a/externals/grill/py/scripts/script.py b/externals/grill/py/scripts/script.py index b4741b00..88f7afd2 100644 --- a/externals/grill/py/scripts/script.py +++ b/externals/grill/py/scripts/script.py @@ -1,6 +1,6 @@ # py/pyext - python script objects for PD and MaxMSP # -# Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) +# 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. # @@ -22,7 +22,8 @@ def numargs(*args): # variable argument list def strlen(arg): """Return the string length""" - return len(arg) + # we must convert to string first (it's a symbol type most likely) + return len(str(arg)) def strcat(*args): diff --git a/externals/grill/py/scripts/sendrecv.py b/externals/grill/py/scripts/sendrecv.py index e3295ab6..a8b57469 100644 --- a/externals/grill/py/scripts/sendrecv.py +++ b/externals/grill/py/scripts/sendrecv.py @@ -1,6 +1,6 @@ # py/pyext - python script objects for PD and MaxMSP # -# Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) +# 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. # @@ -49,7 +49,7 @@ class ex1(pyext._class): recvname="" sendname="" - def recv(self,arg): + def recv(self,*arg): """This is a class-local receive function, which has access to class members.""" # print some stuff @@ -59,7 +59,7 @@ class ex1(pyext._class): self._send(self.sendname,arg) - def __init__(self,args): + def __init__(self,*args): """Class constructor""" # store sender/receiver names @@ -100,7 +100,7 @@ class ex2(pyext._class): recvname="" - def recv(self,arg): + def recv(self,*arg): """This is a class-local receive function""" # send received data to outlet diff --git a/externals/grill/py/scripts/simple.py b/externals/grill/py/scripts/simple.py index b178bf35..04bea7ac 100644 --- a/externals/grill/py/scripts/simple.py +++ b/externals/grill/py/scripts/simple.py @@ -1,6 +1,6 @@ # py/pyext - python script objects for PD and MaxMSP # -# Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) +# 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. # @@ -24,14 +24,14 @@ pyext Usage: e.g. if your PD or MaxMSP object looks like [pyext script class arg1 arg2 arg3] - then the __init__(self,args) function will be called with a tuple argument + then the __init__(self,*args) function will be called with a tuple argument args = (arg1,arg2,arg3) With this syntax, you will have to give at least one argument. By defining the constructor as __init__(self,*args) you can also initialize the class without arguments. - Methods called by pyext - The general format is 'tag_inlet(self,args)' resp. 'tag_inlet(self,*args)': + The general format is 'tag_inlet(self,arg)' resp. 'tag_inlet(self,*args)': tag is the PD or MaxMSP message header.. either bang, float, list etc. inlet is the inlet (starting from 1) from which messages are received. args is a tuple which corresponds to the content of the message. args can be omitted. @@ -40,9 +40,9 @@ pyext Usage: Here, the inlet index is a additional parameter to the method You can also set up methods which react on any message. These have the special forms - _anything_inlet(self,args) + _anything_inlet(self,*args) or - _anything_(self,inlet,args) + _anything_(self,inlet,*args) Please see below for examples. @@ -89,7 +89,7 @@ class ex1(pyext._class): def float_1(self,f): print "Float",f,"into first inlet" - def list_1(self,s): + def list_1(self,*s): print "List",s,"into first inlet" @@ -107,7 +107,7 @@ class ex1(pyext._class): def go_2(self): print "Tag 'go' into second inlet" - def _anything_2(self,args): + def _anything_2(self,*args): print "Some other message into second inlet:",args @@ -116,13 +116,13 @@ class ex1(pyext._class): def onearg_3(self,a): print "Tag 'onearg' into third inlet:",a - def twoargs_3(self,a): + def twoargs_3(self,*a): if len(a) == 2: print "Tag 'twoargs' into third inlet:",a[0],a[1] else: print "Tag 'twoargs': wrong number of arguments" - def threeargs_3(self,a): + def threeargs_3(self,*a): if len(a) == 3: print "Tag 'threeargs' into third inlet",a[0],a[1],a[2] else: @@ -149,7 +149,7 @@ class ex2(pyext._class): def hello_(self,n): print "Tag 'hello' into inlet",n - def _anything_(self,n,args): + def _anything_(self,n,*args): print "Message into inlet",n,":",args diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp index 1b549160..aee12a17 100644 --- a/externals/grill/py/source/pyargs.cpp +++ b/externals/grill/py/source/pyargs.cpp @@ -51,8 +51,10 @@ PyObject *py::MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,int inlet int ix; PyObject *tmp; - if(!withself || argc < (any?1:2)) tmp = pArgs,ix = pix; - else tmp = PyTuple_New(argc+(any?1:0)),ix = 0; +// if(!withself || argc < (any?1:2)) + tmp = pArgs,ix = pix; +// else +// tmp = PyTuple_New(argc+(any?1:0)),ix = 0; if(any) PyTuple_SET_ITEM(tmp, ix++, pySymbol_FromSymbol(s)); diff --git a/externals/grill/py/source/pyprefix.h b/externals/grill/py/source/pyprefix.h index fcce64a1..3f149b61 100644 --- a/externals/grill/py/source/pyprefix.h +++ b/externals/grill/py/source/pyprefix.h @@ -8,8 +8,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. */
-#ifndef __PREFIX_H
-#define __PREFIX_H
+#ifndef __PYPREFIX_H
+#define __PYPREFIX_H
#define FLEXT_ATTRIBUTES 1
#include <flext.h>
diff --git a/externals/grill/py/source/pysymbol.cpp b/externals/grill/py/source/pysymbol.cpp index 176f9895..189d6a6f 100644 --- a/externals/grill/py/source/pysymbol.cpp +++ b/externals/grill/py/source/pysymbol.cpp @@ -8,6 +8,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. */
+#include "pyprefix.h"
#include "pysymbol.h"
inline pySymbol *symbol_newsym(const t_symbol *sym)
diff --git a/externals/grill/py/source/pysymbol.h b/externals/grill/py/source/pysymbol.h index bf06437d..c6e057d4 100644 --- a/externals/grill/py/source/pysymbol.h +++ b/externals/grill/py/source/pysymbol.h @@ -8,7 +8,31 @@ WARRANTIES, see the file, "license.txt," in this distribution. */
-#include "pyprefix.h"
+#ifndef __PYSYMBOL_H
+#define __PYSYMBOL_H
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 500)
+#error You need at least flext version 0.5.0
+#endif
+
+#if FLEXT_OS == FLEXT_OS_MAC
+#include <Python/Python.h>
+#else
+#include <Python.h>
+#endif
+
+
+#ifdef _MSC_VER
+ #ifdef PY_EXPORTS
+ #define PY_EXPORT __declspec(dllexport)
+ #else
+ #define PY_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define PY_EXPORT
+#endif
typedef struct {
PyObject_HEAD
@@ -16,21 +40,31 @@ typedef struct { const t_symbol *sym;
} pySymbol;
-extern PyTypeObject pySymbol_Type;
+PY_EXPORT extern PyTypeObject pySymbol_Type;
-extern pySymbol *pySymbol__;
-extern pySymbol *pySymbol_bang;
-extern pySymbol *pySymbol_list;
-extern pySymbol *pySymbol_symbol;
-extern pySymbol *pySymbol_float;
-extern pySymbol *pySymbol_int;
+PY_EXPORT extern pySymbol *pySymbol__;
+PY_EXPORT extern pySymbol *pySymbol_bang;
+PY_EXPORT extern pySymbol *pySymbol_list;
+PY_EXPORT extern pySymbol *pySymbol_symbol;
+PY_EXPORT extern pySymbol *pySymbol_float;
+PY_EXPORT extern pySymbol *pySymbol_int;
#define pySymbol_Check(op) PyObject_TypeCheck(op, &pySymbol_Type) #define pySymbol_CheckExact(op) ((op)->ob_type == &PySymbol_Type) -PyObject *pySymbol_FromSymbol(const t_symbol *sym); +PY_EXPORT PyObject *pySymbol_FromSymbol(const t_symbol *sym); + +inline PyObject *pySymbol_FromString(const char *str) +{ + return pySymbol_FromSymbol(flext::MakeSymbol(str)); +} + +inline PyObject *pySymbol_FromString(PyObject *str) +{ + return pySymbol_FromSymbol(flext::MakeSymbol(PyString_AsString(str))); +} inline const t_symbol *pySymbol_AS_SYMBOL(PyObject *op)
{
@@ -55,3 +89,4 @@ inline const t_symbol *pyObject_AsSymbol(PyObject *op) return pySymbol_AsSymbol(op);
}
+#endif
|