1 /*
2  * pycall.auto.c
3  *
4  * Copyright (C) 2002 Maurizio Umberto Puxeddu, Michael Gogins
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this software; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20 
pycall0_krate(CSOUND * csound,PYCALL0 * p)21 static int pycall0_krate(CSOUND *csound, PYCALL0 *p)
22 {
23     char      command[1024];
24     PyObject  *result;
25     int *py_initialize_done;
26     if (UNLIKELY((py_initialize_done =
27                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
28                  *py_initialize_done == 0))
29       return NOTOK;
30 
31     format_call_statement(command, (char*) p->function->data,
32                           p->INOCOUNT, p->args, 1);
33 
34     result = eval_string_in_given_context(command, 0);
35 
36     if (result == NULL)
37       return pyErrMsg(p, "python exception");
38 
39     if (result != Py_None)
40       return errMsg(p, "callable must return None");
41 
42     Py_DECREF(result);
43     return OK;
44 }
45 
pylcall0_irate(CSOUND * csound,PYCALL0 * p)46 static int pylcall0_irate(CSOUND *csound, PYCALL0 *p)
47 {
48     int *py_initialize_done;
49     if (UNLIKELY((py_initialize_done =
50                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
51                  *py_initialize_done == 0))
52       return NOTOK;
53     create_private_namespace_if_needed(&p->h);
54     return OK;
55 }
56 
pylcall0_krate(CSOUND * csound,PYCALL0 * p)57 static int pylcall0_krate(CSOUND *csound, PYCALL0 *p)
58 {
59     char      command[1024];
60     PyObject  *result;
61     int *py_initialize_done;
62     if (UNLIKELY((py_initialize_done =
63                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
64                  *py_initialize_done == 0))
65       return NOTOK;
66     format_call_statement(command, (char*) p->function->data,
67                           p->INOCOUNT, p->args, 1);
68 
69     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
70 
71     if (UNLIKELY(result == NULL))
72       return pyErrMsg(p, "python exception");
73 
74     if (UNLIKELY(result != Py_None))
75       return errMsg(p, "callable must return None");
76 
77     Py_DECREF(result);
78     return OK;
79 }
80 
pylcall0i_irate(CSOUND * csound,PYCALL0 * p)81 static int pylcall0i_irate(CSOUND *csound, PYCALL0 *p)
82 {
83     char      command[1024];
84     PyObject  *result;
85     int *py_initialize_done;
86     if (UNLIKELY((py_initialize_done =
87                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
88                  *py_initialize_done == 0))
89       return NOTOK;
90     format_call_statement(command, (char*) p->function->data,
91                           p->INOCOUNT, p->args, 1);
92 
93     create_private_namespace_if_needed(&p->h);
94 
95     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
96 
97     if (UNLIKELY(result == NULL))
98       return pyErrMsg(p, "python exception");
99 
100     if (UNLIKELY(result != Py_None))
101       return errMsg(p, "callable must return None");
102 
103     Py_DECREF(result);
104     return OK;
105 }
106 
pycall0t_krate(CSOUND * csound,PYCALL0T * p)107 static int pycall0t_krate(CSOUND *csound, PYCALL0T *p)
108 {
109     char      command[1024];
110     PyObject  *result;
111     int *py_initialize_done;
112     if (UNLIKELY((py_initialize_done =
113                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
114                  *py_initialize_done == 0))
115       return NOTOK;
116     if (!*p->trigger) {
117       return OK;
118     }
119 
120     format_call_statement(command, (char*) p->function->data,
121                           p->INOCOUNT, p->args, 2);
122 
123     result = eval_string_in_given_context(command, 0);
124 
125     if (UNLIKELY(result == NULL))
126       return pyErrMsg(p, "python exception");
127 
128     if (UNLIKELY(result != Py_None))
129       return errMsg(p, "callable must return None");
130 
131     Py_DECREF(result);
132     return OK;
133 }
134 
pylcall0t_irate(CSOUND * csound,PYCALL0T * p)135 static int pylcall0t_irate(CSOUND *csound, PYCALL0T *p)
136 {
137     int *py_initialize_done;
138     if (UNLIKELY((py_initialize_done =
139                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
140                  *py_initialize_done == 0))
141       return NOTOK;
142     create_private_namespace_if_needed(&p->h);
143     return OK;
144 }
145 
pylcall0t_krate(CSOUND * csound,PYCALL0T * p)146 static int pylcall0t_krate(CSOUND *csound, PYCALL0T *p)
147 {
148     char      command[1024];
149     PyObject  *result;
150     int *py_initialize_done;
151     if (UNLIKELY((py_initialize_done =
152                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
153                  *py_initialize_done == 0))
154       return NOTOK;
155     if (!*p->trigger) {
156       return OK;
157     }
158 
159     format_call_statement(command, (char*) p->function->data,
160                           p->INOCOUNT, p->args, 2);
161 
162     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
163 
164     if (UNLIKELY(result == NULL))
165       return pyErrMsg(p, "python exception");
166 
167     if (UNLIKELY(result != Py_None))
168       return errMsg(p, "callable must return None");
169 
170     Py_DECREF(result);
171     return OK;
172 }
173 
pycall1_krate(CSOUND * csound,PYCALL1 * p)174 static int pycall1_krate(CSOUND *csound, PYCALL1 *p)
175 {
176     char      command[1024];
177     PyObject  *result;
178     int *py_initialize_done;
179     if (UNLIKELY((py_initialize_done =
180                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
181                  *py_initialize_done == 0))
182       return NOTOK;
183     format_call_statement(command, (char*) p->function->data,
184                           p->INOCOUNT, p->args, 1);
185 
186     result = eval_string_in_given_context(command, 0);
187 
188     if (UNLIKELY(result == NULL))
189       return pyErrMsg(p, "python exception");
190 
191     if (UNLIKELY(!PyFloat_Check(result))) {
192       return errMsg(p, "callable must return a float");
193     }
194     else {
195       *p->result = PyFloat_AsDouble(result);
196     }
197     return OK;
198 
199     Py_DECREF(result);
200     return OK;
201 }
202 
pylcall1_irate(CSOUND * csound,PYCALL1 * p)203 static int pylcall1_irate(CSOUND *csound, PYCALL1 *p)
204 {
205      IGN(csound);
206     create_private_namespace_if_needed(&p->h);
207     return OK;
208 }
209 
pylcall1_krate(CSOUND * csound,PYCALL1 * p)210 static int pylcall1_krate(CSOUND *csound, PYCALL1 *p)
211 {
212     char      command[1024];
213     PyObject  *result;
214     int *py_initialize_done;
215     if (UNLIKELY((py_initialize_done =
216                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
217                  *py_initialize_done == 0))
218       return NOTOK;
219     format_call_statement(command, (char*) p->function->data,
220                           p->INOCOUNT, p->args, 1);
221 
222     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
223 
224     if (UNLIKELY(result == NULL))
225       return pyErrMsg(p, "python exception");
226 
227     if (UNLIKELY(!PyFloat_Check(result))) {
228       return errMsg(p, "callable must return a float");
229     }
230     else {
231       *p->result = PyFloat_AsDouble(result);
232     }
233     return OK;
234 
235     Py_DECREF(result);
236     return OK;
237 }
238 
pylcall1i_irate(CSOUND * csound,PYCALL1 * p)239 static int pylcall1i_irate(CSOUND *csound, PYCALL1 *p)
240 {
241     char      command[1024];
242     PyObject  *result;
243     int *py_initialize_done;
244     if (UNLIKELY((py_initialize_done =
245                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
246                  *py_initialize_done == 0))
247       return NOTOK;
248     format_call_statement(command, (char*) p->function->data,
249                           p->INOCOUNT, p->args, 1);
250 
251     create_private_namespace_if_needed(&p->h);
252 
253     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
254 
255     if (UNLIKELY(result == NULL))
256       return pyErrMsg(p, "python exception");
257 
258     if (UNLIKELY(!PyFloat_Check(result))) {
259       return errMsg(p, "callable must return a float");
260     }
261     else {
262       *p->result = PyFloat_AsDouble(result);
263     }
264     return OK;
265 
266     Py_DECREF(result);
267     return OK;
268 }
269 
pycall1t_krate(CSOUND * csound,PYCALL1T * p)270 static int pycall1t_krate(CSOUND *csound, PYCALL1T *p)
271 {
272     char      command[1024];
273     PyObject  *result;
274     int *py_initialize_done;
275     if (UNLIKELY((py_initialize_done =
276                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
277                  *py_initialize_done == 0))
278       return NOTOK;
279     if (!*p->trigger) {
280       *p->result = p->oresult;
281       return OK;
282     }
283 
284     format_call_statement(command, (char*) p->function->data,
285                           p->INOCOUNT, p->args, 2);
286 
287     result = eval_string_in_given_context(command, 0);
288 
289     if (UNLIKELY(result == NULL))
290       return pyErrMsg(p, "python exception");
291 
292     if (UNLIKELY(!PyFloat_Check(result))) {
293       return errMsg(p, "callable must return a float");
294     }
295     else {
296       *p->result = PyFloat_AsDouble(result);
297       p->oresult = *p->result;
298     }
299     return OK;
300 
301     Py_DECREF(result);
302     return OK;
303 }
304 
pylcall1t_irate(CSOUND * csound,PYCALL1T * p)305 static int pylcall1t_irate(CSOUND *csound, PYCALL1T *p)
306 {
307     int *py_initialize_done;
308     if (UNLIKELY((py_initialize_done =
309                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
310                  *py_initialize_done == 0))
311       return NOTOK;
312     create_private_namespace_if_needed(&p->h);
313     return OK;
314 }
315 
pylcall1t_krate(CSOUND * csound,PYCALL1T * p)316 static int pylcall1t_krate(CSOUND *csound, PYCALL1T *p)
317 {
318     char      command[1024];
319     PyObject  *result;
320     int *py_initialize_done;
321     if (UNLIKELY((py_initialize_done =
322                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
323                  *py_initialize_done == 0))
324       return NOTOK;
325     if (!*p->trigger) {
326       *p->result = p->oresult;
327       return OK;
328     }
329 
330     format_call_statement(command, (char*) p->function->data,
331                           p->INOCOUNT, p->args, 2);
332 
333     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
334 
335     if (UNLIKELY(result == NULL))
336       return pyErrMsg(p, "python exception");
337 
338     if (UNLIKELY(!PyFloat_Check(result))) {
339       return errMsg(p, "callable must return a float");
340     }
341     else {
342       *p->result = PyFloat_AsDouble(result);
343       p->oresult = *p->result;
344     }
345     return OK;
346 
347     Py_DECREF(result);
348     return OK;
349 }
350 
pycall2_krate(CSOUND * csound,PYCALL2 * p)351 static int pycall2_krate(CSOUND *csound, PYCALL2 *p)
352 {
353     char      command[1024];
354     PyObject  *result;
355     int *py_initialize_done;
356     if (UNLIKELY((py_initialize_done =
357                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
358                  *py_initialize_done == 0))
359       return NOTOK;
360     format_call_statement(command, (char*) p->function->data,
361                           p->INOCOUNT, p->args, 1);
362 
363     result = eval_string_in_given_context(command, 0);
364 
365     if (UNLIKELY(result == NULL))
366       return pyErrMsg(p, "python exception");
367 
368     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 2)) {
369       return errMsg(p, "callable must return 2 values");
370     }
371     else {
372       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
373       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
374     }
375 
376     Py_DECREF(result);
377     return OK;
378 }
379 
pylcall2_irate(CSOUND * csound,PYCALL2 * p)380 static int pylcall2_irate(CSOUND *csound, PYCALL2 *p)
381 {
382     int *py_initialize_done;
383     if (UNLIKELY((py_initialize_done =
384                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
385                  *py_initialize_done == 0))
386       return NOTOK;
387     create_private_namespace_if_needed(&p->h);
388     return OK;
389 }
390 
pylcall2_krate(CSOUND * csound,PYCALL2 * p)391 static int pylcall2_krate(CSOUND *csound, PYCALL2 *p)
392 {
393     char      command[1024];
394     PyObject  *result;
395     int *py_initialize_done;
396     if (UNLIKELY((py_initialize_done =
397                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
398                  *py_initialize_done == 0))
399       return NOTOK;
400     format_call_statement(command, (char*) p->function->data,
401                           p->INOCOUNT, p->args, 1);
402 
403     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
404 
405     if (UNLIKELY(result == NULL))
406       return pyErrMsg(p, "python exception");
407 
408     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 2)) {
409       return errMsg(p, "callable must return 2 values");
410     }
411     else {
412       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
413       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
414     }
415 
416     Py_DECREF(result);
417     return OK;
418 }
419 
pylcall2i_irate(CSOUND * csound,PYCALL2 * p)420 static int pylcall2i_irate(CSOUND *csound, PYCALL2 *p)
421 {
422     char      command[1024];
423     PyObject  *result;
424     int *py_initialize_done;
425     if (UNLIKELY((py_initialize_done =
426                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
427                  *py_initialize_done == 0))
428       return NOTOK;
429     format_call_statement(command, (char*) p->function->data,
430                           p->INOCOUNT, p->args, 1);
431 
432     create_private_namespace_if_needed(&p->h);
433 
434     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
435 
436     if (UNLIKELY(result == NULL))
437       return pyErrMsg(p, "python exception");
438 
439     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 2)) {
440       return errMsg(p, "callable must return 2 values");
441     }
442     else {
443       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
444       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
445     }
446 
447     Py_DECREF(result);
448     return OK;
449 }
450 
pycall2t_krate(CSOUND * csound,PYCALL2T * p)451 static int pycall2t_krate(CSOUND *csound, PYCALL2T *p)
452 {
453     char      command[1024];
454     PyObject  *result;
455     int *py_initialize_done;
456     if (UNLIKELY((py_initialize_done =
457                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
458                  *py_initialize_done == 0))
459       return NOTOK;
460     if (!*p->trigger) {
461       *p->result1 = p->oresult1;
462       *p->result2 = p->oresult2;
463       return OK;
464     }
465 
466     format_call_statement(command, (char*) p->function->data,
467                           p->INOCOUNT, p->args, 2);
468 
469     result = eval_string_in_given_context(command, 0);
470 
471     if (UNLIKELY(result == NULL))
472       return pyErrMsg(p, "python exception");
473 
474     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 2)) {
475       return errMsg(p, "callable must return 2 values");
476     }
477     else {
478       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
479       p->oresult1 = *p->result1;
480       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
481       p->oresult2 = *p->result2;
482     }
483 
484     Py_DECREF(result);
485     return OK;
486 }
487 
pylcall2t_irate(CSOUND * csound,PYCALL2T * p)488 static int pylcall2t_irate(CSOUND *csound, PYCALL2T *p)
489 {
490     int *py_initialize_done;
491     if (UNLIKELY((py_initialize_done =
492                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
493                  *py_initialize_done == 0))
494       return NOTOK;
495    create_private_namespace_if_needed(&p->h);
496     return OK;
497 }
498 
pylcall2t_krate(CSOUND * csound,PYCALL2T * p)499 static int pylcall2t_krate(CSOUND *csound, PYCALL2T *p)
500 {
501     char      command[1024];
502     PyObject  *result;
503     int *py_initialize_done;
504     if (UNLIKELY((py_initialize_done =
505                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
506                  *py_initialize_done == 0))
507       return NOTOK;
508     if (!*p->trigger) {
509       *p->result1 = p->oresult1;
510       *p->result2 = p->oresult2;
511       return OK;
512     }
513 
514     format_call_statement(command, (char*) p->function->data,
515                           p->INOCOUNT, p->args, 2);
516 
517     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
518 
519     if (UNLIKELY(result == NULL))
520       return pyErrMsg(p, "python exception");
521 
522     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 2)) {
523       return errMsg(p, "callable must return 2 values");
524     }
525     else {
526       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
527       p->oresult1 = *p->result1;
528       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
529       p->oresult2 = *p->result2;
530     }
531 
532     Py_DECREF(result);
533     return OK;
534 }
535 
pycall3_krate(CSOUND * csound,PYCALL3 * p)536 static int pycall3_krate(CSOUND *csound, PYCALL3 *p)
537 {
538     char      command[1024];
539     PyObject  *result;
540     int *py_initialize_done;
541     if (UNLIKELY((py_initialize_done =
542                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
543                  *py_initialize_done == 0))
544       return NOTOK;
545     format_call_statement(command, (char*) p->function->data,
546                           p->INOCOUNT, p->args, 1);
547 
548     result = eval_string_in_given_context(command, 0);
549 
550     if (UNLIKELY(result == NULL))
551       return pyErrMsg(p, "python exception");
552 
553     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 3)) {
554       return errMsg(p, "callable must return 3 values");
555     }
556     else {
557       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
558       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
559       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
560     }
561 
562     Py_DECREF(result);
563     return OK;
564 }
565 
pylcall3_irate(CSOUND * csound,PYCALL3 * p)566 static int pylcall3_irate(CSOUND *csound, PYCALL3 *p)
567 {
568     int *py_initialize_done;
569     if (UNLIKELY((py_initialize_done =
570                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
571                  *py_initialize_done == 0))
572       return NOTOK;
573     create_private_namespace_if_needed(&p->h);
574     return OK;
575 }
576 
pylcall3_krate(CSOUND * csound,PYCALL3 * p)577 static int pylcall3_krate(CSOUND *csound, PYCALL3 *p)
578 {
579     char      command[1024];
580     PyObject  *result;
581     int *py_initialize_done;
582     if (UNLIKELY((py_initialize_done =
583                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
584                  *py_initialize_done == 0))
585       return NOTOK;
586     format_call_statement(command, (char*) p->function->data,
587                           p->INOCOUNT, p->args, 1);
588 
589     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
590 
591     if (UNLIKELY(result == NULL))
592       return pyErrMsg(p, "python exception");
593 
594     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 3)) {
595       return errMsg(p, "callable must return 3 values");
596     }
597     else {
598       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
599       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
600       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
601     }
602 
603     Py_DECREF(result);
604     return OK;
605 }
606 
pylcall3i_irate(CSOUND * csound,PYCALL3 * p)607 static int pylcall3i_irate(CSOUND *csound, PYCALL3 *p)
608 {
609     char      command[1024];
610     PyObject  *result;
611     int *py_initialize_done;
612     if (UNLIKELY((py_initialize_done =
613                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
614                  *py_initialize_done == 0))
615       return NOTOK;
616     format_call_statement(command, (char*) p->function->data,
617                           p->INOCOUNT, p->args, 1);
618 
619     create_private_namespace_if_needed(&p->h);
620 
621     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
622 
623     if (UNLIKELY(result == NULL))
624       return pyErrMsg(p, "python exception");
625 
626     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 3)) {
627       return errMsg(p, "callable must return 3 values");
628     }
629     else {
630       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
631       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
632       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
633     }
634 
635     Py_DECREF(result);
636     return OK;
637 }
638 
pycall3t_krate(CSOUND * csound,PYCALL3T * p)639 static int pycall3t_krate(CSOUND *csound, PYCALL3T *p)
640 {
641     char      command[1024];
642     PyObject  *result;
643     int *py_initialize_done;
644     if (UNLIKELY((py_initialize_done =
645                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
646                  *py_initialize_done == 0))
647       return NOTOK;
648     if (!*p->trigger) {
649       *p->result1 = p->oresult1;
650       *p->result2 = p->oresult2;
651       *p->result3 = p->oresult3;
652       return OK;
653     }
654 
655     format_call_statement(command, (char*) p->function->data,
656                           p->INOCOUNT, p->args, 2);
657 
658     result = eval_string_in_given_context(command, 0);
659 
660     if (UNLIKELY(result == NULL))
661       return pyErrMsg(p, "python exception");
662 
663     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 3)) {
664       return errMsg(p, "callable must return 3 values");
665     }
666     else {
667       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
668       p->oresult1 = *p->result1;
669       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
670       p->oresult2 = *p->result2;
671       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
672       p->oresult3 = *p->result3;
673     }
674 
675     Py_DECREF(result);
676     return OK;
677 }
678 
pylcall3t_irate(CSOUND * csound,PYCALL3T * p)679 static int pylcall3t_irate(CSOUND *csound, PYCALL3T *p)
680 {
681     int *py_initialize_done;
682     if (UNLIKELY((py_initialize_done =
683                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
684                  *py_initialize_done == 0))
685       return NOTOK;
686     create_private_namespace_if_needed(&p->h);
687     return OK;
688 }
689 
pylcall3t_krate(CSOUND * csound,PYCALL3T * p)690 static int pylcall3t_krate(CSOUND *csound, PYCALL3T *p)
691 {
692     char      command[1024];
693     PyObject  *result;
694     int *py_initialize_done;
695     if (UNLIKELY((py_initialize_done =
696                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
697                  *py_initialize_done == 0))
698       return NOTOK;
699     if (!*p->trigger) {
700       *p->result1 = p->oresult1;
701       *p->result2 = p->oresult2;
702       *p->result3 = p->oresult3;
703       return OK;
704     }
705 
706     format_call_statement(command, (char*) p->function->data,
707                           p->INOCOUNT, p->args, 2);
708 
709     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
710 
711     if (UNLIKELY(result == NULL))
712       return pyErrMsg(p, "python exception");
713 
714     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 3)) {
715       return errMsg(p, "callable must return 3 values");
716     }
717     else {
718       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
719       p->oresult1 = *p->result1;
720       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
721       p->oresult2 = *p->result2;
722       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
723       p->oresult3 = *p->result3;
724     }
725 
726     Py_DECREF(result);
727     return OK;
728 }
729 
pycall4_krate(CSOUND * csound,PYCALL4 * p)730 static int pycall4_krate(CSOUND *csound, PYCALL4 *p)
731 {
732     char      command[1024];
733     PyObject  *result;
734     int *py_initialize_done;
735     if (UNLIKELY((py_initialize_done =
736                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
737                  *py_initialize_done == 0))
738       return NOTOK;
739     format_call_statement(command, (char*) p->function->data,
740                           p->INOCOUNT, p->args, 1);
741 
742     result = eval_string_in_given_context(command, 0);
743 
744     if (UNLIKELY(result == NULL))
745       return pyErrMsg(p, "python exception");
746 
747     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 4)) {
748       return errMsg(p, "callable must return 4 values");
749     }
750     else {
751       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
752       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
753       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
754       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
755     }
756 
757     Py_DECREF(result);
758     return OK;
759 }
760 
pylcall4_irate(CSOUND * csound,PYCALL4 * p)761 static int pylcall4_irate(CSOUND *csound, PYCALL4 *p)
762 {
763     int *py_initialize_done;
764     if (UNLIKELY((py_initialize_done =
765                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
766                  *py_initialize_done == 0))
767       return NOTOK;
768     create_private_namespace_if_needed(&p->h);
769     return OK;
770 }
771 
pylcall4_krate(CSOUND * csound,PYCALL4 * p)772 static int pylcall4_krate(CSOUND *csound, PYCALL4 *p)
773 {
774     char      command[1024];
775     PyObject  *result;
776     int *py_initialize_done;
777     if (UNLIKELY((py_initialize_done =
778                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
779                  *py_initialize_done == 0))
780       return NOTOK;
781     format_call_statement(command, (char*) p->function->data,
782                           p->INOCOUNT, p->args, 1);
783 
784     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
785 
786     if (UNLIKELY(result == NULL))
787       return pyErrMsg(p, "python exception");
788 
789     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 4)) {
790       return errMsg(p, "callable must return 4 values");
791     }
792     else {
793       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
794       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
795       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
796       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
797     }
798 
799     Py_DECREF(result);
800     return OK;
801 }
802 
pylcall4i_irate(CSOUND * csound,PYCALL4 * p)803 static int pylcall4i_irate(CSOUND *csound, PYCALL4 *p)
804 {
805     char      command[1024];
806     PyObject  *result;
807     int *py_initialize_done;
808     if (UNLIKELY((py_initialize_done =
809                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
810                  *py_initialize_done == 0))
811       return NOTOK;
812     format_call_statement(command, (char*) p->function->data,
813                           p->INOCOUNT, p->args, 1);
814 
815     create_private_namespace_if_needed(&p->h);
816 
817     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
818 
819     if (UNLIKELY(result == NULL))
820       return pyErrMsg(p, "python exception");
821 
822     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 4)) {
823       return errMsg(p, "callable must return 4 values");
824     }
825     else {
826       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
827       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
828       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
829       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
830     }
831 
832     Py_DECREF(result);
833     return OK;
834 }
835 
pycall4t_krate(CSOUND * csound,PYCALL4T * p)836 static int pycall4t_krate(CSOUND *csound, PYCALL4T *p)
837 {
838     char      command[1024];
839     PyObject  *result;
840     int *py_initialize_done;
841     if (UNLIKELY((py_initialize_done =
842                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
843                  *py_initialize_done == 0))
844       return NOTOK;
845     if (!*p->trigger) {
846       *p->result1 = p->oresult1;
847       *p->result2 = p->oresult2;
848       *p->result3 = p->oresult3;
849       *p->result4 = p->oresult4;
850       return OK;
851     }
852 
853     format_call_statement(command, (char*) p->function->data,
854                           p->INOCOUNT, p->args, 2);
855 
856     result = eval_string_in_given_context(command, 0);
857 
858     if (UNLIKELY(result == NULL))
859       return pyErrMsg(p, "python exception");
860 
861     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 4)) {
862       return errMsg(p, "callable must return 4 values");
863     }
864     else {
865       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
866       p->oresult1 = *p->result1;
867       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
868       p->oresult2 = *p->result2;
869       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
870       p->oresult3 = *p->result3;
871       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
872       p->oresult4 = *p->result4;
873     }
874 
875     Py_DECREF(result);
876     return OK;
877 }
878 
pylcall4t_irate(CSOUND * csound,PYCALL4T * p)879 static int pylcall4t_irate(CSOUND *csound, PYCALL4T *p)
880 {
881     int *py_initialize_done;
882     if (UNLIKELY((py_initialize_done =
883                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
884                  *py_initialize_done == 0))
885       return NOTOK;
886     create_private_namespace_if_needed(&p->h);
887     return OK;
888 }
889 
pylcall4t_krate(CSOUND * csound,PYCALL4T * p)890 static int pylcall4t_krate(CSOUND *csound, PYCALL4T *p)
891 {
892     char      command[1024];
893     PyObject  *result;
894     int *py_initialize_done;
895     if (UNLIKELY((py_initialize_done =
896                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
897                  *py_initialize_done == 0))
898       return NOTOK;
899     if (!*p->trigger) {
900       *p->result1 = p->oresult1;
901       *p->result2 = p->oresult2;
902       *p->result3 = p->oresult3;
903       *p->result4 = p->oresult4;
904       return OK;
905     }
906 
907     format_call_statement(command, (char*) p->function->data,
908                           p->INOCOUNT, p->args, 2);
909 
910     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
911 
912     if (UNLIKELY(result == NULL))
913       return pyErrMsg(p, "python exception");
914 
915     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 4)) {
916       return errMsg(p, "callable must return 4 values");
917     }
918     else {
919       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
920       p->oresult1 = *p->result1;
921       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
922       p->oresult2 = *p->result2;
923       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
924       p->oresult3 = *p->result3;
925       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
926       p->oresult4 = *p->result4;
927     }
928 
929     Py_DECREF(result);
930     return OK;
931 }
932 
pycall5_krate(CSOUND * csound,PYCALL5 * p)933 static int pycall5_krate(CSOUND *csound, PYCALL5 *p)
934 {
935     char      command[1024];
936     PyObject  *result;
937     int *py_initialize_done;
938     if (UNLIKELY((py_initialize_done =
939                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
940                  *py_initialize_done == 0))
941       return NOTOK;
942     format_call_statement(command, (char*) p->function->data,
943                           p->INOCOUNT, p->args, 1);
944 
945     result = eval_string_in_given_context(command, 0);
946 
947     if (UNLIKELY(result == NULL))
948       return pyErrMsg(p, "python exception");
949 
950     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 5)) {
951       return errMsg(p, "callable must return 5 values");
952     }
953     else {
954       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
955       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
956       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
957       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
958       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
959     }
960 
961     Py_DECREF(result);
962     return OK;
963 }
964 
pylcall5_irate(CSOUND * csound,PYCALL5 * p)965 static int pylcall5_irate(CSOUND *csound, PYCALL5 *p)
966 {
967     int *py_initialize_done;
968     if (UNLIKELY((py_initialize_done =
969                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
970                  *py_initialize_done == 0))
971       return NOTOK;
972     create_private_namespace_if_needed(&p->h);
973     return OK;
974 }
975 
pylcall5_krate(CSOUND * csound,PYCALL5 * p)976 static int pylcall5_krate(CSOUND *csound, PYCALL5 *p)
977 {
978     char      command[1024];
979     PyObject  *result;
980     int *py_initialize_done;
981     if (UNLIKELY((py_initialize_done =
982                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
983                  *py_initialize_done == 0))
984       return NOTOK;
985     format_call_statement(command, (char*) p->function->data,
986                           p->INOCOUNT, p->args, 1);
987 
988     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
989 
990     if (UNLIKELY(result == NULL))
991       return pyErrMsg(p, "python exception");
992 
993     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 5)) {
994       return errMsg(p, "callable must return 5 values");
995     }
996     else {
997       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
998       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
999       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1000       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1001       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1002     }
1003 
1004     Py_DECREF(result);
1005     return OK;
1006 }
1007 
pylcall5i_irate(CSOUND * csound,PYCALL5 * p)1008 static int pylcall5i_irate(CSOUND *csound, PYCALL5 *p)
1009 {
1010     char      command[1024];
1011     PyObject  *result;
1012     int *py_initialize_done;
1013     if (UNLIKELY((py_initialize_done =
1014                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1015                  *py_initialize_done == 0))
1016       return NOTOK;
1017     format_call_statement(command, (char*) p->function->data,
1018                           p->INOCOUNT, p->args, 1);
1019 
1020     create_private_namespace_if_needed(&p->h);
1021 
1022     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1023 
1024     if (UNLIKELY(result == NULL))
1025       return pyErrMsg(p, "python exception");
1026 
1027     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 5)) {
1028       return errMsg(p, "callable must return 5 values");
1029     }
1030     else {
1031       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1032       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1033       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1034       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1035       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1036     }
1037 
1038     Py_DECREF(result);
1039     return OK;
1040 }
1041 
pycall5t_krate(CSOUND * csound,PYCALL5T * p)1042 static int pycall5t_krate(CSOUND *csound, PYCALL5T *p)
1043 {
1044     char      command[1024];
1045     PyObject  *result;
1046     int *py_initialize_done;
1047     if (UNLIKELY((py_initialize_done =
1048                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1049                  *py_initialize_done == 0))
1050       return NOTOK;
1051     if (!*p->trigger) {
1052       *p->result1 = p->oresult1;
1053       *p->result2 = p->oresult2;
1054       *p->result3 = p->oresult3;
1055       *p->result4 = p->oresult4;
1056       *p->result5 = p->oresult5;
1057       return OK;
1058     }
1059 
1060     format_call_statement(command, (char*) p->function->data,
1061                           p->INOCOUNT, p->args, 2);
1062 
1063     result = eval_string_in_given_context(command, 0);
1064 
1065     if (UNLIKELY(result == NULL))
1066       return pyErrMsg(p, "python exception");
1067 
1068     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 5)) {
1069       return errMsg(p, "callable must return 5 values");
1070     }
1071     else {
1072       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1073       p->oresult1 = *p->result1;
1074       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1075       p->oresult2 = *p->result2;
1076       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1077       p->oresult3 = *p->result3;
1078       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1079       p->oresult4 = *p->result4;
1080       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1081       p->oresult5 = *p->result5;
1082     }
1083 
1084     Py_DECREF(result);
1085     return OK;
1086 }
1087 
pylcall5t_irate(CSOUND * csound,PYCALL5T * p)1088 static int pylcall5t_irate(CSOUND *csound, PYCALL5T *p)
1089 {
1090     int *py_initialize_done;
1091     if (UNLIKELY((py_initialize_done =
1092                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1093                  *py_initialize_done == 0))
1094       return NOTOK;
1095     create_private_namespace_if_needed(&p->h);
1096     return OK;
1097 }
1098 
pylcall5t_krate(CSOUND * csound,PYCALL5T * p)1099 static int pylcall5t_krate(CSOUND *csound, PYCALL5T *p)
1100 {
1101     char      command[1024];
1102     PyObject  *result;
1103     int *py_initialize_done;
1104     if (UNLIKELY((py_initialize_done =
1105                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1106                  *py_initialize_done == 0))
1107       return NOTOK;
1108     if (!*p->trigger) {
1109       *p->result1 = p->oresult1;
1110       *p->result2 = p->oresult2;
1111       *p->result3 = p->oresult3;
1112       *p->result4 = p->oresult4;
1113       *p->result5 = p->oresult5;
1114       return OK;
1115     }
1116 
1117     format_call_statement(command, (char*) p->function->data,
1118                           p->INOCOUNT, p->args, 2);
1119 
1120     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1121 
1122     if (UNLIKELY(result == NULL))
1123       return pyErrMsg(p, "python exception");
1124 
1125     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 5)) {
1126       return errMsg(p, "callable must return 5 values");
1127     }
1128     else {
1129       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1130       p->oresult1 = *p->result1;
1131       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1132       p->oresult2 = *p->result2;
1133       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1134       p->oresult3 = *p->result3;
1135       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1136       p->oresult4 = *p->result4;
1137       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1138       p->oresult5 = *p->result5;
1139     }
1140 
1141     Py_DECREF(result);
1142     return OK;
1143 }
1144 
pycall6_krate(CSOUND * csound,PYCALL6 * p)1145 static int pycall6_krate(CSOUND *csound, PYCALL6 *p)
1146 {
1147     char      command[1024];
1148     PyObject  *result;
1149     int *py_initialize_done;
1150     if (UNLIKELY((py_initialize_done =
1151                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1152                  *py_initialize_done == 0))
1153       return NOTOK;
1154     format_call_statement(command, (char*) p->function->data,
1155                           p->INOCOUNT, p->args, 1);
1156 
1157     result = eval_string_in_given_context(command, 0);
1158 
1159     if (UNLIKELY(result == NULL))
1160       return pyErrMsg(p, "python exception");
1161 
1162     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 6)) {
1163       return errMsg(p, "callable must return 6 values");
1164     }
1165     else {
1166       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1167       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1168       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1169       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1170       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1171       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1172     }
1173 
1174     Py_DECREF(result);
1175     return OK;
1176 }
1177 
pylcall6_irate(CSOUND * csound,PYCALL6 * p)1178 static int pylcall6_irate(CSOUND *csound, PYCALL6 *p)
1179 {
1180     int *py_initialize_done;
1181     if (UNLIKELY((py_initialize_done =
1182                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1183                  *py_initialize_done == 0))
1184       return NOTOK;
1185     create_private_namespace_if_needed(&p->h);
1186     return OK;
1187 }
1188 
pylcall6_krate(CSOUND * csound,PYCALL6 * p)1189 static int pylcall6_krate(CSOUND *csound, PYCALL6 *p)
1190 {
1191     char      command[1024];
1192     PyObject  *result;
1193     int *py_initialize_done;
1194     if (UNLIKELY((py_initialize_done =
1195                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1196                  *py_initialize_done == 0))
1197       return NOTOK;
1198     format_call_statement(command, (char*) p->function->data,
1199                           p->INOCOUNT, p->args, 1);
1200 
1201     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1202 
1203     if (UNLIKELY(result == NULL))
1204       return pyErrMsg(p, "python exception");
1205 
1206     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 6)) {
1207       return errMsg(p, "callable must return 6 values");
1208     }
1209     else {
1210       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1211       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1212       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1213       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1214       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1215       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1216     }
1217 
1218     Py_DECREF(result);
1219     return OK;
1220 }
1221 
pylcall6i_irate(CSOUND * csound,PYCALL6 * p)1222 static int pylcall6i_irate(CSOUND *csound, PYCALL6 *p)
1223 {
1224     char      command[1024];
1225     PyObject  *result;
1226     int *py_initialize_done;
1227     if (UNLIKELY((py_initialize_done =
1228                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1229                  *py_initialize_done == 0))
1230       return NOTOK;
1231     format_call_statement(command, (char*) p->function->data,
1232                           p->INOCOUNT, p->args, 1);
1233 
1234     create_private_namespace_if_needed(&p->h);
1235 
1236     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1237 
1238     if (UNLIKELY(result == NULL))
1239       return pyErrMsg(p, "python exception");
1240 
1241     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 6)) {
1242       return errMsg(p, "callable must return 6 values");
1243     }
1244     else {
1245       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1246       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1247       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1248       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1249       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1250       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1251     }
1252 
1253     Py_DECREF(result);
1254     return OK;
1255 }
1256 
pycall6t_krate(CSOUND * csound,PYCALL6T * p)1257 static int pycall6t_krate(CSOUND *csound, PYCALL6T *p)
1258 {
1259     char      command[1024];
1260     PyObject  *result;
1261     int *py_initialize_done;
1262     if (UNLIKELY((py_initialize_done =
1263                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1264                  *py_initialize_done == 0))
1265       return NOTOK;
1266     if (!*p->trigger) {
1267       *p->result1 = p->oresult1;
1268       *p->result2 = p->oresult2;
1269       *p->result3 = p->oresult3;
1270       *p->result4 = p->oresult4;
1271       *p->result5 = p->oresult5;
1272       *p->result6 = p->oresult6;
1273       return OK;
1274     }
1275 
1276     format_call_statement(command, (char*) p->function->data,
1277                           p->INOCOUNT, p->args, 2);
1278 
1279     result = eval_string_in_given_context(command, 0);
1280 
1281     if (UNLIKELY(result == NULL))
1282       return pyErrMsg(p, "python exception");
1283 
1284     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 6)) {
1285       return errMsg(p, "callable must return 6 values");
1286     }
1287     else {
1288       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1289       p->oresult1 = *p->result1;
1290       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1291       p->oresult2 = *p->result2;
1292       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1293       p->oresult3 = *p->result3;
1294       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1295       p->oresult4 = *p->result4;
1296       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1297       p->oresult5 = *p->result5;
1298       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1299       p->oresult6 = *p->result6;
1300     }
1301 
1302     Py_DECREF(result);
1303     return OK;
1304 }
1305 
pylcall6t_irate(CSOUND * csound,PYCALL6T * p)1306 static int pylcall6t_irate(CSOUND *csound, PYCALL6T *p)
1307 {
1308     int *py_initialize_done;
1309     if (UNLIKELY((py_initialize_done =
1310                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1311                  *py_initialize_done == 0))
1312       return NOTOK;
1313     create_private_namespace_if_needed(&p->h);
1314     return OK;
1315 }
1316 
pylcall6t_krate(CSOUND * csound,PYCALL6T * p)1317 static int pylcall6t_krate(CSOUND *csound, PYCALL6T *p)
1318 {
1319     char      command[1024];
1320     PyObject  *result;
1321     int *py_initialize_done;
1322     if (UNLIKELY((py_initialize_done =
1323                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1324                  *py_initialize_done == 0))
1325       return NOTOK;
1326     if (!*p->trigger) {
1327       *p->result1 = p->oresult1;
1328       *p->result2 = p->oresult2;
1329       *p->result3 = p->oresult3;
1330       *p->result4 = p->oresult4;
1331       *p->result5 = p->oresult5;
1332       *p->result6 = p->oresult6;
1333       return OK;
1334     }
1335 
1336     format_call_statement(command, (char*) p->function->data,
1337                           p->INOCOUNT, p->args, 2);
1338 
1339     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1340 
1341     if (UNLIKELY(result == NULL))
1342       return pyErrMsg(p, "python exception");
1343 
1344     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 6)) {
1345       return errMsg(p, "callable must return 6 values");
1346     }
1347     else {
1348       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1349       p->oresult1 = *p->result1;
1350       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1351       p->oresult2 = *p->result2;
1352       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1353       p->oresult3 = *p->result3;
1354       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1355       p->oresult4 = *p->result4;
1356       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1357       p->oresult5 = *p->result5;
1358       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1359       p->oresult6 = *p->result6;
1360     }
1361 
1362     Py_DECREF(result);
1363     return OK;
1364 }
1365 
pycall7_krate(CSOUND * csound,PYCALL7 * p)1366 static int pycall7_krate(CSOUND *csound, PYCALL7 *p)
1367 {
1368     char      command[1024];
1369     PyObject  *result;
1370     int *py_initialize_done;
1371     if (UNLIKELY((py_initialize_done =
1372                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1373                  *py_initialize_done == 0))
1374       return NOTOK;
1375     format_call_statement(command, (char*) p->function->data,
1376                           p->INOCOUNT, p->args, 1);
1377 
1378     result = eval_string_in_given_context(command, 0);
1379 
1380     if (UNLIKELY(result == NULL))
1381       return pyErrMsg(p, "python exception");
1382 
1383     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 7)) {
1384       return errMsg(p, "callable must return 7 values");
1385     }
1386     else {
1387       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1388       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1389       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1390       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1391       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1392       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1393       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1394     }
1395 
1396     Py_DECREF(result);
1397     return OK;
1398 }
1399 
pylcall7_irate(CSOUND * csound,PYCALL7 * p)1400 static int pylcall7_irate(CSOUND *csound, PYCALL7 *p)
1401 {
1402     int *py_initialize_done;
1403     if (UNLIKELY((py_initialize_done =
1404                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1405                  *py_initialize_done == 0))
1406       return NOTOK;
1407     create_private_namespace_if_needed(&p->h);
1408     return OK;
1409 }
1410 
pylcall7_krate(CSOUND * csound,PYCALL7 * p)1411 static int pylcall7_krate(CSOUND *csound, PYCALL7 *p)
1412 {
1413     char      command[1024];
1414     PyObject  *result;
1415     int *py_initialize_done;
1416     if (UNLIKELY((py_initialize_done =
1417                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1418                  *py_initialize_done == 0))
1419       return NOTOK;
1420     format_call_statement(command, (char*) p->function->data,
1421                           p->INOCOUNT, p->args, 1);
1422 
1423     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1424 
1425     if (UNLIKELY(result == NULL))
1426       return pyErrMsg(p, "python exception");
1427 
1428     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 7)) {
1429       return errMsg(p, "callable must return 7 values");
1430     }
1431     else {
1432       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1433       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1434       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1435       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1436       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1437       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1438       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1439     }
1440 
1441     Py_DECREF(result);
1442     return OK;
1443 }
1444 
pylcall7i_irate(CSOUND * csound,PYCALL7 * p)1445 static int pylcall7i_irate(CSOUND *csound, PYCALL7 *p)
1446 {
1447     char      command[1024];
1448     PyObject  *result;
1449     int *py_initialize_done;
1450     if (UNLIKELY((py_initialize_done =
1451                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1452                  *py_initialize_done == 0))
1453       return NOTOK;
1454     format_call_statement(command, (char*) p->function->data,
1455                           p->INOCOUNT, p->args, 1);
1456 
1457     create_private_namespace_if_needed(&p->h);
1458 
1459     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1460 
1461     if (UNLIKELY(result == NULL))
1462       return pyErrMsg(p, "python exception");
1463 
1464     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 7)) {
1465       return errMsg(p, "callable must return 7 values");
1466     }
1467     else {
1468       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1469       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1470       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1471       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1472       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1473       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1474       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1475     }
1476 
1477     Py_DECREF(result);
1478     return OK;
1479 }
1480 
pycall7t_krate(CSOUND * csound,PYCALL7T * p)1481 static int pycall7t_krate(CSOUND *csound, PYCALL7T *p)
1482 {
1483     char      command[1024];
1484     PyObject  *result;
1485     int *py_initialize_done;
1486     if (UNLIKELY((py_initialize_done =
1487                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1488                  *py_initialize_done == 0))
1489       return NOTOK;
1490     if (!*p->trigger) {
1491       *p->result1 = p->oresult1;
1492       *p->result2 = p->oresult2;
1493       *p->result3 = p->oresult3;
1494       *p->result4 = p->oresult4;
1495       *p->result5 = p->oresult5;
1496       *p->result6 = p->oresult6;
1497       *p->result7 = p->oresult7;
1498       return OK;
1499     }
1500 
1501     format_call_statement(command, (char*) p->function->data,
1502                           p->INOCOUNT, p->args, 2);
1503 
1504     result = eval_string_in_given_context(command, 0);
1505 
1506     if (UNLIKELY(result == NULL))
1507       return pyErrMsg(p, "python exception");
1508 
1509     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 7)) {
1510       return errMsg(p, "callable must return 7 values");
1511     }
1512     else {
1513       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1514       p->oresult1 = *p->result1;
1515       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1516       p->oresult2 = *p->result2;
1517       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1518       p->oresult3 = *p->result3;
1519       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1520       p->oresult4 = *p->result4;
1521       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1522       p->oresult5 = *p->result5;
1523       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1524       p->oresult6 = *p->result6;
1525       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1526       p->oresult7 = *p->result7;
1527     }
1528 
1529     Py_DECREF(result);
1530     return OK;
1531 }
1532 
pylcall7t_irate(CSOUND * csound,PYCALL7T * p)1533 static int pylcall7t_irate(CSOUND *csound, PYCALL7T *p)
1534 {
1535     int *py_initialize_done;
1536     if (UNLIKELY((py_initialize_done =
1537                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1538                  *py_initialize_done == 0))
1539       return NOTOK;
1540     create_private_namespace_if_needed(&p->h);
1541     return OK;
1542 }
1543 
pylcall7t_krate(CSOUND * csound,PYCALL7T * p)1544 static int pylcall7t_krate(CSOUND *csound, PYCALL7T *p)
1545 {
1546     char      command[1024];
1547     PyObject  *result;
1548     int *py_initialize_done;
1549     if (UNLIKELY((py_initialize_done =
1550                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1551                  *py_initialize_done == 0))
1552       return NOTOK;
1553     if (!*p->trigger) {
1554       *p->result1 = p->oresult1;
1555       *p->result2 = p->oresult2;
1556       *p->result3 = p->oresult3;
1557       *p->result4 = p->oresult4;
1558       *p->result5 = p->oresult5;
1559       *p->result6 = p->oresult6;
1560       *p->result7 = p->oresult7;
1561       return OK;
1562     }
1563 
1564     format_call_statement(command, (char*) p->function->data,
1565                           p->INOCOUNT, p->args, 2);
1566 
1567     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1568 
1569     if (UNLIKELY(result == NULL))
1570       return pyErrMsg(p, "python exception");
1571 
1572     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 7)) {
1573       return errMsg(p, "callable must return 7 values");
1574     }
1575     else {
1576       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1577       p->oresult1 = *p->result1;
1578       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1579       p->oresult2 = *p->result2;
1580       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1581       p->oresult3 = *p->result3;
1582       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1583       p->oresult4 = *p->result4;
1584       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1585       p->oresult5 = *p->result5;
1586       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1587       p->oresult6 = *p->result6;
1588       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1589       p->oresult7 = *p->result7;
1590     }
1591 
1592     Py_DECREF(result);
1593     return OK;
1594 }
1595 
pycall8_krate(CSOUND * csound,PYCALL8 * p)1596 static int pycall8_krate(CSOUND *csound, PYCALL8 *p)
1597 {
1598     char      command[1024];
1599     PyObject  *result;
1600     int *py_initialize_done;
1601     if (UNLIKELY((py_initialize_done =
1602                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1603                  *py_initialize_done == 0))
1604       return NOTOK;
1605     format_call_statement(command, (char*) p->function->data,
1606                           p->INOCOUNT, p->args, 1);
1607 
1608     result = eval_string_in_given_context(command, 0);
1609 
1610     if (UNLIKELY(result == NULL))
1611       return pyErrMsg(p, "python exception");
1612 
1613     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 8)) {
1614       return errMsg(p, "callable must return 8 values");
1615     }
1616     else {
1617       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1618       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1619       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1620       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1621       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1622       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1623       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1624       *p->result8 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 7));
1625     }
1626 
1627     Py_DECREF(result);
1628     return OK;
1629 }
1630 
pylcall8_irate(CSOUND * csound,PYCALL8 * p)1631 static int pylcall8_irate(CSOUND *csound, PYCALL8 *p)
1632 {
1633     int *py_initialize_done;
1634     if (UNLIKELY((py_initialize_done =
1635                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1636                  *py_initialize_done == 0))
1637       return NOTOK;
1638     create_private_namespace_if_needed(&p->h);
1639     return OK;
1640 }
1641 
pylcall8_krate(CSOUND * csound,PYCALL8 * p)1642 static int pylcall8_krate(CSOUND *csound, PYCALL8 *p)
1643 {
1644     char      command[1024];
1645     PyObject  *result;
1646     int *py_initialize_done;
1647     if (UNLIKELY((py_initialize_done =
1648                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1649                  *py_initialize_done == 0))
1650       return NOTOK;
1651     format_call_statement(command, (char*) p->function->data,
1652                           p->INOCOUNT, p->args, 1);
1653 
1654     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1655 
1656     if (UNLIKELY(result == NULL))
1657       return pyErrMsg(p, "python exception");
1658 
1659     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 8)) {
1660       return errMsg(p, "callable must return 8 values");
1661     }
1662     else {
1663       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1664       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1665       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1666       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1667       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1668       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1669       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1670       *p->result8 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 7));
1671     }
1672 
1673     Py_DECREF(result);
1674     return OK;
1675 }
1676 
pylcall8i_irate(CSOUND * csound,PYCALL8 * p)1677 static int pylcall8i_irate(CSOUND *csound, PYCALL8 *p)
1678 {
1679     char      command[1024];
1680     PyObject  *result;
1681     int *py_initialize_done;
1682     if (UNLIKELY((py_initialize_done =
1683                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1684                  *py_initialize_done == 0))
1685       return NOTOK;
1686     format_call_statement(command, (char*) p->function->data,
1687                           p->INOCOUNT, p->args, 1);
1688 
1689     create_private_namespace_if_needed(&p->h);
1690 
1691     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1692 
1693     if (UNLIKELY(result == NULL))
1694       return pyErrMsg(p, "python exception");
1695 
1696     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 8)) {
1697       return errMsg(p, "callable must return 8 values");
1698     }
1699     else {
1700       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1701       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1702       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1703       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1704       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1705       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1706       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1707       *p->result8 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 7));
1708     }
1709 
1710     Py_DECREF(result);
1711     return OK;
1712 }
1713 
pycall8t_krate(CSOUND * csound,PYCALL8T * p)1714 static int pycall8t_krate(CSOUND *csound, PYCALL8T *p)
1715 {
1716     char      command[1024];
1717     PyObject  *result;
1718     int *py_initialize_done;
1719     if (UNLIKELY((py_initialize_done =
1720                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1721                  *py_initialize_done == 0))
1722       return NOTOK;
1723     if (!*p->trigger) {
1724       *p->result1 = p->oresult1;
1725       *p->result2 = p->oresult2;
1726       *p->result3 = p->oresult3;
1727       *p->result4 = p->oresult4;
1728       *p->result5 = p->oresult5;
1729       *p->result6 = p->oresult6;
1730       *p->result7 = p->oresult7;
1731       *p->result8 = p->oresult8;
1732       return OK;
1733     }
1734 
1735     format_call_statement(command, (char*) p->function->data,
1736                           p->INOCOUNT, p->args, 2);
1737 
1738     result = eval_string_in_given_context(command, 0);
1739 
1740     if (UNLIKELY(result == NULL))
1741       return pyErrMsg(p, "python exception");
1742 
1743     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 8)) {
1744       return errMsg(p, "callable must return 8 values");
1745     }
1746     else {
1747       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1748       p->oresult1 = *p->result1;
1749       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1750       p->oresult2 = *p->result2;
1751       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1752       p->oresult3 = *p->result3;
1753       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1754       p->oresult4 = *p->result4;
1755       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1756       p->oresult5 = *p->result5;
1757       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1758       p->oresult6 = *p->result6;
1759       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1760       p->oresult7 = *p->result7;
1761       *p->result8 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 7));
1762       p->oresult8 = *p->result8;
1763     }
1764 
1765     Py_DECREF(result);
1766     return OK;
1767 }
1768 
pylcall8t_irate(CSOUND * csound,PYCALL8T * p)1769 static int pylcall8t_irate(CSOUND *csound, PYCALL8T *p)
1770 {
1771     int *py_initialize_done;
1772     if (UNLIKELY((py_initialize_done =
1773                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1774                  *py_initialize_done == 0))
1775       return NOTOK;
1776     create_private_namespace_if_needed(&p->h);
1777     return OK;
1778 }
1779 
pylcall8t_krate(CSOUND * csound,PYCALL8T * p)1780 static int pylcall8t_krate(CSOUND *csound, PYCALL8T *p)
1781 {
1782     char      command[1024];
1783     PyObject  *result;
1784     int *py_initialize_done;
1785     if (UNLIKELY((py_initialize_done =
1786                   csound->QueryGlobalVariable(csound,"PY_INITIALIZE")) == NULL ||
1787                  *py_initialize_done == 0))
1788       return NOTOK;
1789     if (!*p->trigger) {
1790       *p->result1 = p->oresult1;
1791       *p->result2 = p->oresult2;
1792       *p->result3 = p->oresult3;
1793       *p->result4 = p->oresult4;
1794       *p->result5 = p->oresult5;
1795       *p->result6 = p->oresult6;
1796       *p->result7 = p->oresult7;
1797       *p->result8 = p->oresult8;
1798       return OK;
1799     }
1800 
1801     format_call_statement(command, (char*) p->function->data,
1802                           p->INOCOUNT, p->args, 2);
1803 
1804     result = eval_string_in_given_context(command, GETPYLOCAL(p->h.insdshead));
1805 
1806     if (UNLIKELY(result == NULL))
1807       return pyErrMsg(p, "python exception");
1808 
1809     if (UNLIKELY(!PyTuple_Check(result) || PyTuple_Size(result) != 8)) {
1810       return errMsg(p, "callable must return 8 values");
1811     }
1812     else {
1813       *p->result1 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
1814       p->oresult1 = *p->result1;
1815       *p->result2 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
1816       p->oresult2 = *p->result2;
1817       *p->result3 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 2));
1818       p->oresult3 = *p->result3;
1819       *p->result4 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 3));
1820       p->oresult4 = *p->result4;
1821       *p->result5 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 4));
1822       p->oresult5 = *p->result5;
1823       *p->result6 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 5));
1824       p->oresult6 = *p->result6;
1825       *p->result7 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 6));
1826       p->oresult7 = *p->result7;
1827       *p->result8 = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 7));
1828       p->oresult8 = *p->result8;
1829     }
1830 
1831     Py_DECREF(result);
1832     return OK;
1833 }
1834