clarified names;
authorwenzelm
Sat, 15 Aug 2020 13:45:25 +0200
changeset 72157 d1ca82e27cbc
parent 72156 065dcd80293e
child 72158 cafe00f2161e
clarified names;
etc/settings
src/Pure/ML/ml_statistics.scala
src/Pure/System/scala.scala
--- a/etc/settings	Sat Aug 15 13:37:34 2020 +0200
+++ b/etc/settings	Sat Aug 15 13:45:25 2020 +0200
@@ -27,8 +27,8 @@
 
 isabelle_scala_service 'isabelle.Bibtex$File_Format'
 
-isabelle_scala_service 'isabelle.ML_Statistics$Protocol_Handler'
-isabelle_scala_service 'isabelle.Scala'
+isabelle_scala_service 'isabelle.ML_Statistics$Handler'
+isabelle_scala_service 'isabelle.Scala$Handler'
 isabelle_scala_service 'isabelle.Print_Operation$Handler'
 isabelle_scala_service 'isabelle.Simplifier_Trace$Handler'
 
--- a/src/Pure/ML/ml_statistics.scala	Sat Aug 15 13:37:34 2020 +0200
+++ b/src/Pure/ML/ml_statistics.scala	Sat Aug 15 13:45:25 2020 +0200
@@ -80,7 +80,7 @@
 
   /* protocol handler */
 
-  class Protocol_Handler extends Session.Protocol_Handler
+  class Handler extends Session.Protocol_Handler
   {
     private var session: Session = null
     private var monitoring: Future[Unit] = Future.value(())
--- a/src/Pure/System/scala.scala	Sat Aug 15 13:37:34 2020 +0200
+++ b/src/Pure/System/scala.scala	Sat Aug 15 13:45:25 2020 +0200
@@ -138,71 +138,71 @@
         }
       case None => (Tag.FAIL, "Unknown Isabelle/Scala function: " + quote(name))
     }
-}
 
 
-/* protocol handler */
+  /* protocol handler */
+
+  class Handler extends Session.Protocol_Handler
+  {
+    private var session: Session = null
+    private var futures = Map.empty[String, Future[Unit]]
 
-class Scala extends Session.Protocol_Handler
-{
-  private var session: Session = null
-  private var futures = Map.empty[String, Future[Unit]]
+    override def init(init_session: Session): Unit =
+      synchronized { session = init_session }
 
-  override def init(init_session: Session): Unit =
-    synchronized { session = init_session }
+    override def exit(): Unit = synchronized
+    {
+      for ((id, future) <- futures) cancel(id, future)
+      futures = Map.empty
+    }
 
-  override def exit(): Unit = synchronized
-  {
-    for ((id, future) <- futures) cancel(id, future)
-    futures = Map.empty
-  }
+    private def result(id: String, tag: Scala.Tag.Value, res: String): Unit =
+      synchronized
+      {
+        if (futures.isDefinedAt(id)) {
+          session.protocol_command("Scala.result", id, tag.id.toString, res)
+          futures -= id
+        }
+      }
 
-  private def result(id: String, tag: Scala.Tag.Value, res: String): Unit =
-    synchronized
+    private def cancel(id: String, future: Future[Unit])
+    {
+      future.cancel
+      result(id, Scala.Tag.INTERRUPT, "")
+    }
+
+    private def invoke_scala(msg: Prover.Protocol_Output): Boolean = synchronized
     {
-      if (futures.isDefinedAt(id)) {
-        session.protocol_command("Scala.result", id, tag.id.toString, res)
-        futures -= id
+      msg.properties match {
+        case Markup.Invoke_Scala(name, id) =>
+          futures += (id ->
+            Future.fork {
+              val (tag, res) = Scala.function(name, msg.text)
+              result(id, tag, res)
+            })
+          true
+        case _ => false
       }
     }
 
-  private def cancel(id: String, future: Future[Unit])
-  {
-    future.cancel
-    result(id, Scala.Tag.INTERRUPT, "")
-  }
+    private def cancel_scala(msg: Prover.Protocol_Output): Boolean = synchronized
+    {
+      msg.properties match {
+        case Markup.Cancel_Scala(id) =>
+          futures.get(id) match {
+            case Some(future) => cancel(id, future)
+            case None =>
+          }
+          true
+        case _ => false
+      }
+    }
 
-  private def invoke_scala(msg: Prover.Protocol_Output): Boolean = synchronized
-  {
-    msg.properties match {
-      case Markup.Invoke_Scala(name, id) =>
-        futures += (id ->
-          Future.fork {
-            val (tag, res) = Scala.function(name, msg.text)
-            result(id, tag, res)
-          })
-        true
-      case _ => false
-    }
+    val functions =
+      List(
+        Markup.Invoke_Scala.name -> invoke_scala,
+        Markup.Cancel_Scala.name -> cancel_scala)
   }
-
-  private def cancel_scala(msg: Prover.Protocol_Output): Boolean = synchronized
-  {
-    msg.properties match {
-      case Markup.Cancel_Scala(id) =>
-        futures.get(id) match {
-          case Some(future) => cancel(id, future)
-          case None =>
-        }
-        true
-      case _ => false
-    }
-  }
-
-  val functions =
-    List(
-      Markup.Invoke_Scala.name -> invoke_scala,
-      Markup.Cancel_Scala.name -> cancel_scala)
 }