changeset 13:dc8f6015f3e1 pytave-task

Use octave_main() to initiate Octave
author David Grundberg <individ@acc.umu.se>
date Thu, 23 Oct 2008 20:28:50 +0200
parents a0c819a31e02
children 56254a2e18e3
files ChangeLog pytave.cc
diffstat 2 files changed, 18 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Oct 23 20:16:38 2008 +0200
+++ b/ChangeLog	Thu Oct 23 20:28:50 2008 +0200
@@ -1,5 +1,6 @@
 2008-10-xx  David Grundberg <individ@acc.umu.se>
 
+	* pytave.cc: Use octave_main() to initialize Octave.
 	* configure.ac: Better testing for Python dependencies.
 	* configure.ac: Renamed my_ to pytave_
 	* configure.ac: Fixed whitespace.
--- a/pytave.cc	Thu Oct 23 20:16:38 2008 +0200
+++ b/pytave.cc	Thu Oct 23 20:28:50 2008 +0200
@@ -24,21 +24,14 @@
 
 #undef HAVE_STAT /* Both boost.python and octave define HAVE_STAT... */
 #include <octave/oct.h>
+#include <octave/octave.h>
+#include <octave/ov.h>
 #include <octave/parse.h>
-#include <octave/load-path.h>
-#include <octave/file-io.h>
-#include <octave/ops.h>
 
 #include <iostream>
 #include <sstream>
-
 #include <sys/types.h>
 
-#include <octave/Matrix.h>
-#include <octave/ov.h>
-#include <octave/builtins.h>
-#include <octave/defaults.h>
-
 #include "pytavedefs.h"
 
 #include "exceptions.h"
@@ -59,27 +52,23 @@
          return;
       }
 
-      set_liboctave_error_handler(error);
-      set_liboctave_warning_handler(warning);
-      set_liboctave_warning_with_id_handler(warning_with_id);
-
-      // New in Octave 3
-      initialize_default_warning_state();
+      // Initialize Octave.
+      if (Py_FdIsInteractive(stdin, NULL)) {
+         // Print Octave interactive message.
+         char* argv[] = {"octave", "--no-line-editing", "--no-history", NULL};
+         octave_main(3, argv, 1);
+      } else {
+         // One may use -q to surpress the startup greeting.
+         char* argv[] = {"octave", "-q", "--no-line-editing",
+                         "--no-history", NULL};
+         octave_main(4, argv, 1);
+      }
 
-      install_defaults();
-      initialize_file_io();
-      initialize_symbol_tables();
-      install_types();
-
-      install_ops();
+      // Initialize Python Numeric Array
 
-      install_builtins();
-
-      // true argument new in Octave 3
-      load_path::initialize(true); // or use false to set empty path
-
-      // initialize python numeric array
-      import_array();
+      // This is actually a macro that becomes a block expression. If an error
+      // occurs, e.g. Numeric Array not installed, an exception is set.
+      import_array()
    }
 
    boost::python::tuple get_exceptions() {