src/Pure/System/isabelle_process.scala
changeset 54440 2c4940d2edf7
parent 54005 132640f4c453
child 54442 c39972ddd672
equal deleted inserted replaced
54439:621a155c7715 54440:2c4940d2edf7
   108   }
   108   }
   109 
   109 
   110 
   110 
   111   /* command input actor */
   111   /* command input actor */
   112 
   112 
   113   private case class Input_Chunks(chunks: List[Array[Byte]])
   113   private case class Input_Chunks(chunks: List[Bytes])
   114 
   114 
   115   private case object Close
   115   private case object Close
   116   private def close(p: (Thread, Actor))
   116   private def close(p: (Thread, Actor))
   117   {
   117   {
   118     if (p != null && p._1.isAlive) {
   118     if (p != null && p._1.isAlive) {
   259         var finished = false
   259         var finished = false
   260         while (!finished) {
   260         while (!finished) {
   261           //{{{
   261           //{{{
   262           receive {
   262           receive {
   263             case Input_Chunks(chunks) =>
   263             case Input_Chunks(chunks) =>
   264               stream.write(UTF8.string_bytes(chunks.map(_.length).mkString("", ",", "\n")))
   264               Bytes(chunks.map(_.length).mkString("", ",", "\n")).write(stream)
   265               chunks.foreach(stream.write(_))
   265               chunks.foreach(_.write(stream))
   266               stream.flush
   266               stream.flush
   267             case Close =>
   267             case Close =>
   268               stream.close
   268               stream.close
   269               finished = true
   269               finished = true
   270             case bad => System.err.println(name + ": ignoring bad message " + bad)
   270             case bad => System.err.println(name + ": ignoring bad message " + bad)
   360   }
   360   }
   361 
   361 
   362 
   362 
   363   /** main methods **/
   363   /** main methods **/
   364 
   364 
   365   def protocol_command_raw(name: String, args: Array[Byte]*): Unit =
   365   def protocol_command_raw(name: String, args: Bytes*): Unit =
   366     command_input._2 ! Input_Chunks(UTF8.string_bytes(name) :: args.toList)
   366     command_input._2 ! Input_Chunks(Bytes(name) :: args.toList)
   367 
   367 
   368   def protocol_command(name: String, args: String*)
   368   def protocol_command(name: String, args: String*)
   369   {
   369   {
   370     receiver(new Input(name, args.toList))
   370     receiver(new Input(name, args.toList))
   371     protocol_command_raw(name, args.map(UTF8.string_bytes): _*)
   371     protocol_command_raw(name, args.map(Bytes(_)): _*)
   372   }
   372   }
   373 
   373 
   374   def options(opts: Options): Unit =
   374   def options(opts: Options): Unit =
   375     protocol_command("Isabelle_Process.options", YXML.string_of_body(opts.encode))
   375     protocol_command("Isabelle_Process.options", YXML.string_of_body(opts.encode))
   376 }
   376 }