diff libinterp/corefcn/interpreter-private.cc @ 23511:232c8d69d934

manage interpreter instance in interpreter object Currently it is only possible to have one application or interpreter object. Enforce that restriction. * octave.h, octave.cc (application::the_interpreter): Delete. (application::application): Ensure only one application is created at once. * interpreter.cc, interpreter.h (interpreter::instance): New static variable. (interpreter::interpreter): Ensure only one is created at once. (interpreter::~interpreter): Set instance to nullptr. (interpreter::the_interpreter): New function. * interpreter-private.cc, interpreter-private.cc (__get_interpreter__): Delete. Replace all uses with octave::interpreter::the_interpreter.
author John W. Eaton <jwe@octave.org>
date Thu, 18 May 2017 10:53:24 -0400
parents d24d01273bd0
children 1bc8f1f50b54
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter-private.cc	Wed May 17 22:13:28 2017 -0700
+++ b/libinterp/corefcn/interpreter-private.cc	Thu May 18 10:53:24 2017 -0400
@@ -27,25 +27,19 @@
 #include <string>
 
 #include "error.h"
+#include "load-path.h"
 #include "interpreter-private.h"
-#include "octave.h"
+#include "interpreter.h"
 
 namespace octave
 {
-  interpreter& __get_interpreter__ (const std::string& who)
+  load_path& __get_load_path__ (const std::string& who)
   {
-    interpreter *interp = octave::application::the_interpreter ();
+    interpreter *interp = interpreter::the_interpreter ();
 
     if (! interp)
       error ("%s: interpreter context missing", who.c_str ());
 
-    return *interp;
-  }
-
-  load_path& __get_load_path__ (const std::string& who)
-  {
-    interpreter& interp = __get_interpreter__ (who);
-
-    return interp.get_load_path ();
+    return interp->get_load_path ();
   }
 }