# HG changeset patch # User David Grundberg # Date 1224786530 -7200 # Node ID dc8f6015f3e1db8e7e2b2a6d02d93ce1ab8da7f8 # Parent a0c819a31e02fd7039b854f43662839e08351daf Use octave_main() to initiate Octave diff -r a0c819a31e02 -r dc8f6015f3e1 ChangeLog --- 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 + * 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. diff -r a0c819a31e02 -r dc8f6015f3e1 pytave.cc --- 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 +#include +#include #include -#include -#include -#include #include #include - #include -#include -#include -#include -#include - #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() {