From 29416a643b9c3d19a60b91b37a263d300c11486b Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 9 Jul 2005 13:03:34 +0000 Subject: python-like dotted module.function syntax reworked outbound message generation (now with symbols instead of one-element anythings) multiply inlets for py (hot and cold inlets) cleaned up float vs. int pyext tags pymeth object for object methods enable built-in functions sequence protocol for symbol type enabled built-in functions py: allow all callables svn path=/trunk/; revision=3310 --- externals/grill/py/pd/builtins-1.pd | 47 +++++++++++++++++++++++++++++++++++++ externals/grill/py/pd/methods-1.pd | 24 +++++++++++++++++++ externals/grill/py/pd/methods-2.pd | 28 ++++++++++++++++++++++ externals/grill/py/pd/script-1.pd | 26 ++++++++++---------- externals/grill/py/pd/simple-2.pd | 8 +++---- 5 files changed, 115 insertions(+), 18 deletions(-) create mode 100644 externals/grill/py/pd/builtins-1.pd create mode 100644 externals/grill/py/pd/methods-1.pd create mode 100644 externals/grill/py/pd/methods-2.pd (limited to 'externals/grill/py/pd') diff --git a/externals/grill/py/pd/builtins-1.pd b/externals/grill/py/pd/builtins-1.pd new file mode 100644 index 00000000..095e7690 --- /dev/null +++ b/externals/grill/py/pd/builtins-1.pd @@ -0,0 +1,47 @@ +#N canvas 327 349 706 421 12; +#X obj 36 241 py .range @xlate 0; +#X floatatom 35 356 5 0 0 0 - - -; +#X obj 35 323 py .sum; +#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill; +#X text 235 32 http://grrrr.org/ext; +#X obj 36 159 nbx 5 14 -1e+037 1e+037 0 1 empty empty min 0 -6 0 10 +-262131 -1 -1 38 256; +#X obj 95 159 nbx 5 14 -1e+037 1e+037 0 1 empty empty max 0 -6 0 10 +-262131 -1 -1 100 256; +#X obj 154 159 nbx 5 14 1 100000 1 1 empty empty step 0 -6 0 10 -262131 +-1 -1 1 256; +#N canvas 0 0 462 312 pak3 0; +#X obj 34 26 inlet; +#X obj 81 28 inlet; +#X obj 129 28 inlet; +#X obj 36 158 outlet; +#X obj 36 123 pack 0 0 0; +#X obj 61 78 t b f; +#X obj 108 80 t b f; +#X obj 208 46 loadbang; +#X obj 208 73 1; +#X connect 0 0 4 0; +#X connect 1 0 5 0; +#X connect 2 0 6 0; +#X connect 4 0 3 0; +#X connect 5 0 4 0; +#X connect 5 1 4 1; +#X connect 6 0 4 0; +#X connect 6 1 4 2; +#X connect 7 0 8 0; +#X connect 8 0 4 2; +#X restore 36 195 pd pak3; +#X text 115 240 construct a Python list; +#X text 78 282 Python object pointer is propagated to next object; +#X text 106 320 calculate sum over list elements; +#X text 21 73 Py can use built-in Python functions; +#X text 21 97 A . preceding the function name searches for the function +in either the pyext module or in __builtins__; +#X connect 0 0 2 1; +#X connect 2 0 1 0; +#X connect 6 0 9 0; +#X connect 7 0 9 1; +#X connect 8 0 9 2; +#X connect 9 0 0 1; diff --git a/externals/grill/py/pd/methods-1.pd b/externals/grill/py/pd/methods-1.pd new file mode 100644 index 00000000..8d49f319 --- /dev/null +++ b/externals/grill/py/pd/methods-1.pd @@ -0,0 +1,24 @@ +#N canvas 540 469 714 349 12; +#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill; +#X text 235 32 http://grrrr.org/ext; +#X symbolatom 21 139 10 0 0 0 - - -; +#X symbolatom 25 298 10 0 0 0 - - -; +#X obj 25 252 pym upper; +#X obj 22 179 py .str @xlate 0; +#X text 93 167 convert the symbol to a Python string; +#X text 35 216 pass it as a true Python object; +#X text 105 251 use string.upper method; +#X obj 363 252 py string.upper; +#X symbolatom 364 288 10 0 0 0 - - -; +#X text 495 254 use module function; +#X text 23 119 enter some text; +#X text 21 73 Py can act on Python objects in a object-oriented manner +; +#X text 93 184 using the built-in str function; +#X connect 3 0 6 1; +#X connect 5 0 4 0; +#X connect 6 0 5 1; +#X connect 6 0 10 1; +#X connect 10 0 11 0; diff --git a/externals/grill/py/pd/methods-2.pd b/externals/grill/py/pd/methods-2.pd new file mode 100644 index 00000000..b10e183c --- /dev/null +++ b/externals/grill/py/pd/methods-2.pd @@ -0,0 +1,28 @@ +#N canvas 540 469 734 339 12; +#X obj 16 13 cnv 15 650 40 empty empty py/pyext 10 22 0 24 -260818 +-1 0; +#X text 235 16 Python script objects \, (C)2003-2005 Thomas Grill; +#X text 235 32 http://grrrr.org/ext; +#X symbolatom 21 139 10 0 0 0 - #0-t -; +#X text 23 119 enter some text; +#X text 21 73 Py can act on Python objects in a object-oriented manner +; +#X obj 25 252 pym 2 *; +#X obj 213 169 t b f; +#X text 105 251 repeat text; +#X text 215 117 multiply it!; +#X symbolatom 25 283 80 0 0 0 - - -; +#X obj 214 139 nbx 5 14 1 100 0 1 empty empty empty 0 -6 0 10 -262131 +-1 -1 34 256; +#N canvas 0 0 458 308 init 0; +#X obj 61 116 s \$0-t; +#X obj 64 44 loadbang; +#X obj 64 81 symbol a; +#X connect 1 0 2 0; +#X connect 2 0 0 0; +#X restore 606 127 pd init; +#X connect 3 0 6 1; +#X connect 6 0 10 0; +#X connect 7 0 6 0; +#X connect 7 1 6 2; +#X connect 11 0 7 0; diff --git a/externals/grill/py/pd/script-1.pd b/externals/grill/py/pd/script-1.pd index 328b096d..98fee527 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 696 538 12; +#N canvas 297 17 700 542 12; #X obj 39 278 print; #X obj 345 251 print; #X msg 499 149 freakhole; @@ -26,7 +26,6 @@ file.; #X obj 39 241 py script strcat; #X obj 43 424 py script addall; #X obj 350 420 py script; -#X obj 516 419 py script ret3; #X obj 346 204 py script strlen; #X msg 21 159 dir; #X obj 146 279 print A; @@ -39,26 +38,27 @@ file.; #X text 556 181 too many args; #X text 505 372 just trigger without arguments; #X msg 386 371 set ret4; -#X connect 2 0 25 1; +#X obj 516 419 py script ret3; +#X connect 2 0 24 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 11 0 35 0; #X connect 12 0 21 1; -#X connect 13 0 25 0; +#X connect 13 0 24 0; #X connect 14 0 23 0; #X connect 15 0 23 0; -#X connect 17 0 25 1; +#X connect 17 0 24 1; #X connect 19 0 21 0; #X connect 21 0 0 0; -#X connect 21 1 27 0; +#X connect 21 1 26 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; -#X connect 32 0 25 1; -#X connect 35 0 23 0; +#X connect 24 0 1 0; +#X connect 25 0 21 0; +#X connect 27 0 21 0; +#X connect 31 0 24 1; +#X connect 34 0 23 0; +#X connect 35 0 10 0; diff --git a/externals/grill/py/pd/simple-2.pd b/externals/grill/py/pd/simple-2.pd index 1845b032..4c857d49 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 654 394 12; +#N canvas 570 275 788 398 12; #X floatatom 202 113 5 0 0 0 - - -; #X text 338 286 watch the console output!; #X msg 20 115 help; @@ -16,13 +16,11 @@ file.; #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 16 Python script objects \, (C)2003-2005 Thomas Grill; #X text 213 32 http://grrrr.org/ext; +#X msg 333 186 whoopie a b c; #X connect 0 0 8 1; #X connect 2 0 8 0; #X connect 4 0 8 0; @@ -36,4 +34,4 @@ so _anything_ is called!; #X connect 13 0 8 1; #X connect 14 0 8 3; #X connect 15 0 8 2; -#X connect 16 0 8 3; +#X connect 19 0 8 3; -- cgit v1.2.1