Changed the Rain TLP interface to use lists for output streams as I'd originally intended
This commit is contained in:
parent
0b1708c241
commit
0627ff2b4f
|
@ -136,15 +136,17 @@ cppgenTopLevel s
|
||||||
call genStructured s (\m _ -> tell ["\n#error Invalid top-level item: ",show m])
|
call genStructured s (\m _ -> tell ["\n#error Invalid top-level item: ",show m])
|
||||||
(name, chans) <- tlpInterface
|
(name, chans) <- tlpInterface
|
||||||
tell ["int main (int argc, char** argv) { csp::Start_CPPCSP();"]
|
tell ["int main (int argc, char** argv) { csp::Start_CPPCSP();"]
|
||||||
(chanType, writer, reader) <-
|
(chanTypeRead, chanTypeWrite, writer, reader) <-
|
||||||
do st <- getCompState
|
do st <- getCompState
|
||||||
case csFrontend st of
|
case csFrontend st of
|
||||||
FrontendOccam -> return ("tockSendableArrayOfBytes",
|
FrontendOccam -> return ("tockSendableArrayOfBytes",
|
||||||
|
"tockSendableArrayOfBytes",
|
||||||
"StreamWriterByteArray",
|
"StreamWriterByteArray",
|
||||||
"StreamReaderByteArray")
|
"StreamReaderByteArray")
|
||||||
_ -> return ("uint8_t", "StreamWriter", "StreamReader")
|
_ -> return ("uint8_t", "tockList<uint8_t>/**/","StreamWriterList", "StreamReader")
|
||||||
|
|
||||||
tell ["csp::One2OneChannel<",chanType,"> in,out,err;"]
|
tell ["csp::One2OneChannel<",chanTypeRead,"> in;"]
|
||||||
|
tell ["csp::One2OneChannel<",chanTypeWrite,"> out,err;"]
|
||||||
tell [" csp::Run( csp::InParallel ",
|
tell [" csp::Run( csp::InParallel ",
|
||||||
"(new ",writer,"(std::cout,out.reader())) ",
|
"(new ",writer,"(std::cout,out.reader())) ",
|
||||||
"(new ",writer,"(std::cerr,err.reader())) ",
|
"(new ",writer,"(std::cerr,err.reader())) ",
|
||||||
|
|
|
@ -398,6 +398,41 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class StreamWriterList : public csp::CSProcess
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::ostream& out;
|
||||||
|
csp::Chanin< tockList<uint8_t> > in;
|
||||||
|
protected:
|
||||||
|
virtual void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tockList<uint8_t> cs;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
in >> cs;
|
||||||
|
for (tockList<uint8_t>::iterator it = cs.beginSeqEach();it != cs.limitIterator();it++)
|
||||||
|
{
|
||||||
|
out << *it;
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (csp::PoisonException& e)
|
||||||
|
{
|
||||||
|
in.poison();
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
inline StreamWriterList(std::ostream& _out,const csp::Chanin< tockList<uint8_t> >& _in)
|
||||||
|
: out(_out),in(_in)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Time addition and subtraction:
|
// Time addition and subtraction:
|
||||||
|
|
||||||
inline csp::Time occam_plus_time (const csp::Time& a, const csp::Time& b, const char *)
|
inline csp::Time occam_plus_time (const csp::Time& a, const csp::Time& b, const char *)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user