diff options
Diffstat (limited to 'externals/grill/py')
-rw-r--r-- | externals/grill/py/pd/attr-1.pd | 66 | ||||
-rw-r--r-- | externals/grill/py/pd/script-1.pd | 52 | ||||
-rw-r--r-- | externals/grill/py/pd/sendrecv-1.pd | 54 | ||||
-rw-r--r-- | externals/grill/py/pd/sendrecv-2.pd | 20 | ||||
-rw-r--r-- | externals/grill/py/pd/sendrecv-3.pd | 14 | ||||
-rw-r--r-- | externals/grill/py/pd/simple-1.pd | 14 | ||||
-rw-r--r-- | externals/grill/py/pd/simple-2.pd | 76 | ||||
-rw-r--r-- | externals/grill/py/pd/simple-3.pd | 56 | ||||
-rw-r--r-- | externals/grill/py/pd/thread-1.pd | 52 | ||||
-rw-r--r-- | externals/grill/py/py.vcproj | 6 | ||||
-rw-r--r-- | externals/grill/py/readme.txt | 6 | ||||
-rw-r--r-- | externals/grill/py/source/bound.cpp | 10 | ||||
-rw-r--r-- | externals/grill/py/source/clmeth.cpp | 4 | ||||
-rw-r--r-- | externals/grill/py/source/main.cpp | 159 | ||||
-rw-r--r-- | externals/grill/py/source/main.h | 26 | ||||
-rw-r--r-- | externals/grill/py/source/modmeth.cpp | 10 | ||||
-rw-r--r-- | externals/grill/py/source/py.cpp | 4 | ||||
-rw-r--r-- | externals/grill/py/source/pyargs.cpp | 12 | ||||
-rw-r--r-- | externals/grill/py/source/pyext.cpp | 115 | ||||
-rw-r--r-- | externals/grill/py/source/pyext.h | 5 |
20 files changed, 387 insertions, 374 deletions
diff --git a/externals/grill/py/pd/attr-1.pd b/externals/grill/py/pd/attr-1.pd index f302db7e..bf797c70 100644 --- a/externals/grill/py/pd/attr-1.pd +++ b/externals/grill/py/pd/attr-1.pd @@ -1,32 +1,34 @@ -#N canvas 114 127 687 417 12; -#X obj 224 370 pyext simple ex3; -#X obj 392 371 print A; -#X msg 252 180 get tmp; -#X msg 369 210 get _inlets; -#X msg 253 204 set tmp 3; -#X msg 368 234 set _inlets 4; -#X msg 18 179 dir; -#X msg 15 282 getattributes; -#X msg 15 309 getmethods; -#X msg 18 207 dir+; -#X text 15 48 This demonstrates the usage of attributes. See the simple.py -file.; -#X text 252 161 access a class variable; -#X text 368 191 try to get/set internal stuff; -#X text 479 234 (NOT allowed!); -#X text 16 15 py/pyext - Python script objects \, (C)2003 Thomas Grill -; -#X text 16 261 get attributes and methods; -#X text 51 178 Python module dict; -#X text 59 208 Python class dict; -#X text 17 101 All attribute-related methods dump eventual output to -the attribute outlet (which is the right-most one); -#X connect 0 1 1 0; -#X connect 2 0 0 0; -#X connect 3 0 0 0; -#X connect 4 0 0 0; -#X connect 5 0 0 0; -#X connect 6 0 0 0; -#X connect 7 0 0 0; -#X connect 8 0 0 0; -#X connect 9 0 0 0; +#N canvas 114 127 693 451 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 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 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 connect 0 1 1 0;
+#X connect 2 0 0 0;
+#X connect 3 0 0 0;
+#X connect 4 0 0 0;
+#X connect 5 0 0 0;
+#X connect 6 0 0 0;
+#X connect 7 0 0 0;
+#X connect 8 0 0 0;
+#X connect 9 0 0 0;
diff --git a/externals/grill/py/pd/script-1.pd b/externals/grill/py/pd/script-1.pd index 4ac23971..d0d7e5b2 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 676 527 12;
+#N canvas 297 17 680 522 12;
#X obj 39 278 print;
#X obj 345 251 print;
#X msg 499 149 freakhole;
@@ -21,9 +21,7 @@ #X msg 421 120 somewhere_past_mars;
#X text 152 101 reload with new arguments;
#X msg 40 104 reload 1 2 3;
-#X text 23 13 py/pyext - Python script objects \, (C)2002 Thomas Grill
-;
-#X text 21 42 This demonstrates simple scripting. See the script.py
+#X text 21 69 This demonstrates simple scripting. See the script.py
file.;
#X obj 39 241 py script strcat;
#X obj 43 424 py script addall;
@@ -33,24 +31,28 @@ file.; #X msg 21 159 dir;
#X obj 146 279 print A;
#X msg 58 160 dir+;
-#X connect 2 0 26 1;
-#X connect 3 0 22 1;
-#X connect 4 0 22 1;
-#X connect 6 0 23 1;
-#X connect 7 0 23 1;
-#X connect 9 0 24 0;
-#X connect 11 0 25 0;
-#X connect 12 0 22 1;
-#X connect 13 0 26 0;
-#X connect 14 0 24 0;
-#X connect 15 0 24 0;
-#X connect 17 0 26 1;
-#X connect 19 0 22 0;
-#X connect 22 0 0 0;
-#X connect 22 1 28 0;
-#X connect 23 0 5 0;
-#X connect 24 0 8 0;
-#X connect 25 0 10 0;
-#X connect 26 0 1 0;
-#X connect 27 0 22 0;
-#X connect 29 0 22 0;
+#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 connect 2 0 25 1;
+#X connect 3 0 21 1;
+#X connect 4 0 21 1;
+#X connect 6 0 22 1;
+#X connect 7 0 22 1;
+#X connect 9 0 23 0;
+#X connect 11 0 24 0;
+#X connect 12 0 21 1;
+#X connect 13 0 25 0;
+#X connect 14 0 23 0;
+#X connect 15 0 23 0;
+#X connect 17 0 25 1;
+#X connect 19 0 21 0;
+#X connect 21 0 0 0;
+#X connect 21 1 27 0;
+#X connect 22 0 5 0;
+#X connect 23 0 8 0;
+#X connect 24 0 10 0;
+#X connect 25 0 1 0;
+#X connect 26 0 21 0;
+#X connect 28 0 21 0;
diff --git a/externals/grill/py/pd/sendrecv-1.pd b/externals/grill/py/pd/sendrecv-1.pd index d2d4b50a..56810c74 100644 --- a/externals/grill/py/pd/sendrecv-1.pd +++ b/externals/grill/py/pd/sendrecv-1.pd @@ -1,25 +1,29 @@ -#N canvas 343 246 466 316 12; -#X msg 125 52 reload mi ma; -#X floatatom 48 173 5 0 0; -#X floatatom 181 174 5 0 0; -#X obj 181 198 s mi; -#X floatatom 49 265 5 0 0; -#X floatatom 181 266 5 0 0; -#X obj 181 239 r ma; -#X obj 48 197 s he; -#X obj 49 238 r hu; -#X text 233 51 reload with different args; -#X msg 20 17 help; -#X msg 19 49 doc; -#X msg 58 49 doc+; -#X obj 49 100 pyext sendrecv ex1 he hu; -#X text 28 151 scroll here; -#X text 176 152 or here; -#X connect 0 0 13 0; -#X connect 1 0 7 0; -#X connect 2 0 3 0; -#X connect 6 0 5 0; -#X connect 8 0 4 0; -#X connect 10 0 13 0; -#X connect 11 0 13 0; -#X connect 12 0 13 0; +#N canvas 145 126 642 317 12;
+#X msg 125 117 reload mi ma;
+#X floatatom 48 238 5 0 0 0 - - -;
+#X floatatom 297 239 5 0 0 0 - - -;
+#X obj 297 263 s mi;
+#X floatatom 143 265 5 0 0 0 - - -;
+#X floatatom 382 267 5 0 0 0 - - -;
+#X obj 382 240 r ma;
+#X obj 48 262 s he;
+#X obj 143 238 r hu;
+#X text 233 116 reload with different args;
+#X msg 20 82 help;
+#X msg 19 114 doc;
+#X msg 58 114 doc+;
+#X obj 49 165 pyext sendrecv ex1 he hu;
+#X text 30 218 scroll here;
+#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 connect 0 0 13 0;
+#X connect 1 0 7 0;
+#X connect 2 0 3 0;
+#X connect 6 0 5 0;
+#X connect 8 0 4 0;
+#X connect 10 0 13 0;
+#X connect 11 0 13 0;
+#X connect 12 0 13 0;
diff --git a/externals/grill/py/pd/sendrecv-2.pd b/externals/grill/py/pd/sendrecv-2.pd index 9f015b4c..a257d5e8 100644 --- a/externals/grill/py/pd/sendrecv-2.pd +++ b/externals/grill/py/pd/sendrecv-2.pd @@ -1,8 +1,12 @@ -#N canvas 133 322 454 304 12; -#X obj 36 135 pyext sendrecv ex2 huha; -#X floatatom 36 165 5 0 0; -#X floatatom 35 38 5 0 0; -#X obj 34 65 s huha; -#X text 22 19 scroll here; -#X connect 0 0 1 0; -#X connect 2 0 3 0; +#N canvas 133 322 643 185 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 - - -;
+#X obj 32 123 s huha;
+#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 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 0f42edfc..037895fb 100644 --- a/externals/grill/py/pd/sendrecv-3.pd +++ b/externals/grill/py/pd/sendrecv-3.pd @@ -1,5 +1,9 @@ -#N canvas 294 237 484 334 12; -#X obj 283 258 pyext sendrecv ex3; -#X obj 437 255 bng 25 250 50 0 empty ugh empty 0 -6 64 8 -258699 -1 --1; -#X connect 1 0 0 1; +#N canvas 294 237 640 319 12;
+#X obj 410 265 pyext sendrecv ex3;
+#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 connect 1 0 0 1;
diff --git a/externals/grill/py/pd/simple-1.pd b/externals/grill/py/pd/simple-1.pd index 2d60db5b..f4b10cae 100644 --- a/externals/grill/py/pd/simple-1.pd +++ b/externals/grill/py/pd/simple-1.pd @@ -1,7 +1,7 @@ -#N canvas 156 192 650 389 12;
+#N canvas 156 192 662 389 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;
+#X floatatom 52 155 5 0 0 0 - - -;
#X text 388 337 watch the console output!;
#X msg 52 186 2 3 4;
#X msg 277 131 ho;
@@ -16,13 +16,15 @@ #X msg 447 140 twoargs 41 15;
#X msg 453 239 twoargs 1 2 3;
#X msg 71 299 help;
-#X text 16 15 py/pyext - Python script objects \, (C)2002 Thomas Grill
-;
-#X text 15 57 This demonstrates message handling. See the simple.py
+#X text 16 69 This demonstrates message handling. See the simple.py
file.;
#X text 232 322 file class;
#X msg 70 324 doc;
#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 connect 0 0 9 1;
#X connect 1 0 9 1;
#X connect 3 0 9 1;
@@ -37,5 +39,5 @@ file.; #X connect 13 0 9 3;
#X connect 14 0 9 3;
#X connect 15 0 9 0;
+#X connect 18 0 9 0;
#X connect 19 0 9 0;
-#X connect 20 0 9 0;
diff --git a/externals/grill/py/pd/simple-2.pd b/externals/grill/py/pd/simple-2.pd index e20be506..31680d87 100644 --- a/externals/grill/py/pd/simple-2.pd +++ b/externals/grill/py/pd/simple-2.pd @@ -1,37 +1,39 @@ -#N canvas 225 210 689 411 12; -#X floatatom 251 106 5 0 0; -#X text 409 291 watch the console output!; -#X msg 55 213 help; -#X text 15 57 This demonstrates message handling. See the simple.py -file.; -#X msg 54 238 doc; -#X msg 90 239 doc+; -#X floatatom 308 106 5 0 0; -#X msg 218 228 msg 2; -#X obj 172 282 pyext simple ex2; -#X floatatom 172 327 5 0 0; -#X floatatom 289 328 5 0 0; -#X text 17 22 py/pyext - Python script objects \, (C)2002 Thomas Grill -; -#X msg 149 197 msg 1 3; -#X msg 283 213 msg a b; -#X msg 169 167 hello; -#X msg 242 173 hello; -#X msg 315 172 msg; -#X msg 374 147 hello 3; -#X text 418 172 special case: 'hello' handler doesn't like args \, -so _anything_ is called!; -#X connect 0 0 8 1; -#X connect 2 0 8 0; -#X connect 4 0 8 0; -#X connect 5 0 8 0; -#X connect 6 0 8 2; -#X connect 7 0 8 2; -#X connect 8 0 9 0; -#X connect 8 1 10 0; -#X connect 12 0 8 1; -#X connect 13 0 8 3; -#X connect 14 0 8 1; -#X connect 15 0 8 3; -#X connect 16 0 8 2; -#X connect 17 0 8 3; +#N canvas 95 223 650 390 12;
+#X floatatom 202 113 5 0 0 0 - - -;
+#X text 338 286 watch the console output!;
+#X msg 20 115 help;
+#X text 16 69 This demonstrates message handling. See the simple.py
+file.;
+#X msg 19 140 doc;
+#X msg 55 141 doc+;
+#X floatatom 259 113 5 0 0 0 - - -;
+#X msg 169 235 msg 2;
+#X obj 123 289 pyext simple ex2;
+#X floatatom 123 334 5 0 0 0 - - -;
+#X floatatom 240 335 5 0 0 0 - - -;
+#X msg 100 204 msg 1 3;
+#X msg 234 220 msg a b;
+#X msg 120 174 hello;
+#X msg 193 180 hello;
+#X msg 266 179 msg;
+#X msg 325 154 hello 3;
+#X text 338 189 special case: 'hello' handler doesn't like args \,
+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 connect 0 0 8 1;
+#X connect 2 0 8 0;
+#X connect 4 0 8 0;
+#X connect 5 0 8 0;
+#X connect 6 0 8 2;
+#X connect 7 0 8 2;
+#X connect 8 0 9 0;
+#X connect 8 1 10 0;
+#X connect 11 0 8 1;
+#X connect 12 0 8 3;
+#X connect 13 0 8 1;
+#X connect 14 0 8 3;
+#X connect 15 0 8 2;
+#X connect 16 0 8 3;
diff --git a/externals/grill/py/pd/simple-3.pd b/externals/grill/py/pd/simple-3.pd index 450a3ec9..9cdb3f1b 100644 --- a/externals/grill/py/pd/simple-3.pd +++ b/externals/grill/py/pd/simple-3.pd @@ -1,27 +1,29 @@ -#N canvas 384 270 546 386 12; -#X msg 88 279 help; -#X text 15 50 This demonstrates message handling. See the simple.py -file.; -#X msg 87 304 doc; -#X msg 123 305 doc+; -#X floatatom 288 345 5 0 0 0 - - -; -#X text 17 22 py/pyext - Python script objects \, (C)2002 Thomas Grill -; -#X floatatom 316 119 5 0 0 0 - - -; -#X floatatom 399 119 5 0 0 0 - - -; -#X obj 225 279 pyext simple ex3 1; -#X msg 39 195 reload.; -#X msg 39 223 reload -10; -#X text 110 194 reload script and keep arguments; -#X text 128 224 reload script with new arguments; -#X text 281 140 triggers; -#X text 340 344 result; -#X text 410 140 sets argument; -#X connect 0 0 8 0; -#X connect 2 0 8 0; -#X connect 3 0 8 0; -#X connect 6 0 8 1; -#X connect 7 0 8 2; -#X connect 8 0 4 0; -#X connect 9 0 8 0; -#X connect 10 0 8 0; +#N canvas 136 275 649 361 12;
+#X msg 73 266 help;
+#X text 17 80 This demonstrates message handling. See the simple.py
+file.;
+#X msg 72 291 doc;
+#X msg 108 292 doc+;
+#X floatatom 258 305 5 0 0 0 - - -;
+#X floatatom 316 119 5 0 0 0 - - -;
+#X floatatom 399 119 5 0 0 0 - - -;
+#X obj 210 266 pyext simple ex3 1;
+#X msg 24 182 reload.;
+#X msg 24 210 reload -10;
+#X text 95 181 reload script and keep arguments;
+#X text 113 211 reload script with new arguments;
+#X text 281 140 triggers;
+#X text 310 304 result;
+#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 connect 0 0 7 0;
+#X connect 2 0 7 0;
+#X connect 3 0 7 0;
+#X connect 5 0 7 1;
+#X connect 6 0 7 2;
+#X connect 7 0 4 0;
+#X connect 8 0 7 0;
+#X connect 9 0 7 0;
diff --git a/externals/grill/py/pd/thread-1.pd b/externals/grill/py/pd/thread-1.pd index be775852..b2daa5f0 100644 --- a/externals/grill/py/pd/thread-1.pd +++ b/externals/grill/py/pd/thread-1.pd @@ -1,32 +1,34 @@ -#N canvas 440 61 590 402 12;
-#X msg 38 265 help;
-#X msg 37 290 doc;
-#X msg 73 291 doc+;
-#X floatatom 145 323 5 0 0 0 - - -;
-#X text 14 44 This demonstrates threading. See the threads.py file.
+#N canvas 135 178 644 401 12;
+#X msg 35 292 help;
+#X msg 34 317 doc;
+#X msg 70 318 doc+;
+#X floatatom 142 340 5 0 0 0 - - -;
+#X text 17 66 This demonstrates threading. See the threads.py file.
;
-#X obj 140 216 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+#X obj 137 243 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X msg 140 236 detach \$1;
-#X floatatom 253 324 5 0 0 0 - - -;
-#X obj 275 123 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+#X msg 137 263 detach \$1;
+#X floatatom 250 341 5 0 0 0 - - -;
+#X obj 272 150 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
-1;
-#X obj 146 127 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
+#X obj 143 154 bng 15 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
-1;
-#X obj 146 154 t b b b;
-#X obj 275 150 t b b b;
-#X obj 289 179 1;
-#X obj 160 181 0;
-#X text 87 87 without threads;
-#X text 251 85 with threads;
-#X text 252 102 non-blocking;
-#X text 178 345 watch that!;
-#X msg 414 127 stop;
-#X text 384 106 you can even stop it;
-#X obj 145 279 pyext threads ex1;
-#X text 93 101 - blocking!! -;
-#X text 16 14 py/pyext - Python script objects \, (C)2002 \, 2003 Thomas
-Grill;
+#X obj 143 181 t b b b;
+#X obj 272 177 t b b b;
+#X obj 286 206 1;
+#X obj 157 208 0;
+#X text 84 114 without threads;
+#X text 248 112 with threads;
+#X text 249 129 non-blocking;
+#X text 175 362 watch that!;
+#X msg 411 154 stop;
+#X text 381 133 you can even stop it;
+#X obj 142 306 pyext threads ex1;
+#X text 90 128 - blocking!! -;
+#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 connect 0 0 20 0;
#X connect 1 0 20 0;
#X connect 2 0 20 0;
diff --git a/externals/grill/py/py.vcproj b/externals/grill/py/py.vcproj index 92f66da5..cbc08f0f 100644 --- a/externals/grill/py/py.vcproj +++ b/externals/grill/py/py.vcproj @@ -88,7 +88,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;FLEXT_THREADS;_USEFLEXTBINDING" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FLEXT_SYS=2;FLEXT_THREADS" BasicRuntimeChecks="3" RuntimeLibrary="1" RuntimeTypeInfo="TRUE" @@ -103,10 +103,10 @@ <Tool Name="VCLinkerTool" AdditionalDependencies="pd.lib pthreadVC.lib" - OutputFile=".\pd-msvc\td/py.dll" + OutputFile="$(outdir)/py.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="c:/programme/audio/pd/bin;"..\flext\pd-msvc";"f:\prog\packs\Python-2.3.2\PCbuild"" + AdditionalLibraryDirectories="c:/programme/audio/pd/bin;"..\flext\pd-msvc";"f:\prog\packs\Python-2.3.4\PCbuild"" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\pd-msvc\td/py.pdb" ImportLibrary=".\pd-msvc\td/py.lib" diff --git a/externals/grill/py/readme.txt b/externals/grill/py/readme.txt index 1573c931..0f9121a7 100644 --- a/externals/grill/py/readme.txt +++ b/externals/grill/py/readme.txt @@ -90,6 +90,11 @@ Version history: - ADD: inlet and outlet count can be given for pyext, python _inlet and _outlet members are ignored then - FIX: crash if script or class names are non-strings - FIX: long multi-line doc strings are now printed correctly +- FIX: message "doc+" for class/instance __doc__ now working +- FIX: improved/debugged handling of reference counts +- FIX: _pyext._send will now send anythings if feasible +- CHANGE: no more finalization - it's really not necessary... +- FIX: calling from unregistered threads (like flext helper thread) now works 0.1.2: - CHANGE: updates for flext 0.4.1 - method registering within class scope @@ -138,6 +143,7 @@ features: - enable multiple interpreters? - make a pygui object where Tkinter draws to the PD canvas... - stop individual threads +- Python type for symbols tests: - check for python threading support diff --git a/externals/grill/py/source/bound.cpp b/externals/grill/py/source/bound.cpp index 928d7b67..9578e4c0 100644 --- a/externals/grill/py/source/bound.cpp +++ b/externals/grill/py/source/bound.cpp @@ -13,10 +13,12 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include <set> +typedef std::set<PyObject *> FuncSet; + struct bounddata { PyObject *self; - std::set<PyObject *> funcs; + FuncSet funcs; }; bool pyext::boundmeth(flext_base *,t_symbol *sym,int argc,t_atom *argv,void *data) @@ -25,10 +27,10 @@ bool pyext::boundmeth(flext_base *,t_symbol *sym,int argc,t_atom *argv,void *dat PY_LOCK - PyObject *args = MakePyArgs(sym,AtomList(argc,argv),-1,obj->self != NULL); + PyObject *args = MakePyArgs(sym,argc,argv,-1,obj->self != NULL); // call all functions bound by this symbol - for(std::set<PyObject *>::iterator it = obj->funcs.begin(); it != obj->funcs.end(); ++it) { + for(FuncSet::iterator it = obj->funcs.begin(); it != obj->funcs.end(); ++it) { PyObject *ret = PyObject_CallObject(*it,args); if(!ret) { PyErr_Print(); @@ -135,7 +137,7 @@ V pyext::ClearBinding() while(GetThis(pyobj)->UnbindMethod(sym,NULL,&data)) { bounddata *bdt = (bounddata *)data; if(bdt) { - for(std::set<PyObject *>::iterator it = bdt->funcs.begin(); it != bdt->funcs.end(); ++it) { + for(FuncSet::iterator it = bdt->funcs.begin(); it != bdt->funcs.end(); ++it) { PyObject *func = *it; if(PyMethod_Check(func)) Py_DECREF(func); } diff --git a/externals/grill/py/source/clmeth.cpp b/externals/grill/py/source/clmeth.cpp index a17c010a..d3b909ff 100644 --- a/externals/grill/py/source/clmeth.cpp +++ b/externals/grill/py/source/clmeth.cpp @@ -161,8 +161,10 @@ PyObject *pyext::pyext_outlet(PyObject *,PyObject *args) // deadlock would occur if this was another py/pyext object! if(lst->Count() && IsSymbol((*lst)[0])) ext->ToQueueAnything(o-1,GetSymbol((*lst)[0]),lst->Count()-1,lst->Atoms()+1); +// ext->ToOutAnything(o-1,GetSymbol((*lst)[0]),lst->Count()-1,lst->Atoms()+1); else ext->ToQueueList(o-1,*lst); +// ext->ToOutList(o-1,*lst); } else post("pyext: outlet index out of range"); @@ -230,7 +232,7 @@ PyObject *pyext::pyext_stop(PyObject *,PyObject *args) //! Query whether threading is enabled PyObject *pyext::pyext_isthreaded(PyObject *,PyObject *) { - return Py_BuildValue("i", + return PyInt_FromLong( #ifdef FLEXT_THREADED 1 #else diff --git a/externals/grill/py/source/main.cpp b/externals/grill/py/source/main.cpp index e552bc5a..0434f682 100644 --- a/externals/grill/py/source/main.cpp +++ b/externals/grill/py/source/main.cpp @@ -10,82 +10,83 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "main.h" + +static PyMethodDef StdOut_Methods[] = +{ + { "write", py::StdOut_Write, 1 }, + { NULL, NULL, } +}; + V py::lib_setup() { post(""); post("py/pyext %s - python script objects, (C)2002-2004 Thomas Grill",PY__VERSION); post(""); + // ------------------------------------------------------------- + + Py_Initialize(); + +#if 0 //def FLEXT_DEBUG + Py_DebugFlag = 1; + Py_VerboseFlag = 1; +#endif + +#ifdef FLEXT_THREADS + // enable thread support and acquire the global thread lock + PyEval_InitThreads(); + + // get thread state + pythrmain = PyThreadState_Get(); + // get main interpreter state + pystate = pythrmain->interp; + + // add thread state of main thread to map + pythrmap[GetThreadId()] = pythrmain; +#endif + + // register/initialize pyext module only once! + module_obj = Py_InitModule(PYEXT_MODULE, func_tbl); + module_dict = PyModule_GetDict(module_obj); // borrowed reference + + PyModule_AddStringConstant(module_obj,"__doc__",(C *)py_doc); + + // redirect stdout + PyObject* py_out = Py_InitModule("stdout", StdOut_Methods); + PySys_SetObject("stdout", py_out); + +#ifdef FLEXT_THREADS + // release global lock + PyEval_ReleaseLock(); +#endif + + // ------------------------------------------------------------- + FLEXT_SETUP(pyobj); FLEXT_SETUP(pyext); - - pyref = 0; } FLEXT_LIB_SETUP(py,py::lib_setup) -PyInterpreterState *py::pystate = NULL; #ifdef FLEXT_THREADS -std::map<flext::thrid_t,PyThreadState *> py::pythrmap; +PyInterpreterState *py::pystate = NULL; +PyThreadState *py::pythrmain = NULL; +PyThrMap py::pythrmap; #endif -I py::pyref = 0; PyObject *py::module_obj = NULL; PyObject *py::module_dict = NULL; -static PyMethodDef StdOut_Methods[] = -{ - { "write", py::StdOut_Write, 1 }, - { NULL, NULL, } -}; - - py::py(): module(NULL), detach(false),shouldexit(false),thrcount(0), stoptick(0) { - Lock(); - - if(!(pyref++)) { - Py_Initialize(); - - #ifdef FLEXT_THREADS - // enable thread support and acquire the global thread lock - PyEval_InitThreads(); - - // get thread state - PyThreadState *pythrmain = PyThreadState_Get(); - // get main interpreter state - pystate = pythrmain->interp; - - // release global lock - PyEval_ReleaseLock(); - - // add thread state of main thread to map - pythrmap[GetThreadId()] = pythrmain; - #endif - - // register/initialize pyext module only once! - module_obj = Py_InitModule(PYEXT_MODULE, func_tbl); - module_dict = PyModule_GetDict(module_obj); - - PyModule_AddStringConstant(module_obj,"__doc__",(C *)py_doc); - - // redirect stdout - PyObject* py_out = Py_InitModule("stdout", StdOut_Methods); - PySys_SetObject("stdout", py_out); - } - else { - PY_LOCK - Py_INCREF(module_obj); - Py_INCREF(module_dict); - PY_UNLOCK - } - - Unlock(); + PY_LOCK + Py_INCREF(module_obj); + PY_UNLOCK FLEXT_ADDTIMER(stoptmr,tick); } @@ -104,38 +105,7 @@ py::~py() post("%s - Okay, all threads have terminated",thisName()); } - Lock(); - - if(!(--pyref)) { - // no more py/pyext objects left... shut down Python - - module_obj = NULL; - module_dict = NULL; - - Py_XDECREF(module); - - PyEval_AcquireLock(); - -#ifdef FLEXT_THREADS - PyThreadState_Swap(pythrmap[GetThreadId()]); -#endif - -#if 0 //def FLEXT_DEBUG - // need not necessarily do that.... - Py_Finalize(); -#endif - -#ifdef FLEXT_THREADS - // reset thread state map - pythrmap.clear(); -#endif - } - else { - Py_DECREF(module_obj); - Py_DECREF(module_dict); - } - - Unlock(); + Py_XDECREF(module_obj); } @@ -229,16 +199,31 @@ V py::ImportModule(const C *name) { if(!name) return; - module = PyImport_ImportModule((C *)name); + module = PyImport_ImportModule((C *)name); // increases module_obj ref count by one if (!module) { + PyErr_Print(); dict = NULL; } else - dict = PyModule_GetDict(module); // borrowed - + dict = PyModule_GetDict(module); } +V py::UnimportModule() +{ + if(!module) return; + + assert(dict && module_obj && module_dict); + + Py_DECREF(module); + + // reference count to module is not 0 here, altough probably the last instance was unloaded + // Python retains one reference to the module all the time + // we don't care + + module = NULL; + dict = NULL; +} V py::ReloadModule() { @@ -262,7 +247,7 @@ V py::ReloadModule() V py::GetModulePath(const C *mod,C *dir,I len) { #if FLEXT_SYS == FLEXT_SYS_PD - // uarghh... pd doesn't show it's path for extra modules + // uarghh... pd doesn't show its path for extra modules C *name; I fd = open_via_path("",mod,".py",dir,&name,len,0); diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h index d6ca52cb..2e8419d3 100644 --- a/externals/grill/py/source/main.h +++ b/externals/grill/py/source/main.h @@ -50,6 +50,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "main.h" +typedef std::map<flext::thrid_t,PyThreadState *> PyThrMap; + class py: public flext_base { @@ -60,7 +62,7 @@ public: ~py(); static V lib_setup(); - static PyObject *MakePyArgs(const t_symbol *s,const AtomList &args,I inlet = -1,BL withself = false); + static PyObject *MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,I inlet = -1,BL withself = false); static AtomList *GetPyArgs(PyObject *pValue,PyObject **self = NULL); protected: @@ -74,7 +76,6 @@ protected: PyObject *module,*dict; // inherited user class module and associated dictionary - static I pyref; static const C *py_doc; V GetDir(PyObject *obj,AtomList &lst); @@ -83,6 +84,7 @@ protected: V AddToPath(const C *dir); V SetArgs(I argc,const t_atom *argv); V ImportModule(const C *name); + V UnimportModule(); V ReloadModule(); V Register(const C *reg); @@ -124,16 +126,17 @@ protected: V tick(V *); public: - static PyInterpreterState *pystate; #ifdef FLEXT_THREADS - static std::map<flext::thrid_t,PyThreadState *> pythrmap; + static PyInterpreterState *pystate; + static PyThreadState *pythrmain; + static PyThrMap pythrmap; ThrMutex mutex; - V Lock() { mutex.Unlock(); } - V Unlock() { mutex.Unlock(); } + inline V Lock() { mutex.Unlock(); } + inline V Unlock() { mutex.Unlock(); } #else - V Lock() {} - V Unlock() {} + inline V Lock() {} + inline V Unlock() {} #endif static PyObject* StdOut_Write(PyObject* Self, PyObject* Args); @@ -152,11 +155,14 @@ protected: #ifdef FLEXT_THREADS +// if thread is not found in the thread map, the state of the system thread is used +// we have yet to see if this has bad side-effects + #define PY_LOCK \ { \ PyEval_AcquireLock(); \ - PyThreadState *__st = pythrmap[GetThreadId()]; \ - FLEXT_ASSERT(__st != NULL); \ + PyThrMap::iterator it = pythrmap.find(GetThreadId()); \ + PyThreadState *__st = it != pythrmap.end()?it->second:pythrmain; \ PyThreadState *__oldst = PyThreadState_Swap(__st); #define PY_UNLOCK \ diff --git a/externals/grill/py/source/modmeth.cpp b/externals/grill/py/source/modmeth.cpp index f7dae309..b3a98c98 100644 --- a/externals/grill/py/source/modmeth.cpp +++ b/externals/grill/py/source/modmeth.cpp @@ -142,11 +142,15 @@ PyObject *py::py_send(PyObject *,PyObject *args) AtomList *lst = GetPyArgs(val); if(lst) { - if(!Forward(recv,*lst)) + bool ok; + if(lst->Count() && IsSymbol((*lst)[0])) + ok = Forward(recv,GetSymbol((*lst)[0]),lst->Count()-1,lst->Atoms()+1); + else + ok = Forward(recv,*lst); + #ifdef FLEXT_DEBUG + if(!ok) post("py/pyext - Receiver doesn't exist"); -#else - {} #endif } else diff --git a/externals/grill/py/source/py.cpp b/externals/grill/py/source/py.cpp index e7524ce1..8b14a485 100644 --- a/externals/grill/py/source/py.cpp +++ b/externals/grill/py/source/py.cpp @@ -2,7 +2,7 @@ py/pyext - python script object for PD and Max/MSP -Copyright (c) 2002-2004 Thomas Grill (xovo@gmx.net) +Copyright (c)2002-2004 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. @@ -297,7 +297,7 @@ BL pyobj::work(const t_symbol *s,I argc,const t_atom *argv) PY_LOCK if(function) { - PyObject *pArgs = MakePyArgs(s,AtomList(argc,argv)); + PyObject *pArgs = MakePyArgs(s,argc,argv); PyObject *pValue = PyObject_CallObject(function, pArgs); rargs = GetPyArgs(pValue); diff --git a/externals/grill/py/source/pyargs.cpp b/externals/grill/py/source/pyargs.cpp index 8fe68cbd..1b204273 100644 --- a/externals/grill/py/source/pyargs.cpp +++ b/externals/grill/py/source/pyargs.cpp @@ -27,7 +27,7 @@ static PyObject *MakePyAtom(const t_atom &at) return NULL; } -PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withself) +PyObject *py::MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,I inlet,BL withself) { PyObject *pArgs; @@ -41,7 +41,7 @@ PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withs */ { BL any = IsAnything(s); - pArgs = PyTuple_New(args.Count()+(any?1:0)+(inlet >= 0?1:0)); + pArgs = PyTuple_New(argc+(any?1:0)+(inlet >= 0?1:0)); I pix = 0; @@ -54,8 +54,8 @@ PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withs I ix; PyObject *tmp; - if(!withself || args.Count() < (any?1:2)) tmp = pArgs,ix = pix; - else tmp = PyTuple_New(args.Count()+(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) { PyObject *pValue = PyString_FromString(GetString(s)); @@ -64,8 +64,8 @@ PyObject *py::MakePyArgs(const t_symbol *s,const AtomList &args,I inlet,BL withs PyTuple_SetItem(tmp, ix++, pValue); } - for(I i = 0; i < args.Count(); ++i) { - PyObject *pValue = MakePyAtom(args[i]); + for(I i = 0; i < argc; ++i) { + PyObject *pValue = MakePyAtom(argv[i]); if(!pValue) { post("py/pyext: cannot convert argument %i",any?i+1:i); continue; diff --git a/externals/grill/py/source/pyext.cpp b/externals/grill/py/source/pyext.cpp index 7dd4d805..66428054 100644 --- a/externals/grill/py/source/pyext.cpp +++ b/externals/grill/py/source/pyext.cpp @@ -34,6 +34,43 @@ V pyext::Setup(t_classid c) FLEXT_CADDMETHOD_(c,0,"set",m_set); FLEXT_CADDATTR_VAR1(c,"respond",respond); + + + // ---------------------------------------------------- + + // register/initialize pyext base class along with module + class_dict = PyDict_New(); + PyObject *className = PyString_FromString(PYEXT_CLASS); + PyMethodDef *def; + + // add setattr/getattr to class + for(def = attr_tbl; def->ml_name; def++) { + PyObject *func = PyCFunction_New(def, NULL); + PyDict_SetItemString(class_dict, def->ml_name, func); + Py_DECREF(func); + } + + class_obj = PyClass_New(NULL, class_dict, className); + Py_DECREF(className); + + // add methods to class + for (def = meth_tbl; def->ml_name != NULL; def++) { + PyObject *func = PyCFunction_New(def, NULL); + PyObject *method = PyMethod_New(func, NULL, class_obj); // increases class_obj ref count by 1 + PyDict_SetItemString(class_dict, def->ml_name, method); + Py_DECREF(func); + Py_DECREF(method); + } + +#if PY_VERSION_HEX >= 0x02020000 + // not absolutely necessary, existent in python 2.2 upwards + // make pyext functions available in class scope + PyDict_Merge(class_dict,module_dict,0); +#endif + // after merge so that it's not in class_dict as well... + PyDict_SetItemString(module_dict, PYEXT_CLASS,class_obj); // increases class_obj ref count by 1 + + PyDict_SetItemString(class_dict,"__doc__",PyString_FromString(pyext_doc)); } pyext *pyext::GetThis(PyObject *self) @@ -60,7 +97,6 @@ static short patcher_myvol(t_patcher *x) #endif -I pyext::pyextref = 0; PyObject *pyext::class_obj = NULL; PyObject *pyext::class_dict = NULL; @@ -71,53 +107,14 @@ pyext::pyext(I argc,const t_atom *argv): { int apre = 0; - PY_LOCK - - if(!pyextref++) { - // register/initialize pyext base class along with module - class_dict = PyDict_New(); - PyObject *className = PyString_FromString(PYEXT_CLASS); - PyMethodDef *def; - - // add setattr/getattr to class - for(def = attr_tbl; def->ml_name; def++) { - PyObject *func = PyCFunction_New(def, NULL); - PyDict_SetItemString(class_dict, def->ml_name, func); - Py_DECREF(func); - } - - class_obj = PyClass_New(NULL, class_dict, className); - PyDict_SetItemString(module_dict, PYEXT_CLASS,class_obj); - Py_DECREF(className); - - // add methods to class - for (def = meth_tbl; def->ml_name != NULL; def++) { - PyObject *func = PyCFunction_New(def, NULL); - PyObject *method = PyMethod_New(func, NULL, class_obj); - PyDict_SetItemString(class_dict, def->ml_name, method); - Py_DECREF(func); - Py_DECREF(method); - } - -#if PY_VERSION_HEX >= 0x02020000 - // not absolutely necessary, existent in python 2.2 upwards - // make pyext functions available in class scope - PyDict_Merge(class_dict,module_dict,0); -#endif - - PyDict_SetItemString(class_dict,"__doc__",PyString_FromString(pyext_doc)); - } - else { - Py_INCREF(class_obj); - Py_INCREF(class_dict); - } - if(argc >= apre+2 && CanbeInt(argv[apre]) && CanbeInt(argv[apre+1])) { inlets = GetAInt(argv[apre]); outlets = GetAInt(argv[apre+1]); apre += 2; } + PY_LOCK + // init script module if(argc > apre) { char dir[1024]; @@ -151,7 +148,7 @@ pyext::pyext(I argc,const t_atom *argv): ++apre; } - Register("_pyext"); + Register("_pyext"); // t_symbol *sobj = NULL; if(argc > apre) { @@ -168,7 +165,7 @@ pyext::pyext(I argc,const t_atom *argv): if(argc > apre) args(argc-apre,argv+apre); if(methname) { - SetClssMeth(); + MakeInstance(); if(inlets < 0 && outlets < 0) { // now get number of inlets and outlets @@ -222,22 +219,15 @@ pyext::~pyext() PY_LOCK ClearBinding(); - Unregister("_pyext"); + UnimportModule(); - Py_XDECREF(pyobj); - Py_XDECREF(class_obj); - Py_XDECREF(class_dict); - - if(!--pyextref) { - class_obj = NULL; - class_dict = NULL; - } + Py_XDECREF(pyobj); // opposite of SetClssMeth PY_UNLOCK } -BL pyext::SetClssMeth() //I argc,t_atom *argv) +BL pyext::MakeInstance() { // pyobj should already have been decref'd / cleared before getting here!! @@ -250,7 +240,6 @@ BL pyext::SetClssMeth() //I argc,t_atom *argv) // make instance, but don't call __init__ pyobj = PyInstance_NewRaw(pref,NULL); - Py_DECREF(pref); if(pyobj == NULL) PyErr_Print(); else { @@ -260,8 +249,9 @@ BL pyext::SetClssMeth() //I argc,t_atom *argv) // call init now, after _this has been set, which is // important for eventual callbacks from __init__ to c - PyObject *pargs = MakePyArgs(NULL,args,-1,true); - if (pargs == NULL) PyErr_Print(); + PyObject *pargs = MakePyArgs(NULL,args.Count(),args.Atoms(),-1,true); + if (pargs == NULL) + PyErr_Print(); PyObject *init; init = PyObject_GetAttrString(pyobj,"__init__"); // get ref @@ -300,7 +290,7 @@ V pyext::Reload() SetArgs(0,NULL); ReloadModule(); - SetClssMeth(); + MakeInstance(); } @@ -367,7 +357,7 @@ void pyext::m_set(int argc,const t_atom *argv) post("%s - set: Python variable %s not found",thisName(),ch); } else { - PyObject *pval = MakePyArgs(NULL,AtomList(argc-1,argv+1),-1,false); + PyObject *pval = MakePyArgs(NULL,argc-1,argv+1,-1,false); if(!pval) PyErr_Print(); @@ -438,17 +428,13 @@ PyObject *pyext::call(const C *meth,I inlet,const t_symbol *s,I argc,const t_ato PyErr_Clear(); // no method found } else { - PyObject *pargs = MakePyArgs(s,AtomList(argc,argv),inlet?inlet:-1,true); + PyObject *pargs = MakePyArgs(s,argc,argv,inlet?inlet:-1,true); if(!pargs) PyErr_Print(); else { ret = PyEval_CallObject(pmeth, pargs); if (ret == NULL) // function not found resp. arguments not matching -#ifdef FLEXT_DEBUG PyErr_Print(); -#else - PyErr_Clear(); -#endif Py_DECREF(pargs); } @@ -470,7 +456,6 @@ V pyext::work_wrapper(V *data) // --- make new Python thread --- // get the global lock PyEval_AcquireLock(); - // get a reference to the PyInterpreterState // create a thread state object for this thread PyThreadState *newthr = PyThreadState_New(pystate); // free the lock diff --git a/externals/grill/py/source/pyext.h b/externals/grill/py/source/pyext.h index 976ef0a6..d05ea7e5 100644 --- a/externals/grill/py/source/pyext.h +++ b/externals/grill/py/source/pyext.h @@ -51,7 +51,7 @@ protected: V ms_args(const AtomList &a) { m_reload_(a.Count(),a.Atoms()); } V m_dir_() { m__dir(pyobj); } V mg_dir_(AtomList &lst) { GetDir(pyobj,lst); } - V m_doc_() { m__doc(pyobj); } + V m_doc_() { m__doc(((PyInstanceObject *)pyobj)->in_class->cl_dict); } virtual V m_help(); V m_get(const t_symbol *s); @@ -66,13 +66,12 @@ private: static pyext *GetThis(PyObject *self); V ClearBinding(); - BL SetClssMeth(); //I argc,t_atom *argv); + BL MakeInstance(); AtomList args; virtual V Reload(); - static I pyextref; static PyObject *class_obj,*class_dict; static PyMethodDef attr_tbl[],meth_tbl[]; static const C *pyext_doc; |