forked from wardw/ioscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.h
More file actions
39 lines (32 loc) · 934 Bytes
/
Copy pathpython.h
File metadata and controls
39 lines (32 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include "ioscript.h"
namespace iosc {
#ifdef QPLOT_DEBUG
struct Python { static constexpr const char* cmd = "cat"; };
#else
struct Python { static constexpr const char* cmd = "python"; };
#endif
// See README.md and examples_process.cpp for details
struct PythonHeader
{
void operator()(Process<Python>& python) const
{
python.out()
<< "# This header has been added by Script. See ioscript.h\n"
<< "import os\n"
<< "iosc_in = list()\n"
<< "\n";
for (int i=0; i<python.numChannels(); i++) {
python.out()
<< "os.close(" << python.fd_w(i) << ")\n"
<< "iosc_in.append(os.fdopen(" << python.fd_r(i) << ", 'r'))\n"
<< "\n";
}
}
};
template <typename S>
void addPrivateHeader(Script<Python,S>& python)
{
python.addToHeader(PythonHeader{});
}
} // namespace iosc